0

The company I work on compromises to deliver 99% of their service responses in less than 1 second and 99.9% or their responses in less that 2 seconds. How can I make Locust report if this rule has been broken for any of the virtual users?

  • My first approach would be to make a method in my user (inherited from locust.HttpLocust) that will detect when this event happens and record it in a user-based log. I think this would work but if I have 1000 user it means I will have 1000 different log files.

  • A second approach would be to create a single event log, but I guess that would require me to deal with asynchronos IO handling. I guess there must be a more pythonesque way.

Locust and performance newbie here. Sorry if my question is misguided.

1 Answers1

0

You can add duration checks at the end of each @task like:

@task
   def service_request(self):
       r = self.client.get("/your/service/path")
       assert r.elapsed < datetime.timedelta(seconds = 1), "Request took more than 1 second"

This way you will have a report on individual HTTP Requests level with regards to which ones are successful and which tool > 1 second.

More information: Locust Assertions - A Complete User Manual


Alternatively you can try considering running your test using Taurus tool as a wrapper. Taurus has powerful and flexible Pass/Fail Criteria subsystem which analyses the results on-the-fly and returns a non-zero exit status code which can be used as an indicator of failure for shell scripts or continuous integration solutions.

Dmitri T
  • 159,985
  • 5
  • 83
  • 133