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

Closed
2 tasks done
nanjizhilian opened this issue May 18, 2024 · 4 comments
Closed
2 tasks done

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

nanjizhilian opened this issue May 18, 2024 · 4 comments
Labels
bug invalid stale Issue had no activity. Might still be worth fixing, but dont expect someone else to fix it

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?

Copy link

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions bot added the stale Issue had no activity. Might still be worth fixing, but dont expect someone else to fix it label Jul 18, 2024
@cyberw cyberw added the invalid label Jul 18, 2024
@cyberw cyberw closed this as completed Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug invalid stale Issue had no activity. Might still be worth fixing, but dont expect someone else to fix it
Projects
None yet
Development

No branches or pull requests

2 participants