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
Allow only "client" or "server".
Given save statistics
Given save statistics to "{url}"
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}"
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 ofINFO
,DEBUG
,WARNING
,ERROR
Given run time
Given run for maximum "{timespan}"
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 set global context variable
Given set global context variable "{variable}" to "{value}"
Create a global variable in the context.
Depending on which type of user a scenario is configured for, different variables are available. Check Load User documentation for which context variables are available for each user.
This step can be used if the feature file has multiple scenarios and all of them have the same context variables.
Variable names can contain (one ore more) dot (.
) or slash (/
) to indicate that the variable is in a structure. All names will also be
converted to lower case.
E.g. token.url
and token/URL
results in:
Space in variable names is also allowed and will then be translated to an underscore (_
)
E.g. Client ID
results in client_id
.
{
'token': {
'url': '<value>'
}
}
Example:
And set global context variable "token.url" to "http://example.com/api/auth"
And set global context variable "token/client_id" to "aaaa-bbbb-cccc-dddd"
And set global context variable "token/client secret" to "aasdfasdfasdf=="
And set global context variable "token.resource" to "0000-aaaaaaa-1111-1111-1111"
And set global context variable "log_all_requests" to "True"
And set global context variable "validate_certificates" to "False"
And set global context variable "run_id" to "13"
Data type of values will be guessed, if not explicitly specified by the type of variable used (Atomic*
). E.g. the last two
examples above will result in:
{
'validate_certificates': False,
'run_id': 13
}
Arguments:
variable
str - variable name, as used in templatesvalue
str - variable value
Given message type callback
Given register callback "{callback_name}" for message type "{message_type}" from {from_node:MessageDirection} to {to_node:MessageDirection}
Register a custom callback function for a custom message type, that should be sent from client/server to client/server (exclusive).
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 functionmessage_type
str - unique name of the messagefrom_node
MessageDirection - server or client, exclusiveto_node
MessageDirection - client or server, exclusive