Skip to content

A distributed performance testing tool written in NodeJS

Notifications You must be signed in to change notification settings

LeonPatmore/spammer-v2

Repository files navigation

SpammerV2

LeonPatmore

Running

npm start

Environment Variables

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.

Testing

Unit Tests

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

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.

Mutation Tests

npm run mutation

Report

The mutation report is generated in reports/mutation/html.

Mutation Coverage

Mutation test coverage thresholds are configuered in stryker.conf.js:

thresholds: {
    high: 80,
    low: 60,
    break: 50,
}

Functional

README

Static Analysis

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 **.

API

All paths are prefixed by /vx, where x is the version number.

Leader API

Info

Get some information about this leader.

GET /vx/info

Response:

200 OK

{
    "uuid": "be44c20b-e5e6-40d3-ba07-d1966e158f84"
}

Get Clients

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 Performance Test

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 Performance Test

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
    }
}

Follower API

Connect to a Leader

Connect to a Spammer leader.

POST /vx/connect

Request Body:

{
    "socket_address": "localhost:5435"
}

Response:

200 OK

Disconnect from a Leader

Disconnect from a Spammer leader.

DELETE /vx/leader/${leader_uuid}

Response:

200 OK

Interfaces

Common

Configuration body:

  • rps: Number of requests per second.
  • runtimeSeconds: Total length of the performance test.

HTTP

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
    }

Deployment

AWS

README

About

A distributed performance testing tool written in NodeJS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published