Locust Guide

Before running Locust, we’ll outline some top-level concepts and what a “locustfile” is.


To define a task, annotate a python function with the @task annotation from the Locust library:

def get_front_page(self):

These tasks are composed within a class called a TaskSet, which can be unordered (once again, a TaskSet) or ordered (TaskSequence).

class LoginTask(AppianTaskSet):
    def on_start(self):

    def get_front_page(self):

    def get_help_page(self):

These together form a locustfile. You can see an example file here.


A SequentialTaskSet is a TaskSet whose tasks will be executed in the order that they are declared. It is possible to nest SequentialTaskSets within a TaskSet and vice versa.

class OrderedEndToEndTaskSequence(AppianTaskSequence):
    def nav_to_random_site(self):

    @repeat(5, WAIT_TIME)
    def nav_to_specific_site(self):

    @repeat(10, WAIT_TIME)
    def increment_iteration_counter(self):
        if self.iterations >= max_iterations:
  "Stopping the Locust runner")
  "Incrementing the iteration set counter")
            self.iterations += 1
  • A Locust-spawned user will repeatedly execute tasks in the order and with the frequency specified by @repeat annotation. In this case test will have to be stopped manually by the dev based on some condition. Usually it can be based on a set number of iterations as shown by the example above.

  • WAIT_TIME passed into @repeat decorator will make sure there is set amount of time between the repetitions of a particular task.

  • Taks which do not have the @repeat decorator will only execute one during their turn.


And lastly, you supply a “Locust”, or a representation of a single user that will interact with the system. At runtime you can decide how many users and how fast they should spin up.

class UserActor(HttpUser):
    wait_time = between(0.5, 0.5)
    tasks = [LoginTask]
    host = ""

See How to Run Locust to see how to run a locust file.

A note on config_utils

These two lines look for a config.json file at the location from which the script is run (not where the locustfile is).

from appian_locust.loadDriverUtils import utls


This takes the content of the config.json file and places it into a variable as utls.c. This allows us to access configurations required for logging in inside the class that extends HttpUser:

config = utls.c
auth = utls.c['auth']

A minimal config.json looks like:

    "host_address": "",
    "auth": [

A note on Locust Environments

As of Locust 1.0.0, properties of a particular Locust run have been moved into the environment framework. The best way to get a reference to this environment is to register a listener for initialization (which includes a reference to it) it and to store this reference:

from locust import events
from appian_locust.helper import ENV

def on_locust_init(environment, **kw):
    global ENV
    ENV = environment

def end_test():