Skip to content

Setup

This module contains step implementations that configures the load test scenario with parameters applicable for all scenarios.

parse_message_direction

@parse.with_pattern(r'(client|server)', regex_group_count=1)
@permutation(vector=(True, True))
def parse_message_direction(text: str) -> str

[view_source]

Allow only "client" or "server".

Given save statistics

Given save statistics to "{url}"

[view_source]

Set an URL where locust statistics should be sent.

It has support for InfluxDB and Azure Application Insights endpoints.

For InfluxDB the following format must be used:

For Azure Application Insights the following format must be used:

influxdb://[<username>:<password>@]<hostname>[:<port>]/<database>?TargetEnviroment=<target environment>[&Testplan=<test plan>]
[&TargetEnvironment=<target environment>][&ProfileName=<profile name>][&Description=<description>]
insights://?InstrumentationKey=<instrumentation key>&IngestionEndpoint=<ingestion endpoint>[&Testplan=<test plan>]
insights://<ingestion endpoint>/?InstrumentationKey=<instrumentation key>[&Testplan=<test plan>]

Example:

And save statistics to "influxdb://grizzly:secret-password@influx.example.com/grizzly-statistics"
And save statistics to "insights://?IngestionEndpoint=https://insights.example.com&Testplan=grizzly-statistics&InstrumentationKey=asdfasdfasdf="
And save statistics to "insights://insights.example.com/?Testplan=grizzly-statistics&InstrumentationKey=asdfasdfasdf="
And save statistics to "influxdb://$conf::statistics.username$:$conf::statistics.password$@influx.example.com/$conf::statistics.database$"

Arguments:

  • url str - URL for statistics endpoint

Given log level

Given log level is "{log_level}"

[view_source]

Configure log level for grizzly.

Default value is INFO, by changing to DEBUG there is more information what grizzly is doing behind the curtains.

Example:

And log level is "DEBUG"

Arguments:

  • log_level str - one of INFO, DEBUG, WARNING, ERROR

Given run time

Given run for maximum "{timespan}"

[view_source]

Configure the time period a headless test should run for.

If available test data is infinite, the test will run forever if this step is not used.

Example:

And run for maximum "1h"

Arguments:

  • timespan str - description of how long the test should run for, e.g. 10s, 1h, 40m etc.

Given message type callback

Given register callback "{callback_name}" for message type "{message_type}" from {from_node:MessageDirection} to {to_node:MessageDirection}

[view_source]

Register a custom callback function for a custom message type, that should be sent from client/server to client/server (exclusive).

steps/custom.py
def my_custom_callback(env: Environment, msg: Message) -> None:
    print(msg)
Given register callback "steps.custom.my_custom_callback" for message type "custom_msg" from client to server

Arguments:

  • callback_name str - full namespace and method name to the callback function
  • message_type str - unique name of the message
  • from_node MessageDirection - server or client, exclusive
  • to_node MessageDirection - client or server, exclusive

Given configuration value

Given value for configuration "{name}" is "{value}"

[view_source]

Step to set configuration variables not present in specified environment file.

The configuration value can then be used in the following steps. If the specified name already exists, it will be overwritten.

Example:

Given value for configuration "default.host" is "example.com"
...
Then log message "default.host=$conf::default.host$"

Arguments:

  • name str - dot separated name/path of configuration value
  • value str - configuration value, any $..$ variables are resolved, but {{ .. }} templates are kept