perst

perst is a load test tool for your website. It can be used in your CI or locally.

View on GitHub

perst Build Status Coverage Status

perst is a wrapper around LoaderIO, which can be configured and run in your commandline multiple tests and validates the measureable values like AVG Response Time and AVG Error Rate.

Table of Contents

Command Line Options

Usage: perst [options]

Basic options:

Switch Description
-c, –config FILENAME Use this config file (if argument is used but value is unspecified, defaults to .perstrc)
-d, –dry-run Runs all test in dry-run mode
-h, –help Show this help message
-v, –version Show version number
–ci Runs this on a CI
–dump-config [FORMAT] dumps the config to the stdout in given format (yaml, yml, json, js). Default: yaml
-f, –filter PATTERN filters the task by given regex. The name attribute will be used with the regex
–color force the output with colors
–no-color force the output without colors
–list-tasks lists all available tasks
-s, –silent silent mode
–stop-on-failure stops the tasks execution, if a task fails

Configuration files

At the following locations in the root directory and format can be placed the configuration.

The files will be searched in this order. The first match will be used.

Or you run perst with the command line switch -c.

You can use environment variables in your configuration. Environment variables are only supported in YAML Files. Every environment variable can be written in the format $NAME or ${NAME}. Only existing environment variables will replaced. YAML configuration use YAML Version 1.2 and supports anchors.

Big list of configuration options

version

Defines the version of the configuration file.

api

Defines some api information currently for loader IO.

api.token

Defines the loader IO API token.

api.server

Defines the loader IO API server url.

api.version

Defines the loader IO API version.

app

Defines some application options.

app.domain

Defines the domain for load testing. The domain must be defined in loader IO and must be verified.

tasks

Defines every task which should be run. This is an object of tasks.

tasks.[name].name

Defines the name of the task in loader IO. This name will be used to find an existing task to reuse and rerun them. If no task can be found with this name, the task will be created.

tasks.[name].type

Defines the test type for the task. The article Test Types and Understanding the different test types describe detailed information about the test type.

Task Type “Clients per test” per-test

With the “Clients per test” type, you specify the total number of clients to connect to your application over the duration of the test. If you specify 20000 clients for a 20-second test, 1000 clients will connect each second during that test.

Clients per test

Task Type “Clients per second” per-second

The “Clients per second” type is similar to “Clients per test”, but instead of specifying the total, you specify the number of clients to start each second. A 20-second test with 1000 clients per second is the same as a 20-second test at 20000 clients per test.

Clients per second

Task Type “Maintain client load” maintain-load

This test allows you to specify a from and a to value for clients. If you specify 0 and 10000 here for example, the test will start with 0 clients and increase up to 10000 simultaneous clients by the end of the test.

Maintain client load

tasks.[name].duration

Defines the execution duration of the test in seconds.

tasks.[name].clientsStart

This defines number of clients for the start for the test type Maintain client load. This value will be ignored for all other test types.

tasks.[name].clients

This defines number of clients, which should be used. I case of the test type Maintain client load, this will be the number of client at the end of the test.

tasks.[name].timeout

This defines the timeout for one request. This value is in milliseconds.

tasks.[name].errorThreshold

This defines the error percentage threshold.

tasks.[name].notes

This defines some notes to add to the test.

tasks.[name].tags

This defines some tags to add to the test.

tasks.[name].threshold

This defined the relevant threshold, whether the test should fail or not.

tasks.[name].threshold.avgResponseTime

This defines the maximum average response time in milliseconds, which is allowed. If the test exceeds this value, the task will fail.

tasks.[name].threshold.avgErrorRate

This defines the maximum average error rate, which is allowed. If the test exceeds this value, the task will fail.

tasks.[name].requests

This defines the multiple request options for the test. This property can be defined beside the tasks.[name].request property, but it can also be defined without the tasks.[name].request property. If both properties are defined, the first request is the request, which is defined in the property tasks.[name].request.

The descriptions of the object in this array are the same as described in the property tasks.[name].request.

tasks.[name].request

This defines the request options for the test. This property can be defined beside the tasks.[name].requests property, but it can also be defined without the tasks.[name].requests property. If both properties are defined, the first request is the request, which is defined in the property tasks.[name].request.

tasks.[name].request.path

This defines the absolute path for the request. The path can be start with a / or without it. This path will be combined with the property api.domain.

tasks.[name].request.type

This defines method for the request.

tasks.[name].request.payloadFile

This defines a URL of a payload file. Detailed information about the payload file can be found in the article Payload Files.

tasks.[name].request.headers

This defines header values for the request. If you defined this property, you have to declare the header accept-encoding on your own.

tasks.[name].request.parameters

This defines an array with parameters objects. These parameters will be sent in query string or POST body.

tasks.[name].request.parameters[index].name

This defines the name of the parameter.

tasks.[name].request.parameters[index].value

This defines the name of the parameter.

tasks.[name].request.authentication

This defines options for the authentication.

tasks.[name].request.authentication.type

This defines the type of the authentication.

The value basic defines the authentication as HTTP Basic Auth.

tasks.[name].request.authentication.login

This defines login or user name for the authentication.

tasks.[name].request.authentication.password

