Skip to content

Commit 6036a95

Browse files
authored
Update integ tests (#85)
* Onboard Alpine3.17 and Alpine 3.18 * Remove node setup from Github actions * Remove Alpine3.15
1 parent 532f5cf commit 6036a95

7 files changed

+240
-28
lines changed

.github/workflows/test-on-push-and-pr.yml

-24
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ jobs:
1212

1313
steps:
1414
- uses: actions/checkout@v2
15-
- name: Set up node
16-
uses: actions/setup-node@v1
17-
with:
18-
node-version: '16'
1915
- name: Run 'pr' target
2016
run: make pr
2117

@@ -24,10 +20,6 @@ jobs:
2420

2521
steps:
2622
- uses: actions/checkout@v2
27-
- name: Set up node
28-
uses: actions/setup-node@v1
29-
with:
30-
node-version: '16'
3123
- name: Run alpine integration tests
3224
run: DISTRO=alpine make test-integ
3325

@@ -36,10 +28,6 @@ jobs:
3628

3729
steps:
3830
- uses: actions/checkout@v2
39-
- name: Set up node
40-
uses: actions/setup-node@v1
41-
with:
42-
node-version: '16'
4331
- name: Run amazonlinux integration tests
4432
run: DISTRO=amazonlinux make test-integ
4533

@@ -48,10 +36,6 @@ jobs:
4836

4937
steps:
5038
- uses: actions/checkout@v2
51-
- name: Set up node
52-
uses: actions/setup-node@v1
53-
with:
54-
node-version: '16'
5539
- name: Run centos integration tests
5640
run: DISTRO=centos make test-integ
5741

@@ -60,10 +44,6 @@ jobs:
6044

6145
steps:
6246
- uses: actions/checkout@v2
63-
- name: Set up node
64-
uses: actions/setup-node@v1
65-
with:
66-
node-version: '16'
6747
- name: Run debian integration tests
6848
run: DISTRO=debian make test-integ
6949

@@ -72,9 +52,5 @@ jobs:
7252

7353
steps:
7454
- uses: actions/checkout@v2
75-
- name: Set up node
76-
uses: actions/setup-node@v1
77-
with:
78-
node-version: '16'
7955
- name: Run ubuntu integration tests
8056
run: DISTRO=ubuntu make test-integ

test/integration/codebuild/buildspec.os.alpine.1.yml

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ batch:
1414
env:
1515
variables:
1616
DISTRO_VERSION:
17-
- "3.15"
1817
- "3.16"
1918
RUNTIME_VERSION:
2019
- "14"

test/integration/codebuild/buildspec.os.alpine.2.yml

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ batch:
1616
env:
1717
variables:
1818
DISTRO_VERSION:
19-
- "3.15"
2019
- "3.16"
2120
RUNTIME_VERSION:
2221
- "14"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
version: 0.2
2+
3+
env:
4+
variables:
5+
OS_DISTRIBUTION: alpine
6+
NPX_BINARY_LOCATION: "/usr/local/bin/npx"
7+
batch:
8+
build-matrix:
9+
static:
10+
ignore-failure: false
11+
env:
12+
privileged-mode: true
13+
dynamic:
14+
env:
15+
variables:
16+
DISTRO_VERSION:
17+
- "3.17"
18+
- "3.18"
19+
RUNTIME_VERSION:
20+
- "16"
21+
- "18"
22+
phases:
23+
pre_build:
24+
commands:
25+
- export IMAGE_TAG="nodejs-${OS_DISTRIBUTION}-${DISTRO_VERSION}:${RUNTIME_VERSION}"
26+
- echo "Extracting and including the Runtime Interface Emulator"
27+
- SCRATCH_DIR=".scratch"
28+
- mkdir "${SCRATCH_DIR}"
29+
- ARCHITECTURE=$(arch)
30+
- >
31+
if [[ "$ARCHITECTURE" == "x86_64" ]]; then
32+
RIE="aws-lambda-rie"
33+
elif [[ "$ARCHITECTURE" == "aarch64" ]]; then
34+
RIE="aws-lambda-rie-arm64"
35+
else
36+
echo "Architecture $ARCHITECTURE is not currently supported."
37+
exit 1
38+
fi
39+
- tar -xvf test/integration/resources/${RIE}.tar.gz --directory "${SCRATCH_DIR}"
40+
- >
41+
cp "test/integration/docker/Dockerfile.echo.${OS_DISTRIBUTION}" \
42+
"${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp"
43+
- >
44+
echo "RUN apk add curl" >> \
45+
"${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp"
46+
- >
47+
echo "COPY ${SCRATCH_DIR}/${RIE} /usr/bin/${RIE}" >> \
48+
"${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp"
49+
- >
50+
if [[ -z "${DOCKERHUB_USERNAME}" && -z "${DOCKERHUB_PASSWORD}" ]];
51+
then
52+
echo "DockerHub credentials not set as CodeBuild environment variables. Continuing without docker login."
53+
else
54+
echo "Performing DockerHub login . . ."
55+
docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD
56+
fi
57+
- echo "Building image ${IMAGE_TAG}"
58+
- >
59+
docker build . \
60+
-f "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" \
61+
-t "${IMAGE_TAG}" \
62+
--build-arg RUNTIME_VERSION="${RUNTIME_VERSION}" \
63+
--build-arg DISTRO_VERSION="${DISTRO_VERSION}"
64+
build:
65+
commands:
66+
- set -x
67+
- echo "Running Image ${IMAGE_TAG}"
68+
- docker network create "${OS_DISTRIBUTION}-network"
69+
- >
70+
docker run \
71+
--detach \
72+
--name "${OS_DISTRIBUTION}-app" \
73+
--network "${OS_DISTRIBUTION}-network" \
74+
--entrypoint="" \
75+
"${IMAGE_TAG}" \
76+
sh -c "/usr/bin/${RIE} ${NPX_BINARY_LOCATION} aws-lambda-ric index.handler"
77+
- sleep 2
78+
- >
79+
docker run \
80+
--name "${OS_DISTRIBUTION}-tester" \
81+
--env "TARGET=${OS_DISTRIBUTION}-app" \
82+
--network "${OS_DISTRIBUTION}-network" \
83+
--entrypoint="" \
84+
"${IMAGE_TAG}" \
85+
sh -c 'curl -X POST "http://${TARGET}:8080/2015-03-31/functions/function/invocations" -d "{}" --max-time 10'
86+
- actual="$(docker logs --tail 1 "${OS_DISTRIBUTION}-tester" | xargs)"
87+
- expected='success'
88+
- |
89+
echo "Response: ${actual}"
90+
if [[ "$actual" != "$expected" ]]; then
91+
echo "fail! runtime: $RUNTIME - expected output $expected - got $actual"
92+
exit -1
93+
fi
94+
finally:
95+
- |
96+
echo "---------Container Logs: ${OS_DISTRIBUTION}-app----------"
97+
echo
98+
docker logs "${OS_DISTRIBUTION}-app" || true
99+
echo
100+
echo "---------------------------------------------------"
101+
echo "--------Container Logs: ${OS_DISTRIBUTION}-tester--------"
102+
echo
103+
docker logs "${OS_DISTRIBUTION}-tester" || true
104+
echo
105+
echo "---------------------------------------------------"
106+
- echo "Cleaning up..."
107+
- docker stop "${OS_DISTRIBUTION}-app" || true
108+
- docker rm --force "${OS_DISTRIBUTION}-app" || true
109+
- docker stop "${OS_DISTRIBUTION}-tester" || true
110+
- docker rm --force "${OS_DISTRIBUTION}-tester" || true
111+
- docker network rm "${OS_DISTRIBUTION}-network" || true
112+
- docker rmi "${IMAGE_TAG}" || true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
version: 0.2
2+
3+
env:
4+
variables:
5+
OS_DISTRIBUTION: alpine
6+
NODE_BINARY_LOCATION: "/usr/local/bin/node"
7+
NPX_BINARY_LOCATION: "/usr/local/bin/npx"
8+
batch:
9+
build-matrix:
10+
static:
11+
ignore-failure: false
12+
env:
13+
type: LINUX_CONTAINER
14+
privileged-mode: true
15+
dynamic:
16+
env:
17+
variables:
18+
DISTRO_VERSION:
19+
- "3.17"
20+
- "3.18"
21+
RUNTIME_VERSION:
22+
- "16"
23+
- "18"
24+
phases:
25+
pre_build:
26+
commands:
27+
- export IMAGE_TAG="nodejs-${OS_DISTRIBUTION}-${DISTRO_VERSION}:${RUNTIME_VERSION}"
28+
- echo "Extracting and including the Runtime Interface Emulator"
29+
- SCRATCH_DIR=".scratch"
30+
- mkdir "${SCRATCH_DIR}"
31+
- tar -xvf test/integration/resources/aws-lambda-rie.tar.gz --directory "${SCRATCH_DIR}"
32+
- >
33+
cp "test/integration/docker/Dockerfile.programmatic.${OS_DISTRIBUTION}" \
34+
"${SCRATCH_DIR}/Dockerfile.programmatic.${OS_DISTRIBUTION}.tmp"
35+
- >
36+
echo "RUN apk add curl" >> \
37+
"${SCRATCH_DIR}/Dockerfile.programmatic.${OS_DISTRIBUTION}.tmp"
38+
- >
39+
echo "COPY ${SCRATCH_DIR}/aws-lambda-rie /usr/bin/aws-lambda-rie" >> \
40+
"${SCRATCH_DIR}/Dockerfile.programmatic.${OS_DISTRIBUTION}.tmp"
41+
- >
42+
if [[ -z "${DOCKERHUB_USERNAME}" && -z "${DOCKERHUB_PASSWORD}" ]];
43+
then
44+
echo "DockerHub credentials not set as CodeBuild environment variables. Continuing without docker login."
45+
else
46+
echo "Performing DockerHub login . . ."
47+
docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD
48+
fi
49+
- echo "Building image ${IMAGE_TAG}"
50+
- >
51+
docker build . \
52+
-f "${SCRATCH_DIR}/Dockerfile.programmatic.${OS_DISTRIBUTION}.tmp" \
53+
-t "${IMAGE_TAG}" \
54+
--build-arg RUNTIME_VERSION="${RUNTIME_VERSION}" \
55+
--build-arg DISTRO_VERSION="${DISTRO_VERSION}"
56+
build:
57+
commands:
58+
- set -x
59+
- echo "Running Image ${IMAGE_TAG}"
60+
- docker network create "${OS_DISTRIBUTION}-network"
61+
- >
62+
docker run \
63+
--detach \
64+
-e "NODE_BINARY_LOCATION=${NODE_BINARY_LOCATION}" \
65+
--name "${OS_DISTRIBUTION}-app" \
66+
--network "${OS_DISTRIBUTION}-network" \
67+
--entrypoint="" \
68+
"${IMAGE_TAG}" \
69+
sh -c '/usr/bin/aws-lambda-rie ${NODE_BINARY_LOCATION} index.mjs'
70+
- sleep 2
71+
- >
72+
docker run \
73+
--name "${OS_DISTRIBUTION}-tester" \
74+
--env "TARGET=${OS_DISTRIBUTION}-app" \
75+
--network "${OS_DISTRIBUTION}-network" \
76+
--entrypoint="" \
77+
"${IMAGE_TAG}" \
78+
sh -c 'curl -X POST "http://${TARGET}:8080/2015-03-31/functions/function/invocations" -d "{}" --max-time 10'
79+
- actual="$(docker logs --tail 1 "${OS_DISTRIBUTION}-tester" | xargs)"
80+
- expected='success'
81+
- |
82+
echo "Response: ${actual}"
83+
if [[ "$actual" != "$expected" ]]; then
84+
echo "fail! runtime: $RUNTIME - expected output $expected - got $actual"
85+
echo "---------Container Logs: ${OS_DISTRIBUTION}-app----------"
86+
echo
87+
docker logs "${OS_DISTRIBUTION}-app"
88+
echo
89+
echo "---------------------------------------------------"
90+
echo "--------Container Logs: ${OS_DISTRIBUTION}-tester--------"
91+
echo
92+
docker logs "${OS_DISTRIBUTION}-tester"
93+
echo
94+
echo "---------------------------------------------------"
95+
exit -1
96+
fi
97+
finally:
98+
- echo "Cleaning up..."
99+
- docker stop "${OS_DISTRIBUTION}-app" || true
100+
- docker rm --force "${OS_DISTRIBUTION}-app" || true
101+
- docker stop "${OS_DISTRIBUTION}-tester" || true
102+
- docker rm --force "${OS_DISTRIBUTION}-tester" || true
103+
- docker network rm "${OS_DISTRIBUTION}-network" || true
104+
- docker rmi "${IMAGE_TAG}" || true

test/integration/docker/Dockerfile.echo.alpine

+12-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ ARG DISTRO_VERSION
55

66
# Stage 1 - build function and dependencies
77
FROM node:${RUNTIME_VERSION}-alpine${DISTRO_VERSION} AS build-image
8+
# Include global arg in this stage of the build
9+
ARG DISTRO_VERSION
810
# Install aws-lambda-cpp build dependencies
911
RUN apk add --update-cache \
1012
build-base \
@@ -14,12 +16,21 @@ RUN apk add --update-cache \
1416
libffi-dev \
1517
autoconf \
1618
automake \
17-
libexecinfo-dev \
1819
make \
1920
cmake \
2021
python3 \
2122
libcurl
2223

24+
# AWS Lambda CPP and libcurl rely on backtrace which requires libexecinfo from Alpine.
25+
# Since starting from Alpine3.17 libexecinfo is no longer available, temporarily source it from Alpine3.16
26+
# while awaiting an upstream resolution in AWS Lambda CPP.
27+
RUN if [[ "${DISTRO_VERSION}" == "3.17" ]] || [[ "${DISTRO_VERSION}" == "3.18" ]] ; \
28+
then \
29+
apk add --update-cache --repository=https://dl-cdn.alpinelinux.org/alpine/v3.16/main/ libexecinfo-dev ; \
30+
else \
31+
apk add --update-cache libexecinfo-dev ; \
32+
fi
33+
2334
# Include global arg in this stage of the build
2435
ARG FUNCTION_DIR
2536
# Create function directory

test/integration/docker/Dockerfile.programmatic.alpine

+12-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ ARG DISTRO_VERSION
55

66
# Stage 1 - build function and dependencies
77
FROM node:${RUNTIME_VERSION}-alpine${DISTRO_VERSION} AS build-image
8+
# Include global arg in this stage of the build
9+
ARG DISTRO_VERSION
810
# Install aws-lambda-cpp build dependencies
911
RUN apk add --update-cache \
1012
build-base \
@@ -14,12 +16,21 @@ RUN apk add --update-cache \
1416
libffi-dev \
1517
autoconf \
1618
automake \
17-
libexecinfo-dev \
1819
make \
1920
cmake \
2021
python3 \
2122
libcurl
2223

24+
# AWS Lambda CPP and libcurl rely on backtrace which requires libexecinfo from Alpine.
25+
# Since starting from Alpine3.17 libexecinfo is no longer available, temporarily source it from Alpine3.16
26+
# while awaiting an upstream resolution in AWS Lambda CPP.
27+
RUN if [[ "${DISTRO_VERSION}" == "3.17" ]] || [[ "${DISTRO_VERSION}" == "3.18" ]] ; \
28+
then \
29+
apk add --update-cache --repository=https://dl-cdn.alpinelinux.org/alpine/v3.16/main/ libexecinfo-dev ; \
30+
else \
31+
apk add --update-cache libexecinfo-dev ; \
32+
fi
33+
2334
# Include global arg in this stage of the build
2435
ARG FUNCTION_DIR
2536
# Create function directory

0 commit comments

Comments
 (0)