You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the hatching terminates on_master_stop_hatching is not triggered on the master but on_master_start_hatching triggers just fine
Locustfile.py
from locust import Locust, HttpLocust, TaskSet, task, between, events
import json,time
class UserBehavior(TaskSet):
@task(1)
def create_item(self):
headers = {'content-type': 'application/json'}
self.client.post("/create",data= json.dumps({
"title": "PT",
"description": "This is used for performance test"
}),
headers=headers,
name = "Create a new item")
@task(1)
def list_items(self):
headers = {'content-type': 'application/json'}
self.client.get("/list",
headers=headers,
name = "List all items")
class WebsiteUser(HttpLocust):
def setup(self):
print("Hello.. I am just starting the test")
task_set = UserBehavior
wait_time = between(3, 25)
def on_master_stop_hatching():
print("")
print("I am stopping on master")
print("")
events.master_stop_hatching += on_master_stop_hatching
I'm not sure if this is by design. When you run using --run-time, locust will "quit" on the master process after the specified time instead of "stop". As far as I can tell, the master process only "stop"s when you click stop in the web browser mode. The docstring mentions this:
*master_stop_hatching* is fired when terminate the hatching process on the master.
This event is especially useful to detect when the 'stop' button is clicked on the web ui.
So, if you want to know when the run time is over, you could use the quitting EventHook.
Or if you wanted to know when the all of the locusts are spawned, you should use the hatch_complete EventHook.
It does seem a bit weird though that the locust_stop_hatching event is fired on the worker processes but master_stop_hatching isn't on the master process when the time runs out.
This event and locust_stop_hatching have been replaced by test_stop in #1309, and the event runs just fine when running the 1.0.0 version of this script/commands. Actually, it runs twice!
Describe the bug
When the hatching terminates on_master_stop_hatching is not triggered on the master but on_master_start_hatching triggers just fine
Locustfile.py
from locust import Locust, HttpLocust, TaskSet, task, between, events
import json,time
class UserBehavior(TaskSet):
class WebsiteUser(HttpLocust):
def setup(self):
print("Hello.. I am just starting the test")
task_set = UserBehavior
wait_time = between(3, 25)
def on_master_stop_hatching():
print("")
print("I am stopping on master")
print("")
events.master_stop_hatching += on_master_stop_hatching
Master
locust --host=https://test.com --master --no-web --expect-slaves=1 -c 10 -r 10 --run-time=10s
Slave
locust -f locustfile.py --slave
Expected behavior
Master console should print
Actual behavior
Nothing gets printed
Steps to reproduce
Environment
The text was updated successfully, but these errors were encountered: