Skip to content

Artillery Config

The artillery.yml file is a config file that contains the scenarios to run. It has three main sections:

  • config: the variables used in the scenarios
  • setup: the steps to run before the scenarios
  • scenarios: the scenarios to run

The config section

The config section contains the static variables that can be used in the scenarios.

config:
  variables:
    variable_name1: "variable value 1"
    # ...
    variable_nameN: "variable value N"

Note

All variables are usable in the following sections via the {{ variable_name }} syntax.

The setup section

The setup section is mainly used to retrieve dynamic variables from an API before running the scenarios. A typical example is retrieving a bearer token from the Woosmap authentication API. It can contain the following steps:

  • log: log a message in the console
  • request: make a request to the Woosmap API
    • url: url to call (mandatory)
    • kind: method to use (get, post)
    • json: json body to send
    • qs: query string to send
    • headers: headers to send
    • capture: capture a variable from the response
setup:
  - log: "Retrieve Bearer from authent and store it in a variable bearer_token"
  - request:
      url: "/auth/access_tokens"
      kind: "post"
      json:
        username: "{{ username_variable }}"
        password: "{{ password_variable }}"
      qs:
        param1: "{{ variable_name1 }}"
      headers:
        CustomHeader: "custom value in header"
      capture:
        - responseData: "access_token"
          as: "bearer_token"

The scenarios section

The scenarios section contains the scenarios to run. A scenario is a set of steps, and its syntax is mainly based on artillery's. It can contain the following steps:

  • flow: run a set of steps
    • log: log a message in the console
    • get | post: make a request to the Woosmap API
      • url: url to call (mandatory)
      • qs: query string to send
      • json: json body to send
      • headers: headers to send
      • capture: capture a variable from the response
      • expect: what is expected in the response (mandatory)
        • statusCode: expected status code (mandatory)
        • contentType: expected content type (mandatory)
        • bodyContain: expected body content matches this regexp (optional)
        • bodyCheck: list of expected values present in the json response (optional)
scenarios:
  - flow:
      - log: "Some debug message"
      - get | post:
          url: "/exemple/of/api/url_path"
          qs:
            params: "params_value"
            param_from_variable: "{{ variable_name1 }}"
          json:
            param_body1: "param_value"
            param_bodyN: "{{ variable_nameN }}"
          headers:
            Authorization: "Bearer {{ bearer_token }}"
          expect:
            statusCode: 200
            contentType: application/json
            bodyContain: 'body response should contain regexp .*'
            bodyCheck:
              response.details.0: ".*"
          capture:
            - responseData: "json.path"
              as: "variable_name"

The bodyCheck section

bodyCheck checks values in a JSON response. You can check several parts of the JSON. The key is a path following the gjson syntax and the value can be a regexp or a string.

Note

The regexp is currently matched against the whole response body, not against the value at the gjson path. A check passes if the regexp matches anywhere in the body. The gjson path is only used to report the resolved value when the check fails.

The capture section

The capture section captures a value from the response and stores it in a variable usable by the following steps. It can contain:

  • responseData: the path to the value to capture, following the gjson syntax
  • as: the name of the variable to store the value in