Created
February 16, 2020 19:45
-
-
Save ashokc/19e6939c9c95cb3bafa1f5c9a79e4759 to your computer and use it in GitHub Desktop.
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 HttpLocust, TaskSet, task, between | |
import random, sys, json | |
# We have 7 ways of engaging the API via Http | |
url = "http://localhost/gunicorn/quotes" # for nginx + gunicorn | |
#url = "http://localhost/uwsgi/quotes" # for nginx + uwsgi | |
#url = "http://localhost/uwsgi-http/quotes" # for nginx + uwsgi-http | |
#url = "http://localhost/werkzeug/quotes" # for nginx + werkzeug | |
#url = "http://localhost:9999/quotes" # for direct gunicorn | |
#url = "http://localhost:9997/quotes" # for direct uwsgi-http | |
#url = "http://localhost:9996/uwsgi/quotes" # for direct werkzeug | |
class UserBehaviour(TaskSet): | |
@task(1) | |
def getAQuote (self): | |
quoteId = random.randint(1,900000) | |
self.client.get(url + "/byId?id="+str(quoteId)) | |
class WebsiteUser(HttpLocust): | |
task_set = UserBehaviour | |
wait_time = between(1, 3) # wait between 1 - 3 seconds |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment