Skip to content

Setup

This module contains step implementations that setup the load test scenario with parameters that is going to be used in the scenario they are defined in.

Given iterations

Given repeat for "{value}" {iteration_number:IterationGramaticalNumber}

[view_source]

Set how many iterations of the Tasks in the scenario should execute.

Default value is 1. A value of 0 means to run until all test data is consumed, or that the (optional) specified runtime for the scenario is reached.

Example:

And repeat for "10" iterations
And repeat for "1" iteration
And value for variable "leveranser" is "100"
And repeat for "{{ leveranser * 0.25 }}" iterations

Arguments:

  • value str - number of iterations of the scenario, can be a templatning string or a environment configuration variable

Given pace

Given set iteration time to "{pace_time}" milliseconds

[view_source]

Set minimum time one iterations of the Tasks in the scenario should take. E.g. if pace is set to 2000 ms and the time since it last ran was 300 ms, this task will sleep for 1700 ms. If the time of all tasks is greater than the specified time, there will be an error, but the scenario will continue.

This is useful to be able to control the intensity towards the loadtesting target.

Example:

Then set iteration time to "2000" milliseconds
Then set iteration time to "{{ pace }}" milliseconds

Given set variable alias

Given set alias "{alias}" for variable "{variable}"

[view_source]

Create an alias for a variable that points to another structure in the context.

This is useful if you have test data that somehow should change the behavior for a user, e.g. username and password.

Example:

And value for variable "AtomicCsvReader.users" is "users.csv | repeat=True"
And set alias "auth.user.username" for variable "AtomicCsvReader.users.username"
And set alias "auth.user.password" for variable "AtomicCsvReader.users.password"

Variables in payload templates are not allowed to have an alias.

Arguments:

  • alias str - which node in the context that should get the value of variable
  • variable str - an already initialized variable that should be renamed

Given log all requests

Given log all requests

[view_source]

Set if all requests should be logged to a file.

By default only failed requests (and responses) will be logged.

Example:

And log all requests

Given stop user on failure

Given stop user on failure

[view_source]

Stop user if a request fails.

Attention

This step is deprecated and will be removed in the future, use step_setup_failed_task_default instead.

Default behavior is to continue the scenario if a request fails.

Example:

And stop user on failure

Given restart scenario on failure

Given restart scenario on failure

[view_source]

Restart scenario, from first task, if a request fails.

Attention

This step is deprecated and will be removed in the future, use step_setup_failed_task_default instead.

Default behavior is to continue the scenario if a request fails.

Example:

And restart scenario on failure

When failed task custom

When a task fails with "{failure:FailureType}" {failure_action:FailureActionStepExpression}

[view_source]

Set behavior when specific failure occurs.

It can be either a str or an exception type, where the later is more specific.

Example:

When a task fails with "504 gateway timeout" retry step
When a task fails with "RuntimeError" stop user

When failed task default

When a task fails {failure_action:FailureActionStepExpression}

[view_source]

Set default behavior when a task fails.

If no default behavior is set, the scenario will continue as nothing happened.

Example:

When a task fails restart scenario
When a task fails stop user

Then metadata

Then metadata "{key}" is "{value}"

[view_source]

Set a metadata (header) value to be used by the user when sending requests.

When step expression is used before any tasks has been added in the scenario the metadata will be used for all requests the specified loadtesting user executes in the scenario.

If used after a Request task, the metadata will be added and only used for that request.

If used after a task that implements grizzly.auth.GrizzlyHttpAuthClient (e.g. HTTP), the metadata will be added and only used when that task executes.

Example:

And metadata "Content-Type" is "application/xml"
And metadata "Ocp-Apim-Subscription-Key" is "9asdf00asdf00adsf034"

Or, for use in one request only, specify metadata after the request:

Then post request ...
And metadata "x-header" is "{{ value }}"

Then get from "https://{{ client_url }}" with name "client-http" and save response payload in "payload"
And metadata "Ocp-Apim-Subscription-Key" is "deadbeefb00f"