locustfile.py 617 B

1234567891011121314151617181920212223
  1. import random
  2. from locust import HttpUser, task, between
  3. class QuickstartUser(HttpUser):
  4. wait_time = between(5, 9)
  5. @task(10)
  6. def health_page(self):
  7. self.client.get("/health")
  8. @task(100)
  9. def timer_page(self):
  10. rand_start = random.randint(1, 1000)
  11. rand_end = random.randint(1000, 20000)
  12. self.client.get(f"/timer/{rand_start}/{rand_end}", name="/timer")
  13. @task(100)
  14. def status_page(self):
  15. codes = [ "301", "302", "404", "500", "503" ]
  16. seed = random.randint(0, len(codes)-1)
  17. self.client.get(f"/status/{codes[seed]}", name="/status")