Skip to content
Merged
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: 7 additions & 6 deletions tests/integrations/aws_lambda/test_aws_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

DOCKER_NETWORK_NAME = "lambda-test-network"
SAM_TEMPLATE_FILE = "sam.template.yaml"
SAM_SHUTDOWN_TIMEOUT = 10


@pytest.fixture(scope="session", autouse=True)
Expand Down Expand Up @@ -54,7 +55,7 @@ def test_environment():
"--template",
SAM_TEMPLATE_FILE,
"--warm-containers",
"EAGER",
"LAZY", # Start each Docker container on its function's first invocation
"--docker-network",
DOCKER_NETWORK_NAME,
],
Expand All @@ -78,13 +79,13 @@ def before_test():

finally:
print("[test_environment fixture] Tearing down AWS Lambda test infrastructure")

process.terminate()
process.wait(timeout=10) # Give it time to shut down gracefully

# Force kill if still running
if process.poll() is None:
try:
# Teardown is typically ~7s; escalate with kill if SAM exceeds this.
process.wait(timeout=SAM_SHUTDOWN_TIMEOUT)
except subprocess.TimeoutExpired:
process.kill()
process.wait()


@pytest.fixture(autouse=True)
Expand Down
Loading