Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The exit code for controlling the locust process has a bug #2716

Open
2 tasks done
nanjizhilian opened this issue May 18, 2024 · 3 comments
Open
2 tasks done

The exit code for controlling the locust process has a bug #2716

nanjizhilian opened this issue May 18, 2024 · 3 comments
Labels

Comments

@nanjizhilian
Copy link

Prerequisites

Description

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 percentile response time > 800 ms")
environment.process_exit_code = 1
else:
environment.process_exit_code = 0

The above code, placed in my user class file, did not print the corresponding log, and the stress testing interface also reported an error. The code still did not work

Command line

locust -f locustfile.py --users 10 --spawn-rate 10 --host=https://********com --run-time 60s

Locustfile contents

nothing

Python version

3.9.6

Locust version

2.20.0

Operating system

mac os

@cyberw
Copy link
Collaborator

cyberw commented May 18, 2024

Please use latest version

@nanjizhilian
Copy link
Author

nanjizhilian commented May 18, 2024 via email

@cyberw
Copy link
Collaborator

cyberw commented May 18, 2024

If you see no logging it seems more likely that your if statement did not evaluate to true, so that code never ran?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants