-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Execution order? task lifetime? #195
Comments
Correct.
Correct.
The task will restart after some wait time. If you want to kill the Locust you can raise |
Though possible, Locust instances are not designed to die or complete until the test has finished. If they die, Locust will not spawn a new one. If you want to simulate users starting and ending sessions, I would recommend you to have a task that ends the session and starts a new one in the same Locust instance, and thus recycle the existing locusts/greenlets that have been spawned. Then weight that task appropriately to control how likely it is that a new session will be started. Something like this: class UserBehaviour(TaskSet):
def on_start(self):
self.new_session()
@task(1)
def new_session():
if self.locust.session:
self.locust.session.end()
self.locust.session.create()
... |
I'm seeing some issues with the lifecycle in my behavior where the test goes on forever, but it shouldn ultimately finish, correct? I've modeled it off of your example, @heyman, where the session is terminated when the Task is re-used. I also played around with raising StopLocust on complete (after calling my session end) which resulted in the test reducing down to 0 clients and just sitting there (not giving the final stats list). I guess I'm just not completely clear on what constitutes the Locust suite "completing". Any insight that might help me wrap my head around it? |
Except when setting a maximum number of requests using |
I must have been setting that previously when I was seeing it completing. Hm. |
How do we publish stats every hour without stopping locust. I am running several threads and I want to collect the stats for each thread, rather than aggregated_stats(). Any suggestions/help? |
Did you get any way to do this? |
I'm trying to use Locust to test the lifecycle of a user on top of my API. The lifecycle being, create, a heartbeat, update requests and finally a destroy/end of the session; however, I'm not entirely clear on the lifecycle of the tasks.
Locust spawns a greenlet for each "user" which runs the task set, correct?
So if I define specific actions within a single task, they should operate synchronously?
And then the greenlet is destroyed/ended when the tasks have completed?
Illustrated in code: Given a single task in a behavior set, each spawned user should create their session, heartbeat for 60 seconds and then end their session.
Am I approaching this correctly?
@heyman
The text was updated successfully, but these errors were encountered: