Locust: received 0 response status_code and None content

I wrote a simple load test using Locust ( http://locust.io ).

Now I noticed that sometimes (using a higher load) the response that I get from the mail call has status_code 0 and None . Status code 0 is not automatically recognized as an error in Locust, so I have to check it manually.

My piece of code is the following:

 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 part of the expected response content.

Question: is this expected behavior? Is this a Locust (or Python) problem or is it a bug in the application under test?

+4
source share
1 answer

From locust documentation to: http://docs.locust.io/en/latest/writing-a-locustfile.html

Safe mode

The HTTP client is configured to run in safe_mode. This means that any request that fails due to a connection error, timeout, or the like, will not throw an exception, but rather will return an empty Response object. The request will be reported as a failure in locust statistics. The attribute of the returned Responses dummy attribute will be None, and its status_code will be 0.

It seems that the server cannot handle all the requests with which you are teeming with it, and some of them fail.

+7
source

Source: https://habr.com/ru/post/1488248/


All Articles