-
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
Smoke Test Loop Script #2038
Closed
Closed
Smoke Test Loop Script #2038
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
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
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,88 @@ | ||
import os | ||
import subprocess | ||
import time | ||
from argparse import ArgumentParser | ||
|
||
from smoke.common import Attachment_type, Config, Notification_type # type: ignore | ||
from smoke.test_admin_csv import test_admin_csv # type: ignore | ||
from smoke.test_admin_one_off import test_admin_one_off # type: ignore | ||
from smoke.test_api_bulk import test_api_bulk # type: ignore | ||
from smoke.test_api_one_off import test_api_one_off # type: ignore | ||
|
||
class bcolors: | ||
|
||
HEADER = '\033[95m' | ||
OKBLUE = '\033[94m' | ||
OKCYAN = '\033[96m' | ||
OKGREEN = '\033[92m' | ||
WARNING = '\033[93m' | ||
FAIL = '\033[91m' | ||
ENDC = '\033[0m' | ||
BOLD = '\033[1m' | ||
UNDERLINE = '\033[4m' | ||
|
||
def main(): | ||
|
||
runCount = 0 | ||
maxRuns = 0 | ||
|
||
parser = ArgumentParser() | ||
parser.add_argument("-m", "--max-runs", dest="maxruns", | ||
help="Set the maximum number of runs you want", metavar="MAXRUNS") | ||
parser.add_argument("-s", "--source-script", dest="source", | ||
help="Pass a shell script to source environment variables from", metavar="SOURCE") | ||
args = parser.parse_args() | ||
|
||
print(bcolors.OKBLUE) | ||
|
||
print("API Smoke test\n") | ||
for key in ["API_HOST_NAME", "SERVICE_ID", "EMAIL_TEMPLATE_ID", "SMS_TEMPLATE_ID", "EMAIL_TO", "SMS_TO"]: | ||
print(f"{key:>17}: {Config.__dict__[key]}") | ||
print("") | ||
|
||
if args.maxruns is not None: | ||
print(f"Running smoke tests in a loop up to {args.maxruns} times") | ||
maxRuns = int(args.maxruns) | ||
else: | ||
print("Running smoke tests in a loop indefinitely") | ||
|
||
os.chdir('../') | ||
|
||
if args.source is not None: | ||
print(f"Sourcing environment variables from external shell script {args.source}") | ||
subprocess.run(["source", args.source], executable='/bin/bash') | ||
|
||
print(bcolors.ENDC) | ||
|
||
while True: | ||
|
||
runCount += 1 | ||
print(bcolors.OKBLUE) | ||
print(f"Running smoke test #{str(runCount)}") | ||
print(bcolors.ENDC) | ||
startTime = time.time() | ||
|
||
for notification_type in [Notification_type.EMAIL, Notification_type.SMS]: | ||
test_admin_one_off(notification_type) | ||
test_admin_csv(notification_type) | ||
test_api_one_off(notification_type) | ||
test_api_bulk(notification_type) | ||
test_api_one_off(Notification_type.EMAIL, Attachment_type.ATTACHED) | ||
test_api_one_off(Notification_type.EMAIL, Attachment_type.LINK) | ||
|
||
print(subprocess.STDOUT) | ||
endTime = time.time() | ||
totalTime = endTime - startTime | ||
print(bcolors.OKBLUE) | ||
print(f"Smoke Test {str(runCount)} complete in {totalTime} seconds") | ||
print(bcolors.ENDC) | ||
if maxRuns != 0: | ||
if maxRuns >= runCount: | ||
print(bcolors.WARNING) | ||
print("Run limit reached. Stopping") | ||
print(bcolors.ENDC) | ||
break | ||
|
||
if __name__ == "__main__": | ||
main() | ||
|
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.
you could add this documentation in either the Makefile and on top of this script so folks have an example of how to run it