I have written a simple load test using Locust (http://locust.io).
Now I noticed that sometimes (using a higher load) the response I get from a post call has a status_code of 0 and a None
content. The 0 status code is not automatically recognized as a failure in Locust, so I have to test it manually.
My code fragment is this:
with self.client.get(path, catch_response=True) as response:
if response.status_code != 200:
response.failure(path + ": returned " + str(response.status_code))
elif check not in response.content:
response.failure(path + ": wrong response, missing '" + check + "'")
Note: check
is a variable for a part of the expected response content.
The question is: is this a expected behaviour? Is this a problem of Locust (or Python) or is this a fault in the tested application?
From the locust documentation in: http://docs.locust.io/en/latest/writing-a-locustfile.html
Safe mode
The HTTP client is configured to run in safe_mode. What this does is that any request that fails due to a connection error, timeout, or similar will not raise an exception, but rather return an empty dummy Response object. The request will be reported as a failure in Locust’s statistics. The returned dummy Response’s content attribute will be set to None, and it’s status_code will be 0.
It looks like the server can´t handle all the requests you are swarming it with and some of them are timing out.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With