Loads is built in a way which makes it possible to have tests runners written in any language. To do that, it uses ZeroMQ to do communication.
This document describes the protocol you need to implement if you want to create your own runner.
Currently, there is only a Python implementation and a JavaScript implementation. The JS runner is provided in a separate project named loads.js.
If you have implemented your own runner, feel free to submit us a patch or a pull request.
To instruct loads to use an external test runner, specify the path to the executable in the –test-runner option like this:
$ loads-runner --test-runner="./loadsjs/runner.js {test}" javascript_tests.js
The format variable {test} will be replaced with the fully-qualified test name that is specified on the command-line.
Loads will spawn one instance of the external runner process per user, per cycle. Details about the current cycle are passed in environment variables as follows:
The LOADS_TOTAL_HITS and LOADS_DURATION variables define how many runs of the tests should be performed, and are equivalent to the –hits and –duration command-line arguments. They are mutually exclusive.
The runner reports on its progress by sending messages to the specified ZeroMQ endpoint. Each message sent to Loads needs to respect the following rules:
A message generally looks like this:
{
data_type: 'something',
agent_id: '1',
run_id: '1234',
other_key_1: 'foo'
other_key_2: 'bar'
}
Some messages take a loads_status argument. loads_status is a list of values concerning the current status of the load.
With loads, you can run cycle of runs. For instance, if you pass 10:50:100 for the users, it will start with 10 users in parallel, and then 50 and finally 100.
Loads status contains information about the current number of users we have to run for the cycle we are in (50, for instance), and the user we are currently taking care of (could be 12). Same applies for the hits.
It contains, in this order:
When errors / exceptions are caught, they are serialised and sent trough the wire, as well. When you see an exc *, it is a list containing this:
When using Loads, you usually run a test suite. Tests start, stop, succeed and fail. Here are the APIs you can use:
You should not send the startTestRun and stopTestRun messages.
To track requests, you only have one method, named “add_hit” with the following parameters:
If you’re also able to track what’s going on with the socket connections, then you can use the following messages: