Skip to content

Instantly share code, notes, and snippets.

@elyssonmr
Created March 15, 2019 03:43
Show Gist options
  • Save elyssonmr/ff8e7634b6acabd83f64fbe3b2d459db to your computer and use it in GitHub Desktop.
Save elyssonmr/ff8e7634b6acabd83f64fbe3b2d459db to your computer and use it in GitHub Desktop.
Locust test failing when the median is slower than a value.
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