Skip to content
This repository was archived by the owner on Aug 22, 2022. It is now read-only.

Commit b047a4d

Browse files
zsombor-baloghSordie
authored andcommitted
Fix os compatibility test local builds on arm64 hosts (aws#338)
* Fix os compatibility test local builds on arm64 hosts * Extract log fetching and clean up to separate scripts
1 parent 9d33d26 commit b047a4d

12 files changed

+117
-320
lines changed

aws-lambda-java-runtime-interface-client/test/integration/codebuild-local/codebuild_build.sh

+15-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
# This file is copied from https://github.com/aws/aws-codebuild-docker-images/blob/f0912e4b16e427da35351fc102f0f56f4ceb938a/local_builds/codebuild_build.sh
2+
# This file is copied from https://github.com/aws/aws-codebuild-docker-images/blob/282c6634e8c83c2a9841719b09aabfced3461981/local_builds/codebuild_build.sh
33

44
function allOSRealPath() {
55
if isOSWindows
@@ -36,6 +36,7 @@ function usage {
3636
echo " -a Used to specify an artifact output directory."
3737
echo "Options:"
3838
echo " -l IMAGE Used to override the default local agent image."
39+
echo " -r Used to specify a report output directory."
3940
echo " -s Used to specify source information. Defaults to the current working directory for primary source."
4041
echo " * First (-s) is for primary source"
4142
echo " * Use additional (-s) in <sourceIdentifier>:<sourceLocation> format for secondary source"
@@ -61,10 +62,11 @@ awsconfig_flag=false
6162
mount_src_dir_flag=false
6263
docker_privileged_mode_flag=false
6364

64-
while getopts "cmdi:a:s:b:e:l:p:h" opt; do
65+
while getopts "cmdi:a:r:s:b:e:l:p:h" opt; do
6566
case $opt in
6667
i ) image_flag=true; image_name=$OPTARG;;
6768
a ) artifact_flag=true; artifact_dir=$OPTARG;;
69+
r ) report_dir=$OPTARG;;
6870
b ) buildspec=$OPTARG;;
6971
c ) awsconfig_flag=true;;
7072
m ) mount_src_dir_flag=true;;
@@ -106,6 +108,11 @@ fi
106108
docker_command+="\"IMAGE_NAME=$image_name\" -e \
107109
\"ARTIFACTS=$(allOSRealPath "$artifact_dir")\""
108110

111+
if [ -n "$report_dir" ]
112+
then
113+
docker_command+=" -e \"REPORTS=$(allOSRealPath "$report_dir")\""
114+
fi
115+
109116
if [ -z "$source_dirs" ]
110117
then
111118
docker_command+=" -e \"SOURCE=$(allOSRealPath "$PWD")\""
@@ -176,7 +183,12 @@ else
176183
docker_command+=" -e \"INITIATOR=$USER\""
177184
fi
178185

179-
docker_command+=" public.ecr.aws/codebuild/local-builds:latest"
186+
if [ -n "$local_agent_image" ]
187+
then
188+
docker_command+=" $local_agent_image"
189+
else
190+
docker_command+=" public.ecr.aws/codebuild/local-builds:latest"
191+
fi
180192

181193
# Note we do not expose the AWS_SECRET_ACCESS_KEY or the AWS_SESSION_TOKEN
182194
exposed_command=$docker_command

aws-lambda-java-runtime-interface-client/test/integration/codebuild-local/test_one.sh

+12-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ function usage {
1818
>&2 echo " env Additional environment variables file."
1919
}
2020

21+
# codebuild/local-builds images are not multi-architectural
22+
function get_local_agent_image() {
23+
if [[ "$(arch)" == "aarch64" ]]; then
24+
echo "public.ecr.aws/codebuild/local-builds:aarch64"
25+
else
26+
echo "public.ecr.aws/codebuild/local-builds:latest"
27+
fi
28+
}
29+
2130
main() {
2231
if (( $# != 5 && $# != 6)); then
2332
>&2 echo "Invalid number of parameters."
@@ -48,7 +57,7 @@ main() {
4857
echo "RUNTIME_VERSION=$RUNTIME_VERSION"
4958
echo "PLATFORM=$PLATFORM"
5059
} >> "$ENVFILE"
51-
60+
5261
ARTIFACTS_DIR="$CODEBUILD_TEMP_DIR/artifacts"
5362
mkdir -p "$ARTIFACTS_DIR"
5463
# Run CodeBuild local agent.
@@ -57,7 +66,8 @@ main() {
5766
-a "$ARTIFACTS_DIR" \
5867
-e "$ENVFILE" \
5968
-b "$BUILDSPEC_YML" \
60-
-s "$(dirname $PWD)"
69+
-s "$(dirname $PWD)" \
70+
-l "$(get_local_agent_image)"
6171
}
6272

6373
main "$@"

aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.alpine.yml

+3-45
Original file line numberDiff line numberDiff line change
@@ -79,49 +79,7 @@ phases:
7979
--build-arg DISTRO_VERSION="${DISTRO_VERSION}"
8080
build:
8181
commands:
82-
- set -x
83-
- echo "Running Image ${IMAGE_TAG}"
84-
- docker network create "${OS_DISTRIBUTION}-network"
85-
- >
86-
docker run \
87-
--detach \
88-
--name "${OS_DISTRIBUTION}-app" \
89-
--network "${OS_DISTRIBUTION}-network" \
90-
--entrypoint="" \
91-
"${IMAGE_TAG}" \
92-
sh -c "/usr/bin/${RIE} ${JAVA_BINARY_LOCATION} -jar ./HelloWorld-1.0.jar helloworld.App"
93-
- sleep 2
94-
- >
95-
docker run \
96-
--name "${OS_DISTRIBUTION}-tester" \
97-
--env "TARGET=${OS_DISTRIBUTION}-app" \
98-
--network "${OS_DISTRIBUTION}-network" \
99-
--entrypoint="" \
100-
"${IMAGE_TAG}" \
101-
sh -c 'curl -X POST "http://${TARGET}:8080/2015-03-31/functions/function/invocations" -d "{}" --max-time 10'
102-
- actual="$(docker logs --tail 1 "${OS_DISTRIBUTION}-tester" | xargs)"
103-
- expected='success'
104-
- |
105-
echo "Response: ${actual}"
106-
if [[ "$actual" != "$expected" ]]; then
107-
echo "fail! runtime: $RUNTIME - expected output $expected - got $actual"
108-
exit -1
109-
fi
82+
- aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/run_invocation_test.sh
11083
finally:
111-
- |
112-
echo "---------Container Logs: ${OS_DISTRIBUTION}-app----------"
113-
echo
114-
docker logs "${OS_DISTRIBUTION}-app" || true
115-
echo
116-
echo "---------------------------------------------------"
117-
echo "--------Container Logs: ${OS_DISTRIBUTION}-tester--------"
118-
echo
119-
docker logs "${OS_DISTRIBUTION}-tester" || true
120-
echo
121-
echo "---------------------------------------------------"
122-
- echo "Cleaning up..."
123-
- docker stop "${OS_DISTRIBUTION}-app" || true
124-
- docker rm --force "${OS_DISTRIBUTION}-app" || true
125-
- docker stop "${OS_DISTRIBUTION}-tester" || true
126-
- docker rm --force "${OS_DISTRIBUTION}-tester" || true
127-
- docker network rm "${OS_DISTRIBUTION}-network" || true
84+
- aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/fetch_test_container_logs.sh
85+
- aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/clean_up.sh

aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.amazoncorretto.yml

+3-45
Original file line numberDiff line numberDiff line change
@@ -75,49 +75,7 @@ phases:
7575
--build-arg DISTRO_VERSION="${DISTRO_VERSION}"
7676
build:
7777
commands:
78-
- set -x
79-
- echo "Running Image ${IMAGE_TAG}"
80-
- docker network create "${OS_DISTRIBUTION}-network"
81-
- >
82-
docker run \
83-
--detach \
84-
--name "${OS_DISTRIBUTION}-app" \
85-
--network "${OS_DISTRIBUTION}-network" \
86-
--entrypoint="" \
87-
"${IMAGE_TAG}" \
88-
sh -c "/usr/bin/${RIE} ${JAVA_BINARY_LOCATION} -jar ./HelloWorld-1.0.jar helloworld.App"
89-
- sleep 2
90-
- >
91-
docker run \
92-
--name "${OS_DISTRIBUTION}-tester" \
93-
--env "TARGET=${OS_DISTRIBUTION}-app" \
94-
--network "${OS_DISTRIBUTION}-network" \
95-
--entrypoint="" \
96-
"${IMAGE_TAG}" \
97-
sh -c 'curl -X POST "http://${TARGET}:8080/2015-03-31/functions/function/invocations" -d "{}" --max-time 10'
98-
- actual="$(docker logs --tail 1 "${OS_DISTRIBUTION}-tester" | xargs)"
99-
- expected='success'
100-
- |
101-
echo "Response: ${actual}"
102-
if [[ "$actual" != "$expected" ]]; then
103-
echo "fail! runtime: $RUNTIME - expected output $expected - got $actual"
104-
exit -1
105-
fi
78+
- aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/run_invocation_test.sh
10679
finally:
107-
- |
108-
echo "---------Container Logs: ${OS_DISTRIBUTION}-app----------"
109-
echo
110-
docker logs "${OS_DISTRIBUTION}-app" || true
111-
echo
112-
echo "---------------------------------------------------"
113-
echo "--------Container Logs: ${OS_DISTRIBUTION}-tester--------"
114-
echo
115-
docker logs "${OS_DISTRIBUTION}-tester" || true
116-
echo
117-
echo "---------------------------------------------------"
118-
- echo "Cleaning up..."
119-
- docker stop "${OS_DISTRIBUTION}-app" || true
120-
- docker rm --force "${OS_DISTRIBUTION}-app" || true
121-
- docker stop "${OS_DISTRIBUTION}-tester" || true
122-
- docker rm --force "${OS_DISTRIBUTION}-tester" || true
123-
- docker network rm "${OS_DISTRIBUTION}-network" || true
80+
- aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/fetch_test_container_logs.sh
81+
- aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/clean_up.sh

aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.amazonlinux.1.yml

+3-45
Original file line numberDiff line numberDiff line change
@@ -61,49 +61,7 @@ phases:
6161
--build-arg DISTRO_VERSION="${DISTRO_VERSION}"
6262
build:
6363
commands:
64-
- set -x
65-
- echo "Running Image ${IMAGE_TAG}"
66-
- docker network create "${OS_DISTRIBUTION}-network"
67-
- >
68-
docker run \
69-
--detach \
70-
--name "${OS_DISTRIBUTION}-app" \
71-
--network "${OS_DISTRIBUTION}-network" \
72-
--entrypoint="" \
73-
"${IMAGE_TAG}" \
74-
sh -c "/usr/bin/${RIE} ${JAVA_BINARY_LOCATION} -jar ./HelloWorld-1.0.jar helloworld.App"
75-
- sleep 2
76-
- >
77-
docker run \
78-
--name "${OS_DISTRIBUTION}-tester" \
79-
--env "TARGET=${OS_DISTRIBUTION}-app" \
80-
--network "${OS_DISTRIBUTION}-network" \
81-
--entrypoint="" \
82-
"${IMAGE_TAG}" \
83-
sh -c 'curl -X POST "http://${TARGET}:8080/2015-03-31/functions/function/invocations" -d "{}" --max-time 10'
84-
- actual="$(docker logs --tail 1 "${OS_DISTRIBUTION}-tester" | xargs)"
85-
- expected='success'
86-
- |
87-
echo "Response: ${actual}"
88-
if [[ "$actual" != "$expected" ]]; then
89-
echo "fail! runtime: $RUNTIME - expected output $expected - got $actual"
90-
exit -1
91-
fi
64+
- aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/run_invocation_test.sh
9265
finally:
93-
- |
94-
echo "---------Container Logs: ${OS_DISTRIBUTION}-app----------"
95-
echo
96-
docker logs "${OS_DISTRIBUTION}-app" || true
97-
echo
98-
echo "---------------------------------------------------"
99-
echo "--------Container Logs: ${OS_DISTRIBUTION}-tester--------"
100-
echo
101-
docker logs "${OS_DISTRIBUTION}-tester" || true
102-
echo
103-
echo "---------------------------------------------------"
104-
- echo "Cleaning up..."
105-
- docker stop "${OS_DISTRIBUTION}-app" || true
106-
- docker rm --force "${OS_DISTRIBUTION}-app" || true
107-
- docker stop "${OS_DISTRIBUTION}-tester" || true
108-
- docker rm --force "${OS_DISTRIBUTION}-tester" || true
109-
- docker network rm "${OS_DISTRIBUTION}-network" || true
66+
- aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/fetch_test_container_logs.sh
67+
- aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/clean_up.sh

aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.amazonlinux.2.yml

+3-45
Original file line numberDiff line numberDiff line change
@@ -74,49 +74,7 @@ phases:
7474
--build-arg DISTRO_VERSION="${DISTRO_VERSION}"
7575
build:
7676
commands:
77-
- set -x
78-
- echo "Running Image ${IMAGE_TAG}"
79-
- docker network create "${OS_DISTRIBUTION}-network"
80-
- >
81-
docker run \
82-
--detach \
83-
--name "${OS_DISTRIBUTION}-app" \
84-
--network "${OS_DISTRIBUTION}-network" \
85-
--entrypoint="" \
86-
"${IMAGE_TAG}" \
87-
sh -c "/usr/bin/${RIE} ${JAVA_BINARY_LOCATION} -jar ./HelloWorld-1.0.jar helloworld.App"
88-
- sleep 2
89-
- >
90-
docker run \
91-
--name "${OS_DISTRIBUTION}-tester" \
92-
--env "TARGET=${OS_DISTRIBUTION}-app" \
93-
--network "${OS_DISTRIBUTION}-network" \
94-
--entrypoint="" \
95-
"${IMAGE_TAG}" \
96-
sh -c 'curl -X POST "http://${TARGET}:8080/2015-03-31/functions/function/invocations" -d "{}" --max-time 10'
97-
- actual="$(docker logs --tail 1 "${OS_DISTRIBUTION}-tester" | xargs)"
98-
- expected='success'
99-
- |
100-
echo "Response: ${actual}"
101-
if [[ "$actual" != "$expected" ]]; then
102-
echo "fail! runtime: $RUNTIME - expected output $expected - got $actual"
103-
exit -1
104-
fi
77+
- aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/run_invocation_test.sh
10578
finally:
106-
- |
107-
echo "---------Container Logs: ${OS_DISTRIBUTION}-app----------"
108-
echo
109-
docker logs "${OS_DISTRIBUTION}-app" || true
110-
echo
111-
echo "---------------------------------------------------"
112-
echo "--------Container Logs: ${OS_DISTRIBUTION}-tester--------"
113-
echo
114-
docker logs "${OS_DISTRIBUTION}-tester" || true
115-
echo
116-
echo "---------------------------------------------------"
117-
- echo "Cleaning up..."
118-
- docker stop "${OS_DISTRIBUTION}-app" || true
119-
- docker rm --force "${OS_DISTRIBUTION}-app" || true
120-
- docker stop "${OS_DISTRIBUTION}-tester" || true
121-
- docker rm --force "${OS_DISTRIBUTION}-tester" || true
122-
- docker network rm "${OS_DISTRIBUTION}-network" || true
79+
- aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/fetch_test_container_logs.sh
80+
- aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/clean_up.sh

aws-lambda-java-runtime-interface-client/test/integration/codebuild/buildspec.os.centos.yml

+3-45
Original file line numberDiff line numberDiff line change
@@ -74,49 +74,7 @@ phases:
7474
--build-arg DISTRO_VERSION="${DISTRO_VERSION}"
7575
build:
7676
commands:
77-
- set -x
78-
- echo "Running Image ${IMAGE_TAG}"
79-
- docker network create "${OS_DISTRIBUTION}-network"
80-
- >
81-
docker run \
82-
--detach \
83-
--name "${OS_DISTRIBUTION}-app" \
84-
--network "${OS_DISTRIBUTION}-network" \
85-
--entrypoint="" \
86-
"${IMAGE_TAG}" \
87-
sh -c "/usr/bin/${RIE} ${JAVA_BINARY_LOCATION} -jar ./HelloWorld-1.0.jar helloworld.App"
88-
- sleep 2
89-
- >
90-
docker run \
91-
--name "${OS_DISTRIBUTION}-tester" \
92-
--env "TARGET=${OS_DISTRIBUTION}-app" \
93-
--network "${OS_DISTRIBUTION}-network" \
94-
--entrypoint="" \
95-
"${IMAGE_TAG}" \
96-
sh -c 'curl -X POST "http://${TARGET}:8080/2015-03-31/functions/function/invocations" -d "{}" --max-time 10'
97-
- actual="$(docker logs --tail 1 "${OS_DISTRIBUTION}-tester" | xargs)"
98-
- expected='success'
99-
- |
100-
echo "Response: ${actual}"
101-
if [[ "$actual" != "$expected" ]]; then
102-
echo "fail! runtime: $RUNTIME - expected output $expected - got $actual"
103-
exit -1
104-
fi
77+
- aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/run_invocation_test.sh
10578
finally:
106-
- |
107-
echo "---------Container Logs: ${OS_DISTRIBUTION}-app----------"
108-
echo
109-
docker logs "${OS_DISTRIBUTION}-app" || true
110-
echo
111-
echo "---------------------------------------------------"
112-
echo "--------Container Logs: ${OS_DISTRIBUTION}-tester--------"
113-
echo
114-
docker logs "${OS_DISTRIBUTION}-tester" || true
115-
echo
116-
echo "---------------------------------------------------"
117-
- echo "Cleaning up..."
118-
- docker stop "${OS_DISTRIBUTION}-app" || true
119-
- docker rm --force "${OS_DISTRIBUTION}-app" || true
120-
- docker stop "${OS_DISTRIBUTION}-tester" || true
121-
- docker rm --force "${OS_DISTRIBUTION}-tester" || true
122-
- docker network rm "${OS_DISTRIBUTION}-network" || true
79+
- aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/fetch_test_container_logs.sh
80+
- aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/clean_up.sh

0 commit comments

Comments
 (0)