diff --git a/README.md b/README.md index 63cbcb5..1a71488 100644 --- a/README.md +++ b/README.md @@ -175,4 +175,4 @@ If you discover a potential security issue in this project we ask that you notif ## License -This project is licensed under the Apache-2.0 License. +This project is licensed under the Apache-2.0 License. \ No newline at end of file diff --git a/awslambdaric/__init__.py b/awslambdaric/__init__.py index 0d6494a..fd6d8bf 100644 --- a/awslambdaric/__init__.py +++ b/awslambdaric/__init__.py @@ -2,4 +2,4 @@ Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. """ -__version__ = "1.2.2" +__version__ = "2.0.0" diff --git a/scripts/preinstall.sh b/scripts/preinstall.sh index 5db0c46..6cf8ff5 100755 --- a/scripts/preinstall.sh +++ b/scripts/preinstall.sh @@ -34,6 +34,7 @@ else --prefix "$ARTIFACTS_DIR" \ --disable-shared \ --without-ssl \ + --with-pic \ --without-zlib && \ make && \ make install diff --git a/tests/integration/codebuild/buildspec.os.alpine.1.yml b/tests/integration/codebuild/buildspec.os.alpine.1.yml index bea310e..3192257 100644 --- a/tests/integration/codebuild/buildspec.os.alpine.1.yml +++ b/tests/integration/codebuild/buildspec.os.alpine.1.yml @@ -10,7 +10,6 @@ batch: static: ignore-failure: false env: - type: LINUX_CONTAINER privileged-mode: true dynamic: env: @@ -27,7 +26,17 @@ phases: - echo "Extracting and including the Runtime Interface Emulator" - SCRATCH_DIR=".scratch" - mkdir "${SCRATCH_DIR}" - - tar -xvf tests/integration/resources/aws-lambda-rie.tar.gz --directory "${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" @@ -35,7 +44,7 @@ phases: echo "RUN apk add curl" >> \ "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" - > - echo "COPY ${SCRATCH_DIR}/aws-lambda-rie /usr/bin/aws-lambda-rie" >> \ + echo "COPY ${SCRATCH_DIR}/${RIE} /usr/bin/${RIE}" >> \ "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" - > if [[ -z "${DOCKERHUB_USERNAME}" && -z "${DOCKERHUB_PASSWORD}" ]]; @@ -60,12 +69,11 @@ phases: - > docker run \ --detach \ - -e "PYTHON_LOCATION=${PYTHON_LOCATION}" \ --name "${TEST_NAME}-app" \ --network "${TEST_NAME}-network" \ --entrypoint="" \ "${IMAGE_TAG}" \ - sh -c '/usr/bin/aws-lambda-rie ${PYTHON_LOCATION} -m awslambdaric app.handler' + sh -c "/usr/bin/${RIE} ${PYTHON_LOCATION} -m awslambdaric app.handler" - sleep 2 - > docker run \ @@ -81,19 +89,20 @@ phases: echo "Response: ${actual}" if [[ "$actual" != "$expected" ]]; then echo "fail! runtime: $RUNTIME - expected output $expected - got $actual" - echo "---------Container Logs: ${TEST_NAME}-app----------" - echo - docker logs "${TEST_NAME}-app" - echo - echo "---------------------------------------------------" - echo "--------Container Logs: ${TEST_NAME}-tester--------" - echo - docker logs "${TEST_NAME}-tester" - echo - echo "---------------------------------------------------" 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 diff --git a/tests/integration/codebuild/buildspec.os.alpine.2.yml b/tests/integration/codebuild/buildspec.os.alpine.2.yml index 0222c98..c5950e3 100644 --- a/tests/integration/codebuild/buildspec.os.alpine.2.yml +++ b/tests/integration/codebuild/buildspec.os.alpine.2.yml @@ -10,7 +10,6 @@ batch: static: ignore-failure: false env: - type: LINUX_CONTAINER privileged-mode: true dynamic: env: @@ -29,7 +28,17 @@ phases: - echo "Extracting and including the Runtime Interface Emulator" - SCRATCH_DIR=".scratch" - mkdir "${SCRATCH_DIR}" - - tar -xvf tests/integration/resources/aws-lambda-rie.tar.gz --directory "${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" @@ -37,7 +46,7 @@ phases: echo "RUN apk add curl" >> \ "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" - > - echo "COPY ${SCRATCH_DIR}/aws-lambda-rie /usr/bin/aws-lambda-rie" >> \ + echo "COPY ${SCRATCH_DIR}/${RIE} /usr/bin/${RIE}" >> \ "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" - > if [[ -z "${DOCKERHUB_USERNAME}" && -z "${DOCKERHUB_PASSWORD}" ]]; @@ -62,12 +71,11 @@ phases: - > docker run \ --detach \ - -e "PYTHON_LOCATION=${PYTHON_LOCATION}" \ --name "${TEST_NAME}-app" \ --network "${TEST_NAME}-network" \ --entrypoint="" \ "${IMAGE_TAG}" \ - sh -c '/usr/bin/aws-lambda-rie ${PYTHON_LOCATION} -m awslambdaric app.handler' + sh -c "/usr/bin/${RIE} ${PYTHON_LOCATION} -m awslambdaric app.handler" - sleep 2 - > docker run \ @@ -83,19 +91,20 @@ phases: echo "Response: ${actual}" if [[ "$actual" != "$expected" ]]; then echo "fail! runtime: $RUNTIME - expected output $expected - got $actual" - echo "---------Container Logs: ${TEST_NAME}-app----------" - echo - docker logs "${TEST_NAME}-app" - echo - echo "---------------------------------------------------" - echo "--------Container Logs: ${TEST_NAME}-tester--------" - echo - docker logs "${TEST_NAME}-tester" - echo - echo "---------------------------------------------------" 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 diff --git a/tests/integration/codebuild/buildspec.os.alpine.3.yml b/tests/integration/codebuild/buildspec.os.alpine.3.yml index bcb64ce..0d8dab4 100644 --- a/tests/integration/codebuild/buildspec.os.alpine.3.yml +++ b/tests/integration/codebuild/buildspec.os.alpine.3.yml @@ -10,7 +10,6 @@ batch: static: ignore-failure: false env: - type: LINUX_CONTAINER privileged-mode: true dynamic: env: @@ -29,7 +28,17 @@ phases: - echo "Extracting and including the Runtime Interface Emulator" - SCRATCH_DIR=".scratch" - mkdir "${SCRATCH_DIR}" - - tar -xvf tests/integration/resources/aws-lambda-rie.tar.gz --directory "${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" @@ -37,7 +46,7 @@ phases: echo "RUN apk add curl" >> \ "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" - > - echo "COPY ${SCRATCH_DIR}/aws-lambda-rie /usr/bin/aws-lambda-rie" >> \ + echo "COPY ${SCRATCH_DIR}/${RIE} /usr/bin/${RIE}" >> \ "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" - > if [[ -z "${DOCKERHUB_USERNAME}" && -z "${DOCKERHUB_PASSWORD}" ]]; @@ -62,12 +71,11 @@ phases: - > docker run \ --detach \ - -e "PYTHON_LOCATION=${PYTHON_LOCATION}" \ --name "${TEST_NAME}-app" \ --network "${TEST_NAME}-network" \ --entrypoint="" \ "${IMAGE_TAG}" \ - sh -c '/usr/bin/aws-lambda-rie ${PYTHON_LOCATION} -m awslambdaric app.handler' + sh -c "/usr/bin/${RIE} ${PYTHON_LOCATION} -m awslambdaric app.handler" - sleep 2 - > docker run \ @@ -83,19 +91,20 @@ phases: echo "Response: ${actual}" if [[ "$actual" != "$expected" ]]; then echo "fail! runtime: $RUNTIME - expected output $expected - got $actual" - echo "---------Container Logs: ${TEST_NAME}-app----------" - echo - docker logs "${TEST_NAME}-app" - echo - echo "---------------------------------------------------" - echo "--------Container Logs: ${TEST_NAME}-tester--------" - echo - docker logs "${TEST_NAME}-tester" - echo - echo "---------------------------------------------------" 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 diff --git a/tests/integration/codebuild/buildspec.os.amazonlinux.yml b/tests/integration/codebuild/buildspec.os.amazonlinux.1.yml similarity index 93% rename from tests/integration/codebuild/buildspec.os.amazonlinux.yml rename to tests/integration/codebuild/buildspec.os.amazonlinux.1.yml index a8e9f4c..7b94572 100644 --- a/tests/integration/codebuild/buildspec.os.amazonlinux.yml +++ b/tests/integration/codebuild/buildspec.os.amazonlinux.1.yml @@ -10,14 +10,12 @@ batch: static: ignore-failure: false env: - type: LINUX_CONTAINER privileged-mode: true dynamic: env: variables: DISTRO_VERSION: - "1" - - "2" RUNTIME_VERSION: - "3.6" - "3.7" @@ -30,6 +28,7 @@ phases: - echo "Extracting and including the Runtime Interface Emulator" - SCRATCH_DIR=".scratch" - mkdir "${SCRATCH_DIR}" + - ARCHITECTURE=$(arch) - tar -xvf tests/integration/resources/aws-lambda-rie.tar.gz --directory "${SCRATCH_DIR}" - > cp "tests/integration/docker/Dockerfile.echo.${OS_DISTRIBUTION}" \ @@ -51,7 +50,8 @@ phases: -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 DISTRO_VERSION="${DISTRO_VERSION}" \ + --build-arg ARCHITECTURE="${ARCHITECTURE}" build: commands: - set -x @@ -83,12 +83,12 @@ phases: echo "fail! runtime: $RUNTIME - expected output $expected - got $actual" echo "---------Container Logs: ${TEST_NAME}-app----------" echo - docker logs "${TEST_NAME}-app" + docker logs "${TEST_NAME}-app" || true echo echo "---------------------------------------------------" echo "--------Container Logs: ${TEST_NAME}-tester--------" echo - docker logs "${TEST_NAME}-tester" + docker logs "${TEST_NAME}-tester" || true echo echo "---------------------------------------------------" exit -1 diff --git a/tests/integration/codebuild/buildspec.os.amazonlinux.2.yml b/tests/integration/codebuild/buildspec.os.amazonlinux.2.yml new file mode 100644 index 0000000..33c4761 --- /dev/null +++ b/tests/integration/codebuild/buildspec.os.amazonlinux.2.yml @@ -0,0 +1,111 @@ +version: 0.2 + +env: + variables: + OS_DISTRIBUTION: amazonlinux + PYTHON_LOCATION: "/usr/local/bin/python3" + TEST_NAME: "aws-lambda-python-rtc-amazonlinux-test" +batch: + build-matrix: + static: + ignore-failure: false + env: + privileged-mode: true + dynamic: + env: + variables: + DISTRO_VERSION: + - "2" + 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.1.yml index 48760d6..c910cf7 100644 --- a/tests/integration/codebuild/buildspec.os.centos.1.yml +++ b/tests/integration/codebuild/buildspec.os.centos.1.yml @@ -10,7 +10,6 @@ batch: static: ignore-failure: false env: - type: LINUX_CONTAINER privileged-mode: true dynamic: env: @@ -29,12 +28,22 @@ phases: - echo "Extracting and including the Runtime Interface Emulator" - SCRATCH_DIR=".scratch" - mkdir "${SCRATCH_DIR}" - - tar -xvf tests/integration/resources/aws-lambda-rie.tar.gz --directory "${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}/aws-lambda-rie /usr/bin/aws-lambda-rie" >> \ + echo "COPY ${SCRATCH_DIR}/${RIE} /usr/bin/${RIE}" >> \ "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" - > if [[ -z "${DOCKERHUB_USERNAME}" && -z "${DOCKERHUB_PASSWORD}" ]]; @@ -50,7 +59,8 @@ phases: -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 DISTRO_VERSION="${DISTRO_VERSION}" \ + --build-arg ARCHITECTURE="${ARCHITECTURE}" build: commands: - set -x @@ -59,12 +69,11 @@ phases: - > docker run \ --detach \ - -e "PYTHON_LOCATION=${PYTHON_LOCATION}" \ --name "${TEST_NAME}-app" \ --network "${TEST_NAME}-network" \ --entrypoint="" \ "${IMAGE_TAG}" \ - sh -c '/usr/bin/aws-lambda-rie ${PYTHON_LOCATION} -m awslambdaric app.handler' + sh -c "/usr/bin/${RIE} ${PYTHON_LOCATION} -m awslambdaric app.handler" - sleep 2 - > docker run \ @@ -80,19 +89,20 @@ phases: echo "Response: ${actual}" if [[ "$actual" != "$expected" ]]; then echo "fail! runtime: $RUNTIME - expected output $expected - got $actual" - echo "---------Container Logs: ${TEST_NAME}-app----------" - echo - docker logs "${TEST_NAME}-app" - echo - echo "---------------------------------------------------" - echo "--------Container Logs: ${TEST_NAME}-tester--------" - echo - docker logs "${TEST_NAME}-tester" - echo - echo "---------------------------------------------------" 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 diff --git a/tests/integration/codebuild/buildspec.os.centos.2.yml b/tests/integration/codebuild/buildspec.os.centos.2.yml index a09bf70..45589d7 100644 --- a/tests/integration/codebuild/buildspec.os.centos.2.yml +++ b/tests/integration/codebuild/buildspec.os.centos.2.yml @@ -10,7 +10,6 @@ batch: static: ignore-failure: false env: - type: LINUX_CONTAINER privileged-mode: true dynamic: env: @@ -29,12 +28,22 @@ phases: - echo "Extracting and including the Runtime Interface Emulator" - SCRATCH_DIR=".scratch" - mkdir "${SCRATCH_DIR}" - - tar -xvf tests/integration/resources/aws-lambda-rie.tar.gz --directory "${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}/aws-lambda-rie /usr/bin/aws-lambda-rie" >> \ + echo "COPY ${SCRATCH_DIR}/${RIE} /usr/bin/${RIE}" >> \ "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" - > if [[ -z "${DOCKERHUB_USERNAME}" && -z "${DOCKERHUB_PASSWORD}" ]]; @@ -50,7 +59,8 @@ phases: -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 DISTRO_VERSION="${DISTRO_VERSION}" \ + --build-arg ARCHITECTURE="${ARCHITECTURE}" build: commands: - set -x @@ -59,12 +69,11 @@ phases: - > docker run \ --detach \ - -e "PYTHON_LOCATION=${PYTHON_LOCATION}" \ --name "${TEST_NAME}-app" \ --network "${TEST_NAME}-network" \ --entrypoint="" \ "${IMAGE_TAG}" \ - sh -c '/usr/bin/aws-lambda-rie ${PYTHON_LOCATION} -m awslambdaric app.handler' + sh -c "/usr/bin/${RIE} ${PYTHON_LOCATION} -m awslambdaric app.handler" - sleep 2 - > docker run \ @@ -80,19 +89,20 @@ phases: echo "Response: ${actual}" if [[ "$actual" != "$expected" ]]; then echo "fail! runtime: $RUNTIME - expected output $expected - got $actual" - echo "---------Container Logs: ${TEST_NAME}-app----------" - echo - docker logs "${TEST_NAME}-app" - echo - echo "---------------------------------------------------" - echo "--------Container Logs: ${TEST_NAME}-tester--------" - echo - docker logs "${TEST_NAME}-tester" - echo - echo "---------------------------------------------------" 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 diff --git a/tests/integration/codebuild/buildspec.os.debian.yml b/tests/integration/codebuild/buildspec.os.debian.yml index 227e994..453bb34 100644 --- a/tests/integration/codebuild/buildspec.os.debian.yml +++ b/tests/integration/codebuild/buildspec.os.debian.yml @@ -10,7 +10,6 @@ batch: static: ignore-failure: false env: - type: LINUX_CONTAINER privileged-mode: true dynamic: env: @@ -29,12 +28,25 @@ phases: - echo "Extracting and including the Runtime Interface Emulator" - SCRATCH_DIR=".scratch" - mkdir "${SCRATCH_DIR}" - - tar -xvf tests/integration/resources/aws-lambda-rie.tar.gz --directory "${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}/aws-lambda-rie /usr/bin/aws-lambda-rie" >> \ + echo "COPY ${SCRATCH_DIR}/${RIE} /usr/bin/${RIE}" >> \ + "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" + - > + echo "RUN apt-get update && apt-get install -y curl" >> \ "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" - > if [[ -z "${DOCKERHUB_USERNAME}" && -z "${DOCKERHUB_PASSWORD}" ]]; @@ -44,9 +56,6 @@ phases: echo "Performing DockerHub login . . ." docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD fi - - > - echo "RUN apt-get update && apt-get install -y curl" >> \ - "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" - echo "Building image ${IMAGE_TAG}" - > docker build . \ @@ -62,12 +71,11 @@ phases: - > docker run \ --detach \ - -e "PYTHON_LOCATION=${PYTHON_LOCATION}" \ --name "${TEST_NAME}-app" \ --network "${TEST_NAME}-network" \ --entrypoint="" \ "${IMAGE_TAG}" \ - sh -c '/usr/bin/aws-lambda-rie ${PYTHON_LOCATION} -m awslambdaric app.handler' + sh -c "/usr/bin/${RIE} ${PYTHON_LOCATION} -m awslambdaric app.handler" - sleep 2 - > docker run \ @@ -83,19 +91,20 @@ phases: echo "Response: ${actual}" if [[ "$actual" != "$expected" ]]; then echo "fail! runtime: $RUNTIME - expected output $expected - got $actual" - echo "---------Container Logs: ${TEST_NAME}-app----------" - echo - docker logs "${TEST_NAME}-app" - echo - echo "---------------------------------------------------" - echo "--------Container Logs: ${TEST_NAME}-tester--------" - echo - docker logs "${TEST_NAME}-tester" - echo - echo "---------------------------------------------------" 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 diff --git a/tests/integration/codebuild/buildspec.os.ubuntu.1.yml b/tests/integration/codebuild/buildspec.os.ubuntu.1.yml index 655e443..4ba7c29 100644 --- a/tests/integration/codebuild/buildspec.os.ubuntu.1.yml +++ b/tests/integration/codebuild/buildspec.os.ubuntu.1.yml @@ -10,7 +10,6 @@ batch: static: ignore-failure: false env: - type: LINUX_CONTAINER privileged-mode: true dynamic: env: @@ -28,12 +27,22 @@ phases: - echo "Extracting and including the Runtime Interface Emulator" - SCRATCH_DIR=".scratch" - mkdir "${SCRATCH_DIR}" - - tar -xvf tests/integration/resources/aws-lambda-rie.tar.gz --directory "${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}/aws-lambda-rie /usr/bin/aws-lambda-rie" >> \ + echo "COPY ${SCRATCH_DIR}/${RIE} /usr/bin/${RIE}" >> \ "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" - > if [[ -z "${DOCKERHUB_USERNAME}" && -z "${DOCKERHUB_PASSWORD}" ]]; @@ -55,15 +64,15 @@ phases: - set -x - echo "Running Image ${IMAGE_TAG}" - docker network create "${TEST_NAME}-network" + - PYTHON_LOCATION=${PYTHON_LOCATION}${RUNTIME_VERSION} - > docker run \ --detach \ - -e "PYTHON_LOCATION=${PYTHON_LOCATION}${RUNTIME_VERSION}" \ --name "${TEST_NAME}-app" \ --network "${TEST_NAME}-network" \ --entrypoint="" \ "${IMAGE_TAG}" \ - sh -c '/usr/bin/aws-lambda-rie ${PYTHON_LOCATION} -m awslambdaric app.handler' + sh -c "/usr/bin/${RIE} ${PYTHON_LOCATION} -m awslambdaric app.handler" - sleep 2 - > docker run \ @@ -79,19 +88,20 @@ phases: echo "Response: ${actual}" if [[ "$actual" != "$expected" ]]; then echo "fail! runtime: $RUNTIME - expected output $expected - got $actual" - echo "---------Container Logs: ${TEST_NAME}-app----------" - echo - docker logs "${TEST_NAME}-app" - echo - echo "---------------------------------------------------" - echo "--------Container Logs: ${TEST_NAME}-tester--------" - echo - docker logs "${TEST_NAME}-tester" - echo - echo "---------------------------------------------------" 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 diff --git a/tests/integration/codebuild/buildspec.os.ubuntu.2.yml b/tests/integration/codebuild/buildspec.os.ubuntu.2.yml index 453c4ab..4f3ab58 100644 --- a/tests/integration/codebuild/buildspec.os.ubuntu.2.yml +++ b/tests/integration/codebuild/buildspec.os.ubuntu.2.yml @@ -10,7 +10,6 @@ batch: static: ignore-failure: false env: - type: LINUX_CONTAINER privileged-mode: true dynamic: env: @@ -27,12 +26,22 @@ phases: - echo "Extracting and including the Runtime Interface Emulator" - SCRATCH_DIR=".scratch" - mkdir "${SCRATCH_DIR}" - - tar -xvf tests/integration/resources/aws-lambda-rie.tar.gz --directory "${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}/aws-lambda-rie /usr/bin/aws-lambda-rie" >> \ + echo "COPY ${SCRATCH_DIR}/${RIE} /usr/bin/${RIE}" >> \ "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" - > if [[ -z "${DOCKERHUB_USERNAME}" && -z "${DOCKERHUB_PASSWORD}" ]]; @@ -54,15 +63,15 @@ phases: - set -x - echo "Running Image ${IMAGE_TAG}" - docker network create "${TEST_NAME}-network" + - PYTHON_LOCATION=${PYTHON_LOCATION}${RUNTIME_VERSION} - > docker run \ --detach \ - -e "PYTHON_LOCATION=${PYTHON_LOCATION}${RUNTIME_VERSION}" \ --name "${TEST_NAME}-app" \ --network "${TEST_NAME}-network" \ --entrypoint="" \ "${IMAGE_TAG}" \ - sh -c '/usr/bin/aws-lambda-rie ${PYTHON_LOCATION} -m awslambdaric app.handler' + sh -c "/usr/bin/${RIE} ${PYTHON_LOCATION} -m awslambdaric app.handler" - sleep 2 - > docker run \ @@ -78,19 +87,20 @@ phases: echo "Response: ${actual}" if [[ "$actual" != "$expected" ]]; then echo "fail! runtime: $RUNTIME - expected output $expected - got $actual" - echo "---------Container Logs: ${TEST_NAME}-app----------" - echo - docker logs "${TEST_NAME}-app" - echo - echo "---------------------------------------------------" - echo "--------Container Logs: ${TEST_NAME}-tester--------" - echo - docker logs "${TEST_NAME}-tester" - echo - echo "---------------------------------------------------" 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 diff --git a/tests/integration/docker/Dockerfile.echo.amazonlinux b/tests/integration/docker/Dockerfile.echo.amazonlinux index 701420a..962c4e5 100644 --- a/tests/integration/docker/Dockerfile.echo.amazonlinux +++ b/tests/integration/docker/Dockerfile.echo.amazonlinux @@ -1,5 +1,4 @@ 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 @@ -50,6 +49,7 @@ ENV LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH # Stage 3 - build function and dependencies FROM python-amazonlinux-builder AS build-image ARG RUNTIME_VERSION +ARG ARCHITECTURE # Install aws-lambda-cpp build dependencies RUN yum install -y \ @@ -64,7 +64,7 @@ RUN yum install -y \ wget # Install a modern CMake -RUN wget --quiet -O cmake-install https://github.com/Kitware/CMake/releases/download/v3.18.4/cmake-3.18.4-Linux-x86_64.sh && \ +RUN wget --quiet -O cmake-install https://github.com/Kitware/CMake/releases/download/v3.20.0/cmake-3.20.0-linux-${ARCHITECTURE}.sh && \ sh cmake-install --skip-license --prefix=/usr --exclude-subdirectory; ENV PATH=/usr/local/bin:$PATH diff --git a/tests/integration/docker/Dockerfile.echo.centos b/tests/integration/docker/Dockerfile.echo.centos index 62bcc61..b686649 100644 --- a/tests/integration/docker/Dockerfile.echo.centos +++ b/tests/integration/docker/Dockerfile.echo.centos @@ -50,6 +50,7 @@ ENV LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH # Stage 3 - build function and dependencies FROM python-centos-builder AS build-image ARG RUNTIME_VERSION +ARG ARCHITECTURE # Install aws-lambda-cpp build dependencies RUN yum install -y \ @@ -64,7 +65,7 @@ RUN yum install -y \ wget # Install a modern CMake -RUN wget --quiet -O cmake-install https://github.com/Kitware/CMake/releases/download/v3.18.4/cmake-3.18.4-Linux-x86_64.sh && \ +RUN wget --quiet -O cmake-install https://github.com/Kitware/CMake/releases/download/v3.20.0/cmake-3.20.0-linux-${ARCHITECTURE}.sh && \ sh cmake-install --skip-license --prefix=/usr --exclude-subdirectory; ENV PATH=/usr/local/bin:$PATH diff --git a/tests/integration/resources/aws-lambda-rie-arm64.tar.gz b/tests/integration/resources/aws-lambda-rie-arm64.tar.gz new file mode 100644 index 0000000..f62577f Binary files /dev/null and b/tests/integration/resources/aws-lambda-rie-arm64.tar.gz differ