-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Comments
Please use latest version |
I have updated to 2.27.0, but it still hasn't been triggered
locust -f locustfile.py --users 10 --spawn-rate 10 --host=https://www.asdashdkjashd.com --run-time 60s
from locust import HttpUser, task, events, between
import logging
class MyUser(HttpUser):
wait_time = between(1, 5)
@task
def my_task(self):
with self.client.get("/") as response:
pass
@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) > 80:
logging.error("Test failed due to 95th percentile response time > 800 ms")
environment.process_exit_code = 1
else:
environment.process_exit_code = 0
…------------------ 原始邮件 ------------------
发件人: "locustio/locust" ***@***.***>;
发送时间: 2024年5月18日(星期六) 晚上10:23
***@***.***>;
***@***.******@***.***>;
主题: Re: [locustio/locust] The exit code for controlling the locust process has a bug (Issue #2716)
Please use latest version
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
If you see no logging it seems more likely that your if statement did not evaluate to true, so that code never ran? |
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. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
The text was updated successfully, but these errors were encountered: