Skip to content
This repository has been archived by the owner on Jul 26, 2024. It is now read-only.

Commit

Permalink
test: return JSON in response content for smoke tests (#395)
Browse files Browse the repository at this point in the history
  • Loading branch information
hackebrot authored Jun 3, 2022
1 parent 64a401b commit c5fa2ab
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
23 changes: 22 additions & 1 deletion smoke-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,25 @@

This directory contains code for a smoke-test suite for Contile deployments.

**Please note that this is work in progress.** 🚧
## Setup

Set runtime environment variables for the `runner` function that contain trigger
URLs for the clients using the following naming scheme:

`CLIENT_URL_<COUNTRY_CODE>`

Examples:
```
CLIENT_URL_US
CLIENT_URL_GB
CLIENT_URL_CH
```

## Example runner invocation

```bash
curl -m 70 -X POST <RUNNER_TRIGGER_URL> \
-H "Authorization:bearer $(gcloud auth print-identity-token)" \
-H "Content-Type:application/json" \
-d '{"environments": ["STAGE", "PROD"]}'
```
1 change: 1 addition & 0 deletions smoke-tests/client/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def run_geo_smoke_test(request: Request):

location_url = f"{env.value}{LOCATION_ENDPOINT}"

# Send a HTTP request to the Contile "location test" API endpoint
loc_response = requests.get(location_url)

if loc_response.status_code != 200:
Expand Down
9 changes: 6 additions & 3 deletions smoke-tests/runner/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Clients(Enum):
"""Enum with clients deployed as Cloud Functions."""

US: Client = Client(country="US", region="OR", gcp_region="us-west1")
GB: Client = Client(country="GB", region="LND", gcp_region="europe-west2")
GB: Client = Client(country="GB", region="ENG", gcp_region="europe-west2")
CH: Client = Client(country="CH", region="ZH", gcp_region="europe-west6")


Expand Down Expand Up @@ -106,10 +106,13 @@ def run_geo_smoke_tests(request: Request):
"expected_country": client.value.country,
"expected_region": client.value.region,
},
headers={"Authorization": f"Bearer {id_token}"},
headers={
"Authorization": f"Bearer {id_token}",
"Accept": "application/json",
},
)
response_data.results[env.name][client.name] = ClientResponse(
status_code=response.status_code, content=response.text
status_code=response.status_code, content=response.json()
)

return jsonify(asdict(response_data))

0 comments on commit c5fa2ab

Please sign in to comment.