Skip to content

Commit f9d370f

Browse files
authoredAug 8, 2024··
Fix integration tests (#165)
* Fix integration tests
1 parent d9bb2e4 commit f9d370f

13 files changed

+76
-431
lines changed
 

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

+5-13
Original file line numberDiff line numberDiff line change
@@ -11,46 +11,38 @@ jobs:
1111
runs-on: ubuntu-latest
1212

1313
steps:
14-
- uses: actions/checkout@v2
14+
- uses: actions/checkout@v4
1515
- name: Run 'pr' target
1616
run: make pr
1717

1818
alpine:
1919
runs-on: ubuntu-latest
2020

2121
steps:
22-
- uses: actions/checkout@v2
22+
- uses: actions/checkout@v4
2323
- name: Run alpine integration tests
2424
run: DISTRO=alpine make test-integ
2525

2626
amazonlinux:
2727
runs-on: ubuntu-latest
2828

2929
steps:
30-
- uses: actions/checkout@v2
30+
- uses: actions/checkout@v4
3131
- name: Run amazonlinux integration tests
3232
run: DISTRO=amazonlinux make test-integ
3333

34-
centos:
35-
runs-on: ubuntu-latest
36-
37-
steps:
38-
- uses: actions/checkout@v2
39-
- name: Run centos integration tests
40-
run: DISTRO=centos make test-integ
41-
4234
debian:
4335
runs-on: ubuntu-latest
4436

4537
steps:
46-
- uses: actions/checkout@v2
38+
- uses: actions/checkout@v4
4739
- name: Run debian integration tests
4840
run: DISTRO=debian make test-integ
4941

5042
ubuntu:
5143
runs-on: ubuntu-latest
5244

5345
steps:
54-
- uses: actions/checkout@v2
46+
- uses: actions/checkout@v4
5547
- name: Run ubuntu integration tests
5648
run: DISTRO=ubuntu make test-integ

‎Makefile

+3-2
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ dev: init test
4141

4242
# Verifications to run before sending a pull request
4343
.PHONY: pr
44-
pr: init check-format check-security dev setup-codebuild-agent
45-
CODEBUILD_IMAGE_TAG=codebuild-agent DISTRO="$(DISTRO)" tests/integration/codebuild-local/test_all.sh tests/integration/codebuild
44+
pr: init check-format check-security dev
4645

46+
codebuild: setup-codebuild-agent
47+
CODEBUILD_IMAGE_TAG=codebuild-agent DISTRO="$(DISTRO)" tests/integration/codebuild-local/test_all.sh tests/integration/codebuild
4748

4849
.PHONY: clean
4950
clean:

‎README.md

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ First step is to choose the base image to be used. The supported Linux OS distri
1919

2020
- Amazon Linux 2
2121
- Alpine
22-
- CentOS
2322
- Debian
2423
- Ubuntu
2524

‎tests/integration/codebuild/buildspec.os.alpine.yml

+7-12
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@ batch:
1515
env:
1616
variables:
1717
DISTRO_VERSION:
18-
- "3.13"
19-
- "3.14"
20-
- "3.15"
18+
- "3.17"
19+
- "3.18"
20+
- "3.19"
2121
RUNTIME_VERSION:
22-
- "3.8"
2322
- "3.9"
2423
- "3.10"
2524
- "3.11"
@@ -52,20 +51,16 @@ phases:
5251
echo "COPY ${SCRATCH_DIR}/${RIE} /usr/bin/${RIE}" >> \
5352
"${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp"
5453
- >
55-
if [[ -z "${DOCKERHUB_USERNAME}" && -z "${DOCKERHUB_PASSWORD}" ]];
56-
then
57-
echo "DockerHub credentials not set as CodeBuild environment variables. Continuing without docker login."
58-
else
59-
echo "Performing DockerHub login . . ."
60-
docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD
61-
fi
54+
echo '{"registry-mirrors": ["https://mirror.gcr.io"]}' > /etc/docker/daemon.json
55+
service docker restart
6256
- echo "Building image ${IMAGE_TAG}"
6357
- >
6458
docker build . \
6559
-f "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" \
6660
-t "${IMAGE_TAG}" \
6761
--build-arg RUNTIME_VERSION="${RUNTIME_VERSION}" \
68-
--build-arg DISTRO_VERSION="${DISTRO_VERSION}"
62+
--build-arg DISTRO_VERSION="${DISTRO_VERSION}" \
63+
--load
6964
build:
7065
commands:
7166
- set -x

‎tests/integration/codebuild/buildspec.os.amazonlinux.1.yml

-104
This file was deleted.

‎tests/integration/codebuild/buildspec.os.amazonlinux.2.yml

+4-10
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ batch:
1717
DISTRO_VERSION:
1818
- "2"
1919
RUNTIME_VERSION:
20-
- "3.7"
21-
- "3.8"
2220
- "3.9"
2321
- "3.10"
2422
- "3.11"
@@ -48,21 +46,17 @@ phases:
4846
echo "COPY ${SCRATCH_DIR}/${RIE} /usr/bin/${RIE}" >> \
4947
"${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp"
5048
- >
51-
if [[ -z "${DOCKERHUB_USERNAME}" && -z "${DOCKERHUB_PASSWORD}" ]];
52-
then
53-
echo "DockerHub credentials not set as CodeBuild environment variables. Continuing without docker login."
54-
else
55-
echo "Performing DockerHub login . . ."
56-
docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD
57-
fi
49+
echo '{"registry-mirrors": ["https://mirror.gcr.io"]}' > /etc/docker/daemon.json
50+
service docker restart
5851
- echo "Building image ${IMAGE_TAG}"
5952
- >
6053
docker build . \
6154
-f "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" \
6255
-t "${IMAGE_TAG}" \
6356
--build-arg RUNTIME_VERSION="${RUNTIME_VERSION}" \
6457
--build-arg DISTRO_VERSION="${DISTRO_VERSION}" \
65-
--build-arg ARCHITECTURE="${ARCHITECTURE}"
58+
--build-arg ARCHITECTURE="${ARCHITECTURE}" \
59+
--load
6660
build:
6761
commands:
6862
- set -x

‎tests/integration/codebuild/buildspec.os.centos.yml

-112
This file was deleted.

‎tests/integration/codebuild/buildspec.os.debian.yml

+5-10
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@ batch:
1515
env:
1616
variables:
1717
DISTRO_VERSION:
18-
- "buster"
18+
- "bookworm"
1919
- "bullseye"
2020
RUNTIME_VERSION:
21-
- "3.8"
2221
- "3.9"
2322
- "3.10"
2423
- "3.11"
@@ -51,20 +50,16 @@ phases:
5150
echo "RUN apt-get update && apt-get install -y curl" >> \
5251
"${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp"
5352
- >
54-
if [[ -z "${DOCKERHUB_USERNAME}" && -z "${DOCKERHUB_PASSWORD}" ]];
55-
then
56-
echo "DockerHub credentials not set as CodeBuild environment variables. Continuing without docker login."
57-
else
58-
echo "Performing DockerHub login . . ."
59-
docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD
60-
fi
53+
echo '{"registry-mirrors": ["https://mirror.gcr.io"]}' > /etc/docker/daemon.json
54+
service docker restart
6155
- echo "Building image ${IMAGE_TAG}"
6256
- >
6357
docker build . \
6458
-f "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" \
6559
-t "${IMAGE_TAG}" \
6660
--build-arg RUNTIME_VERSION="${RUNTIME_VERSION}" \
67-
--build-arg DISTRO_VERSION="${DISTRO_VERSION}"
61+
--build-arg DISTRO_VERSION="${DISTRO_VERSION}" \
62+
--load
6863
build:
6964
commands:
7065
- set -x

‎tests/integration/codebuild/buildspec.os.ubuntu.yml

+5-10
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@ batch:
1515
env:
1616
variables:
1717
DISTRO_VERSION:
18-
- "20.04"
1918
- "22.04"
19+
- "24.04"
2020
RUNTIME_VERSION:
21-
- "3.8"
2221
- "3.9"
2322
- "3.10"
2423
- "3.11"
@@ -48,20 +47,16 @@ phases:
4847
echo "COPY ${SCRATCH_DIR}/${RIE} /usr/bin/${RIE}" >> \
4948
"${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp"
5049
- >
51-
if [[ -z "${DOCKERHUB_USERNAME}" && -z "${DOCKERHUB_PASSWORD}" ]];
52-
then
53-
echo "DockerHub credentials not set as CodeBuild environment variables. Continuing without docker login."
54-
else
55-
echo "Performing DockerHub login . . ."
56-
docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD
57-
fi
50+
echo '{"registry-mirrors": ["https://mirror.gcr.io"]}' > /etc/docker/daemon.json
51+
service docker restart
5852
- echo "Building image ${IMAGE_TAG}"
5953
- >
6054
docker build . \
6155
-f "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" \
6256
-t "${IMAGE_TAG}" \
6357
--build-arg RUNTIME_VERSION="${RUNTIME_VERSION}" \
64-
--build-arg DISTRO_VERSION="${DISTRO_VERSION}"
58+
--build-arg DISTRO_VERSION="${DISTRO_VERSION}" \
59+
--load
6560
build:
6661
commands:
6762
- set -x

‎tests/integration/docker/Dockerfile.echo.alpine

+4-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ ARG DISTRO_VERSION
77
FROM public.ecr.aws/docker/library/python:${RUNTIME_VERSION}-alpine${DISTRO_VERSION} AS python-alpine
88
# Install libstdc++
99
RUN apk add --no-cache \
10-
libstdc++
10+
libstdc++ \
11+
binutils
1112

1213

1314
# Stage 2 - build function and dependencies
@@ -39,15 +40,12 @@ ARG FUNCTION_DIR="/home/app/"
3940
RUN mkdir -p ${FUNCTION_DIR}
4041
# Copy function code
4142
COPY tests/integration/test-handlers/echo/* ${FUNCTION_DIR}
42-
# Copy Runtime Interface Client .tgz
43-
RUN cp ./dist/awslambdaric-test.tar.gz ${FUNCTION_DIR}/awslambdaric-test.tar.gz
4443

4544
# Install the function's dependencies
4645
WORKDIR ${FUNCTION_DIR}
4746
RUN python${RUNTIME_VERSION} -m pip install \
48-
awslambdaric-test.tar.gz \
49-
--target ${FUNCTION_DIR} && \
50-
rm awslambdaric-test.tar.gz
47+
${RIC_BUILD_DIR}/dist/awslambdaric-test.tar.gz \
48+
--target ${FUNCTION_DIR}
5149

5250

5351
# Stage 3 - final runtime interface client image

‎tests/integration/docker/Dockerfile.echo.amazonlinux

+8-1
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ RUN yum install -y \
1717
freetype-devel \
1818
yum-utils \
1919
findutils \
20-
openssl-devel \
2120
wget \
21+
openssl11 \
22+
openssl11-devel \
23+
bzip2-devel \
2224
libffi-devel \
2325
sqlite-devel
2426

@@ -78,6 +80,11 @@ RUN mkdir -p ${RIC_BUILD_DIR}
7880
# Copy function code and Runtime Interface Client .tgz
7981
WORKDIR ${RIC_BUILD_DIR}
8082
COPY . .
83+
84+
# distutils no longer available in python3.12 and later
85+
# https://docs.python.org/3/whatsnew/3.12.html
86+
# https://peps.python.org/pep-0632/
87+
RUN if [ $(cut -d '.' -f 2 <<< ${RUNTIME_VERSION}) -ge 12 ]; then pip3 install setuptools; fi
8188
RUN make init build test && \
8289
mv ./dist/awslambdaric-*.tar.gz ./dist/awslambdaric-test.tar.gz
8390

‎tests/integration/docker/Dockerfile.echo.centos

-117
This file was deleted.

‎tests/integration/docker/Dockerfile.echo.ubuntu

+35-33
Original file line numberDiff line numberDiff line change
@@ -9,40 +9,41 @@ ENV DEBIAN_FRONTEND=noninteractive
99
ARG RUNTIME_VERSION
1010

1111
# Install python and pip
12-
RUN apt-get update && \
13-
apt-get install -y \
14-
software-properties-common
12+
RUN apt-get update && apt-get install -y software-properties-common
1513
RUN add-apt-repository ppa:deadsnakes/ppa
1614
RUN apt-get update && \
17-
apt-get install -y \
18-
curl \
19-
python${RUNTIME_VERSION} \
20-
python${RUNTIME_VERSION}-distutils
15+
apt-get install -y \
16+
curl \
17+
python${RUNTIME_VERSION} \
18+
python3-pip \
19+
python3-virtualenv
20+
21+
# python3xx-distutils is needed for python < 3.12
22+
RUN if [ $(echo ${RUNTIME_VERSION} | cut -d '.' -f 2) -lt 12 ]; then \
23+
apt-get install -y python${RUNTIME_VERSION}-distutils; \
24+
fi
25+
RUN virtualenv --python /usr/bin/python${RUNTIME_VERSION} --no-setuptools /home/venv
26+
2127

22-
RUN ln -s /usr/bin/python${RUNTIME_VERSION} /usr/local/bin/python3
2328

2429
# Stage 2 - build function and dependencies
2530
FROM python-image AS python-ubuntu-builder
2631

2732
ARG RUNTIME_VERSION
2833

29-
RUN curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
30-
RUN python${RUNTIME_VERSION} get-pip.py
31-
3234
# Install aws-lambda-cpp build dependencies
33-
RUN apt-get update && \
34-
apt-get install -y \
35-
g++ \
36-
gcc \
37-
tar \
38-
gzip \
39-
make \
40-
cmake \
41-
autoconf \
42-
automake \
43-
libtool \
44-
libcurl4-openssl-dev \
45-
python${RUNTIME_VERSION}-dev
35+
RUN apt-get install -y \
36+
g++ \
37+
gcc \
38+
tar \
39+
gzip \
40+
make \
41+
cmake \
42+
autoconf \
43+
automake \
44+
libtool \
45+
libcurl4-openssl-dev \
46+
python${RUNTIME_VERSION}-dev
4647

4748
# Include global args in this stage of the build
4849
ARG RIC_BUILD_DIR="/home/build/"
@@ -51,27 +52,28 @@ RUN mkdir -p ${RIC_BUILD_DIR}
5152
# Copy function code and Runtime Interface Client .tgz
5253
WORKDIR ${RIC_BUILD_DIR}
5354
COPY . .
54-
RUN make init build test && \
55+
RUN . /home/venv/bin/activate && \
56+
pip install setuptools && \
57+
make init build test && \
5558
mv ./dist/awslambdaric-*.tar.gz ./dist/awslambdaric-test.tar.gz
5659

60+
61+
5762
# Include global args in this stage of the build
5863
ARG FUNCTION_DIR="/home/app/"
5964
# Create function directory
6065
RUN mkdir -p ${FUNCTION_DIR}
6166
# Copy function code
6267
COPY tests/integration/test-handlers/echo/* ${FUNCTION_DIR}
63-
# Copy Runtime Interface Client .tgz
64-
RUN cp ./dist/awslambdaric-test.tar.gz ${FUNCTION_DIR}/awslambdaric-test.tar.gz
65-
6668
# Install the function's dependencies
6769
WORKDIR ${FUNCTION_DIR}
68-
RUN python${RUNTIME_VERSION} -m pip install \
69-
awslambdaric-test.tar.gz \
70-
--target ${FUNCTION_DIR} && \
71-
rm awslambdaric-test.tar.gz
70+
RUN . /home/venv/bin/activate && \
71+
pip install ${RIC_BUILD_DIR}/dist/awslambdaric-test.tar.gz --target ${FUNCTION_DIR}
72+
73+
7274

7375

74-
# Stage 4 - final runtime interface client image
76+
# Stage 3 - final runtime interface client image
7577
# Grab a fresh copy of the Python image
7678
FROM python-image
7779

0 commit comments

Comments
 (0)
Please sign in to comment.