Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Locust: got 0 response status_code and None content

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?

like image 210
obecker Avatar asked Jun 26 '13 10:06

obecker


1 Answers

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.

like image 192
Nettok Avatar answered Sep 23 '22 23:09

Nettok