npm start
Generic variables (applicable for followers and leaders):
SPAMMER_PORT
: Port of the server.SPAMMER_HOST
: Host for server to bind to.SPAMMER_TYPE
: Either follower or leader.
Follower variables:
SPAMMER_INITIAL_LEADER_SOCKET_ADDRESS
: [Optional] Socket address of leader to automatically connect to.
npm test
Running an individual test:
npx jest -t <test_name>
or
npm test -- -t <test_name>
Running a test file:
npx jest test/spammer.unit.test.js
Coverage results are generated by default in the folder coverage
.
The following thresholds must be met in order for the command to pass:
"globals": {
"branches": 70,
"functions": 80,
"lines": 80,
"statements": 80
}
The thresholds can be configured in package.json
.
npm run mutation
The mutation report is generated in reports/mutation/html
.
Mutation test coverage thresholds are configuered in stryker.conf.js
:
thresholds: {
high: 80,
low: 60,
break: 50,
}
npm run lint
: Run ESLint against all JS code, including the Prettier plugin.
npx prettier -c **
: Ensures that all files (not just JS files) are correctly formatted. To fix formatting, you can run npx prettier --write **
.
All paths are prefixed by /vx
, where x
is the version number.
Get some information about this leader.
GET /vx/info
Response:
200 OK
{
"uuid": "be44c20b-e5e6-40d3-ba07-d1966e158f84"
}
Get a list of clients connected to this leader.
POST /vx/clients
Response:
200 OK
{
"clients": [
{
"uuid": "be44c20b-e5e6-40d3-ba07-d1966e158f84",
"available": true,
"status": "hi",
"lastUpdate": "2020-07-18T22:35:33.531Z"
}
]
}
Add a performance test to the queue.
POST /vx/performance
Request Body:
function runRequest() {
console.log("hi")
}
module.exports = {
runtimeSeconds: 5,
runRequest: runRequest
}
Response:
200 OK
{
"test_uuid": "223fe4d4-bbbf-47f0-b1cb-abe0b357d842"
}
Get a performance test .
GET /vx/performance/{performance_uuid}
Response:
200 OK
{
"uuid": "223fe4d4-bbbf-47f0-b1cb-abe0b357d842",
"status": "done",
"followers": [
{
"uuid": "9041a92f-6d44-4b31-aa5d-65851fd32616",
"available": true,
"status": "hi",
"lastUpdate": "2020-07-18T02:38:42.467Z"
}
],
"run_jobs": [
{
"config": {
"performanceUuid": "223fe4d4-bbbf-47f0-b1cb-abe0b357d842"
},
"status": "completed",
"uuid": "28f0fce9-2f00-4e08-97ac-5eca091c27ed",
"type": "performance_run",
"result": {
"total": 10,
"success": 10,
"failed": 0
}
}
],
"plan_jobs": [
{
"config": {
"performanceUuid": "223fe4d4-bbbf-47f0-b1cb-abe0b357d842",
"config": "\r\nfunction runRequest() {\r\n console.log(\"hi\")\r\n}\r\n\r\nmodule.exports = {\r\n runtimeSeconds: 5,\r\n runRequest: runRequest\r\n}\r\n"
},
"status": "completed",
"uuid": "706495ee-91a9-476e-9b59-ddadefc9003e",
"type": "peformance_plan"
}
],
"result": {
"total": 10,
"success": 10,
"failed": 0
}
}
Connect to a Spammer leader.
POST /vx/connect
Request Body:
{
"socket_address": "localhost:5435"
}
Response:
200 OK
Disconnect from a Spammer leader.
DELETE /vx/leader/${leader_uuid}
Response:
200 OK
Configuration body:
rps
: Number of requests per second.runtimeSeconds
: Total length of the performance test.
Configuration body:
interface: http
method
: The HTTP method to use.url
: The url to send the request to.
Metrics:
response_code
: A list of response codes.response_time
: A list of response times in ms.
Example:
Configuration body:
module.exports = {
runtimeSeconds: 5,
interface: 'http',
method: 'post',
url: 'http://localhost:5435/123'
}
Metrics:
"result": {
"response_code": [
[
404,
404,
404,
404,
404,
404,
404,
404,
404,
404
]
],
"response_time": [
[
4,
6,
2,
4,
4,
6,
2,
3,
3,
5
]
],
"successful_requests": 10,
"total_requests": 10,
"response_code_percentile_80": 4,
"response_code_percentile_95": 5,
"response_code_percentile_99": 6
}