Skip to content

Events v4 serialization v2 #336

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ ___
'com.amazonaws:aws-lambda-java-tests:1.1.1'
```

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

```clojure
[com.amazonaws/aws-lambda-java-core "1.2.1"]
Expand Down
16 changes: 13 additions & 3 deletions aws-lambda-java-runtime-interface-client/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
x86_64_ALIAS := amd64
aarch64_ALIAS := arm64
ARCHITECTURE := $(shell arch)
ARCHITECTURE_ALIAS := $($(shell echo "$(ARCHITECTURE)_ALIAS"))
ARCHITECTURE_ALIAS := $(or $(ARCHITECTURE_ALIAS),amd64) # on any other archs defaulting to amd64

.PHONY: target
target:
$(info ${HELP_MESSAGE})
Expand All @@ -9,12 +15,16 @@ test:

.PHONY: setup-codebuild-agent
setup-codebuild-agent:
docker build -t codebuild-agent - < test/integration/codebuild-local/Dockerfile.agent
docker build -t codebuild-agent \
--build-arg ARCHITECTURE=$(ARCHITECTURE_ALIAS) \
- < test/integration/codebuild-local/Dockerfile.agent

.PHONY: test-smoke
test-smoke: setup-codebuild-agent
CODEBUILD_IMAGE_TAG=codebuild-agent test/integration/codebuild-local/test_one.sh test/integration/codebuild/buildspec.os.alpine.yml alpine 3.12 corretto11
CODEBUILD_IMAGE_TAG=codebuild-agent test/integration/codebuild-local/test_one.sh test/integration/codebuild/buildspec.os.amazoncorretto.yml amazoncorretto amazoncorretto 11
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
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
CODEBUILD_IMAGE_TAG=codebuild-agent test/integration/codebuild-local/test_one.sh test/integration/codebuild/buildspec.os.amazoncorretto.yml amazoncorretto amazoncorretto 11 linux/amd64
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

.PHONY: test-integ
test-integ: setup-codebuild-agent
Expand Down
2 changes: 1 addition & 1 deletion aws-lambda-java-runtime-interface-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The Runtime Interface Client library can be installed into the image separate fr
Dockerfile
```dockerfile
# we'll use Amazon Linux 2 + Corretto 11 as our base
FROM amazoncorretto:11 as base
FROM public.ecr.aws/amazoncorretto/amazoncorretto:11 as base

# configure the build environment
FROM base as build
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
*/
public class ClasspathLoader {

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

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

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

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

if(BLACKLIST.contains(name)) {
if(BLOCKLIST.contains(name)) {
continue;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# we use centos 7 to build against glibc 2.17
FROM centos:7
FROM public.ecr.aws/docker/library/centos:7

ARG CURL_VERSION

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM alpine:3
FROM public.ecr.aws/docker/library/alpine:3

ARG CURL_VERSION

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set -euo pipefail
SRC_DIR=$(dirname "$0")
DST_DIR=${1}
MULTI_ARCH=${2}
CURL_VERSION=7.77.0
CURL_VERSION=7.83.0

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

ARG ARCHITECTURE="amd64"

ENV DOCKER_CLI_PLUGIN_DIR="/root/.docker/cli-plugins"

RUN amazon-linux-extras enable docker && \
yum clean metadata && \
yum install -y docker tar maven unzip file
yum install -y docker tar maven unzip file wget
RUN mkdir -p "${DOCKER_CLI_PLUGIN_DIR}"
RUN wget \
"$(curl https://api.github.com/repos/docker/buildx/releases/latest | grep browser_download_url | grep "linux-${ARCHITECTURE}" | cut -d '"' -f 4)" \
-O "${DOCKER_CLI_PLUGIN_DIR}"/docker-buildx
RUN chmod +x "${DOCKER_CLI_PLUGIN_DIR}"/docker-buildx
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,19 @@ do_one_yaml() {

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

for DISTRO_VERSION in $DISTRO_VERSIONS ; do
for RUNTIME_VERSION in $RUNTIME_VERSIONS ; do
if (( DRYRUN == 1 )) ; then
echo DRYRUN test_one_combination "$YML" "$OS_DISTRIBUTION" "$DISTRO_VERSION" "$RUNTIME_VERSION"
else
test_one_combination "$YML" "$OS_DISTRIBUTION" "$DISTRO_VERSION" "$RUNTIME_VERSION"
fi
for DISTRO_VERSION in $DISTRO_VERSIONS; do
for RUNTIME_VERSION in $RUNTIME_VERSIONS; do
for PLATFORM in $PLATFORMS; do
if (( DRYRUN == 1 )); then
echo DRYRUN test_one_combination "$YML" "$OS_DISTRIBUTION" "$DISTRO_VERSION" "$RUNTIME_VERSION" "$PLATFORM"
else
test_one_combination "$YML" "$OS_DISTRIBUTION" "$DISTRO_VERSION" "$RUNTIME_VERSION" "$PLATFORM"
fi
done
done
done
}

Expand All @@ -36,13 +39,15 @@ test_one_combination() {
local -r OS_DISTRIBUTION="$2"
local -r DISTRO_VERSION="$3"
local -r RUNTIME_VERSION="$4"

local -r PLATFORM="$5"
local -r PLATFORM_SANITIZED=$(echo "$PLATFORM" | tr "/" ".")

echo Testing:
echo " BUILDSPEC" "$YML"
echo " with" "$OS_DISTRIBUTION"-"$DISTRO_VERSION" "$RUNTIME_VERSION"
echo " with" "$OS_DISTRIBUTION"-"$DISTRO_VERSION" "$RUNTIME_VERSION" "$PLATFORM"

"$(dirname "$0")"/test_one.sh "$YML" "$OS_DISTRIBUTION" "$DISTRO_VERSION" "$RUNTIME_VERSION" \
> >(sed "s/^/$OS_DISTRIBUTION$DISTRO_VERSION-$RUNTIME_VERSION: /") 2> >(sed "s/^/$OS_DISTRIBUTION-$DISTRO_VERSION:$RUNTIME_VERSION: /" >&2)
"$(dirname "$0")"/test_one.sh "$YML" "$OS_DISTRIBUTION" "$DISTRO_VERSION" "$RUNTIME_VERSION" "$PLATFORM" \
> >(sed "s/^/$OS_DISTRIBUTION$DISTRO_VERSION-$RUNTIME_VERSION-$PLATFORM_SANITIZED: /") 2> >(sed "s/^/$OS_DISTRIBUTION-$DISTRO_VERSION:$RUNTIME_VERSION:$PLATFORM_SANITIZED: /" >&2)
}

main() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ function usage {
>&2 echo " os_distribution Used to specify the OS distribution to build."
>&2 echo " distro_version Used to specify the distro version of <os_distribution>."
>&2 echo " runtime_version Used to specify the runtime version to test on the selected <distro_version>."
>&2 echo " platform Used to specify the architecture platform to test on the selected <distro_version>."
>&2 echo "Optional:"
>&2 echo " env Additional environment variables file."
}

main() {
if (( $# != 3 && $# != 4)); then
if (( $# != 5 && $# != 6)); then
>&2 echo "Invalid number of parameters."
usage
exit 1
Expand All @@ -28,9 +29,11 @@ main() {
OS_DISTRIBUTION="$2"
DISTRO_VERSION="$3"
RUNTIME_VERSION="$4"
EXTRA_ENV="${5-}"
PLATFORM="$5"
PLATFORM_SANITIZED=$(echo "$PLATFORM" | tr "/" ".")
EXTRA_ENV="${6-}"

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

# Create an env file for codebuild_build.
Expand All @@ -43,6 +46,7 @@ main() {
echo "OS_DISTRIBUTION=$OS_DISTRIBUTION"
echo "DISTRO_VERSION=$DISTRO_VERSION"
echo "RUNTIME_VERSION=$RUNTIME_VERSION"
echo "PLATFORM=$PLATFORM"
} >> "$ENVFILE"

ARTIFACTS_DIR="$CODEBUILD_TEMP_DIR/artifacts"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ env:
variables:
OS_DISTRIBUTION: alpine
JAVA_BINARY_LOCATION: "/usr/bin/java"
DOCKER_CLI_EXPERIMENTAL: "enabled"
DOCKER_CLI_PLUGIN_DIR: "/root/.docker/cli-plugins"
batch:
build-matrix:
static:
Expand All @@ -14,12 +16,14 @@ batch:
env:
variables:
DISTRO_VERSION:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.13"
- "3.14"
- "3.15"
RUNTIME_VERSION:
- "corretto11"
PLATFORM:
- "linux/amd64"
- "linux/arm64/v8"
phases:
install:
commands:
Expand All @@ -31,6 +35,7 @@ phases:
echo "Performing DockerHub login . . ."
docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD
fi
- aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/configure_multi_arch_env.sh
pre_build:
commands:
# Log some environment variables for troubleshooting
Expand All @@ -39,20 +44,19 @@ phases:
- (cd aws-lambda-java-events && mvn install)
# Install serialization (dependency of RIC)
- (cd aws-lambda-java-serialization && mvn install)
- (cd aws-lambda-java-runtime-interface-client && mvn install -DmultiArch=false)
- (cd aws-lambda-java-runtime-interface-client && mvn install)
- (cd aws-lambda-java-runtime-interface-client/test/integration/test-handler && mvn install)
- export IMAGE_TAG="java-${OS_DISTRIBUTION}-${DISTRO_VERSION}:${RUNTIME_VERSION}"
- echo "Extracting and including Runtime Interface Emulator"
- SCRATCH_DIR=".scratch"
- mkdir "${SCRATCH_DIR}"
- ARCHITECTURE=$(arch)
- >
if [[ "$ARCHITECTURE" == "x86_64" ]]; then
if [[ "$PLATFORM" == "linux/amd64" ]]; then
RIE="aws-lambda-rie"
elif [[ "$ARCHITECTURE" == "aarch64" ]]; then
elif [[ "$PLATFORM" == "linux/arm64/v8" ]]; then
RIE="aws-lambda-rie-arm64"
else
echo "Architecture $ARCHITECTURE is not currently supported."
echo "Platform $PLATFORM is not currently supported."
exit 1
fi
- tar -xvf aws-lambda-java-runtime-interface-client/test/integration/resources/${RIE}.tar.gz --directory "${SCRATCH_DIR}"
Expand All @@ -70,6 +74,7 @@ phases:
docker build . \
-f "${SCRATCH_DIR}/Dockerfile.function.${OS_DISTRIBUTION}.tmp" \
-t "${IMAGE_TAG}" \
--platform="${PLATFORM}" \
--build-arg RUNTIME_VERSION="${RUNTIME_VERSION}" \
--build-arg DISTRO_VERSION="${DISTRO_VERSION}"
build:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ env:
variables:
OS_DISTRIBUTION: amazoncorretto
JAVA_BINARY_LOCATION: "/usr/bin/java"
DOCKER_CLI_EXPERIMENTAL: "enabled"
DOCKER_CLI_PLUGIN_DIR: "/root/.docker/cli-plugins"
batch:
build-matrix:
static:
Expand All @@ -18,6 +20,9 @@ batch:
RUNTIME_VERSION:
- "8"
- "11"
PLATFORM:
- "linux/amd64"
- "linux/arm64/v8"
phases:
install:
commands:
Expand All @@ -29,6 +34,7 @@ phases:
echo "Performing DockerHub login . . ."
docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD
fi
- aws-lambda-java-runtime-interface-client/test/integration/codebuild/scripts/configure_multi_arch_env.sh
pre_build:
commands:
# Log some environment variables for troubleshooting
Expand All @@ -37,20 +43,19 @@ phases:
- (cd aws-lambda-java-events && mvn install)
# Install serialization (dependency of RIC)
- (cd aws-lambda-java-serialization && mvn install)
- (cd aws-lambda-java-runtime-interface-client && mvn install -DmultiArch=false)
- (cd aws-lambda-java-runtime-interface-client && mvn install)
- (cd aws-lambda-java-runtime-interface-client/test/integration/test-handler && mvn install)
- export IMAGE_TAG="java-${OS_DISTRIBUTION}-${DISTRO_VERSION}:${RUNTIME_VERSION}"
- echo "Extracting and including Runtime Interface Emulator"
- SCRATCH_DIR=".scratch"
- mkdir "${SCRATCH_DIR}"
- ARCHITECTURE=$(arch)
- >
if [[ "$ARCHITECTURE" == "x86_64" ]]; then
if [[ "$PLATFORM" == "linux/amd64" ]]; then
RIE="aws-lambda-rie"
elif [[ "$ARCHITECTURE" == "aarch64" ]]; then
elif [[ "$PLATFORM" == "linux/arm64/v8" ]]; then
RIE="aws-lambda-rie-arm64"
else
echo "Architecture $ARCHITECTURE is not currently supported."
echo "Platform $PLATFORM is not currently supported."
exit 1
fi
- tar -xvf aws-lambda-java-runtime-interface-client/test/integration/resources/${RIE}.tar.gz --directory "${SCRATCH_DIR}"
Expand All @@ -65,6 +70,7 @@ phases:
docker build . \
-f "${SCRATCH_DIR}/Dockerfile.function.${OS_DISTRIBUTION}.tmp" \
-t "${IMAGE_TAG}" \
--platform="${PLATFORM}" \
--build-arg RUNTIME_VERSION="${RUNTIME_VERSION}" \
--build-arg DISTRO_VERSION="${DISTRO_VERSION}"
build:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ batch:
- "1"
RUNTIME_VERSION:
- "openjdk8"
PLATFORM:
- "linux/amd64"
phases:
install:
commands:
Expand All @@ -36,22 +38,13 @@ phases:
- (cd aws-lambda-java-events && mvn install)
# Install serialization (dependency of RIC)
- (cd aws-lambda-java-serialization && mvn install)
- (cd aws-lambda-java-runtime-interface-client && mvn install)
- (cd aws-lambda-java-runtime-interface-client && mvn install -DmultiArch=false)
- (cd aws-lambda-java-runtime-interface-client/test/integration/test-handler && mvn install)
- export IMAGE_TAG="java-${OS_DISTRIBUTION}-${DISTRO_VERSION}:${RUNTIME_VERSION}"
- echo "Extracting and including 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
- RIE="aws-lambda-rie"
- tar -xvf aws-lambda-java-runtime-interface-client/test/integration/resources/${RIE}.tar.gz --directory "${SCRATCH_DIR}"
- >
cp "aws-lambda-java-runtime-interface-client/test/integration/docker/Dockerfile.function.${OS_DISTRIBUTION}" \
Expand Down
Loading