Created
September 1, 2015 23:42
-
-
Save rdegges/9d782bca29c51526fdfd to your computer and use it in GitHub Desktop.
Load testing application #2.
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 2: users logging into a group | |
# protected page, refreshing their custom data, and saving it. | |
# | |
# This script will run the above operations 1,000 times in a row, and 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_2'}, create_directory=True) | |
except: | |
application = client.applications.search({'name': 'scenario_2'})[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' | |
account = application.accounts.create({ | |
'given_name': 'test', | |
'surname': 'test', | |
'email': email, | |
'password': PASSWORD, | |
}) | |
print 'Account created:', email | |
account.add_group(group) | |
print 'Added account to group:', group.name | |
if account.in_group(group): | |
print 'Verified group membership:', group.name | |
account.custom_data.refresh() | |
account.save() | |
print 'Updated custom data for account:', email |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment