Skip to content
Open
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
32 changes: 24 additions & 8 deletions .github/workflows/test-on-push-and-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,30 @@ on:
branches: [ '*' ]

jobs:
build:

unit_test:
runs-on: ubuntu-latest
strategy:
matrix:
ruby_version: [3.2, 3.3]
steps:
- uses: actions/checkout@v2
- name: Set up ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby_version }}
- name: Run unit tests
run: |
make init test-unit


integration_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
- name: Run 'pr' target
run: make pr
- uses: actions/checkout@v2
- name: Set up ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2
- name: Run 'pr' target
run: make pr
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ test/examples/hello-world-docker/pkg
*.iml
.DS_Store
Gemfile.lock
codebuild.*/
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ setup-codebuild-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.1.yml alpine 3.12 2.7
CODEBUILD_IMAGE_TAG=codebuild-agent test/integration/codebuild-local/test_one.sh test/integration/codebuild/buildspec.os.alpine.yml alpine 3.20 3.2
CODEBUILD_IMAGE_TAG=codebuild-agent test/integration/codebuild-local/test_one.sh test/integration/codebuild/buildspec.os.alpine.yml alpine 3.20 3.3

.PHONY: test-unit
test-unit:
Expand All @@ -28,7 +29,7 @@ build:
rake build

.PHONY: pr
pr: init test-unit test-smoke
pr: init test-smoke test-integ

define HELP_MESSAGE

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ batch:
env:
variables:
DISTRO_VERSION:
- "3.11"
- "3.19"
- "3.20"
RUNTIME_VERSION:
- "2.5"
- "2.6"
- "2.7"
- "3.2"
- "3.3"
phases:
pre_build:
commands:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ batch:
DISTRO_VERSION:
- "2"
RUNTIME_VERSION:
- "2.5"
- "2.6"
- "2.7"
- "3.0"
- "3.2"
phases:
pre_build:
commands:
Expand All @@ -40,7 +37,7 @@ phases:
fi
- tar -xvf test/integration/resources/${RIE}.tar.gz --directory "${SCRATCH_DIR}"
- >
cp "test/integration/docker/Dockerfile.echo.${OS_DISTRIBUTION}" \
cp "test/integration/docker/Dockerfile.echo.${OS_DISTRIBUTION}${DISTRO_VERSION}" \
"${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp"
- >
echo "COPY ${SCRATCH_DIR}/${RIE} /usr/bin/${RIE}" >> \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ version: 0.2

env:
variables:
OS_DISTRIBUTION: alpine
EXECUTABLE: "/usr/local/bundle/bin/aws_lambda_ric"
TEST_NAME: "aws-lambda-ruby-ric-alpine-test"
OS_DISTRIBUTION: amazonlinux
EXECUTABLE: "/usr/local/bin/aws_lambda_ric"
TEST_NAME: "aws-lambda-ruby-ric-amazonlinux-test"
batch:
build-matrix:
static:
Expand All @@ -15,12 +15,9 @@ batch:
env:
variables:
DISTRO_VERSION:
- "3.12"
- "2023"
RUNTIME_VERSION:
- "2.5"
- "2.6"
- "2.7"
- "3.0"
- "3.3"
phases:
pre_build:
commands:
Expand All @@ -40,10 +37,7 @@ phases:
fi
- tar -xvf test/integration/resources/${RIE}.tar.gz --directory "${SCRATCH_DIR}"
- >
cp "test/integration/docker/Dockerfile.echo.${OS_DISTRIBUTION}" \
"${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp"
- >
echo "RUN apk add curl" >> \
cp "test/integration/docker/Dockerfile.echo.${OS_DISTRIBUTION}${DISTRO_VERSION}" \
"${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp"
- >
echo "COPY ${SCRATCH_DIR}/${RIE} /usr/bin/${RIE}" >> \
Expand Down
8 changes: 3 additions & 5 deletions test/integration/codebuild/buildspec.os.centos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ batch:
env:
variables:
DISTRO_VERSION:
- "7"
- "8"
RUNTIME_VERSION:
- "2.7"
- "2.6"
- "2.5"
- "3.0"
- "3.2"
- "3.3"
phases:
pre_build:
commands:
Expand Down
8 changes: 3 additions & 5 deletions test/integration/codebuild/buildspec.os.debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ batch:
env:
variables:
DISTRO_VERSION:
- "buster"
- "bookworm"
RUNTIME_VERSION:
- "2.5"
- "2.6"
- "2.7"
- "3.0"
- "3.2"
- "3.3"
phases:
pre_build:
commands:
Expand Down
9 changes: 4 additions & 5 deletions test/integration/codebuild/buildspec.os.ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@ batch:
env:
variables:
DISTRO_VERSION:
- "24.04"
- "22.04"
- "20.04"
- "18.04"
RUNTIME_VERSION:
- "2.7"
- "2.6"
- "2.5"
- "3.0"
- "3.2"
- "3.3"
phases:
pre_build:
commands:
Expand Down
64 changes: 64 additions & 0 deletions test/integration/docker/Dockerfile.echo.amazonlinux2
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Define global args
ARG DISTRO_VERSION

# Grab a fresh copy of the image and install ruby and build the runtime interface client gem
FROM amazonlinux:${DISTRO_VERSION} AS build-image

ARG RUNTIME_VERSION

RUN yum update -y && \
yum install -y git-core zlib zlib-devel gcc-c++ patch readline readline-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison curl sqlite-devel libyaml-devel

RUN rm -rf /root/.rbenv/
RUN git clone https://github.com/rbenv/rbenv.git /root/.rbenv
ENV PATH="/root/.rbenv/bin:$PATH"
RUN echo 'eval "$(rbenv init -)"' >> /root/.bashrc
RUN git clone https://github.com/rbenv/ruby-build.git /root/.rbenv/plugins/ruby-build
RUN source /root/.bashrc
RUN RUNTIME_VERSIONS=($(rbenv install -L | grep -oE $(echo "^${RUNTIME_VERSION}\.[0-9]+"))) && \
RUNTIME_LATEST_VERSION=${RUNTIME_VERSIONS[-1]} && \
rbenv install -v ${RUNTIME_LATEST_VERSION} && \
rbenv global ${RUNTIME_LATEST_VERSION} && \
cp /root/.rbenv/versions/${RUNTIME_LATEST_VERSION}/bin/gem /usr/local/bin/gem && \
cp /root/.rbenv/versions/${RUNTIME_LATEST_VERSION}/bin/rake /usr/local/bin/rake && \
gem install bundler

ARG RIC_BUILD_DIR="/build"
# Create directory to build the Runtime Interface Client gem
RUN mkdir -p ${RIC_BUILD_DIR}

WORKDIR ${RIC_BUILD_DIR}
COPY . .
RUN rake build


# Grab a fresh copy of the Ruby image
FROM amazonlinux:${DISTRO_VERSION}
RUN yum update -y && yum install -y libyaml-devel
ARG RUNTIME_VERSION

# Copy ruby from the build-image
COPY --from=build-image /root/.rbenv /root/.rbenv

ENV PATH="/root/.rbenv/bin:$PATH"

# Copy the Runtime Interface Client gem and install it
ARG RIC_BUILD_DIR="/build"
COPY --from=build-image ${RIC_BUILD_DIR}/pkg/aws_lambda_ric*.gem aws_lambda_ric.gem
RUN RUNTIME_VERSIONS=($(rbenv install -L | grep -oE $(echo "^${RUNTIME_VERSION}\.[0-9]+"))) && \
RUNTIME_LATEST_VERSION=${RUNTIME_VERSIONS[-1]} && \
cp /root/.rbenv/versions/${RUNTIME_LATEST_VERSION}/bin/gem /usr/local/bin/gem && \
gem install aws_lambda_ric.gem && \
cp /root/.rbenv/versions/${RUNTIME_LATEST_VERSION}/bin/aws_lambda_ric /usr/local/bin/aws_lambda_ric

ARG FUNCTION_DIR="/function"

