Extract new entity creation percentages to constants

This commit is contained in:
tomdds 2019-11-18 13:47:17 -05:00
parent 03d816884b
commit 9b64d26961

View File

@ -1,5 +1,5 @@
import os import os
from random import choice, choices, randint from random import choice, choices, randrange
from urllib.parse import urlparse from urllib.parse import urlparse
from locust import HttpLocust, TaskSequence, seq_task from locust import HttpLocust, TaskSequence, seq_task
@ -16,6 +16,9 @@ DISABLE_VERIFY = os.getenv("DISABLE_VERIFY", "true").lower() == "true"
# Alpha numerics for random entity names # Alpha numerics for random entity names
LETTERS = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890" LETTERS = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890"
NEW_PORTFOLIO_CHANCE = 10
NEW_APPLICATION_CHANCE = 10
def login(l): def login(l):
l.client.get("/login-dev", auth=(USERNAME, PASSWORD)) l.client.get("/login-dev", auth=(USERNAME, PASSWORD))
@ -43,7 +46,7 @@ def get_portfolios(l):
".global-panel-container .atat-table tbody tr td:first-child a" ".global-panel-container .atat-table tbody tr td:first-child a"
).items() ).items()
] ]
force_new_portfolio = randint(0, 10) > 9 force_new_portfolio = randrange(0, 100) < NEW_PORTFOLIO_CHANCE
if len(portfolio_links) == 0 or force_new_portfolio: if len(portfolio_links) == 0 or force_new_portfolio:
portfolio_links += [create_portfolio(l)] portfolio_links += [create_portfolio(l)]
@ -71,7 +74,7 @@ def update_app_registry(l, portfolio_id, app_links):
def get_app(l): def get_app(l):
app_link = pick_app(l) app_link = pick_app(l)
force_new_app = randint(0, 10) > 9 force_new_app = randrange(0, 100) < NEW_APPLICATION_CHANCE
if app_link is not None and not force_new_app: if app_link is not None and not force_new_app:
l.client.get(app_link) l.client.get(app_link)
else: else: