From cb7817c98ac04eac09f45c7d1cf10cb8d7cf4786 Mon Sep 17 00:00:00 2001 From: Zsombor Balogh Date: Wed, 25 May 2022 16:34:52 +0100 Subject: [PATCH 1/3] Update distro and runtime versions in compatibility tests --- Makefile | 2 +- README.md | 6 +- .../codebuild-local/Dockerfile.agent | 2 +- .../codebuild/buildspec.os.alpine.3.yml | 7 +- .../codebuild/buildspec.os.amazonlinux.1.yml | 1 - .../codebuild/buildspec.os.amazonlinux.2.yml | 1 - .../codebuild/buildspec.os.centos.1.yml | 3 +- .../codebuild/buildspec.os.debian.yml | 2 +- .../codebuild/buildspec.os.ubuntu.1.yml | 110 ------------------ ...s.ubuntu.2.yml => buildspec.os.ubuntu.yml} | 4 +- .../integration/docker/Dockerfile.echo.alpine | 2 +- .../docker/Dockerfile.echo.amazonlinux | 4 +- .../integration/docker/Dockerfile.echo.centos | 4 +- .../integration/docker/Dockerfile.echo.debian | 6 +- .../integration/docker/Dockerfile.echo.ubuntu | 6 +- 15 files changed, 27 insertions(+), 133 deletions(-) delete mode 100644 tests/integration/codebuild/buildspec.os.ubuntu.1.yml rename tests/integration/codebuild/{buildspec.os.ubuntu.2.yml => buildspec.os.ubuntu.yml} (97%) diff --git a/Makefile b/Makefile index 27576e8..ab2ba46 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ setup-codebuild-agent: .PHONY: test-smoke test-smoke: setup-codebuild-agent - CODEBUILD_IMAGE_TAG=codebuild-agent tests/integration/codebuild-local/test_one.sh tests/integration/codebuild/buildspec.os.alpine.1.yml alpine 3.12 3.8 + CODEBUILD_IMAGE_TAG=codebuild-agent tests/integration/codebuild-local/test_one.sh tests/integration/codebuild/buildspec.os.alpine.yml alpine 3.15 3.9 .PHONY: test-integ test-integ: setup-codebuild-agent diff --git a/README.md b/README.md index 1a71488..b8d79d5 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ You can include this package in your preferred base image to make that base imag ## Requirements The Python Runtime Interface Client package currently supports Python versions: - - 3.6.x up to and including 3.9.x + - 3.7.x up to and including 3.9.x ## Usage @@ -58,7 +58,7 @@ Example Dockerfile (to keep the image light we use a multi-stage build): # Define custom function directory ARG FUNCTION_DIR="/function" -FROM python:buster as build-image +FROM public.ecr.aws/docker/library/python:buster as build-image # Include global arg in this stage of the build ARG FUNCTION_DIR @@ -82,7 +82,7 @@ RUN pip install \ awslambdaric -FROM python:buster +FROM public.ecr.aws/docker/library/python:buster # Include global arg in this stage of the build ARG FUNCTION_DIR diff --git a/tests/integration/codebuild-local/Dockerfile.agent b/tests/integration/codebuild-local/Dockerfile.agent index e9a9ffe..1016c0c 100644 --- a/tests/integration/codebuild-local/Dockerfile.agent +++ b/tests/integration/codebuild-local/Dockerfile.agent @@ -1,4 +1,4 @@ -FROM amazonlinux:2 +FROM public.ecr.aws/amazonlinux/amazonlinux:2 RUN amazon-linux-extras enable docker && \ yum clean metadata && \ diff --git a/tests/integration/codebuild/buildspec.os.alpine.3.yml b/tests/integration/codebuild/buildspec.os.alpine.3.yml index 0d8dab4..f938447 100644 --- a/tests/integration/codebuild/buildspec.os.alpine.3.yml +++ b/tests/integration/codebuild/buildspec.os.alpine.3.yml @@ -4,7 +4,7 @@ env: variables: OS_DISTRIBUTION: alpine PYTHON_LOCATION: "/usr/local/bin/python" - TEST_NAME: "aws-lambda-python-rtc-alpine-3-test" + TEST_NAME: "aws-lambda-python-rtc-alpine-test" batch: build-matrix: static: @@ -15,9 +15,10 @@ batch: env: variables: DISTRO_VERSION: - - "3.12" + - "3.13" + - "3.14" + - "3.15" RUNTIME_VERSION: - - "3.6" - "3.7" - "3.8" - "3.9" diff --git a/tests/integration/codebuild/buildspec.os.amazonlinux.1.yml b/tests/integration/codebuild/buildspec.os.amazonlinux.1.yml index 7b94572..a5cd1bc 100644 --- a/tests/integration/codebuild/buildspec.os.amazonlinux.1.yml +++ b/tests/integration/codebuild/buildspec.os.amazonlinux.1.yml @@ -17,7 +17,6 @@ batch: DISTRO_VERSION: - "1" RUNTIME_VERSION: - - "3.6" - "3.7" - "3.8" - "3.9" diff --git a/tests/integration/codebuild/buildspec.os.amazonlinux.2.yml b/tests/integration/codebuild/buildspec.os.amazonlinux.2.yml index 33c4761..4ce4b1f 100644 --- a/tests/integration/codebuild/buildspec.os.amazonlinux.2.yml +++ b/tests/integration/codebuild/buildspec.os.amazonlinux.2.yml @@ -17,7 +17,6 @@ batch: DISTRO_VERSION: - "2" RUNTIME_VERSION: - - "3.6" - "3.7" - "3.8" - "3.9" diff --git a/tests/integration/codebuild/buildspec.os.centos.1.yml b/tests/integration/codebuild/buildspec.os.centos.1.yml index c910cf7..900860e 100644 --- a/tests/integration/codebuild/buildspec.os.centos.1.yml +++ b/tests/integration/codebuild/buildspec.os.centos.1.yml @@ -4,7 +4,7 @@ env: variables: OS_DISTRIBUTION: centos PYTHON_LOCATION: "/usr/local/bin/python3" - TEST_NAME: "aws-lambda-python-rtc-centos-1-test" + TEST_NAME: "aws-lambda-python-rtc-centos-test" batch: build-matrix: static: @@ -17,7 +17,6 @@ batch: DISTRO_VERSION: - "7" RUNTIME_VERSION: - - "3.6" - "3.7" - "3.8" - "3.9" diff --git a/tests/integration/codebuild/buildspec.os.debian.yml b/tests/integration/codebuild/buildspec.os.debian.yml index 453bb34..a9187f5 100644 --- a/tests/integration/codebuild/buildspec.os.debian.yml +++ b/tests/integration/codebuild/buildspec.os.debian.yml @@ -16,8 +16,8 @@ batch: variables: DISTRO_VERSION: - "buster" + - "bullseye" RUNTIME_VERSION: - - "3.6" - "3.7" - "3.8" - "3.9" diff --git a/tests/integration/codebuild/buildspec.os.ubuntu.1.yml b/tests/integration/codebuild/buildspec.os.ubuntu.1.yml deleted file mode 100644 index 4ba7c29..0000000 --- a/tests/integration/codebuild/buildspec.os.ubuntu.1.yml +++ /dev/null @@ -1,110 +0,0 @@ -version: 0.2 - -env: - variables: - OS_DISTRIBUTION: ubuntu - PYTHON_LOCATION: "/usr/bin/python" - TEST_NAME: "aws-lambda-python-rtc-ubuntu-1-test" -batch: - build-matrix: - static: - ignore-failure: false - env: - privileged-mode: true - dynamic: - env: - variables: - DISTRO_VERSION: - - "18.04" - RUNTIME_VERSION: - - "3.6" - - "3.7" - - "3.8" -phases: - pre_build: - commands: - - export IMAGE_TAG="python-${OS_DISTRIBUTION}-${DISTRO_VERSION}:${RUNTIME_VERSION}" - - echo "Extracting and including the Runtime Interface Emulator" - - SCRATCH_DIR=".scratch" - - mkdir "${SCRATCH_DIR}" - - ARCHITECTURE=$(arch) - - > - if [[ "$ARCHITECTURE" == "x86_64" ]]; then - RIE="aws-lambda-rie" - elif [[ "$ARCHITECTURE" == "aarch64" ]]; then - RIE="aws-lambda-rie-arm64" - else - echo "Architecture $ARCHITECTURE is not currently supported." - exit 1 - fi - - tar -xvf tests/integration/resources/${RIE}.tar.gz --directory "${SCRATCH_DIR}" - - > - cp "tests/integration/docker/Dockerfile.echo.${OS_DISTRIBUTION}" \ - "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" - - > - echo "COPY ${SCRATCH_DIR}/${RIE} /usr/bin/${RIE}" >> \ - "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" - - > - if [[ -z "${DOCKERHUB_USERNAME}" && -z "${DOCKERHUB_PASSWORD}" ]]; - then - echo "DockerHub credentials not set as CodeBuild environment variables. Continuing without docker login." - else - echo "Performing DockerHub login . . ." - docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD - fi - - echo "Building image ${IMAGE_TAG}" - - > - docker build . \ - -f "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" \ - -t "${IMAGE_TAG}" \ - --build-arg RUNTIME_VERSION="${RUNTIME_VERSION}" \ - --build-arg DISTRO_VERSION="${DISTRO_VERSION}" - build: - commands: - - set -x - - echo "Running Image ${IMAGE_TAG}" - - docker network create "${TEST_NAME}-network" - - PYTHON_LOCATION=${PYTHON_LOCATION}${RUNTIME_VERSION} - - > - docker run \ - --detach \ - --name "${TEST_NAME}-app" \ - --network "${TEST_NAME}-network" \ - --entrypoint="" \ - "${IMAGE_TAG}" \ - sh -c "/usr/bin/${RIE} ${PYTHON_LOCATION} -m awslambdaric app.handler" - - sleep 2 - - > - docker run \ - --name "${TEST_NAME}-tester" \ - --env "TARGET=${TEST_NAME}-app" \ - --network "${TEST_NAME}-network" \ - --entrypoint="" \ - "${IMAGE_TAG}" \ - sh -c 'curl -X POST "http://${TARGET}:8080/2015-03-31/functions/function/invocations" -d "{}" --max-time 10' - - actual="$(docker logs --tail 1 "${TEST_NAME}-tester" | xargs)" - - expected='success' - - | - echo "Response: ${actual}" - if [[ "$actual" != "$expected" ]]; then - echo "fail! runtime: $RUNTIME - expected output $expected - got $actual" - exit -1 - fi - finally: - - | - echo "---------Container Logs: ${TEST_NAME}-app----------" - echo - docker logs "${TEST_NAME}-app" || true - echo - echo "---------------------------------------------------" - echo "--------Container Logs: ${TEST_NAME}-tester--------" - echo - docker logs "${TEST_NAME}-tester" || true - echo - echo "---------------------------------------------------" - - echo "Cleaning up..." - - docker stop "${TEST_NAME}-app" || true - - docker rm --force "${TEST_NAME}-app" || true - - docker stop "${TEST_NAME}-tester" || true - - docker rm --force "${TEST_NAME}-tester" || true - - docker network rm "${TEST_NAME}-network" || true \ No newline at end of file diff --git a/tests/integration/codebuild/buildspec.os.ubuntu.2.yml b/tests/integration/codebuild/buildspec.os.ubuntu.yml similarity index 97% rename from tests/integration/codebuild/buildspec.os.ubuntu.2.yml rename to tests/integration/codebuild/buildspec.os.ubuntu.yml index 4f3ab58..8a882a8 100644 --- a/tests/integration/codebuild/buildspec.os.ubuntu.2.yml +++ b/tests/integration/codebuild/buildspec.os.ubuntu.yml @@ -4,7 +4,7 @@ env: variables: OS_DISTRIBUTION: ubuntu PYTHON_LOCATION: "/usr/bin/python" - TEST_NAME: "aws-lambda-python-rtc-ubuntu-2-test" + TEST_NAME: "aws-lambda-python-rtc-ubuntu-test" batch: build-matrix: static: @@ -16,7 +16,9 @@ batch: variables: DISTRO_VERSION: - "20.04" + - "22.04" RUNTIME_VERSION: + - "3.7" - "3.8" - "3.9" phases: diff --git a/tests/integration/docker/Dockerfile.echo.alpine b/tests/integration/docker/Dockerfile.echo.alpine index d4f8ae1..9b239e4 100644 --- a/tests/integration/docker/Dockerfile.echo.alpine +++ b/tests/integration/docker/Dockerfile.echo.alpine @@ -4,7 +4,7 @@ ARG DISTRO_VERSION # Stage 1 - bundle base image + runtime interface client # Grab a fresh copy of the image and install GCC -FROM python:${RUNTIME_VERSION}-alpine${DISTRO_VERSION} AS python-alpine +FROM public.ecr.aws/docker/library/python:${RUNTIME_VERSION}-alpine${DISTRO_VERSION} AS python-alpine # Install libstdc++ RUN apk add --no-cache \ libstdc++ diff --git a/tests/integration/docker/Dockerfile.echo.amazonlinux b/tests/integration/docker/Dockerfile.echo.amazonlinux index 962c4e5..188de01 100644 --- a/tests/integration/docker/Dockerfile.echo.amazonlinux +++ b/tests/integration/docker/Dockerfile.echo.amazonlinux @@ -1,7 +1,7 @@ ARG DISTRO_VERSION # Stage 1 - bundle base image + runtime interface client # Grab a fresh copy of the image and install Python -FROM amazonlinux:${DISTRO_VERSION} AS python-amazonlinux-builder +FROM public.ecr.aws/amazonlinux/amazonlinux:${DISTRO_VERSION} AS python-amazonlinux-builder ARG RUNTIME_VERSION @@ -38,7 +38,7 @@ RUN RUNTIME_LATEST_VERSION=${RUNTIME_VERSION}.$(curl -s https://www.python.org/f && ln -s /usr/local/bin/python${RUNTIME_VERSION} /usr/local/bin/python${RUNTIME_LATEST_VERSION} # Stage 2 - clean python build dependencies -FROM amazonlinux:${DISTRO_VERSION} AS python-amazonlinux +FROM public.ecr.aws/amazonlinux/amazonlinux:${DISTRO_VERSION} AS python-amazonlinux RUN yum install -y \ libffi-devel diff --git a/tests/integration/docker/Dockerfile.echo.centos b/tests/integration/docker/Dockerfile.echo.centos index b686649..e2dd3d0 100644 --- a/tests/integration/docker/Dockerfile.echo.centos +++ b/tests/integration/docker/Dockerfile.echo.centos @@ -2,7 +2,7 @@ ARG DISTRO_VERSION # Stage 1 - bundle base image + runtime interface client # Grab a fresh copy of the image and install Python -FROM centos:${DISTRO_VERSION} AS python-centos-builder +FROM public.ecr.aws/docker/library/centos:${DISTRO_VERSION} AS python-centos-builder ARG RUNTIME_VERSION @@ -39,7 +39,7 @@ RUN RUNTIME_LATEST_VERSION=${RUNTIME_VERSION}.$(curl -s https://www.python.org/f && ln -s /usr/local/bin/python${RUNTIME_VERSION} /usr/local/bin/python${RUNTIME_LATEST_VERSION} # Stage 2 - clean python build dependencies -FROM centos:${DISTRO_VERSION} AS python-centos +FROM public.ecr.aws/docker/library/centos:${DISTRO_VERSION} AS python-centos RUN yum install -y \ libffi-devel diff --git a/tests/integration/docker/Dockerfile.echo.debian b/tests/integration/docker/Dockerfile.echo.debian index 8842792..8ac660b 100644 --- a/tests/integration/docker/Dockerfile.echo.debian +++ b/tests/integration/docker/Dockerfile.echo.debian @@ -2,7 +2,7 @@ ARG RUNTIME_VERSION ARG DISTRO_VERSION # Stage 1 - build function and dependencies -FROM python:${RUNTIME_VERSION}-${DISTRO_VERSION} AS python-debian-builder +FROM public.ecr.aws/docker/library/python:${RUNTIME_VERSION}-${DISTRO_VERSION} AS python-debian-builder # Install aws-lambda-cpp build dependencies RUN apt-get update && \ @@ -40,8 +40,8 @@ RUN pip install \ # Stage 2 - final runtime interface client image -# Grab a fresh slim copy of the Node image -FROM python:${RUNTIME_VERSION}-slim-${DISTRO_VERSION} +# Grab a fresh slim copy of the Python image +FROM public.ecr.aws/docker/library/python:${RUNTIME_VERSION}-slim-${DISTRO_VERSION} # Include global arg in this stage of the build ARG FUNCTION_DIR="/home/app/" diff --git a/tests/integration/docker/Dockerfile.echo.ubuntu b/tests/integration/docker/Dockerfile.echo.ubuntu index 83e4a6e..692b3f2 100644 --- a/tests/integration/docker/Dockerfile.echo.ubuntu +++ b/tests/integration/docker/Dockerfile.echo.ubuntu @@ -2,13 +2,17 @@ ARG DISTRO_VERSION # Stage 1 - bundle base image + runtime interface client # Grab a fresh copy of the image and install Python -FROM ubuntu:${DISTRO_VERSION} AS python-image +FROM public.ecr.aws/ubuntu/ubuntu:${DISTRO_VERSION} AS python-image ENV DEBIAN_FRONTEND=noninteractive ARG RUNTIME_VERSION # Install python and pip +RUN apt-get update && \ + apt-get install -y \ + software-properties-common +RUN add-apt-repository ppa:deadsnakes/ppa RUN apt-get update && \ apt-get install -y \ curl \ From 15efe4e9ecc04895de9c6c4573f3d225b7089bf9 Mon Sep 17 00:00:00 2001 From: Zsombor Balogh Date: Wed, 25 May 2022 16:51:59 +0100 Subject: [PATCH 2/3] Clean up obsolete alpine buildspec files --- .../codebuild/buildspec.os.alpine.1.yml | 111 ----------------- .../codebuild/buildspec.os.alpine.2.yml | 113 ------------------ ...s.alpine.3.yml => buildspec.os.alpine.yml} | 0 3 files changed, 224 deletions(-) delete mode 100644 tests/integration/codebuild/buildspec.os.alpine.1.yml delete mode 100644 tests/integration/codebuild/buildspec.os.alpine.2.yml rename tests/integration/codebuild/{buildspec.os.alpine.3.yml => buildspec.os.alpine.yml} (100%) diff --git a/tests/integration/codebuild/buildspec.os.alpine.1.yml b/tests/integration/codebuild/buildspec.os.alpine.1.yml deleted file mode 100644 index 3192257..0000000 --- a/tests/integration/codebuild/buildspec.os.alpine.1.yml +++ /dev/null @@ -1,111 +0,0 @@ -version: 0.2 - -env: - variables: - OS_DISTRIBUTION: alpine - PYTHON_LOCATION: "/usr/local/bin/python" - TEST_NAME: "aws-lambda-python-rtc-alpine-1-test" -batch: - build-matrix: - static: - ignore-failure: false - env: - privileged-mode: true - dynamic: - env: - variables: - DISTRO_VERSION: - - "3.9" - RUNTIME_VERSION: - - "3.6" - - "3.7" -phases: - pre_build: - commands: - - export IMAGE_TAG="python-${OS_DISTRIBUTION}-${DISTRO_VERSION}:${RUNTIME_VERSION}" - - echo "Extracting and including the Runtime Interface Emulator" - - SCRATCH_DIR=".scratch" - - mkdir "${SCRATCH_DIR}" - - ARCHITECTURE=$(arch) - - > - if [[ "$ARCHITECTURE" == "x86_64" ]]; then - RIE="aws-lambda-rie" - elif [[ "$ARCHITECTURE" == "aarch64" ]]; then - RIE="aws-lambda-rie-arm64" - else - echo "Architecture $ARCHITECTURE is not currently supported." - exit 1 - fi - - tar -xvf tests/integration/resources/${RIE}.tar.gz --directory "${SCRATCH_DIR}" - - > - cp "tests/integration/docker/Dockerfile.echo.${OS_DISTRIBUTION}" \ - "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" - - > - echo "RUN apk add curl" >> \ - "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" - - > - echo "COPY ${SCRATCH_DIR}/${RIE} /usr/bin/${RIE}" >> \ - "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" - - > - if [[ -z "${DOCKERHUB_USERNAME}" && -z "${DOCKERHUB_PASSWORD}" ]]; - then - echo "DockerHub credentials not set as CodeBuild environment variables. Continuing without docker login." - else - echo "Performing DockerHub login . . ." - docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD - fi - - echo "Building image ${IMAGE_TAG}" - - > - docker build . \ - -f "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" \ - -t "${IMAGE_TAG}" \ - --build-arg RUNTIME_VERSION="${RUNTIME_VERSION}" \ - --build-arg DISTRO_VERSION="${DISTRO_VERSION}" - build: - commands: - - set -x - - echo "Running Image ${IMAGE_TAG}" - - docker network create "${TEST_NAME}-network" - - > - docker run \ - --detach \ - --name "${TEST_NAME}-app" \ - --network "${TEST_NAME}-network" \ - --entrypoint="" \ - "${IMAGE_TAG}" \ - sh -c "/usr/bin/${RIE} ${PYTHON_LOCATION} -m awslambdaric app.handler" - - sleep 2 - - > - docker run \ - --name "${TEST_NAME}-tester" \ - --env "TARGET=${TEST_NAME}-app" \ - --network "${TEST_NAME}-network" \ - --entrypoint="" \ - "${IMAGE_TAG}" \ - sh -c 'curl -X POST "http://${TARGET}:8080/2015-03-31/functions/function/invocations" -d "{}" --max-time 10' - - actual="$(docker logs --tail 1 "${TEST_NAME}-tester" | xargs)" - - expected='success' - - | - echo "Response: ${actual}" - if [[ "$actual" != "$expected" ]]; then - echo "fail! runtime: $RUNTIME - expected output $expected - got $actual" - exit -1 - fi - finally: - - | - echo "---------Container Logs: ${TEST_NAME}-app----------" - echo - docker logs "${TEST_NAME}-app" || true - echo - echo "---------------------------------------------------" - echo "--------Container Logs: ${TEST_NAME}-tester--------" - echo - docker logs "${TEST_NAME}-tester" || true - echo - echo "---------------------------------------------------" - - echo "Cleaning up..." - - docker stop "${TEST_NAME}-app" || true - - docker rm --force "${TEST_NAME}-app" || true - - docker stop "${TEST_NAME}-tester" || true - - docker rm --force "${TEST_NAME}-tester" || true - - docker network rm "${TEST_NAME}-network" || true \ No newline at end of file diff --git a/tests/integration/codebuild/buildspec.os.alpine.2.yml b/tests/integration/codebuild/buildspec.os.alpine.2.yml deleted file mode 100644 index c5950e3..0000000 --- a/tests/integration/codebuild/buildspec.os.alpine.2.yml +++ /dev/null @@ -1,113 +0,0 @@ -version: 0.2 - -env: - variables: - OS_DISTRIBUTION: alpine - PYTHON_LOCATION: "/usr/local/bin/python" - TEST_NAME: "aws-lambda-python-rtc-alpine-2-test" -batch: - build-matrix: - static: - ignore-failure: false - env: - privileged-mode: true - dynamic: - env: - variables: - DISTRO_VERSION: - - "3.10" - - "3.11" - RUNTIME_VERSION: - - "3.6" - - "3.7" - - "3.8" -phases: - pre_build: - commands: - - export IMAGE_TAG="python-${OS_DISTRIBUTION}-${DISTRO_VERSION}:${RUNTIME_VERSION}" - - echo "Extracting and including the Runtime Interface Emulator" - - SCRATCH_DIR=".scratch" - - mkdir "${SCRATCH_DIR}" - - ARCHITECTURE=$(arch) - - > - if [[ "$ARCHITECTURE" == "x86_64" ]]; then - RIE="aws-lambda-rie" - elif [[ "$ARCHITECTURE" == "aarch64" ]]; then - RIE="aws-lambda-rie-arm64" - else - echo "Architecture $ARCHITECTURE is not currently supported." - exit 1 - fi - - tar -xvf tests/integration/resources/${RIE}.tar.gz --directory "${SCRATCH_DIR}" - - > - cp "tests/integration/docker/Dockerfile.echo.${OS_DISTRIBUTION}" \ - "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" - - > - echo "RUN apk add curl" >> \ - "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" - - > - echo "COPY ${SCRATCH_DIR}/${RIE} /usr/bin/${RIE}" >> \ - "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" - - > - if [[ -z "${DOCKERHUB_USERNAME}" && -z "${DOCKERHUB_PASSWORD}" ]]; - then - echo "DockerHub credentials not set as CodeBuild environment variables. Continuing without docker login." - else - echo "Performing DockerHub login . . ." - docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD - fi - - echo "Building image ${IMAGE_TAG}" - - > - docker build . \ - -f "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" \ - -t "${IMAGE_TAG}" \ - --build-arg RUNTIME_VERSION="${RUNTIME_VERSION}" \ - --build-arg DISTRO_VERSION="${DISTRO_VERSION}" - build: - commands: - - set -x - - echo "Running Image ${IMAGE_TAG}" - - docker network create "${TEST_NAME}-network" - - > - docker run \ - --detach \ - --name "${TEST_NAME}-app" \ - --network "${TEST_NAME}-network" \ - --entrypoint="" \ - "${IMAGE_TAG}" \ - sh -c "/usr/bin/${RIE} ${PYTHON_LOCATION} -m awslambdaric app.handler" - - sleep 2 - - > - docker run \ - --name "${TEST_NAME}-tester" \ - --env "TARGET=${TEST_NAME}-app" \ - --network "${TEST_NAME}-network" \ - --entrypoint="" \ - "${IMAGE_TAG}" \ - sh -c 'curl -X POST "http://${TARGET}:8080/2015-03-31/functions/function/invocations" -d "{}" --max-time 10' - - actual="$(docker logs --tail 1 "${TEST_NAME}-tester" | xargs)" - - expected='success' - - | - echo "Response: ${actual}" - if [[ "$actual" != "$expected" ]]; then - echo "fail! runtime: $RUNTIME - expected output $expected - got $actual" - exit -1 - fi - finally: - - | - echo "---------Container Logs: ${TEST_NAME}-app----------" - echo - docker logs "${TEST_NAME}-app" || true - echo - echo "---------------------------------------------------" - echo "--------Container Logs: ${TEST_NAME}-tester--------" - echo - docker logs "${TEST_NAME}-tester" || true - echo - echo "---------------------------------------------------" - - echo "Cleaning up..." - - docker stop "${TEST_NAME}-app" || true - - docker rm --force "${TEST_NAME}-app" || true - - docker stop "${TEST_NAME}-tester" || true - - docker rm --force "${TEST_NAME}-tester" || true - - docker network rm "${TEST_NAME}-network" || true diff --git a/tests/integration/codebuild/buildspec.os.alpine.3.yml b/tests/integration/codebuild/buildspec.os.alpine.yml similarity index 100% rename from tests/integration/codebuild/buildspec.os.alpine.3.yml rename to tests/integration/codebuild/buildspec.os.alpine.yml From 0da3a57d19297dcce29f5bbe5a30f98a324260d9 Mon Sep 17 00:00:00 2001 From: Zsombor Balogh Date: Wed, 25 May 2022 16:52:56 +0100 Subject: [PATCH 3/3] Clean up obsolete centos buildspec file --- .../codebuild/buildspec.os.centos.2.yml | 111 ------------------ ...s.centos.1.yml => buildspec.os.centos.yml} | 0 2 files changed, 111 deletions(-) delete mode 100644 tests/integration/codebuild/buildspec.os.centos.2.yml rename tests/integration/codebuild/{buildspec.os.centos.1.yml => buildspec.os.centos.yml} (100%) diff --git a/tests/integration/codebuild/buildspec.os.centos.2.yml b/tests/integration/codebuild/buildspec.os.centos.2.yml deleted file mode 100644 index 45589d7..0000000 --- a/tests/integration/codebuild/buildspec.os.centos.2.yml +++ /dev/null @@ -1,111 +0,0 @@ -version: 0.2 - -env: - variables: - OS_DISTRIBUTION: centos - PYTHON_LOCATION: "/usr/local/bin/python3" - TEST_NAME: "aws-lambda-python-rtc-centos-2-test" -batch: - build-matrix: - static: - ignore-failure: false - env: - privileged-mode: true - dynamic: - env: - variables: - DISTRO_VERSION: - - "8" - RUNTIME_VERSION: - - "3.6" - - "3.7" - - "3.8" - - "3.9" -phases: - pre_build: - commands: - - export IMAGE_TAG="python-${OS_DISTRIBUTION}-${DISTRO_VERSION}:${RUNTIME_VERSION}" - - echo "Extracting and including the Runtime Interface Emulator" - - SCRATCH_DIR=".scratch" - - mkdir "${SCRATCH_DIR}" - - ARCHITECTURE=$(arch) - - > - if [[ "$ARCHITECTURE" == "x86_64" ]]; then - RIE="aws-lambda-rie" - elif [[ "$ARCHITECTURE" == "aarch64" ]]; then - RIE="aws-lambda-rie-arm64" - else - echo "Architecture $ARCHITECTURE is not currently supported." - exit 1 - fi - - tar -xvf tests/integration/resources/${RIE}.tar.gz --directory "${SCRATCH_DIR}" - - > - cp "tests/integration/docker/Dockerfile.echo.${OS_DISTRIBUTION}" \ - "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" - - > - echo "COPY ${SCRATCH_DIR}/${RIE} /usr/bin/${RIE}" >> \ - "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" - - > - if [[ -z "${DOCKERHUB_USERNAME}" && -z "${DOCKERHUB_PASSWORD}" ]]; - then - echo "DockerHub credentials not set as CodeBuild environment variables. Continuing without docker login." - else - echo "Performing DockerHub login . . ." - docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD - fi - - echo "Building image ${IMAGE_TAG}" - - > - docker build . \ - -f "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" \ - -t "${IMAGE_TAG}" \ - --build-arg RUNTIME_VERSION="${RUNTIME_VERSION}" \ - --build-arg DISTRO_VERSION="${DISTRO_VERSION}" \ - --build-arg ARCHITECTURE="${ARCHITECTURE}" - build: - commands: - - set -x - - echo "Running Image ${IMAGE_TAG}" - - docker network create "${TEST_NAME}-network" - - > - docker run \ - --detach \ - --name "${TEST_NAME}-app" \ - --network "${TEST_NAME}-network" \ - --entrypoint="" \ - "${IMAGE_TAG}" \ - sh -c "/usr/bin/${RIE} ${PYTHON_LOCATION} -m awslambdaric app.handler" - - sleep 2 - - > - docker run \ - --name "${TEST_NAME}-tester" \ - --env "TARGET=${TEST_NAME}-app" \ - --network "${TEST_NAME}-network" \ - --entrypoint="" \ - "${IMAGE_TAG}" \ - sh -c 'curl -X POST "http://${TARGET}:8080/2015-03-31/functions/function/invocations" -d "{}" --max-time 10' - - actual="$(docker logs --tail 1 "${TEST_NAME}-tester" | xargs)" - - expected='success' - - | - echo "Response: ${actual}" - if [[ "$actual" != "$expected" ]]; then - echo "fail! runtime: $RUNTIME - expected output $expected - got $actual" - exit -1 - fi - finally: - - | - echo "---------Container Logs: ${TEST_NAME}-app----------" - echo - docker logs "${TEST_NAME}-app" || true - echo - echo "---------------------------------------------------" - echo "--------Container Logs: ${TEST_NAME}-tester--------" - echo - docker logs "${TEST_NAME}-tester" || true - echo - echo "---------------------------------------------------" - - echo "Cleaning up..." - - docker stop "${TEST_NAME}-app" || true - - docker rm --force "${TEST_NAME}-app" || true - - docker stop "${TEST_NAME}-tester" || true - - docker rm --force "${TEST_NAME}-tester" || true - - docker network rm "${TEST_NAME}-network" || true \ No newline at end of file diff --git a/tests/integration/codebuild/buildspec.os.centos.1.yml b/tests/integration/codebuild/buildspec.os.centos.yml similarity index 100% rename from tests/integration/codebuild/buildspec.os.centos.1.yml rename to tests/integration/codebuild/buildspec.os.centos.yml