Skip to content

Commit

Permalink
Add logging messages to custom exit code example
Browse files Browse the repository at this point in the history
  • Loading branch information
heyman committed May 26, 2020
1 parent 502ba0b commit 48fd3f4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/running-locust-without-web-ui.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,19 @@ Below is an example that'll set the exit code to non zero if any of the followin

.. code-block:: python
import logging
from locust import events
@events.quitting.add_listener
def _(environment, **kw):
if environment.stats.total.fail_ratio > 0.01:
logging.error("Test failed due to failure ratio > 1%")
environment.process_exit_code = 1
elif environment.stats.total.avg_response_time > 200:
logging.error("Test failed due to average response time ratio > 200 ms")
environment.process_exit_code = 1
elif environment.stats.total.get_response_time_percentile(0.95) > 800:
logging.error("Test failed due to 95th percentil response time > 800 ms")
environment.process_exit_code = 1
else:
environment.process_exit_code = 0
Expand Down

0 comments on commit 48fd3f4

Please sign in to comment.