0

I am trying to run a large test, which typically has lot of errors, But seems the errors are reported individually irrespective of the providing a safe name.

What I am getting

This is causing huge error list which is difficult in analyze, also I suspect this eats up lot of RAM and the process gets killed eventually.

1 Answers1

0

The problem is the error Locust is getting back from your requests isn't a normal status code. Presently, it checks the status code to make sure it's in this list valid_response_codes = frozenset([200, 206, 301, 302, 303, 307]). If it's not, it returns BadStatusCode(url, code=status_code). It looks like your URLs are unique and you're already editing the URL that's being reported back in the UI. You'll have to do something similar for errors, or if you are already you need to broaden the scope.

In my usage, I also have many unique URLs. To prevent this sort of thing from happening I catch the response like so:

with fast_http_session.request(method, url, catch_response=True, stream=False, **kwargs) as response:
    …
    # Code to check and report response
    …
    response._manual_result = False
    return response

Then in my code to check and report the response, I massage the URL and response codes and messages so they're non-unique and then fire failure and success events manually:

env.events.request_failure.fire(request_type=response.locust_request_meta["method"], name=response.locust_request_meta["name"], exception=except_string, response_time=response.locust_request_meta["response_time"], response_length=response.locust_request_meta["content_size"])

I'm using FastHttpSession which requires the locust_request_meta stuff but you can get the same data (and I believe more cleanly) from HttpSession responses if you use that. In this case, except_string is what will be shown in the UI where you're seeing the BadStatus messages.

If you don't want to manually fire the events, you would still catch the response but you could either overwrite the attributes of the response and let it continue as normal or you could call response.failure(failure_string) with whatever string you want.

Solowalker
  • 2,431
  • 8
  • 13