Let’s say this is the primary file I would run in terminal i.e locusts -f main.py
. Is it possible to have it also run code after the locust instance is terminated or when time limit is reached? Possibly a cleanup script or sending the csv reports generated somewhere.
JavaScript
x
7
1
class setup(HttpUser):
2
wait_time = between(3, 5)
3
host = 'www.example.com'
4
tasks = [a, b, c ]
5
6
#do something after time limit reached
7
Advertisement
Answer
There is a test_stop
event (https://docs.locust.io/en/stable/extending-locust.html) as well as a quitting
event (https://docs.locust.io/en/stable/api.html#locust.event.Events.quitting) you can use for this purpose.