This defines password for the authentication.

tasks.[name].request.variables

This defines variables whose values will be taken from the header. These variables can be used in all following request. You can read more information in the article Variables.

tasks.[name].request.variables[index].name

This defines the name of the variable for later use.

tasks.[name].request.variables[index].property

This defines the header property name to get the value from the request.

tasks.[name].request.variables[index].source

This defines source of the variables.

Configuration Examples

YAML

version: 1
api:
    token:   bb74abe565ec005944ffcbfa846431e1
    server:  https://api.loader.io
    version: v2

app:
    domain: https://www.example.com

tasks:
    tasks1:
        name:         Task 1
        type:         per-second
        duration:     60
        clientsStart: 1
        clients:      25
        timeout:      10000
        notes:        "some notes"
        tags:
            - tag 1
            - tag 2
        threshold:
            avgResponseTime: 500
            avgErrorRate:    0
        request:
            path:        /nuff/narf
            type:        GET
            payloadFile: https://www.example.de/file
            headers:
                accept-encoding: gzip
            parameters:
                -   name:  parameter 1
                    value: value of parameter 1
                -   name:  parameter 2
                    value: value of parameter 2
            authentication:
                type:     basic
                login:    login
                password: password
            variables:
                -   name:     variable 1 name
                    property: variable 1 property
                    source:   variable 1 source
                -   name:     variable 2 name
                    property: variable 2 property
                    source:   variable 2 source
    tasks2:
        name:     Task 2
        duration: 60
        clients:  25
        threshold:
            avgResponseTime: 500
            avgErrorRate:    0
        requests:
            -   path: /nuff/narf
            -   path: /rofl/copoter

JSON

{
    "version": 1,
    "api": {
        "token": "bb74abe565ec005944ffcbfa846431e1",
        "server": "https://api.loader.io",
        "version": "v2"
    },
    "app": {
        "domain": "https://www.example.com"
    },
    "tasks": {
        "tasks1": {
            "name": "Task 1",
            "type": "per-second",
            "duration": 60,
            "clientsStart": 1,
            "clients": 25,
            "timeout": 10000,
            "notes": "some notes",
            "tags": [
                "tag 1",
                "tag 2"
            ],
            "threshold": {
                "avgResponseTime": 500,
                "avgErrorRate": 0
            },
            "request": {
                "path": "/nuff/narf",
                "type": "GET",
                "payloadFile": "https://www.example.de/file",
                "headers": {
                    "accept-encoding": "gzip"
                },
                "parameters": [
                    {
                        "name": "parameter 1",
                        "value": "value of parameter 1"
                    },
                    {
                        "name": "parameter 2",
                        "value": "value of parameter 2"
                    }
                ],
                "authentication": {
                    "type": "basic",
                    "login": "login",
                    "password": "password"
                },
                "variables": [
                    {
                        "name": "variable 1 name",
                        "property": "variable 1 property",
                        "source": "variable 1 source"
                    },
                    {
                        "name": "variable 2 name",
                        "property": "variable 2 property",
                        "source": "variable 2 source"
                    }
                ]
            }
        },
        "tasks2": {
            "name": "Task 2",
            "duration": 60,
            "clients": 25,
            "threshold": {
                "avgResponseTime": 500,
                "avgErrorRate": 0
            },
            "requests": [
                {"path": "/nuff/narf"},
                {"path": "/rofl/copoter"}
            ]
        }
    }
}

JavaScript

export default {
    "version": 1,
    "api": {
        "token": "bb74abe565ec005944ffcbfa846431e1",
        "server": "https://api.loader.io",
        "version": "v2"
    },
    "app": {
        "domain": "https://www.example.com"
    },
    "tasks": {
        "tasks1": {
            "name": "Task 1",
            "type": "per-second",
            "duration": 60,
            "clientsStart": 1,
            "clients": 25,
            "timeout": 10000,
            "notes": "some notes",
            "tags": [
                "tag 1",
                "tag 2"
            ],
            "threshold": {
                "avgResponseTime": 500,
                "avgErrorRate": 50
            },
            "request": {
                "path": "/nuff/narf",
                "type": "GET",
                "payloadFile": "https://www.example.de/file",
                "headers": {
                    "accept-encoding": "gzip"
                },
                "parameters": [
                    {
                        "name": "parameter 1",
                        "value": "value of parameter 1"
                    },
                    {
                        "name": "parameter 2",
                        "value": "value of parameter 2"
                    }
                ],
                "authentication": {
                    "type": "basic",
                    "login": "login",
                    "password": "password"
                },
                "variables": [
                    {
                        "name": "variable 1 name",
                        "property": "variable 1 property",
                        "source": "variable 1 source"
                    },
                    {
                        "name": "variable 2 name",
                        "property": "variable 2 property",
                        "source": "variable 2 source"
                    }
                ]
            }
        },
        "tasks2": {
            "name": "Task 2",
            "duration": 60,
            "clients": 25,
            "threshold": {
                "avgResponseTime": 500,
                "avgErrorRate": 0
            },
            "requests": [
                {"path": "/nuff/narf"},
                {"path": "/rofl/copoter"}
            ]
        }
    }
}