Skip to content

Commit f5f105a

Browse files
committed
python integration test
1 parent 1fd3646 commit f5f105a

File tree

3 files changed

+48
-5
lines changed

3 files changed

+48
-5
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
[![LocalStack Pods Launchpad](https://localstack.cloud/gh/launch-pod-badge.svg)](https://app.localstack.cloud/launchpad?url=https://github.com//releases/download/latest/release-pod.zip
2-
1+
[![LocalStack Pods Launchpad](https://localstack.cloud/gh/launch-pod-badge.svg)](https://app.localstack.cloud/launchpad?url=https://github.com/localstack-samples/wordpress-ecs-rds-cdk/releases/download/latest/release-pod.zip
2+
[![GitHub Actions](https://github.com/localstack-samples/wordpress-ecs-rds-cdk/actions/workflows/integration-test.yml/badge.svg)](https://github.com/localstack-samples/wordpress-ecs-rds-cdk/actions/workflows/integration-test.yml)
33
wordpress-ecs-rds-cdk
44
===============================
55

setup.cfg

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ dev =
2828
pre-commit==2.13.0
2929
pyproject-flake8
3030
isort==5.9.1
31-
pytest>=7.0
31+
pytest>=8.3
3232
awscli
33+
boto3
3334
awscli-local
3435
%(deploy)s
3536

@@ -38,8 +39,9 @@ deploy =
3839
constructs>=10.0.0,<11.0.0
3940

4041
test =
41-
boto3 >=
42-
pytest>=7.0
42+
boto3 >=1.34
43+
pytest>=8.3
44+
requests>=2.3
4345

4446
[options.package_data]
4547
* = *.md

tests/test_integration.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import time
2+
3+
import boto3
4+
import requests
5+
6+
LOCALSTACK_HOST = "https://localhost.localstack.cloud:4566"
7+
STACK_NAME = "WordpressStack"
8+
9+
10+
def client(service: str):
11+
return boto3.client(service, endpoint_url=LOCALSTACK_HOST)
12+
13+
14+
def retry(function: callable, retries=3, sleep=1.0, sleep_before=0, **kwargs):
15+
raise_error = None
16+
if sleep_before > 0:
17+
time.sleep(sleep_before)
18+
retries = int(retries)
19+
for i in range(0, retries + 1):
20+
try:
21+
return function(**kwargs)
22+
except Exception as error:
23+
raise_error = error
24+
time.sleep(sleep)
25+
raise raise_error
26+
27+
28+
def test_wordpress_status_code():
29+
cloudformation = client("cloudformation")
30+
31+
stack_info = cloudformation.describe_stacks(StackName=STACK_NAME)["Stacks"][0]
32+
wp_endpoint = stack_info["Outputs"][0]["OutputValue"]
33+
wp_url = f"http://{wp_endpoint}:4566"
34+
35+
def _assert_wp_response():
36+
result = requests.get(wp_url)
37+
38+
assert result.status_code == 200
39+
assert "WordPress" in result.text
40+
41+
retry(_assert_wp_response, sleep=2)

0 commit comments

Comments
 (0)