-
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
Make resetting stats after hatching configurable #289
Conversation
* By default, stats are reset after hatching * Added a cli flag --no-reset-stats to disable stats resetting * Can also set locust.runners.RESET_STATS_AFTER_HATCHING = False from within a locust file * This does not affect the "Reset stats" link in the web interface
thanks for this patch! saves me hours of debug time. |
I just wanted to comment to support this PR. We have been using locust for load testing, but we have started to venture into determining if all insert records stemmed from the API are making it into our database. Unfortunately with the reset happening after everything is hatched, makes this task difficult, when it shouldn't be. As an example, if I hatch 10000 users, there will be 8000-11000 requests prior to the stats being reset. Which means the counts themselves will be off. If we are going to compare the number of requests made by locust, to the number of records in the database, it will appear that the database has more records than it should. |
Adding a vote to this - about to do some similar testing that @secretobsession described so having this merged in would be great. |
+1 |
12 similar comments
+1 |
+1 |
+1 |
+1 |
+1 |
+1 |
+1 |
+1 |
+1 |
+1 |
+1 |
+1 |
+1 Just starting using locust and ran into the same issue were requests did not match the database records. Would be really great to get this finally merged in. |
@@ -392,6 +399,11 @@ def main(): | |||
logger.error("Locust can not run distributed with the web interface disabled (do not use --no-web and --master together)") | |||
sys.exit(0) | |||
|
|||
if options.no_reset_stats: | |||
runners.RESET_STATS_AFTER_HATCHING = False | |||
if not runners.RESET_STATS_AFTER_HATCHING: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This if
condition is unnecessary in my opinion. Why not just log when setting the flag to False?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I remember right (after 2 years), it was to handle the case where the module flag was set to false by anything other than the --no-reset-stats
flag. For example, if the locust file imports the module and sets that global flag to false.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the log message all together, and changed so that we don't use the module level variable for controlling the reset behaviour. Let me know if you think that's a bad idea.
Ok, this has now (finally) been merged. Thank you! I cherry picked the commit, but changed the implementation slightly (removed the module level variable for setting the reset behaviour, and removed the log about the setting). |
Hi, is this implemented in version 0.8a2? I have read the change log and download but it seems like nothing changed from 0.7.5 |
@alvissd it shows up in the v0.8a1 release commits: From feb 17th that commit is in there. |
@aldenpeterson-wf thanks, I just found it in the source code. Somehow pip install locustio=0.8a2 doesn't install the newest. |
I can confirm that this is not in 0.8a1 or 0.8a2 on PyPi. I can see that it is in the source code, it just isnt available when installing through pip. |
The first version it's in is 0.8a3 I think. v0.8a1...master will show commits that are not in v0.8a1 I think :)? 0.8 is released on PyPI now. |
This adds a global variable
locust.runners.RESET_STATS_AFTER_HATCHING
that you can use from a locust file, as well as a command line flag--no-reset-stats
. Locust should still default to resetting the statistics and the "Reset Stats" link in the web interface should work regardless of this flag.Resolves #205