Events listeners from all locust files being executed when running a single UserClass
See original GitHub issueDescribe the bug
When running locust with the new class-picker feature to choose the class to be executed the event listeners from all files are being executed, not just the ones inside the same file as the picked UserClass.
The use case for this is being able to use @events.test_start.add_listener
and @events.init.add_listener
to do independent setups for each test with the new class-picker.
Expected behavior
I’d expect that only event listeners inside the same file of the selected UserClass get executed.
Actual behavior
Event listeners of all files are being executed.
Steps to reproduce
- Create two separated locustfiles (each one representing a different test)
- On each locustfile add
@events.test_start.add_listener
methods to setup anything before test run - Execute the files in any of the ways below: a. By running locust with class-picker b. By running locust with multiple files and selecting the UserClass
- Observe the events on both files being executed on test start
Environment
- OS: macOS
- Python version: 3.10
- Locust version: 2.12.0
- Locust command line that you ran:
locust -f . --class-picker
orlocust -f scenario_one.py scenario_two.py ScenarioOneUser
- Locust file contents: https://gist.github.com/leonardoggallardo/db95cb365c9ec6f23f10247afe764d6a
Issue Analytics
- State:
- Created a year ago
- Reactions:4
- Comments:11
Top Results From Across the Web
Writing a locustfile — Locust 2.14.0 documentation
A user class represents one type of user/scenario for your system. When you do a test run you specify the number of concurrent...
Read more >MasterRunner target_user_count no longer set for test_start ...
Describe the bug I was following the custom_messages.py example and noticed that environment.runner.target_user_count is no longer resolving ...
Read more >Performance and load testing with Locust - Xray Documentation
The file will have two classes, one to define the requests we want to do and another to specify the endpoint and the...
Read more >Locust, how to access custom command line argument from ...
You can access the locust environment inside your LoadTestShape class using self.runner.environment (same as in a User/@task).
Read more >Load Testing Using Locust.io - Medium
There is a time after our application or service is running, we want to know the performance and load that can be handled...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, I think so. Thank you for all the support 😃
Can I close this?