Skip to content

Commit 5ce0f33

Browse files
authored
Merge pull request #336 from andclt/events-v4-serialization-v2
Events v4 serialization v2
2 parents d8deb6b + 61653bf commit 5ce0f33

25 files changed

+164
-77
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ ___
7373
'com.amazonaws:aws-lambda-java-tests:1.1.1'
7474
```
7575

76-
[Leiningen](http://leiningen.org) and [Boot](http://boot-clj.com)
76+
[Leiningen](http://leiningen.org)
7777

7878
```clojure
7979
[com.amazonaws/aws-lambda-java-core "1.2.1"]

aws-lambda-java-runtime-interface-client/Makefile

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
x86_64_ALIAS := amd64
2+
aarch64_ALIAS := arm64
3+
ARCHITECTURE := $(shell arch)
4+
ARCHITECTURE_ALIAS := $($(shell echo "$(ARCHITECTURE)_ALIAS"))
5+
ARCHITECTURE_ALIAS := $(or $(ARCHITECTURE_ALIAS),amd64) # on any other archs defaulting to amd64
6+
17
.PHONY: target
28
target:
39
$(info ${HELP_MESSAGE})
@@ -9,12 +15,16 @@ test:
915

1016
.PHONY: setup-codebuild-agent
1117
setup-codebuild-agent:
12-
docker build -t codebuild-agent - < test/integration/codebuild-local/Dockerfile.agent
18+
docker build -t codebuild-agent \
19+
--build-arg ARCHITECTURE=$(ARCHITECTURE_ALIAS) \
20+
- < test/integration/codebuild-local/Dockerfile.agent
1321

1422
.PHONY: test-smoke
1523
test-smoke: setup-codebuild-agent
16-
CODEBUILD_IMAGE_TAG=codebuild-agent test/integration/codebuild-local/test_one.sh test/integration/codebuild/buildspec.os.alpine.yml alpine 3.12 corretto11
17-
CODEBUILD_IMAGE_TAG=codebuild-agent test/integration/codebuild-local/test_one.sh test/integration/codebuild/buildspec.os.amazoncorretto.yml amazoncorretto amazoncorretto 11
24+
CODEBUILD_IMAGE_TAG=codebuild-agent test/integration/codebuild-local/test_one.sh test/integration/codebuild/buildspec.os.alpine.yml alpine 3.15 corretto11 linux/amd64
25+
CODEBUILD_IMAGE_TAG=codebuild-agent test/integration/codebuild-local/test_one.sh test/integration/codebuild/buildspec.os.alpine.yml alpine 3.15 corretto11 linux/arm64/v8
26+
CODEBUILD_IMAGE_TAG=codebuild-agent test/integration/codebuild-local/test_one.sh test/integration/codebuild/buildspec.os.amazoncorretto.yml amazoncorretto amazoncorretto 11 linux/amd64
27+
CODEBUILD_IMAGE_TAG=codebuild-agent test/integration/codebuild-local/test_one.sh test/integration/codebuild/buildspec.os.amazoncorretto.yml amazoncorretto amazoncorretto 11 linux/arm64/v8
1828

1929
.PHONY: test-integ
2030
test-integ: setup-codebuild-agent

aws-lambda-java-runtime-interface-client/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ The Runtime Interface Client library can be installed into the image separate fr
2424
Dockerfile
2525
```dockerfile
2626
# we'll use Amazon Linux 2 + Corretto 11 as our base
27-
FROM amazoncorretto:11 as base
27+
FROM public.ecr.aws/amazoncorretto/amazoncorretto:11 as base
2828

2929
# configure the build environment
3030
FROM base as build

aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/runtime/api/client/ClasspathLoader.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
*/
2020
public class ClasspathLoader {
2121

22-
private static final Set<String> BLACKLIST = new HashSet<>();
22+
private static final Set<String> BLOCKLIST = new HashSet<>();
2323
private static final ClassLoader SYSTEM_CLASS_LOADER = ClassLoader.getSystemClassLoader();
2424
private static final int CLASS_SUFFIX_LEN = ".class".length();
2525

2626
static {
2727
// NativeClient loads a native library and crashes if loaded here so just exclude it
28-
BLACKLIST.add("lambdainternal.runtimeapi.NativeClient");
28+
BLOCKLIST.add("com.amazonaws.services.lambda.runtime.api.client.runtimeapi.NativeClient");
2929
}
3030

3131
private static String pathToClassName(final String path) {
@@ -52,7 +52,7 @@ private static void loadClassesInJar(File file) throws IOException {
5252

5353
String name = pathToClassName(entry.getName());
5454

55-
if(BLACKLIST.contains(name)) {
55+
if(BLOCKLIST.contains(name)) {
5656
continue;
5757
}
5858

aws-lambda-java-runtime-interface-client/src/main/jni/Dockerfile.glibc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# we use centos 7 to build against glibc 2.17
2-
FROM centos:7
2+
FROM public.ecr.aws/docker/library/centos:7
33

44
ARG CURL_VERSION
55

aws-lambda-java-runtime-interface-client/src/main/jni/Dockerfile.musl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM alpine:3
1+
FROM public.ecr.aws/docker/library/alpine:3
22

33
ARG CURL_VERSION
44

aws-lambda-java-runtime-interface-client/src/main/jni/build-jni-lib.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ set -euo pipefail
66
SRC_DIR=$(dirname "$0")
77
DST_DIR=${1}
88
MULTI_ARCH=${2}
9-
CURL_VERSION=7.77.0
9+
CURL_VERSION=7.83.0
1010

1111
# Not using associative arrays to maintain bash 3 compatibility with building on MacOS
1212
# MacOS ships with bash 3 and associative arrays require bash 4+
Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
FROM public.ecr.aws/amazoncorretto/amazoncorretto:8
22

3+
ARG ARCHITECTURE="amd64"
4+
5+
ENV DOCKER_CLI_PLUGIN_DIR="/root/.docker/cli-plugins"
6+
37
RUN amazon-linux-extras enable docker && \
48
yum clean metadata && \
5-
yum install -y docker tar maven unzip file
9+
yum install -y docker tar maven unzip file wget
10+
RUN mkdir -p "${DOCKER_CLI_PLUGIN_DIR}"
11+
RUN wget \
12+
"$(curl https://api.github.com/repos/docker/buildx/releases/latest | grep browser_download_url | grep "linux-${ARCHITECTURE}" | cut -d '"' -f 4)" \
13+
-O "${DOCKER_CLI_PLUGIN_DIR}"/docker-buildx
14+
RUN chmod +x "${DOCKER_CLI_PLUGIN_DIR}"/docker-buildx

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

+17-12
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,19 @@ do_one_yaml() {
1818

1919
OS_DISTRIBUTION=$(grep -oE 'OS_DISTRIBUTION:\s*(\S+)' "$YML" | cut -d' ' -f2)
2020
DISTRO_VERSIONS=$(sed '1,/DISTRO_VERSION/d;/RUNTIME_VERSION/,$d' "$YML" | tr -d '\-" ')
21-
RUNTIME_VERSIONS=$(sed '1,/RUNTIME_VERSION/d;/phases/,$d' "$YML" | sed '/#.*$/d' | tr -d '\-" ')
21+
RUNTIME_VERSIONS=$(sed '1,/RUNTIME_VERSION/d;/PLATFORM/,$d' "$YML" | sed '/#.*$/d' | tr -d '\-" ')
22+
PLATFORMS=$(sed '1,/PLATFORM/d;/phases/,$d' "$YML" | tr -d '\-" ')
2223

23-
for DISTRO_VERSION in $DISTRO_VERSIONS ; do
24-
for RUNTIME_VERSION in $RUNTIME_VERSIONS ; do
25-
if (( DRYRUN == 1 )) ; then
26-
echo DRYRUN test_one_combination "$YML" "$OS_DISTRIBUTION" "$DISTRO_VERSION" "$RUNTIME_VERSION"
27-
else
28-
test_one_combination "$YML" "$OS_DISTRIBUTION" "$DISTRO_VERSION" "$RUNTIME_VERSION"
29-
fi
24+
for DISTRO_VERSION in $DISTRO_VERSIONS; do
25+
for RUNTIME_VERSION in $RUNTIME_VERSIONS; do
26+
for PLATFORM in $PLATFORMS; do
27+
if (( DRYRUN == 1 )); then
28+
echo DRYRUN test_one_combination "$YML" "$OS_DISTRIBUTION" "$DISTRO_VERSION" "$RUNTIME_VERSION" "$PLATFORM"
29+
else
30+
test_one_combination "$YML" "$OS_DISTRIBUTION" "$DISTRO_VERSION" "$RUNTIME_VERSION" "$PLATFORM"
31+
fi
3032
done
33+
done
3134
done
3235
}
3336

@@ -36,13 +39,15 @@ test_one_combination() {
3639
local -r OS_DISTRIBUTION="$2"
3740
local -r DISTRO_VERSION="$3"
3841
local -r RUNTIME_VERSION="$4"
39-
42+
local -r PLATFORM="$5"
43+
local -r PLATFORM_SANITIZED=$(echo "$PLATFORM" | tr "/" ".")
44+
4045
echo Testing:
4146
echo " BUILDSPEC" "$YML"
42-
echo " with" "$OS_DISTRIBUTION"-"$DISTRO_VERSION" "$RUNTIME_VERSION"
47+
echo " with" "$OS_DISTRIBUTION"-"$DISTRO_VERSION" "$RUNTIME_VERSION" "$PLATFORM"
4348

44-
"$(dirname "$0")"/test_one.sh "$YML" "$OS_DISTRIBUTION" "$DISTRO_VERSION" "$RUNTIME_VERSION" \
45-
> >(sed "s/^/$OS_DISTRIBUTION$DISTRO_VERSION-$RUNTIME_VERSION: /") 2> >(sed "s/^/$OS_DISTRIBUTION-$DISTRO_VERSION:$RUNTIME_VERSION: /" >&2)
49+
"$(dirname "$0")"/test_one.sh "$YML" "$OS_DISTRIBUTION" "$DISTRO_VERSION" "$RUNTIME_VERSION" "$PLATFORM" \
50+
> >(sed "s/^/$OS_DISTRIBUTION$DISTRO_VERSION-$RUNTIME_VERSION-$PLATFORM_SANITIZED: /") 2> >(sed "s/^/$OS_DISTRIBUTION-$DISTRO_VERSION:$RUNTIME_VERSION:$PLATFORM_SANITIZED: /" >&2)
4651
}
4752

4853
main() {

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

+7-3
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ function usage {
1313
>&2 echo " os_distribution Used to specify the OS distribution to build."
1414
>&2 echo " distro_version Used to specify the distro version of <os_distribution>."
1515
>&2 echo " runtime_version Used to specify the runtime version to test on the selected <distro_version>."
16+
>&2 echo " platform Used to specify the architecture platform to test on the selected <distro_version>."
1617
>&2 echo "Optional:"
1718
>&2 echo " env Additional environment variables file."
1819
}
1920

2021
main() {
21-
if (( $# != 3 && $# != 4)); then
22+
if (( $# != 5 && $# != 6)); then
2223
>&2 echo "Invalid number of parameters."
2324
usage
2425
exit 1
@@ -28,9 +29,11 @@ main() {
2829
OS_DISTRIBUTION="$2"
2930
DISTRO_VERSION="$3"
3031
RUNTIME_VERSION="$4"
31-
EXTRA_ENV="${5-}"
32+
PLATFORM="$5"
33+
PLATFORM_SANITIZED=$(echo "$PLATFORM" | tr "/" ".")
34+
EXTRA_ENV="${6-}"
3235

33-
CODEBUILD_TEMP_DIR=$(mktemp -d codebuild."$OS_DISTRIBUTION"-"$DISTRO_VERSION"-"$RUNTIME_VERSION".XXXXXXXXXX)
36+
CODEBUILD_TEMP_DIR=$(mktemp -d codebuild."$OS_DISTRIBUTION"-"$DISTRO_VERSION"-"$RUNTIME_VERSION"-"$PLATFORM_SANITIZED".XXXXXXXXXX)
3437
trap 'rm -rf $CODEBUILD_TEMP_DIR' EXIT
3538

3639
# Create an env file for codebuild_build.
@@ -43,6 +46,7 @@ main() {
4346
echo "OS_DISTRIBUTION=$OS_DISTRIBUTION"
4447
echo "DISTRO_VERSION=$DISTRO_VERSION"
4548
echo "RUNTIME_VERSION=$RUNTIME_VERSION"
49+
echo "PLATFORM=$PLATFORM"
4650
} >> "$ENVFILE"
4751

4852
ARTIFACTS_DIR="$CODEBUILD_TEMP_DIR/artifacts"

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

+14-9
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ env:
44
variables:
55
OS_DISTRIBUTION: alpine
66
JAVA_BINARY_LOCATION: "/usr/bin/java"
7+
DOCKER_CLI_EXPERIMENTAL: "enabled"
8+
DOCKER_CLI_PLUGIN_DIR: "/root/.docker/cli-plugins"
79
batch:
810
build-matrix:
911
static:
@@ -14,12 +16,14 @@ batch:
1416
env:
1517
variables:
1618
DISTRO_VERSION:
17-
- "3.9"
18-
- "3.10"
19-
- "3.11"
20-
- "3.12"
19+
- "3.13"
20+
- "3.14"
21+
- "3.15"
2122
RUNTIME_VERSION:
2223
- "corretto11"
24+
PLATFORM:
25+
- "linux/amd64"
26+
- "linux/arm64/v8"
2327
phases:
2428
install:
2529
commands:
@@ -31,6 +35,7 @@ phases:
3135
echo "Performing DockerHub login . . ."
3236
docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD
3337
fi
38+
- aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/configure_multi_arch_env.sh
3439
pre_build:
3540
commands:
3641
# Log some environment variables for troubleshooting
@@ -39,20 +44,19 @@ phases:
3944
- (cd aws-lambda-java-events && mvn install)
4045
# Install serialization (dependency of RIC)
4146
- (cd aws-lambda-java-serialization && mvn install)
42-
- (cd aws-lambda-java-runtime-interface-client && mvn install -DmultiArch=false)
47+
- (cd aws-lambda-java-runtime-interface-client && mvn install)
4348
- (cd aws-lambda-java-runtime-interface-client/test/integration/test-handler && mvn install)
4449
- export IMAGE_TAG="java-${OS_DISTRIBUTION}-${DISTRO_VERSION}:${RUNTIME_VERSION}"
4550
- echo "Extracting and including Runtime Interface Emulator"
4651
- SCRATCH_DIR=".scratch"
4752
- mkdir "${SCRATCH_DIR}"
48-
- ARCHITECTURE=$(arch)
4953
- >
50-
if [[ "$ARCHITECTURE" == "x86_64" ]]; then
54+
if [[ "$PLATFORM" == "linux/amd64" ]]; then
5155
RIE="aws-lambda-rie"
52-
elif [[ "$ARCHITECTURE" == "aarch64" ]]; then
56+
elif [[ "$PLATFORM" == "linux/arm64/v8" ]]; then
5357
RIE="aws-lambda-rie-arm64"
5458
else
55-
echo "Architecture $ARCHITECTURE is not currently supported."
59+
echo "Platform $PLATFORM is not currently supported."
5660
exit 1
5761
fi
5862
- tar -xvf aws-lambda-java-runtime-interface-client/test/integration/resources/${RIE}.tar.gz --directory "${SCRATCH_DIR}"
@@ -70,6 +74,7 @@ phases:
7074
docker build . \
7175
-f "${SCRATCH_DIR}/Dockerfile.function.${OS_DISTRIBUTION}.tmp" \
7276
-t "${IMAGE_TAG}" \
77+
--platform="${PLATFORM}" \
7378
--build-arg RUNTIME_VERSION="${RUNTIME_VERSION}" \
7479
--build-arg DISTRO_VERSION="${DISTRO_VERSION}"
7580
build:

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

+11-5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ env:
44
variables:
55
OS_DISTRIBUTION: amazoncorretto
66
JAVA_BINARY_LOCATION: "/usr/bin/java"
7+
DOCKER_CLI_EXPERIMENTAL: "enabled"
8+
DOCKER_CLI_PLUGIN_DIR: "/root/.docker/cli-plugins"
79
batch:
810
build-matrix:
911
static:
@@ -18,6 +20,9 @@ batch:
1820
RUNTIME_VERSION:
1921
- "8"
2022
- "11"
23+
PLATFORM:
24+
- "linux/amd64"
25+
- "linux/arm64/v8"
2126
phases:
2227
install:
2328
commands:
@@ -29,6 +34,7 @@ phases:
2934
echo "Performing DockerHub login . . ."
3035
docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD
3136
fi
37+
- aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/configure_multi_arch_env.sh
3238
pre_build:
3339
commands:
3440
# Log some environment variables for troubleshooting
@@ -37,20 +43,19 @@ phases:
3743
- (cd aws-lambda-java-events && mvn install)
3844
# Install serialization (dependency of RIC)
3945
- (cd aws-lambda-java-serialization && mvn install)
40-
- (cd aws-lambda-java-runtime-interface-client && mvn install -DmultiArch=false)
46+
- (cd aws-lambda-java-runtime-interface-client && mvn install)
4147
- (cd aws-lambda-java-runtime-interface-client/test/integration/test-handler && mvn install)
4248
- export IMAGE_TAG="java-${OS_DISTRIBUTION}-${DISTRO_VERSION}:${RUNTIME_VERSION}"
4349
- echo "Extracting and including Runtime Interface Emulator"
4450
- SCRATCH_DIR=".scratch"
4551
- mkdir "${SCRATCH_DIR}"
46-
- ARCHITECTURE=$(arch)
4752
- >
48-
if [[ "$ARCHITECTURE" == "x86_64" ]]; then
53+
if [[ "$PLATFORM" == "linux/amd64" ]]; then
4954
RIE="aws-lambda-rie"
50-
elif [[ "$ARCHITECTURE" == "aarch64" ]]; then
55+
elif [[ "$PLATFORM" == "linux/arm64/v8" ]]; then
5156
RIE="aws-lambda-rie-arm64"
5257
else
53-
echo "Architecture $ARCHITECTURE is not currently supported."
58+
echo "Platform $PLATFORM is not currently supported."
5459
exit 1
5560
fi
5661
- tar -xvf aws-lambda-java-runtime-interface-client/test/integration/resources/${RIE}.tar.gz --directory "${SCRATCH_DIR}"
@@ -65,6 +70,7 @@ phases:
6570
docker build . \
6671
-f "${SCRATCH_DIR}/Dockerfile.function.${OS_DISTRIBUTION}.tmp" \
6772
-t "${IMAGE_TAG}" \
73+
--platform="${PLATFORM}" \
6874
--build-arg RUNTIME_VERSION="${RUNTIME_VERSION}" \
6975
--build-arg DISTRO_VERSION="${DISTRO_VERSION}"
7076
build:

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

+4-11
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ batch:
1717
- "1"
1818
RUNTIME_VERSION:
1919
- "openjdk8"
20+
PLATFORM:
21+
- "linux/amd64"
2022
phases:
2123
install:
2224
commands:
@@ -36,22 +38,13 @@ phases:
3638
- (cd aws-lambda-java-events && mvn install)
3739
# Install serialization (dependency of RIC)
3840
- (cd aws-lambda-java-serialization && mvn install)
39-
- (cd aws-lambda-java-runtime-interface-client && mvn install)
41+
- (cd aws-lambda-java-runtime-interface-client && mvn install -DmultiArch=false)
4042
- (cd aws-lambda-java-runtime-interface-client/test/integration/test-handler && mvn install)
4143
- export IMAGE_TAG="java-${OS_DISTRIBUTION}-${DISTRO_VERSION}:${RUNTIME_VERSION}"
4244
- echo "Extracting and including Runtime Interface Emulator"
4345
- SCRATCH_DIR=".scratch"
4446
- mkdir "${SCRATCH_DIR}"
45-
- ARCHITECTURE=$(arch)
46-
- >
47-
if [[ "$ARCHITECTURE" == "x86_64" ]]; then
48-
RIE="aws-lambda-rie"
49-
elif [[ "$ARCHITECTURE" == "aarch64" ]]; then
50-
RIE="aws-lambda-rie-arm64"
51-
else
52-
echo "Architecture $ARCHITECTURE is not currently supported."
53-
exit 1
54-
fi
47+
- RIE="aws-lambda-rie"
5548
- tar -xvf aws-lambda-java-runtime-interface-client/test/integration/resources/${RIE}.tar.gz --directory "${SCRATCH_DIR}"
5649
- >
5750
cp "aws-lambda-java-runtime-interface-client/test/integration/docker/Dockerfile.function.${OS_DISTRIBUTION}" \

0 commit comments

Comments
 (0)