-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: add API load testing script, enable easier offline development o…
…f API
- Loading branch information
1 parent
cdd5ccb
commit a8e08ff
Showing
9 changed files
with
169 additions
and
1 deletion.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
api.planx.uk/modules/auth/fixtures/microsoft-openid-configuration.json
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,54 @@ | ||
{ | ||
"token_endpoint": "https://login.microsoftonline.com/common/oauth2/v2.0/token", | ||
"token_endpoint_auth_methods_supported": [ | ||
"client_secret_post", | ||
"private_key_jwt", | ||
"client_secret_basic" | ||
], | ||
"jwks_uri": "https://login.microsoftonline.com/common/discovery/v2.0/keys", | ||
"response_modes_supported": ["query", "fragment", "form_post"], | ||
"subject_types_supported": ["pairwise"], | ||
"id_token_signing_alg_values_supported": ["RS256"], | ||
"response_types_supported": [ | ||
"code", | ||
"id_token", | ||
"code id_token", | ||
"id_token token" | ||
], | ||
"scopes_supported": ["openid", "profile", "email", "offline_access"], | ||
"issuer": "https://login.microsoftonline.com/common/v2.0", | ||
"request_uri_parameter_supported": false, | ||
"userinfo_endpoint": "https://graph.microsoft.com/oidc/userinfo", | ||
"authorization_endpoint": "https://login.microsoftonline.com/common/oauth2/v2.0/authorize", | ||
"device_authorization_endpoint": "https://login.microsoftonline.com/common/oauth2/v2.0/devicecode", | ||
"http_logout_supported": true, | ||
"frontchannel_logout_supported": true, | ||
"end_session_endpoint": "https://login.microsoftonline.com/common/oauth2/v2.0/logout", | ||
"claims_supported": [ | ||
"sub", | ||
"iss", | ||
"cloud_instance_name", | ||
"cloud_instance_host_name", | ||
"cloud_graph_host_name", | ||
"msgraph_host", | ||
"aud", | ||
"exp", | ||
"iat", | ||
"auth_time", | ||
"acr", | ||
"nonce", | ||
"preferred_username", | ||
"name", | ||
"tid", | ||
"ver", | ||
"at_hash", | ||
"c_hash", | ||
"email" | ||
], | ||
"kerberos_endpoint": "https://login.microsoftonline.com/common/kerberos", | ||
"tenant_region_scope": null, | ||
"cloud_instance_name": "microsoftonline.com", | ||
"cloud_graph_host_name": "graph.windows.net", | ||
"msgraph_host": "graph.microsoft.com", | ||
"rbac_url": "https://pas.windows.net" | ||
} |
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
Binary file added
BIN
+2.02 MB
infrastructure/performance/samples/250129-WikiHouse-Manufacturing-Guide.pdf
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.98 MB
infrastructure/performance/samples/marita-kavelashvili-ugnrXk1129g-unsplash.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.07 MB
infrastructure/performance/samples/samuel-regan-asante-g9A2llpDObU-unsplash.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,54 @@ | ||
from locust import ( | ||
constant_pacing, | ||
task, | ||
) | ||
|
||
from base_workload import OpenWorkloadBase | ||
from utils import ( | ||
get_mime_type_from_filename, | ||
get_random_file_from_dir, | ||
get_target_host, | ||
) | ||
|
||
|
||
TASK_INVOCATION_RATE_SECONDS = 10 | ||
HOST_BY_ENV = { | ||
# "local": os.getenv("API_URL_EXT", "http://localhost:7002"), | ||
"local": "http://localhost:8001", | ||
"staging": "https://api.editor.planx.dev", | ||
} | ||
SAMPLE_FILE_DIRECTORY = "samples" | ||
MIME_TYPE_BY_FILE_EXT = { | ||
"jpg": "image/jpeg", | ||
"jpeg": "image/jpeg", | ||
"png": "image/png", | ||
"pdf": "application/pdf", | ||
} | ||
AUTH_JWT = "your-jwt-here" | ||
|
||
|
||
class APIWorkload(OpenWorkloadBase): | ||
wait_time = constant_pacing(TASK_INVOCATION_RATE_SECONDS) | ||
host = get_target_host(HOST_BY_ENV) | ||
|
||
def on_start(self): | ||
# need to auth in order to upload anything | ||
pass | ||
|
||
@task | ||
def upload_public_file(self) -> None: | ||
# it is essentially free to upload files to S3, and also free to delete them | ||
# however it costs more to keep it there and to pull it down, so we don't load test that aspect | ||
# we want to test a range of file types and sizes (although none should be larger than 30MB) | ||
filename, file_bin = get_random_file_from_dir(SAMPLE_FILE_DIRECTORY) | ||
with self.rest( | ||
"POST", | ||
"/file/public/upload", | ||
cookies={"jwt": AUTH_JWT}, | ||
files={"file": (filename, file_bin, get_mime_type_from_filename(filename))}, | ||
) as resp: | ||
print(resp) | ||
|
||
# @task | ||
# def handle_submission(self) -> None: | ||
# pass |
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