-
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
Changes made during setup only effect the first user #1265
Comments
I think the core of this confusion is that setup is only run once, for the first Locust/TaskSet. @heyman How would you feel about changing setup/teardown to functions instead of object methods (so people cant access self and thus get these unexpected behaviours) |
@cyberw I think that's a good idea. I don't think that global setup/teardown functions for a whole test run belongs on the user class at all. I'm working on a branch where I'm refactoring quite a bit of Locust's internal code. I'm introducing an from locust import environment
def setup(**kwargs):
# run setup code
def teardown(**kwargs):
# my teardown
environment.events.test_start.add_listener(setup)
environment.events.test_stop.add_listener(teardown) |
Cool! Lets wait for that them! |
Seems like part of this got done? Is there an issue we can subscribe to for any open items? |
@weitzman Yes, you're right! In the upcoming 1.0 version the |
Describe the bug
Values made during setup (regardless of if it's set on UserBehavior, WebsiteUser or on HttpLocust) are cleared for all locust except for the first one.
Expected behavior
Variable made during setup will effect all locust. Additionally default session should be editable. Or the documentation should be updated to reflect Setup only effecting one User.
Actual behavior
Variables made during setup will only effect the first TaskSet that runs. Other Users will not have access to things done in setup. For example file:
Stdout:
Currently the documentation implies this should effect all users. If you don't plan on changing setup documentation should be updated.
From https://docs.locust.io/en/stable/writing-a-locustfile.html#setups-teardowns-on-start-and-on-stop:
Seems to be running before first TaskSet but not before tasks are run. Or
Would be helpful if you mentioned you can't changes made here will only effect the first locust. Or show some sort of example of how to edit the session (besides cookies) in a way that will effect all Users if I'm not running setup on Locust correctly. Some of the confusion may be like previous ticket I read says in that Locust is both name of tool and name of User and I'm reading it as tool.
But it would make sense if there was a setup that ran once before the test and could effect session defaults and once before each locust runs. But once before a single locust is confusing. Currently it seems the built in setup functions force you to set something that effects all users you need to either do it on on_start (which may make you call an API per client which causes issues) or set it up outside Locust which just doesn't look clean.
Steps to reproduce
Environment
OS: OSX 10.14.6
Python version: Python 3.6.8
Locust version:locust 0.14.4
Locust command line that you ran:
locust -c 5 -r 5 -t 30s --no-web --csv=example.txt -H http://google.com -f example.py
Locust file contents (anonymized if necessary):
Note: I do know you could work around this by running:
at the top of the file, but it seems deceiving to have a Setup that doesn't work as Test Frameworks usually use Setup.
The text was updated successfully, but these errors were encountered: