Created
February 16, 2019 12:15
-
-
Save prakhar21/d66f58494fe0ef871c1b836edabe7d30 to your computer and use it in GitHub Desktop.
Locust Load Testing
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
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