Last active
August 2, 2016 19:49
-
-
Save wehappyfew/fae4a348c2be84548e86cb4a9774ee52 to your computer and use it in GitHub Desktop.
example of simulating multiple users to use in a locust load testing script
This file contains hidden or 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 time,randint,config | |
users = 1000 | |
users_rate = 10 | |
class UserBehavior(TaskSet): | |
wait_secs = config.wait_for_locusts_to_hatch(locusts_num=users, hatch_rate=users_rate) | |
def on_start(self): | |
print "-----Start of locust run-----" | |
user_num = random.randint(602, 10000) | |
username = "user_%s" % user_num | |
password = "secret" | |
# required time to hatch the users | |
config.load_sleep(self.wait_secs, self.wait_secs) | |
self.login_use(user_num, username, password) | |
print "-----End of locust run-----" | |
# This should be imported from a config file | |
# def wait_for_locusts_to_hatch(locusts_num, hatch_rate): | |
# wait_secs = (locusts_num / hatch_rate) + 10 # +10 to be safe | |
# print "-- Waiting %s secs for locusts to hatch --" % wait_secs | |
# return wait_secs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment