Last active
September 1, 2015 23:32
-
-
Save rdegges/1cb1888f4af3274daccf to your computer and use it in GitHub Desktop.
Load testing application #1.
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
# This test is meant to test out Scenario 1: a lot of users are concurrently | |
# creating accounts and then logging into a web service with Stormpath. | |
# | |
# This script will create 1,000 users total before exiting. This script should | |
# be launched as many concurrent times as you want to emulate production | |
# traffic. | |
from uuid import uuid4 | |
from stormpath.client import Client | |
STORMPATH_API_KEY_ID = 'xxx' | |
STORMPATH_API_KEY_SECRET = 'yyy' | |
TOTAL_USERS = 1000 | |
PASSWORD = uuid4().hex + uuid4().hex.upper() + '!' | |
client = Client(id=STORMPATH_API_KEY_ID, secret=STORMPATH_API_KEY_SECRET) | |
try: | |
application = client.applications.create({'name': 'scenario_1'}, create_directory=True) | |
except: | |
application = client.applications.search({'name': 'scenario_1'})[0] | |
try: | |
group = application.groups.create({'name': 'subscribers'}) | |
except: | |
group = application.groups.search({'name': 'subscribers'})[0] | |
for i in xrange(0, TOTAL_USERS): | |
email = uuid4().hex + '@test.com' | |
application.accounts.create({ | |
'given_name': 'test', | |
'surname': 'test', | |
'email': email, | |
'password': PASSWORD, | |
}) | |
print 'Account created:', email | |
account = application.authenticate_account(email, PASSWORD).account | |
print 'Authenticated account:', email | |
account.add_group(group) | |
print 'Added account to group:', group.name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment