Skip to content

Commit 3780a95

Browse files
authored
fix(tests): make sure multiple e2e tests run concurrently (aws-powertools#1861)
1 parent e7527e7 commit 3780a95

22 files changed

+77
-20
lines changed

.github/workflows/run-e2e-tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
id-token: write # needed to request JWT with GitHub's OIDC Token endpoint. docs: https://bit.ly/3MNgQO9
2727
contents: read
2828
strategy:
29+
fail-fast: false # needed so if a version fails, the others will still be able to complete and cleanup
2930
matrix:
3031
version: ["3.7", "3.8", "3.9"]
3132
if: ${{ github.actor != 'dependabot[bot]' }}

parallel_run_e2e.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def main():
88
features = Path("tests/e2e").rglob("infrastructure.py")
99
workers = len(list(features)) - 1
1010

11-
command = f"poetry run pytest -n {workers} --dist loadfile -o log_cli=true tests/e2e"
11+
command = f"poetry run pytest -n {workers} -o log_cli=true tests/e2e"
1212
result = subprocess.run(command.split(), shell=False)
1313
sys.exit(result.returncode)
1414

tests/e2e/event_handler/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from tests.e2e.event_handler.infrastructure import EventHandlerStack
44

55

6-
@pytest.fixture(autouse=True, scope="module")
6+
@pytest.fixture(autouse=True, scope="package")
77
def infrastructure():
88
"""Setup and teardown logic for E2E test infrastructure
99

tests/e2e/event_handler/test_header_serializer.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def lambda_function_url_endpoint(infrastructure: dict) -> str:
3636
return infrastructure.get("LambdaFunctionUrl", "")
3737

3838

39+
@pytest.mark.xdist_group(name="event_handler")
3940
def test_alb_headers_serializer(alb_basic_listener_endpoint):
4041
# GIVEN
4142
url = f"{alb_basic_listener_endpoint}/todos"
@@ -74,6 +75,7 @@ def test_alb_headers_serializer(alb_basic_listener_endpoint):
7475
assert response.cookies.get(last_cookie.name) == last_cookie.value
7576

7677

78+
@pytest.mark.xdist_group(name="event_handler")
7779
def test_alb_multi_value_headers_serializer(alb_multi_value_header_listener_endpoint):
7880
# GIVEN
7981
url = f"{alb_multi_value_header_listener_endpoint}/todos"
@@ -112,6 +114,7 @@ def test_alb_multi_value_headers_serializer(alb_multi_value_header_listener_endp
112114
assert response.cookies.get(cookie.name) == cookie.value
113115

114116

117+
@pytest.mark.xdist_group(name="event_handler")
115118
def test_api_gateway_rest_headers_serializer(apigw_rest_endpoint):
116119
# GIVEN
117120
url = f"{apigw_rest_endpoint}todos"
@@ -147,6 +150,7 @@ def test_api_gateway_rest_headers_serializer(apigw_rest_endpoint):
147150
assert response.cookies.get(cookie.name) == cookie.value
148151

149152

153+
@pytest.mark.xdist_group(name="event_handler")
150154
def test_api_gateway_http_headers_serializer(apigw_http_endpoint):
151155
# GIVEN
152156
url = f"{apigw_http_endpoint}todos"
@@ -182,6 +186,7 @@ def test_api_gateway_http_headers_serializer(apigw_http_endpoint):
182186
assert response.cookies.get(cookie.name) == cookie.value
183187

184188

189+
@pytest.mark.xdist_group(name="event_handler")
185190
def test_lambda_function_url_headers_serializer(lambda_function_url_endpoint):
186191
# GIVEN
187192
url = f"{lambda_function_url_endpoint}todos" # the function url endpoint already has the trailing /

tests/e2e/event_handler/test_paths_ending_with_slash.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def lambda_function_url_endpoint(infrastructure: dict) -> str:
3333
return infrastructure.get("LambdaFunctionUrl", "")
3434

3535

36+
@pytest.mark.xdist_group(name="event_handler")
3637
def test_api_gateway_rest_trailing_slash(apigw_rest_endpoint):
3738
# GIVEN API URL ends in a trailing slash
3839
url = f"{apigw_rest_endpoint}todos/"
@@ -51,6 +52,7 @@ def test_api_gateway_rest_trailing_slash(apigw_rest_endpoint):
5152
assert response.status_code == 200
5253

5354

55+
@pytest.mark.xdist_group(name="event_handler")
5456
def test_api_gateway_http_trailing_slash(apigw_http_endpoint):
5557
# GIVEN the URL for the API ends in a trailing slash API gateway should return a 404
5658
url = f"{apigw_http_endpoint}todos/"
@@ -67,6 +69,7 @@ def test_api_gateway_http_trailing_slash(apigw_http_endpoint):
6769
)
6870

6971

72+
@pytest.mark.xdist_group(name="event_handler")
7073
def test_lambda_function_url_trailing_slash(lambda_function_url_endpoint):
7174
# GIVEN the URL for the API ends in a trailing slash it should behave as if there was not one
7275
url = f"{lambda_function_url_endpoint}todos/" # the function url endpoint already has the trailing /
@@ -83,6 +86,7 @@ def test_lambda_function_url_trailing_slash(lambda_function_url_endpoint):
8386
)
8487

8588

89+
@pytest.mark.xdist_group(name="event_handler")
8690
def test_alb_url_trailing_slash(alb_multi_value_header_listener_endpoint):
8791
# GIVEN url has a trailing slash - it should behave as if there was not one
8892
url = f"{alb_multi_value_header_listener_endpoint}/todos/"

tests/e2e/idempotency/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
from tests.e2e.idempotency.infrastructure import IdempotencyDynamoDBStack
44

55

6-
@pytest.fixture(autouse=True, scope="module")
7-
def infrastructure(tmp_path_factory, worker_id):
6+
@pytest.fixture(autouse=True, scope="package")
7+
def infrastructure():
88
"""Setup and teardown logic for E2E test infrastructure
99
1010
Yields

tests/e2e/idempotency/test_idempotency_dynamodb.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def idempotency_table_name(infrastructure: dict) -> str:
2727
return infrastructure.get("DynamoDBTable", "")
2828

2929

30+
@pytest.mark.xdist_group(name="idempotency")
3031
def test_ttl_caching_expiration_idempotency(ttl_cache_expiration_handler_fn_arn: str):
3132
# GIVEN
3233
payload = json.dumps({"message": "Lambda Powertools - TTL 5s"})
@@ -56,6 +57,7 @@ def test_ttl_caching_expiration_idempotency(ttl_cache_expiration_handler_fn_arn:
5657
assert third_execution_response != second_execution_response
5758

5859

60+
@pytest.mark.xdist_group(name="idempotency")
5961
def test_ttl_caching_timeout_idempotency(ttl_cache_timeout_handler_fn_arn: str):
6062
# GIVEN
6163
payload_timeout_execution = json.dumps({"sleep": 5, "message": "Lambda Powertools - TTL 1s"})
@@ -79,6 +81,7 @@ def test_ttl_caching_timeout_idempotency(ttl_cache_timeout_handler_fn_arn: str):
7981
assert payload_working_execution == execution_working_response
8082

8183

84+
@pytest.mark.xdist_group(name="idempotency")
8285
def test_parallel_execution_idempotency(parallel_execution_handler_fn_arn: str):
8386
# GIVEN
8487
arguments = json.dumps({"message": "Lambda Powertools - Parallel execution"})

tests/e2e/logger/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
from tests.e2e.logger.infrastructure import LoggerStack
44

55

6-
@pytest.fixture(autouse=True, scope="module")
7-
def infrastructure(tmp_path_factory, worker_id):
6+
@pytest.fixture(autouse=True, scope="package")
7+
def infrastructure():
88
"""Setup and teardown logic for E2E test infrastructure
99
1010
Yields

tests/e2e/logger/test_logger.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def basic_handler_fn_arn(infrastructure: dict) -> str:
1717
return infrastructure.get("BasicHandlerArn", "")
1818

1919

20+
@pytest.mark.xdist_group(name="logger")
2021
def test_basic_lambda_logs_visible(basic_handler_fn, basic_handler_fn_arn):
2122
# GIVEN
2223
message = "logs should be visible with default settings"

tests/e2e/metrics/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
from tests.e2e.metrics.infrastructure import MetricsStack
44

55

6-
@pytest.fixture(autouse=True, scope="module")
7-
def infrastructure(tmp_path_factory, worker_id):
6+
@pytest.fixture(autouse=True, scope="package")
7+
def infrastructure():
88
"""Setup and teardown logic for E2E test infrastructure
99
1010
Yields

0 commit comments

Comments
 (0)