anger
A pub-sub load tester for Nes. Designed to be used to write custom
"realworld" like scenarios.
Status: Experimental
Install
npm install --save anger
Usage
To use anger
, simply require it, and supply it some test scenario configuration.
const anger = require('anger')
const instance = anger({
url: 'http://localhost:3000',
subscription: '/greet',
connections: 1000,
senders: 2,
requests: 1000,
responses: 10000,
identifier: (payload) => payload.meta.id,
trigger: (sender) => {
sender.request({
method: 'POST',
path: '/h',
payload: {
id: ++uid
}
})
return uid
}
})
instance.on('end', (result) => {
})
API
anger(opts)
Start an anger instance against a given target.
opts
: An Object
with configuration information. Can contain the following attributes:
url
: The base url of the hapi/nes server you want to test.subscription
: A topic to test.connections
: The number of connections to maintain to server. Each is an individual nes client.senders
: The number of connections that should be senders.responses
: The number of overall expected responses to be recieved during this run.auth
: A Function
or Object
passed to the nes client for authentication. If a Function
, it is passed the client
and index
of that client as params. Must return the auth object options. If an Object
, it must be passed the auth object options. auth object reference.identifier
: A function used to map some payload response data to a requests uid.trigger
: A function which is passed a nes client to emit a message to the server for testing. Must return some uid of a message sent.retryOpts
: An object which is passed to try-again to achieve exponential backoff for retries. Check the try-again docs for reference on how to use it.. Default values below:
retries
: 8max
: 10000jitter
: 0.2factor
: 2min
: 100
Returns an instance/event emitter for tracking progress, etc.
anger events
Because an anger instance is an EventEmitter
, it emits several events. these are below:
error
: emitted on a error. The callback function will receive the error
as the first parameter.connect
: emitted when all clients are connected to the server.subscribe
: emitted when all clients are subscribed to the server.trigger
: emitted when a sender is sending a 'request' message. The callback function will receive the requests uid
as the first parameter.publish-events-recieved
: emitted when all connections receive the message 'response' sent from the server, in response to some triggered 'request'. The callback should receive the uid
for the event that triggered it.end
: emmited when testing finishes, with the result
passed as the first parameter to the callback.
Sample
Check out the examples folder for a simple sample.
License
MIT. Copyright (c) Matteo Collina and David Mark Clements 2016.