I'm trying to understand the flow within a locust test. I've set up this very simple task set and user:
from locust import TaskSet, HttpLocust, task
class BlazeDemoTaskSet(TaskSet):
def setup(self):
print("hello from taskset setup")
def teardown(self):
print("hello from taskset teardown")
def on_start(self):
print("hello from taskset on_start")
def on_stop(self):
print("hello from taskset on_stop")
@task
def reserve_task(self):
post_response = self.client.post(
url="/reserve.php",
params={"toPort": "Buenos Aries", "fromPort": "Paris"})
class BlazeDemoUser(HttpLocust):
task_set = BlazeDemoTaskSet
min_wait = 500
max_wait = 1500
host = "http://www.blazedemo.com"
def setup(self):
print("hello from httplocust setup")
def teardown(self):
print("hello from httplocust teardown")
and I run it with:
locust -f tests/blazedemo.py --no-web -c 1 -r 1 -n 2
I'm not seeing the HttpLocust
setup
or teardown
methods being executed, and I'm not seeing the TaskSet
setup
, on_stop
, or teardown
methods being executed. The only methods that get run are on_start
and reserve_task
According to the docs all of these methods should be run. Setup and teardown once per run, and on_start and on_stop for each user that is started.
Here is the entire output from Locust:
[2018-03-22 18:26:50,698] C02PV7NSG8WP/INFO/locust.main: Starting Locust 0.8.1
[2018-03-22 18:26:50,698] C02PV7NSG8WP/INFO/locust.runners: Hatching and swarming 1 clients at the rate 1 clients/s...
Name # reqs # fails Avg Min Max | Median req/s
--------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------
Total 0 0(0.00%) 0.00
[2018-03-22 18:26:50,699] C02PV7NSG8WP/INFO/stdout: hello from taskset on_start
[2018-03-22 18:26:50,699] C02PV7NSG8WP/INFO/stdout:
[2018-03-22 18:26:51,703] C02PV7NSG8WP/INFO/locust.runners: All locusts hatched: BlazeDemoUser: 1
[2018-03-22 18:26:51,703] C02PV7NSG8WP/INFO/locust.runners: Resetting stats
Name # reqs # fails Avg Min Max | Median req/s
--------------------------------------------------------------------------------------------------------------------------------------------
POST /reserve.php?toPort=Buenos+Aries&fromPort=Paris 1 0(0.00%) 140 140 140 | 140 0.00
--------------------------------------------------------------------------------------------------------------------------------------------
Total 1 0(0.00%) 0.00
[2018-03-22 18:26:53,268] C02PV7NSG8WP/INFO/locust.runners: All locusts dead
[2018-03-22 18:26:53,268] C02PV7NSG8WP/INFO/locust.main: Shutting down (exit code 0), bye.
Name # reqs # fails Avg Min Max | Median req/s
--------------------------------------------------------------------------------------------------------------------------------------------
POST /reserve.php?toPort=Buenos+Aries&fromPort=Paris 2 0(0.00%) 139 139 140 | 140 0.00
--------------------------------------------------------------------------------------------------------------------------------------------
Total 2 0(0.00%) 0.00
Percentage of the requests completed within given times
Name # reqs 50% 66% 75% 80% 90% 95% 98% 99% 100%
--------------------------------------------------------------------------------------------------------------------------------------------
POST /reserve.php?toPort=Buenos+Aries&fromPort=Paris 2 140 140 140 140 140 140 140 140 140
--------------------------------------------------------------------------------------------------------------------------------------------
What have I missed? Thank you in advance!