-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #908 from maykinmedia/issue/1865-mijn-aanvragen-pe…
…rformance ⚡ [#1865/2017] Add basic locust setup & increase catalogi API request timeout default
- Loading branch information
Showing
4 changed files
with
107 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
from urllib.parse import urlencode | ||
|
||
from locust import HttpUser, events, task | ||
|
||
|
||
class OpenInwonerUser(HttpUser): | ||
wait_time = lambda _: 0.5 | ||
|
||
@task | ||
def mijn_aanvragen_list_cached(self): | ||
self.client.get("/mijn-aanvragen/content", headers={"HX-Request": "true"}) | ||
|
||
def on_start(self): | ||
params = urlencode( | ||
{ | ||
"acs": f"{self.host}/digid/acs/", | ||
"next": self.host, | ||
"cancel": f"{self.host}/accounts/login/", | ||
} | ||
) | ||
digid_login_url = f"/digid/idp/inloggen_ww/?{params}" | ||
|
||
response = self.client.get(digid_login_url) | ||
csrftoken = response.cookies["csrftoken"] | ||
|
||
self.client.post( | ||
digid_login_url, | ||
data={ | ||
"auth_name": self.bsn, | ||
"auth_pass": "foo", | ||
"csrfmiddlewaretoken": csrftoken, | ||
"commit": "Inloggen", | ||
}, | ||
) | ||
|
||
# Ensure uncached call is logged separately | ||
self.client.get( | ||
"/mijn-aanvragen/content?_uncached=true", headers={"HX-Request": "true"} | ||
) | ||
|
||
|
||
@events.init_command_line_parser.add_listener | ||
def init_parser(parser): | ||
parser.add_argument("--bsn", type=str, dest="bsn", help="BSN used to login with") | ||
|
||
|
||
@events.init.add_listener | ||
def on_locust_init(environment, **kwargs): | ||
OpenInwonerUser.bsn = environment.parsed_options.bsn |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,6 @@ django-extensions | |
# Documentation | ||
sphinx | ||
sphinx_rtd_theme | ||
|
||
# performance testing | ||
locust |
This file contains 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 file contains 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