Skip to content

Instantly share code, notes, and snippets.

@prakhar21
Created February 16, 2019 12:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prakhar21/d66f58494fe0ef871c1b836edabe7d30 to your computer and use it in GitHub Desktop.
Save prakhar21/d66f58494fe0ef871c1b836edabe7d30 to your computer and use it in GitHub Desktop.
Locust Load Testing
import random
import os
from locust import HttpLocust, TaskSet, task
TEST_DATA_PATH = 'test.csv'
def load_test_sentences():
utterances = []
with open(TEST_DATA_PATH, 'r') as fp:
for row in fp:
row = row.strip()
utterances.append(row)
return utterances
class UserBehavior(TaskSet):
def on_start(self):
pass
@task(1)
def loan_process(self):
for ut in utterances:
self.client.get(
'process_loan?q={}'.format(u)
)
class WebsiteUser(HttpLocust):
task_set = UserBehavior
min_wait = 5000
max_wait = 9000
print 'loaded %s utterances' %len(load_test_sentences())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment