Skip to content

Commit

Permalink
Merge pull request #519 from open5e/228-consider-designing-a-post-dep…
Browse files Browse the repository at this point in the history
…loyment-smoke-test

228 consider designing a post deployment smoke test
  • Loading branch information
augustjohnson authored Aug 22, 2024
2 parents 5f9aa42 + 28fd838 commit f907109
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,7 @@ jobs:
env:
DIGITALOCEAN_TOKEN: ${{ secrets.DIGITALOCEAN_TOKEN }}
run: ./scripts/do_app_deploy.sh
- name: Run Smoke Test
run: |
APP_URL=$(jq -r '.app.live_url' ./app.json)
python3 ./scripts/smoke_test.py --url $APP_URL
37 changes: 37 additions & 0 deletions scripts/smoke_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import argparse
import requests
# This is the smoke test.

# Inputs: url

# Outputs: Whether any of the basic pages end up in a 500 error.

# Pass if not

def main():
parser = argparse.ArgumentParser()

parser.add_argument('-u', '--url',
help='URL of the site to check.')

args = parser.parse_args()
print("For a given input url, this goes and checks the root, and the /v1 and /v2")
print("paths for 200 response codes. It is intended to be run post-deploy.")

# Check the root url.
assert requests.get(args.url).status_code == 200

# Check the /v1 paths
assert requests.get(args.url+'/v1/').status_code == 200
v1_endpoints = requests.get(args.url+'/v1/?format=json').json()
for value in v1_endpoints.values():
assert requests.get(value).status_code == 200

# Checking the /v2 paths
assert requests.get(args.url+'/v2/').status_code == 200
v2_endpoints = requests.get(args.url+'/v2/?format=json').json()
for value in v2_endpoints.values():
assert requests.get(value).status_code == 200

if __name__ == '__main__':
main()

0 comments on commit f907109

Please sign in to comment.