Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/cdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,19 @@ jobs:
awslocal dynamodb list-tables
awslocal s3 ls

- name: Set up test dependencies
run: |
pip install requests boto3 pytest localstack-sdk-python

- name: Run Integration Tests
env:
AWS_DEFAULT_REGION: us-east-1
AWS_REGION: us-east-1
AWS_ACCESS_KEY_ID: test
AWS_SECRET_ACCESS_KEY: test
run: |
pytest tests/test_infra.py

- name: Send a Slack notification
if: failure() || github.event_name != 'pull_request'
uses: ravsamhq/notify-slack-action@v2
Expand Down
3 changes: 2 additions & 1 deletion cdk/quiz_app/quiz_app_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
self.backend_api_url = rest_api.url

# verify email identity for SES
for email in ["your.email@example.com", "admin@localstack.cloud"]:
for email in ["your.email@example.com", "admin@localstack.cloud", "sender@example.com"]:
sanitised_email = email.replace(".", "-").replace("@", "-")
cr.AwsCustomResource(
self,
Expand Down Expand Up @@ -262,6 +262,7 @@ def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
"../configurations/statemachine.json"
),
role=state_machine_role,
state_machine_name="SendEmailStateMachine"
)

# set up lambda permissions
Expand Down
23 changes: 19 additions & 4 deletions tests/test_infra.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,26 @@ def test_quiz_workflow(api_endpoint):

time.sleep(5)

response = requests.get(f"{api_endpoint}/getleaderboard?quiz_id={quiz_id}&top=3")
assert response.status_code == 200
leaderboard = response.json()
assert len(leaderboard) == 3
leaderboard_url = f"{api_endpoint}/getleaderboard?quiz_id={quiz_id}&top=3"
response = requests.get(leaderboard_url)
leaderboard = None

if response.json():
assert response.status_code == 200
leaderboard = response.json()
else:
# If the response is empty, retry it for 5 times with a 2 second delay.
# TODO: This is a hack to get around the fact that the leaderboard is not available immediately.
for _ in range(5):
time.sleep(2)
response = requests.get(leaderboard_url)
if response.json():
assert response.status_code == 200
leaderboard = response.json()
break

assert leaderboard is not None, "Failed to retrieve leaderboard data after retries"
assert len(leaderboard) == 3
expected_scores = {
"user1": None,
"user2": None,
Expand Down