RUN mkdir -p ${FUNCTION_DIR}
# Copy function code
COPY test/integration/test-handlers/echo/* ${FUNCTION_DIR}
# Set working directory to function root directory
WORKDIR ${FUNCTION_DIR}

ENTRYPOINT ["aws_lambda_ric"]
CMD ["app.App::Handler.process"]

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ FROM amazonlinux:${DISTRO_VERSION} AS build-image
ARG RUNTIME_VERSION

RUN yum update -y && \
yum install -y git-core zlib zlib-devel gcc-c++ patch readline readline-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison curl sqlite-devel
yum install -y git-core zlib zlib-devel gcc-c++ patch readline readline-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison sqlite-devel libyaml-devel

RUN rm -rf /root/.rbenv/
RUN git clone https://github.com/rbenv/rbenv.git /root/.rbenv
Expand Down
5 changes: 5 additions & 0 deletions test/integration/docker/Dockerfile.echo.centos
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@ FROM centos:${DISTRO_VERSION} AS build-image

ARG RUNTIME_VERSION

# Fix repo url
RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
RUN sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*

RUN yum update -y && \
yum install -y git-core zlib zlib-devel gcc-c++ patch readline readline-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison curl sqlite-devel
RUN yum --enablerepo=powertools install libyaml-devel libffi-devel -y

RUN rm -rf /root/.rbenv/
RUN git clone https://github.com/rbenv/rbenv.git /root/.rbenv
Expand Down
34 changes: 34 additions & 0 deletions test/unit/harness-suite.disabled.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[
{
"name": "test_logger_uses_telemetry_log_fd_when_logdev_is_stdout",
"handler": "log.log_to_stdout_and_read_fd",
"environmentVariables": {
"_LAMBDA_TELEMETRY_LOG_FD": "test/unit/resources/fd/test_fd"
},
"request": {
"messages": ["Single frame\n even if there are multiple lines\nthird line"],
"fd_path": "test/unit/resources/fd/test_fd"
},
"assertion":
{
"transform": "\"277413888114[0-9]I, \\[[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])T(2[0-3]|[01][0-9]):[0-5][0-9]:[0-9]{2}.[0-9]{6} #[0-9]*\\] INFO ({){0,1}[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}(}){0,1} -- : Single frame\\\\n even if there are multiple lines\\\\nthird line\"",
"response": true
}
},
{
"name": "test_logger_uses_telemetry_log_fd_when_logdev_is_stderr",
"handler": "log.log_to_stderr_and_read_fd",
"environmentVariables": {
"_LAMBDA_TELEMETRY_LOG_FD": "test/unit/resources/fd/test_fd"
},
"request": {
"messages": ["Single frame\n even if there are multiple lines\nthird line"],
"fd_path": "test/unit/resources/fd/test_fd"
},
"assertion":
{
"transform": "\"277413888114[0-9]E, \\[[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])T(2[0-3]|[01][0-9]):[0-5][0-9]:[0-9]{2}.[0-9]{6} #[0-9]*\\] ERROR ({){0,1}[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}(}){0,1} -- : Single frame\\\\n even if there are multiple lines\\\\nthird line\"",
"response": true
}
}
]
32 changes: 0 additions & 32 deletions test/unit/harness-suite.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,22 +189,6 @@
"response": "277413888137First message first line\n second line277413888138Second message first line\n second line"
}
},
{
"name": "test_logger_uses_telemetry_log_fd_when_logdev_is_stdout",
"handler": "log.log_to_stdout_and_read_fd",
"environmentVariables": {
"_LAMBDA_TELEMETRY_LOG_FD": "test/unit/resources/fd/test_fd"
},
"request": {
"messages": ["Single frame\n even if there are multiple lines\nthird line"],
"fd_path": "test/unit/resources/fd/test_fd"
},
"assertion":
{
"transform": "\"277413888114[0-9]I, \\[[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])T(2[0-3]|[01][0-9]):[0-5][0-9]:[0-9]{2}.[0-9]{6} #[0-9]*\\] INFO ({){0,1}[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}(}){0,1} -- : Single frame\\\\n even if there are multiple lines\\\\nthird line\"",
"response": true
}
},
{
"name": "test_logger_logs_to_a_file_when_logdev_is_a_file",
"handler": "log.log_to_file_and_read_back",
Expand All @@ -222,22 +206,6 @@
"response": true
}
},
{
"name": "test_logger_uses_telemetry_log_fd_when_logdev_is_stderr",
"handler": "log.log_to_stderr_and_read_fd",
"environmentVariables": {
"_LAMBDA_TELEMETRY_LOG_FD": "test/unit/resources/fd/test_fd"
},
"request": {
"messages": ["Single frame\n even if there are multiple lines\nthird line"],
"fd_path": "test/unit/resources/fd/test_fd"
},
"assertion":
{
"transform": "\"277413888114[0-9]E, \\[[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])T(2[0-3]|[01][0-9]):[0-5][0-9]:[0-9]{2}.[0-9]{6} #[0-9]*\\] ERROR ({){0,1}[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}(}){0,1} -- : Single frame\\\\n even if there are multiple lines\\\\nthird line\"",
"response": true
}
},
{
"name": "test_arguments_are_flattened_and_separated_by_newline_when_logging",
"handler": "log.put_messages_and_read_fd",
Expand Down
2 changes: 1 addition & 1 deletion test/unit/lambda_log_formatter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ def test_formatter

actual = under_test.call('INFO', time, progname, msg)

assert_equal "I, [#{time.strftime("%Y-%m-%dT%H:%M:%S.%6N")} ##{$$}] INFO #{$_global_aws_request_id} -- #{progname}: #{msg}", actual
assert_equal "I, [#{time.strftime("%Y-%m-%dT%H:%M:%S.%6N")}##{$$}] INFO #{$_global_aws_request_id} -- #{progname}: #{msg}", actual
end
end
2 changes: 1 addition & 1 deletion test/unit/resources/runtime_handlers/dependencies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def get_tomorrow(event:, context:)
end

def find_dynamic_libs(event:, context:)
shared_lib_dep = `ldd /var/lang/lib/ruby/2.7.0/x86_64-linux/*.so`
shared_lib_dep = "/opt/hostedtoolcache/Ruby/*/x64/lib/ruby/*/x86_64-linux/*.so"
if shared_lib_dep.include? "not found"
return "Missing dependency"
end
Expand Down
1 change: 1 addition & 0 deletions trigger_github_action
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ok
Loading