Skip to content

Commit 2103e0e

Browse files
committed
chore: fix backward compatibility with previous tests
1 parent 838ac57 commit 2103e0e

5 files changed

Lines changed: 43 additions & 17 deletions

File tree

.github/workflows/dockerized-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
4747
- name: Build base test image with RIE and custom entrypoint
4848
run: |
49-
docker build . -t local/test-base -f Dockerfile.rie
49+
docker build . -t local/test-base -f Dockerfile.test
5050
5151
- name: Run tests
5252
uses: aws/containerized-test-runner-for-aws-lambda@main

Dockerfile.rie

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
11
FROM public.ecr.aws/lambda/provided:al2023
22

3+
RUN dnf install -y gcc
4+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
5+
ENV PATH="/root/.cargo/bin:${PATH}"
6+
37
ADD https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest/download/aws-lambda-rie /usr/local/bin/aws-lambda-rie
48
RUN chmod +x /usr/local/bin/aws-lambda-rie
59

6-
COPY scripts/custom-lambda-entrypoint.sh /usr/local/bin/lambda-entrypoint
7-
RUN chmod +x /usr/local/bin/lambda-entrypoint
10+
ARG EXAMPLE=basic-lambda
11+
12+
COPY Cargo.* /build/
13+
COPY lambda-runtime /build/lambda-runtime
14+
COPY lambda-runtime-api-client /build/lambda-runtime-api-client
15+
COPY lambda-events /build/lambda-events
16+
COPY lambda-http /build/lambda-http
17+
COPY lambda-extension /build/lambda-extension
18+
COPY examples/${EXAMPLE} /build/examples/${EXAMPLE}
19+
20+
WORKDIR /build/examples/${EXAMPLE}
21+
RUN cargo build --release
22+
RUN cp target/release/${EXAMPLE} ${LAMBDA_RUNTIME_DIR}/bootstrap
823

9-
ENTRYPOINT ["/usr/local/bin/lambda-entrypoint"]
10-
CMD ["basic-lambda"]
24+
ENTRYPOINT []
25+
CMD [ "/usr/local/bin/aws-lambda-rie", "/var/runtime/bootstrap" ]

Dockerfile.test

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM public.ecr.aws/lambda/provided:al2023
2+
3+
ADD https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest/download/aws-lambda-rie /usr/local/bin/aws-lambda-rie
4+
RUN chmod +x /usr/local/bin/aws-lambda-rie
5+
6+
COPY scripts/custom-lambda-entrypoint.sh /usr/local/bin/lambda-entrypoint
7+
RUN chmod +x /usr/local/bin/lambda-entrypoint
8+
9+
ENTRYPOINT ["/usr/local/bin/lambda-entrypoint"]
10+
CMD ["basic-lambda"]

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ test-dockerized: build-examples
135135
@echo "Building base Docker image with RIE and custom entrypoint..."
136136
docker build \
137137
-t local/test-base \
138-
-f Dockerfile.rie \
138+
-f Dockerfile.test \
139139
.
140140

141141
@echo "Setting up containerized test runner..."

scripts/test-rie.sh

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
11
#!/bin/bash
22
set -euo pipefail
33

4+
EXAMPLE=${1:-basic-lambda}
45
# Optional: set RIE_MAX_CONCURRENCY to enable LMI mode (emulates AWS_LAMBDA_MAX_CONCURRENCY)
56
RIE_MAX_CONCURRENCY=${RIE_MAX_CONCURRENCY:-}
6-
# Optional: specify which handler to run (defaults to first handler)
7-
HANDLER=${HANDLER:-basic-lambda}
87

9-
echo "Building Docker image with RIE (handlers: $HANDLER)"
10-
docker build -f Dockerfile.rie --build-arg HANDLERS_TO_BUILD="$HANDLER" -t rust-lambda-rie-test .
8+
echo "Building Docker image with RIE for example: $EXAMPLE..."
9+
docker build -f Dockerfile.rie --build-arg EXAMPLE=$EXAMPLE -t rust-lambda-rie-test .
1110

12-
echo "Starting RIE container on port 9000 with handler: $HANDLER"
11+
echo "Starting RIE container on port 9000..."
1312
if [ -n "$RIE_MAX_CONCURRENCY" ]; then
1413
echo "Enabling LMI mode with AWS_LAMBDA_MAX_CONCURRENCY=$RIE_MAX_CONCURRENCY"
15-
docker run -p 9000:8080 -e AWS_LAMBDA_MAX_CONCURRENCY="$RIE_MAX_CONCURRENCY" rust-lambda-rie-test "$HANDLER" &
14+
docker run -p 9000:8080 -e AWS_LAMBDA_MAX_CONCURRENCY="$RIE_MAX_CONCURRENCY" rust-lambda-rie-test &
1615
else
17-
docker run -p 9000:8080 rust-lambda-rie-test "$HANDLER" &
16+
docker run -p 9000:8080 rust-lambda-rie-test &
1817
fi
1918
CONTAINER_PID=$!
2019

2120
echo "Container started. Test with:"
22-
echo "curl -XPOST 'http://localhost:9000/2015-03-31/functions/function/invocations' -d '{\"command\": \"test from RIE\"}' -H 'Content-Type: application/json'"
23-
echo "or for a specific example check under examples/ for the expected payload format."
24-
21+
if [ "$EXAMPLE" = "basic-lambda" ] || [ "$EXAMPLE" = "basic-lambda-concurrent" ]; then
22+
echo "curl -XPOST 'http://localhost:9000/2015-03-31/functions/function/invocations' -d '{\"command\": \"test from RIE\"}' -H 'Content-Type: application/json'"
23+
else
24+
echo "For example '$EXAMPLE', check examples/$EXAMPLE/src/main.rs for the expected payload format."
25+
fi
2526
echo ""
2627
echo "Press Ctrl+C to stop the container."
2728

28-
wait $CONTAINER_PID
29+
wait $CONTAINER_PID

0 commit comments

Comments
 (0)