Skip to content

Commit 743fe9d

Browse files
authored
Update Distros and integration tests (#82)
* Replace deprecated install scripts for AmazonLinux integration tests * Remove Alpine3.14 since it has reached EOL * Add Debian bookworm to integration tests
1 parent 8c90521 commit 743fe9d

File tree

4 files changed

+120
-5
lines changed

4 files changed

+120
-5
lines changed

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.14"
1817
- "3.15"
1918
- "3.16"
2019
RUNTIME_VERSION:

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

test/integration/docker/Dockerfile.echo.amazonlinux

+10-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,16 @@ ARG DISTRO_VERSION
1212
# Install Py3 required to build Node16+
1313
RUN if [[ "${DISTRO_VERSION}" == "2" ]] ; then amazon-linux-extras install python3.8 && update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1 ; fi
1414
# Install NodeJS
15-
RUN curl -sL https://rpm.nodesource.com/setup_${RUNTIME_VERSION}.x | bash - && \
16-
yum install -y nodejs
17-
15+
RUN if [[ "${RUNTIME_VERSION}" == "14" ]]; then \
16+
yum install -y tar gzip xz && \
17+
AARCH="$([[ "$(arch)" == "x86_64" ]] && echo "x64" || echo "arm64")" && \
18+
NODE_URL="https://nodejs.org/download/release/v14.21.3/node-v14.21.3-linux-$AARCH.tar.xz" && \
19+
curl -fL "$NODE_URL" | tar -C /usr --strip-components 1 -xJf - && \
20+
yum clean all -q && rm -rf /var/cache/yum ; \
21+
else \
22+
yum install https://rpm.nodesource.com/pub_${RUNTIME_VERSION}.x/nodistro/repo/nodesource-release-nodistro-1.noarch.rpm -y && \
23+
yum install nodejs -y --setopt=nodesource-nodejs.module_hotfixes=1s ; \
24+
fi
1825

1926
# Stage 2 - build function and dependencies
2027
FROM node-amazonlinux AS build-image

0 commit comments

Comments
 (0)