Created
March 15, 2019 03:43
-
-
Save elyssonmr/479beece4ff3a6aa7b0fb784788431fb to your computer and use it in GitHub Desktop.
Locust test failing when the median is slower than a value. CMD: locust -f locust_test.py --no-web -c 100 -r 50 -t 10s -H http://elyssonmr.com --only-summary
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from locust import stats, HttpLocust, TaskSet, task, events | |
from locust.runners import locust_runner | |
import sys | |
class QueryElyssonMRTaskSet(TaskSet): | |
@task(5) | |
def query_for_facebook(self): | |
url = "" | |
self.client.get(url) | |
class ElyssonMRLocust(HttpLocust): | |
min_wait = 500 | |
max_wait = 2000 | |
task_set = QueryElyssonMRTaskSet | |
def check_min_stats(): | |
median = stats.global_stats.total.median_response_time | |
if median > 5: | |
#print(stats.global_stats.total.get_stripped_report()) | |
print("Median is bigger than configured median") | |
stats.print_stats(stats.global_stats.entries) | |
stats.print_percentile_stats(stats.global_stats.entries) | |
sys.exit(1) | |
events.quitting += check_min_stats |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment