Skip to content

Commit ca598ac

Browse files
committed
chore: makefile and test scenario
1 parent c672c58 commit ca598ac

2 files changed

Lines changed: 87 additions & 6 deletions

File tree

Makefile

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ HANDLER ?=
1414
-include .env
1515
export
1616

17-
.PHONY: help pr-check integration-tests check-event-features fmt build-examples test-rie test-rie-lmi nuke test-dockerized
17+
.PHONY: help pr-check integration-tests check-event-features fmt build-examples build-test-runner test-rie test-rie-lmi nuke test-dockerized test-dockerized-concurrent
1818

1919
.DEFAULT_GOAL := help
2020

@@ -129,23 +129,39 @@ build-examples:
129129
nuke:
130130
docker kill $$(docker ps -q)
131131

132-
test-dockerized: build-examples
133-
@echo "Running dockerized tests locally..."
134-
132+
build-test-runner: build-examples
135133
@echo "Building base Docker image with RIE and custom entrypoint..."
136134
docker build \
137135
-t local/test-base \
138136
-f Dockerfile.test \
139137
.
140-
138+
141139
@echo "Setting up containerized test runner..."
142140
@if [ ! -d ".test-runner" ]; then \
143141
echo "Cloning containerized-test-runner-for-aws-lambda..."; \
144142
git clone --quiet https://github.com/aws/containerized-test-runner-for-aws-lambda.git .test-runner; \
145143
fi
146144
@echo "Building test runner Docker image..."
147145
@docker build -t test-runner:local -f .test-runner/Dockerfile .test-runner
148-
146+
147+
test-dockerized-concurrent: build-test-runner
148+
@echo "Running concurrent scenarios in Docker..."
149+
@docker network create concurrent-test-net 2>/dev/null || true
150+
@docker run --rm \
151+
--network concurrent-test-net \
152+
-e INPUT_SUITE_FILE_ARRAY='[]' \
153+
-e INPUT_SCENARIO_DIR=/workspace/test/dockerized/scenarios \
154+
-e DOCKER_IMAGE_NAME=local/test-base \
155+
-e TASK_FOLDER=./test/dockerized/tasks \
156+
-e GITHUB_WORKSPACE=/workspace \
157+
-e DOCKER_SHARED_NETWORK=concurrent-test-net \
158+
-v /var/run/docker.sock:/var/run/docker.sock \
159+
-v "$(CURDIR):/workspace" \
160+
-w /workspace \
161+
test-runner:local
162+
@docker network rm --force concurrent-test-net 2>/dev/null || true
163+
164+
test-dockerized: build-test-runner
149165
@echo "Running tests in Docker..."
150166
@docker run --rm \
151167
-e INPUT_SUITE_FILE_ARRAY='["./test/dockerized/suites/*.json"]' \
@@ -179,6 +195,7 @@ help: ## Show this help message
179195
@echo ' Usage: HANDLERS_TO_BUILD="basic-lambda" HANDLER="basic-lambda" make test-rie'
180196
@echo ' test-rie-lmi Test RIE in Lambda Managed Instance mode'
181197
@echo ' Usage: RIE_MAX_CONCURRENCY=4 HANDLERS_TO_BUILD="basic-lambda-concurrent" make test-rie-lmi'
198+
@echo ' test-dockerized-concurrent Run concurrent LMI test scenarios'
182199
@echo ' test-dockerized Run dockerized test harness'
183200
@echo ' nuke Kill all running Docker containers'
184201
@echo ''
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
"""
2+
Multi-concurrency test scenarios for basic-lambda-concurrent.
3+
4+
The handler expects: { "command": "<string>" }
5+
and responds with: { "req_id": "<id>", "msg": "Command <command> executed." }
6+
"""
7+
8+
import os
9+
from containerized_test_runner.models import Request, ConcurrentTest
10+
11+
HANDLER = "basic-lambda-concurrent"
12+
IMAGE = os.environ.get("TEST_IMAGE", "local/test-base")
13+
DEFAULT_CONCURRENCY = 1
14+
15+
16+
def _make_env(concurrency: int = DEFAULT_CONCURRENCY) -> dict:
17+
return {
18+
"_HANDLER": HANDLER,
19+
"AWS_LAMBDA_MAX_CONCURRENCY": str(concurrency),
20+
"AWS_LAMBDA_LOG_FORMAT": "JSON",
21+
}
22+
23+
24+
def get_lmi_scenarios():
25+
scenarios = []
26+
27+
# Happy path: DEFAULT_CONCURRENCY unique commands all succeed concurrently
28+
batch = [
29+
Request(
30+
payload={"command": f"task-{i}"},
31+
assertions=[{"transform": "{msg: .msg}", "response": {"msg": f"Command task-{i} executed."}}],
32+
)
33+
for i in range(DEFAULT_CONCURRENCY)
34+
]
35+
scenarios.append(ConcurrentTest(
36+
name="lmi_concurrent_happy_path",
37+
handler=HANDLER,
38+
environment_variables=_make_env(),
39+
request_batches=[batch],
40+
image=IMAGE,
41+
))
42+
43+
# Error isolation: 9 invalid payloads + 1 valid — the valid one must still succeed
44+
mixed_batch = [
45+
Request(
46+
payload={"not_a_command": "oops"},
47+
assertions=[{"transform": ".errorType", "error": "Runtime.UnmarshalError"}],
48+
)
49+
for _ in range(DEFAULT_CONCURRENCY - 1)
50+
] + [
51+
Request(
52+
payload={"command": "survivor"},
53+
assertions=[{"transform": "{msg: .msg}", "response": {"msg": "Command survivor executed."}}],
54+
)
55+
]
56+
scenarios.append(ConcurrentTest(
57+
name="lmi_error_isolation",
58+
handler=HANDLER,
59+
environment_variables=_make_env(),
60+
request_batches=[mixed_batch],
61+
image=IMAGE,
62+
))
63+
64+
return scenarios

0 commit comments

Comments
 (0)