-
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
confused by multiple requests in on_start #236
Comments
I have a similar problem -- testing a drupal app where you have to get the registration form to get the token and hidden form fields and then register with all the extra detail. Again I'm doing it in one task call, but separate session requests. In my case some of the POSTS are getting through, but not all. From info logs my code was producing, I know lots of users were being registered, as I can also see when I look at the admin screen of the website they are there. However as the paste below shows, they are not making it through, either as errors or as successes, lots are being recorded as GETs --
|
method was set against the request response method. In the case of a POST request being redirected to GET, common on success of POSTs for login and registration. The request is incorrectly logged against the GET method for the original URL. Closes locustio#236
I'm seeing a similar issue. In my case, Edit: Actually it appears that the login requests are very occasionally recorded, but at least <= than 1/6 of the time. I am running a master/slave configuration if that makes any difference. |
Are you getting extra stats for GET requests on the same URL? The problem store meta data that is used when reporting the request to locust'sstatistics request_meta = {} # set up pre_request hook for attaching meta Dan On 27 March 2015 at 10:50, Tom Dalton [email protected] wrote:
Wildman and Herring Limited, Registered Office: 52 Great Eastern Street, |
None of the requests involved in my tests return or make redirects. Also, I don't (think) I'm getting extra stats, my stats (specifically those from on_start) seem to be missing. |
No idea why this issue was closed, sorry about that. @tom-dalton-fanduel Do you think your issue could have anything to do with the stats being reset once all Locust instances are spawned? Perhaps you could post a minimal version of your test script that produces this error? |
@heyman Ahh that would actually fit the pattern - in the test case I was confused by, I had 30 slaves, with 1 user on each slave. Each user makes a single login in the taskset's |
Yep, once all slave nodes are finished "hatching" their locust instances, the stats gets reset. If you'd add |
Ah I didn't know that. So does that mean if you have a long, slow ramp, then when you hit the top of the ramp the stats will be reset? Is there any way to prevent that, so the stats show both the hatching/ramp phase and the subsequent "steady-state"/"table-top" phase? |
At the moment there is no clean way of doing this. The reason the stats are cleared is because the requests made during the hatching phase is usually not representative for the number of users you want to simulate, and there might also be caches that aren't warmed up etc. However it should probably be configurable as it has been requested before, and I can see that there might be cases where you wouldn't want to reset the stats. If you add the following somewhere at the module level of your test scripts you'll monkey patch Locust to not reset any stats ever (will also make the "Reset stats" button in the web UI not work): from locust.stats import RequestStats
def noop(*arg, **kwargs):
print "Stats reset prevented by monkey patch!"
RequestStats.reset_all = noop |
That's fine, thanks. |
Well, why was this closed?
BTW, any exceptions generated in P.S. Keep up the good work, there is really no good alternative for locust, yet. |
@DataGreed This issue was closed because the problem didn't have anything to do with on_start. Instead the problems discussed in this issue are covered in other issues: #267 - Fixed and merged If there is some other issue that I've missed please tell me, and feel free to re-open :) |
@heyman thanks! That was not obvious from the comments :) |
I've just installed locust 0.7.3 on osx to test a django site and used the a virtually identical piece of code to the original poster and run straight into the list index out of range error. I'm probably being dense but its not clear to me from the comments above whether the issue is fixed or whether I need to change my code? I'm just running 1 user with the default call locust --host=http://localhost:8000 |
I don't know either. Can you post the actual code that is causing the Dan On 9 December 2015 at 21:17, Phoebe Bright [email protected] wrote:
Wildman and Herring Limited, Registered Office: 52 Great Eastern Street, |
Here is the locustfile.py
and the error - repeated many times:
|
I think you need to put "@task" above the login function. |
Hi, cjsimpson said "I think you need to put "@task https://github.com/task"
Dan On 10 December 2015 at 09:43, Phoebe Bright [email protected]
Wildman and Herring Limited, Registered Office: 52 Great Eastern Street, |
Yes, adding the task decorator fixes the out of range error. Full code for reference is:
Thanks for your help. |
This is with 0.7.2 from pip, and also using the latest from github. It seems that
on_start
isn't expecting more than one request, and does strange things when this happens.Use case: django apps often use a guard token that is the same in headers and form, and posting the form has to replay it correctly:
csrfmiddlewaretoken
. If a login form uses this token, then the setup phase must GET the form, parse out the token, and then POST the login request with the right token.If this locustfile is run with
n=1
, both login requests are visible in the server log. But locust only reports the GET, not the POST. I think this happens because it is counting requests, and expects theon_start
to only contain one request.If run with
n=2
, the final summary shows bothon_start
requests but the server log also showsGET /
. With sufficiently largen
I suppose this doesn't matter, but it would be more accurate to report on all the requests that were made, whatever valuen
has.If the
GET /
task is removed andn=2
, locust goes into a loop ofIndexError
exceptions.The text was updated successfully, but these errors were encountered: