-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SMS soak test #2011
Merged
Merged
SMS soak test #2011
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
1d5a824
soak test with sms
sastels ed971c8
change README
sastels 1920060
use flag
sastels dfce748
tweak README
sastels 6972523
format
sastels c420e7b
Merge branch 'main' into sms-soak-test
sastels 60fa612
Merge branch 'main' into sms-soak-test
sastels de27377
Merge branch 'main' into sms-soak-test
sastels 3149b19
Merge branch 'main' into sms-soak-test
sastels 8ad8e2c
Merge branch 'main' into sms-soak-test
sastels 27e290c
Merge branch 'main' into sms-soak-test
sastels bdf13e1
Merge branch 'main' into sms-soak-test
sastels 166c51a
Merge branch 'main' into sms-soak-test
sastels 4ac4534
Merge branch 'main' into sms-soak-test
sastels 086bcb1
Merge branch 'main' into sms-soak-test
sastels File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
API_KEY= | ||
EMAIL_TEMPLATE_ID= | ||
SMS_TEMPLATE_ID= |
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 was deleted.
Oops, something went wrong.
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,38 @@ | ||
import os | ||
|
||
from dotenv import load_dotenv | ||
from locust import HttpUser, constant_pacing, events, task | ||
from soak_utils import url_with_prefix | ||
|
||
load_dotenv() | ||
|
||
|
||
@events.init_command_line_parser.add_listener | ||
def _(parser): | ||
parser.add_argument("--ref", type=str, default="test", help="reference") | ||
parser.add_argument("--sms", action='store_true', help="send sms") | ||
|
||
|
||
class NotifyApiUser(HttpUser): | ||
wait_time = constant_pacing(1) # each user makes one post per second | ||
|
||
def __init__(self, *args, **kwargs): | ||
self.host = url_with_prefix(self.host, "api") | ||
|
||
super(NotifyApiUser, self).__init__(*args, **kwargs) | ||
self.headers = {"Authorization": f"apikey-v1 {os.getenv('API_KEY')}"} | ||
self.email_template = os.getenv("EMAIL_TEMPLATE_ID") | ||
self.sms_template = os.getenv("SMS_TEMPLATE_ID") | ||
self.email_address = "[email protected]" | ||
self.phone_number = "+16135550123" # INTERNAL_TEST_NUMBER | ||
self.reference_id = self.environment.parsed_options.ref | ||
self.send_sms = self.environment.parsed_options.sms | ||
|
||
@task(1) | ||
def send_notification(self): | ||
if self.send_sms: | ||
json = {"phone_number": self.phone_number, "template_id": self.sms_template, "reference": self.reference_id} | ||
self.client.post("/v2/notifications/sms", json=json, headers=self.headers) | ||
else: | ||
json = {"email_address": self.email_address, "template_id": self.email_template, "reference": self.reference_id} | ||
self.client.post("/v2/notifications/email", json=json, headers=self.headers) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We didn't want this to sit in a subfolder of tests-stress?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 We could think of this as a very low level stress test... generally I've been using high priority templates for these soak tests and low priority ones for the larger stress tests so it would require either rewriting the code a bit or changing the .env file when switching between them. 🤷