artillery-engine-amqp
v1.0.0-alpha.7
Published
Artillery.io load testing engine for AMQP
Maintainers
Readme
artillery-engine-amqp
Load testing plugin for Artillery.io that adds support for AMQP (RabbitMQ, etc.).
Installation
npm install artillery-engine-amqpUsage
Basic Configuration
Create a scenario file (e.g., scenario.yml):
config:
target: "amqp://localhost:5672"
phases:
- duration: 60
arrivalRate: 10
amqp:
connectionOptions:
heartbeat: 60
scenarios:
- name: "Publish messages to queue"
engine: amqp
flow:
- publishMessage:
queue: "test-queue"
data: "Hello from Artillery!"
batch: 10Publish to Exchange
scenarios:
- name: "Publish to exchange"
engine: amqp
flow:
- publishMessage:
exchange: "my-exchange"
exchangeType: "topic"
routingKey: "test.routing.key"
data:
message: "Test message"
timestamp: "{{ $timestamp }}"
options:
persistent: trueSubscribe to Queue
scenarios:
- name: "Subscribe and consume messages"
engine: amqp
flow:
- subscribe:
queue: "test-queue"
messageCount: 5
timeout: 10000SSL/TLS Connections
Basic SSL Connection
For simple SSL connections using system's trusted CA certificates:
config:
target: "amqps://user:[email protected]:5671"
amqp:
connectionOptions:
heartbeat: 60
ssl:
rejectUnauthorized: trueSSL with Client Certificates
For mutual TLS authentication:
config:
target: "amqps://user:[email protected]:5671"
amqp:
connectionOptions:
heartbeat: 60
ssl:
cert: "/path/to/client-cert.pem"
key: "/path/to/client-key.pem"
ca: "/path/to/ca-cert.pem"
passphrase: "your-key-passphrase"
rejectUnauthorized: trueSelf-Signed Certificates (Development)
For development with self-signed certificates:
config:
target: "amqps://user:password@localhost:5671"
amqp:
ssl:
rejectUnauthorized: falseNote: SSL certificate data and passphrases are automatically redacted from debug logs for security.
See examples/ssl-connection.yml and examples/ssl-simple.yml for complete examples.
Configuration Options
Engine Configuration
target: AMQP connection URL (defined at config level, default:amqp://localhost:5672)- For SSL/TLS connections, use
amqps://protocol (e.g.,amqps://user:pass@host:5671)
- For SSL/TLS connections, use
connectionOptions: Connection options passed to amqplib (e.g., heartbeat)ssl: SSL/TLS configuration (optional)cert: Path to client certificate file (optional)key: Path to client private key file (optional)ca: Path to CA certificate file(s) - can be a string or array of strings (optional)passphrase: Passphrase for encrypted private key (optional)rejectUnauthorized: Whether to reject unauthorized certificates (default:true)
publishMessage Options
exchange: Exchange name (optional, default: '' for default exchange)exchangeType: Exchange type (topic, direct, fanout, headers) (default: 'topic')routingKey: Routing key for message routingqueue: Queue name (will be created if doesn't exist)data: Message payload (string or object)size: Random message size in bytes (default: 300) - used if data is not providedbatch: Number of messages to send (default: 1)options: Publishing optionspersistent: Make message persistent (default: false)contentType: Content type (e.g., 'application/json')headers: Custom headers
subscribe Options
queue: Queue name to subscribe to (required)messageCount: Number of messages to consume (default: 1)timeout: Timeout in milliseconds (default: 5000)
Template Variables
The engine supports Artillery's template variables for dynamic values:
scenarios:
- name: "Dynamic messages"
engine: amqp
flow:
- publishMessage:
queue: "orders-{{ $randomNumber(1, 10) }}"
data:
orderId: "{{ $uuid }}"
timestamp: "{{ $timestamp }}"
amount: "{{ $randomNumber(10, 1000) }}"
customerId: "user-{{ $randomNumber(1, 100) }}"Available template variables:
{{ $uuid }}- Generate a random UUID v4{{ $randomNumber(min, max) }}- Generate random number between min and max{{ $randomString(length) }}- Generate random alphanumeric string{{ $timestamp }}- Current Unix timestamp in milliseconds
See examples/template-variables.yml for more examples.
Run Tests
artillery run scenario.ymlMetrics
The engine emits the following metrics:
amqp.messages.sent: Counter for sent messagesamqp.messages.received: Counter for received messagesamqp.publish.time: Histogram of publish operation timesamqp.subscribe.time: Histogram of subscribe operation times
Debug
Enable debug logging:
DEBUG=engine:amqp artillery run scenario.ymlLicense
MIT
