Get the locustfile running again
This commit is contained in:
parent
3e08211455
commit
d65d500670
@ -15,7 +15,7 @@ PASSWORD = os.getenv("ATAT_BA_PASSWORD", "")
|
|||||||
DISABLE_VERIFY = os.getenv("DISABLE_VERIFY", "true").lower() == "true"
|
DISABLE_VERIFY = os.getenv("DISABLE_VERIFY", "true").lower() == "true"
|
||||||
|
|
||||||
# Alpha numerics for random entity names
|
# Alpha numerics for random entity names
|
||||||
LETTERS = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890" #pragma: allowlist secret
|
LETTERS = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890" # pragma: allowlist secret
|
||||||
|
|
||||||
NEW_PORTFOLIO_CHANCE = 10
|
NEW_PORTFOLIO_CHANCE = 10
|
||||||
NEW_APPLICATION_CHANCE = 10
|
NEW_APPLICATION_CHANCE = 10
|
||||||
@ -29,10 +29,6 @@ def logout(l):
|
|||||||
l.client.get("/logout")
|
l.client.get("/logout")
|
||||||
|
|
||||||
|
|
||||||
def get_index(l):
|
|
||||||
l.client.get("/")
|
|
||||||
|
|
||||||
|
|
||||||
def get_csrf_token(response):
|
def get_csrf_token(response):
|
||||||
d = pq(response.text)
|
d = pq(response.text)
|
||||||
return d("#csrf_token").val()
|
return d("#csrf_token").val()
|
||||||
@ -52,14 +48,9 @@ def extract_id(path):
|
|||||||
|
|
||||||
|
|
||||||
def get_portfolios(l):
|
def get_portfolios(l):
|
||||||
response = l.client.get("/portfolios")
|
response = l.client.get("/home")
|
||||||
d = pq(response.text)
|
d = pq(response.text)
|
||||||
portfolio_links = [
|
portfolio_links = [p.attr("href") for p in d(".sidenav__link").items()]
|
||||||
p.attr("href")
|
|
||||||
for p in d(
|
|
||||||
".global-panel-container .atat-table tbody tr td:first-child a"
|
|
||||||
).items()
|
|
||||||
]
|
|
||||||
force_new_portfolio = randrange(0, 100) < NEW_PORTFOLIO_CHANCE
|
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)]
|
||||||
@ -73,7 +64,7 @@ def get_portfolio(l):
|
|||||||
d = pq(response.text)
|
d = pq(response.text)
|
||||||
application_links = [
|
application_links = [
|
||||||
p.attr("href")
|
p.attr("href")
|
||||||
for p in d(".application-list .accordion__actions a:first-child").items()
|
for p in d(".portfolio-applications .accordion__header-text a").items()
|
||||||
]
|
]
|
||||||
if len(application_links) > 0:
|
if len(application_links) > 0:
|
||||||
portfolio_id = extract_id(portfolio_link)
|
portfolio_id = extract_id(portfolio_link)
|
||||||
@ -161,18 +152,14 @@ class UserBehavior(TaskSequence):
|
|||||||
login(self)
|
login(self)
|
||||||
|
|
||||||
@seq_task(1)
|
@seq_task(1)
|
||||||
def home(l):
|
|
||||||
get_index(l)
|
|
||||||
|
|
||||||
@seq_task(2)
|
|
||||||
def portfolios(l):
|
def portfolios(l):
|
||||||
get_portfolios(l)
|
get_portfolios(l)
|
||||||
|
|
||||||
@seq_task(3)
|
@seq_task(2)
|
||||||
def pick_a_portfolio(l):
|
def pick_a_portfolio(l):
|
||||||
get_portfolio(l)
|
get_portfolio(l)
|
||||||
|
|
||||||
@seq_task(4)
|
@seq_task(3)
|
||||||
def pick_an_app(l):
|
def pick_an_app(l):
|
||||||
get_app(l)
|
get_app(l)
|
||||||
|
|
||||||
@ -189,4 +176,3 @@ class WebsiteUser(HttpLocust):
|
|||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# if run as the main file, will spin up a single locust
|
# if run as the main file, will spin up a single locust
|
||||||
WebsiteUser().run()
|
WebsiteUser().run()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user