-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add send notification task to locust load test file
This adds a send notification task to locust. It also updates the register task to handle errors a bit better. SYNC-3846 Note: I didn't add the unregister function as it seems like we don't need that currently, but it can be added if needed.
- Loading branch information
Showing
8 changed files
with
824 additions
and
560 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
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,24 @@ | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
from locust import between, constant | ||
|
||
|
||
def parse_wait_time(val: str): | ||
"""Parse a wait_time | ||
Either a single numeric (for `constant`) or two separated by a comma (arguments to `between`) | ||
""" | ||
match val.count(","): | ||
case 0: | ||
return constant(float_or_int(val)) | ||
case 1: | ||
return between(*map(float_or_int, val.split(",", 1))) | ||
case _: | ||
raise ValueError("Invalid wait_time") | ||
|
||
|
||
def float_or_int(val: str): | ||
float_val: float = float(val) | ||
return int(float_val) if float_val.is_integer() else float_val |
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,14 @@ | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
|
||
class ZeroStatusRequestError(Exception): | ||
"""Custom exception for when a Locust request fails with a '0' status code.""" | ||
|
||
def __init__(self): | ||
error_message: str = ( | ||
"A connection, timeout or similar error happened while sending a request " | ||
"from Locust. Status Code: 0" | ||
) | ||
super().__init__(error_message) |
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
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
Oops, something went wrong.