From 5d19086ee4551b921c9f9d4264ba3615ed384def Mon Sep 17 00:00:00 2001 From: Zsombor Balogh Date: Fri, 6 May 2022 08:58:30 +0100 Subject: [PATCH 1/2] Fix os compatibility test local builds on arm64 hosts --- .../codebuild-local/codebuild_build.sh | 20 +++++++-- .../integration/codebuild-local/test_one.sh | 14 ++++++- .../codebuild/buildspec.os.alpine.yml | 29 +------------ .../codebuild/buildspec.os.amazoncorretto.yml | 29 +------------ .../codebuild/buildspec.os.amazonlinux.1.yml | 29 +------------ .../codebuild/buildspec.os.amazonlinux.2.yml | 29 +------------ .../codebuild/buildspec.os.centos.yml | 29 +------------ .../codebuild/buildspec.os.debian.yml | 29 +------------ .../codebuild/buildspec.os.ubuntu.yml | 29 +------------ .../codebuild/scripts/run_invocation_test.sh | 41 +++++++++++++++++++ 10 files changed, 76 insertions(+), 202 deletions(-) create mode 100755 aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/run_invocation_test.sh diff --git a/aws-lambda-java-runtime-interface-client/test/integration/codebuild-local/codebuild_build.sh b/aws-lambda-java-runtime-interface-client/test/integration/codebuild-local/codebuild_build.sh index e177edb8..952394b0 100755 --- a/aws-lambda-java-runtime-interface-client/test/integration/codebuild-local/codebuild_build.sh +++ b/aws-lambda-java-runtime-interface-client/test/integration/codebuild-local/codebuild_build.sh @@ -1,5 +1,5 @@ #!/bin/bash -# This file is copied from https://github.com/aws/aws-codebuild-docker-images/blob/f0912e4b16e427da35351fc102f0f56f4ceb938a/local_builds/codebuild_build.sh +# This file is copied from https://github.com/aws/aws-codebuild-docker-images/blob/282c6634e8c83c2a9841719b09aabfced3461981/local_builds/codebuild_build.sh function allOSRealPath() { if isOSWindows @@ -36,6 +36,7 @@ function usage { echo " -a Used to specify an artifact output directory." echo "Options:" echo " -l IMAGE Used to override the default local agent image." + echo " -r Used to specify a report output directory." echo " -s Used to specify source information. Defaults to the current working directory for primary source." echo " * First (-s) is for primary source" echo " * Use additional (-s) in : format for secondary source" @@ -61,10 +62,11 @@ awsconfig_flag=false mount_src_dir_flag=false docker_privileged_mode_flag=false -while getopts "cmdi:a:s:b:e:l:p:h" opt; do +while getopts "cmdi:a:r:s:b:e:l:p:h" opt; do case $opt in i ) image_flag=true; image_name=$OPTARG;; a ) artifact_flag=true; artifact_dir=$OPTARG;; + r ) report_dir=$OPTARG;; b ) buildspec=$OPTARG;; c ) awsconfig_flag=true;; m ) mount_src_dir_flag=true;; @@ -95,7 +97,7 @@ then exit 1 fi -docker_command="docker run " +docker_command="docker run -it " if isOSWindows then docker_command+="-v //var/run/docker.sock:/var/run/docker.sock -e " @@ -106,6 +108,11 @@ fi docker_command+="\"IMAGE_NAME=$image_name\" -e \ \"ARTIFACTS=$(allOSRealPath "$artifact_dir")\"" +if [ -n "$report_dir" ] +then + docker_command+=" -e \"REPORTS=$(allOSRealPath "$report_dir")\"" +fi + if [ -z "$source_dirs" ] then docker_command+=" -e \"SOURCE=$(allOSRealPath "$PWD")\"" @@ -176,7 +183,12 @@ else docker_command+=" -e \"INITIATOR=$USER\"" fi -docker_command+=" public.ecr.aws/codebuild/local-builds:latest" +if [ -n "$local_agent_image" ] +then + docker_command+=" $local_agent_image" +else + docker_command+=" public.ecr.aws/codebuild/local-builds:latest" +fi # Note we do not expose the AWS_SECRET_ACCESS_KEY or the AWS_SESSION_TOKEN exposed_command=$docker_command diff --git a/aws-lambda-java-runtime-interface-client/test/integration/codebuild-local/test_one.sh b/aws-lambda-java-runtime-interface-client/test/integration/codebuild-local/test_one.sh index 838c0ae7..ba49e826 100755 --- a/aws-lambda-java-runtime-interface-client/test/integration/codebuild-local/test_one.sh +++ b/aws-lambda-java-runtime-interface-client/test/integration/codebuild-local/test_one.sh @@ -18,6 +18,15 @@ function usage { >&2 echo " env Additional environment variables file." } +# codebuild/local-builds images are not multi-architectural +function get_local_agent_image() { + if [[ "$(arch)" == "aarch64" ]]; then + echo "public.ecr.aws/codebuild/local-builds:aarch64" + else + echo "public.ecr.aws/codebuild/local-builds:latest" + fi +} + main() { if (( $# != 5 && $# != 6)); then >&2 echo "Invalid number of parameters." @@ -48,7 +57,7 @@ main() { echo "RUNTIME_VERSION=$RUNTIME_VERSION" echo "PLATFORM=$PLATFORM" } >> "$ENVFILE" - + ARTIFACTS_DIR="$CODEBUILD_TEMP_DIR/artifacts" mkdir -p "$ARTIFACTS_DIR" # Run CodeBuild local agent. @@ -57,7 +66,8 @@ main() { -a "$ARTIFACTS_DIR" \ -e "$ENVFILE" \ -b "$BUILDSPEC_YML" \ - -s "$(dirname $PWD)" + -s "$(dirname $PWD)" \ + -l "$(get_local_agent_image)" } main "$@" diff --git a/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.alpine.yml b/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.alpine.yml index fe1c4e98..bbc409a9 100644 --- a/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.alpine.yml +++ b/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.alpine.yml @@ -79,34 +79,7 @@ phases: --build-arg DISTRO_VERSION="${DISTRO_VERSION}" build: commands: - - set -x - - echo "Running Image ${IMAGE_TAG}" - - docker network create "${OS_DISTRIBUTION}-network" - - > - docker run \ - --detach \ - --name "${OS_DISTRIBUTION}-app" \ - --network "${OS_DISTRIBUTION}-network" \ - --entrypoint="" \ - "${IMAGE_TAG}" \ - sh -c "/usr/bin/${RIE} ${JAVA_BINARY_LOCATION} -jar ./HelloWorld-1.0.jar helloworld.App" - - sleep 2 - - > - docker run \ - --name "${OS_DISTRIBUTION}-tester" \ - --env "TARGET=${OS_DISTRIBUTION}-app" \ - --network "${OS_DISTRIBUTION}-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 "${OS_DISTRIBUTION}-tester" | xargs)" - - expected='success' - - | - echo "Response: ${actual}" - if [[ "$actual" != "$expected" ]]; then - echo "fail! runtime: $RUNTIME - expected output $expected - got $actual" - exit -1 - fi + - aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/run_invocation_test.sh finally: - | echo "---------Container Logs: ${OS_DISTRIBUTION}-app----------" diff --git a/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.amazoncorretto.yml b/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.amazoncorretto.yml index 17a0c48f..e7e92ee7 100644 --- a/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.amazoncorretto.yml +++ b/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.amazoncorretto.yml @@ -75,34 +75,7 @@ phases: --build-arg DISTRO_VERSION="${DISTRO_VERSION}" build: commands: - - set -x - - echo "Running Image ${IMAGE_TAG}" - - docker network create "${OS_DISTRIBUTION}-network" - - > - docker run \ - --detach \ - --name "${OS_DISTRIBUTION}-app" \ - --network "${OS_DISTRIBUTION}-network" \ - --entrypoint="" \ - "${IMAGE_TAG}" \ - sh -c "/usr/bin/${RIE} ${JAVA_BINARY_LOCATION} -jar ./HelloWorld-1.0.jar helloworld.App" - - sleep 2 - - > - docker run \ - --name "${OS_DISTRIBUTION}-tester" \ - --env "TARGET=${OS_DISTRIBUTION}-app" \ - --network "${OS_DISTRIBUTION}-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 "${OS_DISTRIBUTION}-tester" | xargs)" - - expected='success' - - | - echo "Response: ${actual}" - if [[ "$actual" != "$expected" ]]; then - echo "fail! runtime: $RUNTIME - expected output $expected - got $actual" - exit -1 - fi + - aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/run_invocation_test.sh finally: - | echo "---------Container Logs: ${OS_DISTRIBUTION}-app----------" diff --git a/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.amazonlinux.1.yml b/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.amazonlinux.1.yml index 9eafb6de..8e28547e 100644 --- a/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.amazonlinux.1.yml +++ b/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.amazonlinux.1.yml @@ -61,34 +61,7 @@ phases: --build-arg DISTRO_VERSION="${DISTRO_VERSION}" build: commands: - - set -x - - echo "Running Image ${IMAGE_TAG}" - - docker network create "${OS_DISTRIBUTION}-network" - - > - docker run \ - --detach \ - --name "${OS_DISTRIBUTION}-app" \ - --network "${OS_DISTRIBUTION}-network" \ - --entrypoint="" \ - "${IMAGE_TAG}" \ - sh -c "/usr/bin/${RIE} ${JAVA_BINARY_LOCATION} -jar ./HelloWorld-1.0.jar helloworld.App" - - sleep 2 - - > - docker run \ - --name "${OS_DISTRIBUTION}-tester" \ - --env "TARGET=${OS_DISTRIBUTION}-app" \ - --network "${OS_DISTRIBUTION}-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 "${OS_DISTRIBUTION}-tester" | xargs)" - - expected='success' - - | - echo "Response: ${actual}" - if [[ "$actual" != "$expected" ]]; then - echo "fail! runtime: $RUNTIME - expected output $expected - got $actual" - exit -1 - fi + - aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/run_invocation_test.sh finally: - | echo "---------Container Logs: ${OS_DISTRIBUTION}-app----------" diff --git a/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.amazonlinux.2.yml b/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.amazonlinux.2.yml index cdd02073..56f5c728 100644 --- a/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.amazonlinux.2.yml +++ b/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.amazonlinux.2.yml @@ -74,34 +74,7 @@ phases: --build-arg DISTRO_VERSION="${DISTRO_VERSION}" build: commands: - - set -x - - echo "Running Image ${IMAGE_TAG}" - - docker network create "${OS_DISTRIBUTION}-network" - - > - docker run \ - --detach \ - --name "${OS_DISTRIBUTION}-app" \ - --network "${OS_DISTRIBUTION}-network" \ - --entrypoint="" \ - "${IMAGE_TAG}" \ - sh -c "/usr/bin/${RIE} ${JAVA_BINARY_LOCATION} -jar ./HelloWorld-1.0.jar helloworld.App" - - sleep 2 - - > - docker run \ - --name "${OS_DISTRIBUTION}-tester" \ - --env "TARGET=${OS_DISTRIBUTION}-app" \ - --network "${OS_DISTRIBUTION}-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 "${OS_DISTRIBUTION}-tester" | xargs)" - - expected='success' - - | - echo "Response: ${actual}" - if [[ "$actual" != "$expected" ]]; then - echo "fail! runtime: $RUNTIME - expected output $expected - got $actual" - exit -1 - fi + - aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/run_invocation_test.sh finally: - | echo "---------Container Logs: ${OS_DISTRIBUTION}-app----------" diff --git a/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.centos.yml b/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.centos.yml index 307b3280..614c2920 100644 --- a/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.centos.yml +++ b/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.centos.yml @@ -74,34 +74,7 @@ phases: --build-arg DISTRO_VERSION="${DISTRO_VERSION}" build: commands: - - set -x - - echo "Running Image ${IMAGE_TAG}" - - docker network create "${OS_DISTRIBUTION}-network" - - > - docker run \ - --detach \ - --name "${OS_DISTRIBUTION}-app" \ - --network "${OS_DISTRIBUTION}-network" \ - --entrypoint="" \ - "${IMAGE_TAG}" \ - sh -c "/usr/bin/${RIE} ${JAVA_BINARY_LOCATION} -jar ./HelloWorld-1.0.jar helloworld.App" - - sleep 2 - - > - docker run \ - --name "${OS_DISTRIBUTION}-tester" \ - --env "TARGET=${OS_DISTRIBUTION}-app" \ - --network "${OS_DISTRIBUTION}-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 "${OS_DISTRIBUTION}-tester" | xargs)" - - expected='success' - - | - echo "Response: ${actual}" - if [[ "$actual" != "$expected" ]]; then - echo "fail! runtime: $RUNTIME - expected output $expected - got $actual" - exit -1 - fi + - aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/run_invocation_test.sh finally: - | echo "---------Container Logs: ${OS_DISTRIBUTION}-app----------" diff --git a/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.debian.yml b/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.debian.yml index 7c088810..63c5d102 100644 --- a/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.debian.yml +++ b/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.debian.yml @@ -78,34 +78,7 @@ phases: --build-arg DISTRO_VERSION="${DISTRO_VERSION}" build: commands: - - set -x - - echo "Running Image ${IMAGE_TAG}" - - docker network create "${OS_DISTRIBUTION}-network" - - > - docker run \ - --detach \ - --name "${OS_DISTRIBUTION}-app" \ - --network "${OS_DISTRIBUTION}-network" \ - --entrypoint="" \ - "${IMAGE_TAG}" \ - sh -c "/usr/bin/${RIE} ${JAVA_BINARY_LOCATION} -jar ./HelloWorld-1.0.jar helloworld.App" - - sleep 2 - - > - docker run \ - --name "${OS_DISTRIBUTION}-tester" \ - --env "TARGET=${OS_DISTRIBUTION}-app" \ - --network "${OS_DISTRIBUTION}-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 "${OS_DISTRIBUTION}-tester" | xargs)" - - expected='success' - - | - echo "Response: ${actual}" - if [[ "$actual" != "$expected" ]]; then - echo "fail! runtime: $RUNTIME - expected output $expected - got $actual" - exit -1 - fi + - aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/run_invocation_test.sh finally: - | echo "---------Container Logs: ${OS_DISTRIBUTION}-app----------" diff --git a/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.ubuntu.yml b/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.ubuntu.yml index 7be6274f..e01e0db4 100644 --- a/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.ubuntu.yml +++ b/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.ubuntu.yml @@ -80,34 +80,7 @@ phases: --build-arg DISTRO_VERSION="${DISTRO_VERSION}" build: commands: - - set -x - - echo "Running Image ${IMAGE_TAG}" - - docker network create "${OS_DISTRIBUTION}-network" - - > - docker run \ - --detach \ - --name "${OS_DISTRIBUTION}-app" \ - --network "${OS_DISTRIBUTION}-network" \ - --entrypoint="" \ - "${IMAGE_TAG}" \ - sh -c "/usr/bin/${RIE} ${JAVA_BINARY_LOCATION} -jar ./HelloWorld-1.0.jar helloworld.App" - - sleep 2 - - > - docker run \ - --name "${OS_DISTRIBUTION}-tester" \ - --env "TARGET=${OS_DISTRIBUTION}-app" \ - --network "${OS_DISTRIBUTION}-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 "${OS_DISTRIBUTION}-tester" | xargs)" - - expected='success' - - | - echo "Response: ${actual}" - if [[ "$actual" != "$expected" ]]; then - echo "fail! runtime: $RUNTIME - expected output $expected - got $actual" - exit -1 - fi + - aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/run_invocation_test.sh finally: - | echo "---------Container Logs: ${OS_DISTRIBUTION}-app----------" diff --git a/aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/run_invocation_test.sh b/aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/run_invocation_test.sh new file mode 100755 index 00000000..0ffddb8a --- /dev/null +++ b/aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/run_invocation_test.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. + +set -euxo pipefail + +echo "Running Image ${IMAGE_TAG}" +docker network create "${OS_DISTRIBUTION}-network" + +docker run \ + --detach \ + --name "${OS_DISTRIBUTION}-app" \ + --network "${OS_DISTRIBUTION}-network" \ + --entrypoint="" \ + --platform="${PLATFORM}" \ + "${IMAGE_TAG}" \ + sh -c "/usr/bin/${RIE} ${JAVA_BINARY_LOCATION} -jar ./HelloWorld-1.0.jar helloworld.App" +sleep 2 + +# running on arm64 hosts with x86_64 being emulated takes significantly more time than any other combination +if [[ "$(arch)" == "aarch64" ]] && [[ "${PLATFORM}" == "linux/amd64" ]]; then + declare -i time_out=150 +else + declare -i time_out=10 +fi + +docker run \ + --name "${OS_DISTRIBUTION}-tester" \ + --env "TARGET=${OS_DISTRIBUTION}-app" \ + --env "MAX_TIME=${time_out}" \ + --network "${OS_DISTRIBUTION}-network" \ + --entrypoint="" \ + --platform="${PLATFORM}" \ + "${IMAGE_TAG}" \ + sh -c 'curl -X POST "http://${TARGET}:8080/2015-03-31/functions/function/invocations" -d "{}" --max-time ${MAX_TIME}' +actual="$(docker logs --tail 1 "${OS_DISTRIBUTION}-tester" | xargs)" +expected='success' +echo "Response: ${actual}" +if [[ "${actual}" != "${expected}" ]]; then + echo "fail! runtime: ${RUNTIME} - expected output ${expected} - got ${actual}" + exit 1 +fi From 8c2c63557dc7da4a603e9999666255c009e010e1 Mon Sep 17 00:00:00 2001 From: Zsombor Balogh Date: Fri, 6 May 2022 10:28:58 +0100 Subject: [PATCH 2/2] Extract log fetching and clean up to separate scripts --- .../codebuild-local/codebuild_build.sh | 2 +- .../codebuild/buildspec.os.alpine.yml | 19 ++----------------- .../codebuild/buildspec.os.amazoncorretto.yml | 19 ++----------------- .../codebuild/buildspec.os.amazonlinux.1.yml | 19 ++----------------- .../codebuild/buildspec.os.amazonlinux.2.yml | 19 ++----------------- .../codebuild/buildspec.os.centos.yml | 19 ++----------------- .../codebuild/buildspec.os.debian.yml | 19 ++----------------- .../codebuild/buildspec.os.ubuntu.yml | 19 ++----------------- .../integration/codebuild/scripts/clean_up.sh | 11 +++++++++++ .../scripts/fetch_test_container_logs.sh | 15 +++++++++++++++ .../codebuild/scripts/run_invocation_test.sh | 4 +++- 11 files changed, 44 insertions(+), 121 deletions(-) create mode 100755 aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/clean_up.sh create mode 100755 aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/fetch_test_container_logs.sh diff --git a/aws-lambda-java-runtime-interface-client/test/integration/codebuild-local/codebuild_build.sh b/aws-lambda-java-runtime-interface-client/test/integration/codebuild-local/codebuild_build.sh index 952394b0..2a6ffa97 100755 --- a/aws-lambda-java-runtime-interface-client/test/integration/codebuild-local/codebuild_build.sh +++ b/aws-lambda-java-runtime-interface-client/test/integration/codebuild-local/codebuild_build.sh @@ -97,7 +97,7 @@ then exit 1 fi -docker_command="docker run -it " +docker_command="docker run " if isOSWindows then docker_command+="-v //var/run/docker.sock:/var/run/docker.sock -e " diff --git a/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.alpine.yml b/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.alpine.yml index bbc409a9..4f8caf39 100644 --- a/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.alpine.yml +++ b/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.alpine.yml @@ -81,20 +81,5 @@ phases: commands: - aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/run_invocation_test.sh finally: - - | - echo "---------Container Logs: ${OS_DISTRIBUTION}-app----------" - echo - docker logs "${OS_DISTRIBUTION}-app" || true - echo - echo "---------------------------------------------------" - echo "--------Container Logs: ${OS_DISTRIBUTION}-tester--------" - echo - docker logs "${OS_DISTRIBUTION}-tester" || true - echo - echo "---------------------------------------------------" - - echo "Cleaning up..." - - docker stop "${OS_DISTRIBUTION}-app" || true - - docker rm --force "${OS_DISTRIBUTION}-app" || true - - docker stop "${OS_DISTRIBUTION}-tester" || true - - docker rm --force "${OS_DISTRIBUTION}-tester" || true - - docker network rm "${OS_DISTRIBUTION}-network" || true + - aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/fetch_test_container_logs.sh + - aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/clean_up.sh diff --git a/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.amazoncorretto.yml b/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.amazoncorretto.yml index e7e92ee7..fd45aabb 100644 --- a/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.amazoncorretto.yml +++ b/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.amazoncorretto.yml @@ -77,20 +77,5 @@ phases: commands: - aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/run_invocation_test.sh finally: - - | - echo "---------Container Logs: ${OS_DISTRIBUTION}-app----------" - echo - docker logs "${OS_DISTRIBUTION}-app" || true - echo - echo "---------------------------------------------------" - echo "--------Container Logs: ${OS_DISTRIBUTION}-tester--------" - echo - docker logs "${OS_DISTRIBUTION}-tester" || true - echo - echo "---------------------------------------------------" - - echo "Cleaning up..." - - docker stop "${OS_DISTRIBUTION}-app" || true - - docker rm --force "${OS_DISTRIBUTION}-app" || true - - docker stop "${OS_DISTRIBUTION}-tester" || true - - docker rm --force "${OS_DISTRIBUTION}-tester" || true - - docker network rm "${OS_DISTRIBUTION}-network" || true + - aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/fetch_test_container_logs.sh + - aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/clean_up.sh diff --git a/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.amazonlinux.1.yml b/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.amazonlinux.1.yml index 8e28547e..197e9724 100644 --- a/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.amazonlinux.1.yml +++ b/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.amazonlinux.1.yml @@ -63,20 +63,5 @@ phases: commands: - aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/run_invocation_test.sh finally: - - | - echo "---------Container Logs: ${OS_DISTRIBUTION}-app----------" - echo - docker logs "${OS_DISTRIBUTION}-app" || true - echo - echo "---------------------------------------------------" - echo "--------Container Logs: ${OS_DISTRIBUTION}-tester--------" - echo - docker logs "${OS_DISTRIBUTION}-tester" || true - echo - echo "---------------------------------------------------" - - echo "Cleaning up..." - - docker stop "${OS_DISTRIBUTION}-app" || true - - docker rm --force "${OS_DISTRIBUTION}-app" || true - - docker stop "${OS_DISTRIBUTION}-tester" || true - - docker rm --force "${OS_DISTRIBUTION}-tester" || true - - docker network rm "${OS_DISTRIBUTION}-network" || true + - aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/fetch_test_container_logs.sh + - aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/clean_up.sh diff --git a/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.amazonlinux.2.yml b/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.amazonlinux.2.yml index 56f5c728..75b816e8 100644 --- a/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.amazonlinux.2.yml +++ b/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.amazonlinux.2.yml @@ -76,20 +76,5 @@ phases: commands: - aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/run_invocation_test.sh finally: - - | - echo "---------Container Logs: ${OS_DISTRIBUTION}-app----------" - echo - docker logs "${OS_DISTRIBUTION}-app" || true - echo - echo "---------------------------------------------------" - echo "--------Container Logs: ${OS_DISTRIBUTION}-tester--------" - echo - docker logs "${OS_DISTRIBUTION}-tester" || true - echo - echo "---------------------------------------------------" - - echo "Cleaning up..." - - docker stop "${OS_DISTRIBUTION}-app" || true - - docker rm --force "${OS_DISTRIBUTION}-app" || true - - docker stop "${OS_DISTRIBUTION}-tester" || true - - docker rm --force "${OS_DISTRIBUTION}-tester" || true - - docker network rm "${OS_DISTRIBUTION}-network" || true + - aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/fetch_test_container_logs.sh + - aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/clean_up.sh diff --git a/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.centos.yml b/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.centos.yml index 614c2920..d718c264 100644 --- a/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.centos.yml +++ b/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.centos.yml @@ -76,20 +76,5 @@ phases: commands: - aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/run_invocation_test.sh finally: - - | - echo "---------Container Logs: ${OS_DISTRIBUTION}-app----------" - echo - docker logs "${OS_DISTRIBUTION}-app" || true - echo - echo "---------------------------------------------------" - echo "--------Container Logs: ${OS_DISTRIBUTION}-tester--------" - echo - docker logs "${OS_DISTRIBUTION}-tester" || true - echo - echo "---------------------------------------------------" - - echo "Cleaning up..." - - docker stop "${OS_DISTRIBUTION}-app" || true - - docker rm --force "${OS_DISTRIBUTION}-app" || true - - docker stop "${OS_DISTRIBUTION}-tester" || true - - docker rm --force "${OS_DISTRIBUTION}-tester" || true - - docker network rm "${OS_DISTRIBUTION}-network" || true + - aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/fetch_test_container_logs.sh + - aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/clean_up.sh diff --git a/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.debian.yml b/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.debian.yml index 63c5d102..d2772fbf 100644 --- a/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.debian.yml +++ b/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.debian.yml @@ -80,20 +80,5 @@ phases: commands: - aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/run_invocation_test.sh finally: - - | - echo "---------Container Logs: ${OS_DISTRIBUTION}-app----------" - echo - docker logs "${OS_DISTRIBUTION}-app" || true - echo - echo "---------------------------------------------------" - echo "--------Container Logs: ${OS_DISTRIBUTION}-tester--------" - echo - docker logs "${OS_DISTRIBUTION}-tester" || true - echo - echo "---------------------------------------------------" - - echo "Cleaning up..." - - docker stop "${OS_DISTRIBUTION}-app" || true - - docker rm --force "${OS_DISTRIBUTION}-app" || true - - docker stop "${OS_DISTRIBUTION}-tester" || true - - docker rm --force "${OS_DISTRIBUTION}-tester" || true - - docker network rm "${OS_DISTRIBUTION}-network" || true + - aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/fetch_test_container_logs.sh + - aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/clean_up.sh diff --git a/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.ubuntu.yml b/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.ubuntu.yml index e01e0db4..2a90017b 100644 --- a/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.ubuntu.yml +++ b/aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.ubuntu.yml @@ -82,20 +82,5 @@ phases: commands: - aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/run_invocation_test.sh finally: - - | - echo "---------Container Logs: ${OS_DISTRIBUTION}-app----------" - echo - docker logs "${OS_DISTRIBUTION}-app" || true - echo - echo "---------------------------------------------------" - echo "--------Container Logs: ${OS_DISTRIBUTION}-tester--------" - echo - docker logs "${OS_DISTRIBUTION}-tester" || true - echo - echo "---------------------------------------------------" - - echo "Cleaning up..." - - docker stop "${OS_DISTRIBUTION}-app" || true - - docker rm --force "${OS_DISTRIBUTION}-app" || true - - docker stop "${OS_DISTRIBUTION}-tester" || true - - docker rm --force "${OS_DISTRIBUTION}-tester" || true - - docker network rm "${OS_DISTRIBUTION}-network" || true + - aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/fetch_test_container_logs.sh + - aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/clean_up.sh diff --git a/aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/clean_up.sh b/aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/clean_up.sh new file mode 100755 index 00000000..236fa7b2 --- /dev/null +++ b/aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/clean_up.sh @@ -0,0 +1,11 @@ +#!/bin/bash +# Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. + +set -euo pipefail + +echo "Cleaning up..." +docker stop "${OS_DISTRIBUTION}-app" || true +docker rm --force "${OS_DISTRIBUTION}-app" || true +docker stop "${OS_DISTRIBUTION}-tester" || true +docker rm --force "${OS_DISTRIBUTION}-tester" || true +docker network rm "${OS_DISTRIBUTION}-network" || true diff --git a/aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/fetch_test_container_logs.sh b/aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/fetch_test_container_logs.sh new file mode 100755 index 00000000..4bc809dc --- /dev/null +++ b/aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/fetch_test_container_logs.sh @@ -0,0 +1,15 @@ +#!/bin/bash +# Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. + +set -euo pipefail + +echo "---------Container Logs: ${OS_DISTRIBUTION}-app----------" +echo +docker logs "${OS_DISTRIBUTION}-app" || true +echo +echo "---------------------------------------------------" +echo "--------Container Logs: ${OS_DISTRIBUTION}-tester--------" +echo +docker logs "${OS_DISTRIBUTION}-tester" || true +echo +echo "---------------------------------------------------" diff --git a/aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/run_invocation_test.sh b/aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/run_invocation_test.sh index 0ffddb8a..f5ebf068 100755 --- a/aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/run_invocation_test.sh +++ b/aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/run_invocation_test.sh @@ -6,6 +6,8 @@ set -euxo pipefail echo "Running Image ${IMAGE_TAG}" docker network create "${OS_DISTRIBUTION}-network" +function_jar="./HelloWorld-1.0.jar" +function_handler="helloworld.App" docker run \ --detach \ --name "${OS_DISTRIBUTION}-app" \ @@ -13,7 +15,7 @@ docker run \ --entrypoint="" \ --platform="${PLATFORM}" \ "${IMAGE_TAG}" \ - sh -c "/usr/bin/${RIE} ${JAVA_BINARY_LOCATION} -jar ./HelloWorld-1.0.jar helloworld.App" + sh -c "/usr/bin/${RIE} ${JAVA_BINARY_LOCATION} -jar ${function_jar} ${function_handler}" sleep 2 # running on arm64 hosts with x86_64 being emulated takes significantly more time than any other combination