Skip to content

YAML configuration

In order to generate a valid LocustTest custom resource, a valid yaml configuration should be prepared.

The following sections will break-down the supported configuration and provide the full YAML spec at the end.

Note

Although all following examples are for a single test, _Intensive Brew_ supports having several _test_ configurations in the same `.yaml` file.

Locust configuration

This sections highlight all the available options that would impact the configuration of Locust.

Test entry point

entry_point: str is a mandatory field that allows Intensive Brew to know which .py file to use as an entry to locust.

test-config.yaml
configurations:
  ...
  test_name:
    entry_point: "<path>/demo.py" # (1)!
  1. The provided path must be relative to the location of test-config.yaml.

Test load requirements

vanilla_specs: object is a mandatory section that can be used to configure:

  • Number of users
  • Users spawn rate
  • Test duration
  • Target host of the test
  • Timeout to end all current tasks if run_time was reached [Optional field]
test-config.yaml
configurations:
  ...
  test_name:
    ...
    vanilla_specs:
      # * Number of users
      users: int
      # * Users spawn rate
      spawn_rate: int
      # * Test duration
      run_time: str # (1)!
      # * Test target URL 
      target_host: str
      # * Timeout to end current task (sec)
      termination_timeout: int
  1. This field support different was of expressing duration e.g. (300s, 20m, 3h, 1h30m, etc.). Default value is 30s.

Custom load shapes

custom_load_shapes: bool is an optional flag that enables the support of Locust "Custom Load Shapes" feature. This feature doesn't follow the traditional way of declaring users, spawn rate and test run duration.

Important

  • When this flag is set to true, the vanilla_specs section becomes optional and is ignored even if provided.
  • Additional configuration like test target host is expected to be passed through custom config files or directly coded into the test.
test-config.yaml
configurations:
  ...
  test_name:
    ...
    # * Enable "custom load shapes" support. Default: false
    custom_load_shapes: true

Cluster nodes configuration

This sections highlight all the available options that would impact the configuration of the deployed cluster nodes.

Locust container image

image: str is an optional flag that instructs Intensive Brew to populate the image field in LocustTest. Default is to use the latest Locust image.

test-config.yaml
configurations:
  ...
  test_name:
    ...
    image: str

Kubernetes test configuration map

configmap: str is an optional flag that instructs Intensive Brew to populate the configMap field in LocustTest. This is a feature supported by the Locust Operator where it is possible to [deploy tests as k8s configMap] and then having it mounted on the load generation pods.

test-config.yaml
configurations:
  ...
  test_name:
    ...
    configmap: <valid k8s configMap name>

Worker replicas count

worker_replicas: int is an optional flag that instructs Intensive Brew to populate the workerReplicas field in LocustTest. Default value is 5.

test-config.yaml
configurations:
  ...
  test_name:
    ...
    worker_replicas: int

Kubernetes Affinity

It is an optional section that instructs Intensive Brew to populate the affinity field in LocustTest. The spec is structured in a similar way as the Operator.

test-config.yaml
configurations:
  ...
  test_name:
    ...
    affinity:
      nodeAffinity:
        requiredDuringSchedulingIgnoredDuringExecution: # (1)!
          <label-key>: <label-value> 
  1. Can contain as many entries as desired.

Kubernetes pod taint tolerations

It is an optional flag that instructs Intensive Brew to populate the tolerations field in LocustTest. The spec is structured in a similar way as the Operator.

test-config.yaml
configurations:
  ...
  tolerations: # (1)!
      - key: <string value>
        operator: <"Exists", "Equal">
        value: <string value>
        effect: <"NoSchedule", "PreferNoSchedule", "NoExecute">
      ...
  1. Can contain as many entries as desired.

Expert mode

expert_mode: obj is an optional section that grants direct control over what the LocustTest fields for masterCommandSeed & workerCommandSeed will contain.

Important

  • When this section is set, all other sections from the "Locust configuration" section becomes optional and is ignored even if provided.

Warning

  • Activating this mode will suppress any processing of the data and directly pass the command "as-is".
  • If you find yourself using this mode frequently, consider opening a feature request to support your use case instead.
test-config.yaml
configurations:
  ...
  test_name:
    # ! USE WITH CAUTION
    expert_mode:
      # * Enable expert mode. Default: false
      enabled: bool
      # * Commands to pass "as-is"
      masterCommandSeed: str
      workerCommandSeed: str

Full YAML spec

test-config.yaml
configurations:
  # Test name
  load_test:

    #  Entry point script
    entry_point: str # (1)!

    # Load requirements
    vanilla_specs: 
      # Number of users
      users: int # (2)!
      # Users spawn rate
      spawn_rate: int # (3)!
      # Test duration
      run_time: str # (4)!
      # Test target URL 
      target_host: str # (5)!
      # Timeout to end current task (sec) 
      termination_timeout: int # (11)!

    # Custom load shapes support.
    custom_load_shapes: bool

    # Locust container image
    image: str # (8)!

    # Test configuration map
    configmap: str # (6)!

    # Worker replicas
    worker_replicas: int # (7)!

    # Kubernetes affinity
    affinity: # (9)!
      nodeAffinity:
        requiredDuringSchedulingIgnoredDuringExecution: 
          <label-key>: <label-value>

    # Kubernetes pod taint toleration      
    tolerations: # (10)!
      - key: <string value>
        operator: <"Exists", "Equal">
        value: <string value>
        effect: <"NoSchedule", "PreferNoSchedule", "NoExecute">

    # ! USE WITH  CAUTION
    expert_mode:
      # Enable expert mode. Default: false
      enabled: bool
      # Commands to pass "as-is"
      masterCommandSeed: str
      workerCommandSeed: str
  1. This field maps to the --locustfile locust switch and appears in masterCommandSeed & workerCommandSeed of the LocustTest custom resource.
  2. This field maps to the --users locust switch and appears in masterCommandSeed of the LocustTest custom resource.
  3. This field maps to the --spawn-rate locust switch and appears in masterCommandSeed of the LocustTest custom resource.
  4. This field maps to the --run-time locust switch and appears in masterCommandSeed of the LocustTest custom resource.
  5. This field maps to the --host locust switch and appears in masterCommandSeed of the LocustTest custom resource.
  6. This field maps to the configMap section of the LocustTest custom resource.
  7. This field maps to the workerReplicas section of the LocustTest custom resource.
  8. This field maps to the image section of the LocustTest custom resource.
  9. This field directly maps to the affinity section of the LocustTest custom resource.
  10. This field directly maps to the tolerations section of the LocustTest custom resource.
  11. This field maps to the --stop-timeout locust switch and appears in masterCommandSeed of the LocustTest custom resource.

Last update: November 21, 2023