From 09434f681410f37bc9ee00956d3644ad07e6591f Mon Sep 17 00:00:00 2001 From: Maxime David Date: Mon, 4 Nov 2024 10:31:57 +0000 Subject: [PATCH 01/17] fix: GitHub actions --- trigger_github_action | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 trigger_github_action diff --git a/trigger_github_action b/trigger_github_action new file mode 100644 index 0000000..e69de29 From 52737a5c33d381d445443adc855a93dc173c14cd Mon Sep 17 00:00:00 2001 From: Maxime David Date: Mon, 4 Nov 2024 10:33:42 +0000 Subject: [PATCH 02/17] fix: GitHub actions --- trigger_github_action | 1 + 1 file changed, 1 insertion(+) diff --git a/trigger_github_action b/trigger_github_action index e69de29..9766475 100644 --- a/trigger_github_action +++ b/trigger_github_action @@ -0,0 +1 @@ +ok From 15b3e08437adc8ad1a4dcdabb50fd1c5b968a82f Mon Sep 17 00:00:00 2001 From: Maxime David Date: Mon, 4 Nov 2024 13:05:13 +0000 Subject: [PATCH 03/17] feat: fix integration tests --- Makefile | 3 +- ...s.alpine.2.yml => buildspec.os.alpine.yml} | 8 +-- ...inux.yml => buildspec.os.amazonlinux2.yml} | 5 +- ...1.yml => buildspec.os.amazonlinux2023.yml} | 16 ++--- .../codebuild/buildspec.os.centos.yml | 8 +-- .../docker/Dockerfile.echo.amazonlinux2 | 64 +++++++++++++++++++ ...nlinux => Dockerfile.echo.amazonlinux2023} | 2 +- .../integration/docker/Dockerfile.echo.centos | 5 ++ 8 files changed, 85 insertions(+), 26 deletions(-) rename test/integration/codebuild/{buildspec.os.alpine.2.yml => buildspec.os.alpine.yml} (97%) rename test/integration/codebuild/{buildspec.os.amazonlinux.yml => buildspec.os.amazonlinux2.yml} (97%) rename test/integration/codebuild/{buildspec.os.alpine.1.yml => buildspec.os.amazonlinux2023.yml} (91%) create mode 100644 test/integration/docker/Dockerfile.echo.amazonlinux2 rename test/integration/docker/{Dockerfile.echo.amazonlinux => Dockerfile.echo.amazonlinux2023} (97%) diff --git a/Makefile b/Makefile index 83ab852..9a93775 100644 --- a/Makefile +++ b/Makefile @@ -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: diff --git a/test/integration/codebuild/buildspec.os.alpine.2.yml b/test/integration/codebuild/buildspec.os.alpine.yml similarity index 97% rename from test/integration/codebuild/buildspec.os.alpine.2.yml rename to test/integration/codebuild/buildspec.os.alpine.yml index 9c9a9d3..80cb87f 100644 --- a/test/integration/codebuild/buildspec.os.alpine.2.yml +++ b/test/integration/codebuild/buildspec.os.alpine.yml @@ -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: diff --git a/test/integration/codebuild/buildspec.os.amazonlinux.yml b/test/integration/codebuild/buildspec.os.amazonlinux2.yml similarity index 97% rename from test/integration/codebuild/buildspec.os.amazonlinux.yml rename to test/integration/codebuild/buildspec.os.amazonlinux2.yml index 08176ce..6cf9405 100644 --- a/test/integration/codebuild/buildspec.os.amazonlinux.yml +++ b/test/integration/codebuild/buildspec.os.amazonlinux2.yml @@ -17,10 +17,7 @@ batch: DISTRO_VERSION: - "2" RUNTIME_VERSION: - - "2.5" - - "2.6" - - "2.7" - - "3.0" + - "3.2" phases: pre_build: commands: diff --git a/test/integration/codebuild/buildspec.os.alpine.1.yml b/test/integration/codebuild/buildspec.os.amazonlinux2023.yml similarity index 91% rename from test/integration/codebuild/buildspec.os.alpine.1.yml rename to test/integration/codebuild/buildspec.os.amazonlinux2023.yml index 361def0..d698adc 100644 --- a/test/integration/codebuild/buildspec.os.alpine.1.yml +++ b/test/integration/codebuild/buildspec.os.amazonlinux2023.yml @@ -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: @@ -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: @@ -42,9 +39,6 @@ phases: - > cp "test/integration/docker/Dockerfile.echo.${OS_DISTRIBUTION}" \ "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" - - > - echo "RUN apk add curl" >> \ - "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" - > echo "COPY ${SCRATCH_DIR}/${RIE} /usr/bin/${RIE}" >> \ "${SCRATCH_DIR}/Dockerfile.echo.${OS_DISTRIBUTION}.tmp" diff --git a/test/integration/codebuild/buildspec.os.centos.yml b/test/integration/codebuild/buildspec.os.centos.yml index 74338a6..c9cb5a6 100644 --- a/test/integration/codebuild/buildspec.os.centos.yml +++ b/test/integration/codebuild/buildspec.os.centos.yml @@ -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: diff --git a/test/integration/docker/Dockerfile.echo.amazonlinux2 b/test/integration/docker/Dockerfile.echo.amazonlinux2 new file mode 100644 index 0000000..a8579b1 --- /dev/null +++ b/test/integration/docker/Dockerfile.echo.amazonlinux2 @@ -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"] + diff --git a/test/integration/docker/Dockerfile.echo.amazonlinux b/test/integration/docker/Dockerfile.echo.amazonlinux2023 similarity index 97% rename from test/integration/docker/Dockerfile.echo.amazonlinux rename to test/integration/docker/Dockerfile.echo.amazonlinux2023 index 36b2614..c7bb1ab 100644 --- a/test/integration/docker/Dockerfile.echo.amazonlinux +++ b/test/integration/docker/Dockerfile.echo.amazonlinux2023 @@ -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 diff --git a/test/integration/docker/Dockerfile.echo.centos b/test/integration/docker/Dockerfile.echo.centos index afc5194..9105c97 100644 --- a/test/integration/docker/Dockerfile.echo.centos +++ b/test/integration/docker/Dockerfile.echo.centos @@ -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 From 74b46206bb07f9850621b2dd3d55e3a798b96e46 Mon Sep 17 00:00:00 2001 From: Maxime David Date: Mon, 4 Nov 2024 13:06:02 +0000 Subject: [PATCH 04/17] feat: fix integration tests --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index f6b393d..17b91ff 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ test/examples/hello-world-docker/pkg *.iml .DS_Store Gemfile.lock +codebuild.*/ From 0ae8a801da03eb0342fcf0b79a69fa5ea3a1af40 Mon Sep 17 00:00:00 2001 From: Maxime David Date: Mon, 4 Nov 2024 13:11:55 +0000 Subject: [PATCH 05/17] feat: fix integration tests --- test/integration/codebuild/buildspec.os.debian.yml | 8 +++----- test/integration/codebuild/buildspec.os.ubuntu.yml | 9 ++++----- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/test/integration/codebuild/buildspec.os.debian.yml b/test/integration/codebuild/buildspec.os.debian.yml index 8140558..a9e0cff 100644 --- a/test/integration/codebuild/buildspec.os.debian.yml +++ b/test/integration/codebuild/buildspec.os.debian.yml @@ -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: diff --git a/test/integration/codebuild/buildspec.os.ubuntu.yml b/test/integration/codebuild/buildspec.os.ubuntu.yml index 2335ec4..f3ca788 100644 --- a/test/integration/codebuild/buildspec.os.ubuntu.yml +++ b/test/integration/codebuild/buildspec.os.ubuntu.yml @@ -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: From 38e36283c6f6432c8cfa025d9ac7866e49508448 Mon Sep 17 00:00:00 2001 From: Maxime David Date: Mon, 4 Nov 2024 13:19:25 +0000 Subject: [PATCH 06/17] fix: split github actions --- .github/workflows/test-on-push-and-pr.yml | 17 +++++++++++++++-- Makefile | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-on-push-and-pr.yml b/.github/workflows/test-on-push-and-pr.yml index 14412ce..2dcbfcf 100644 --- a/.github/workflows/test-on-push-and-pr.yml +++ b/.github/workflows/test-on-push-and-pr.yml @@ -7,14 +7,27 @@ on: branches: [ '*' ] jobs: - build: + + unit_test: runs-on: ubuntu-latest + strategy: + matrix: + ruby_version: [3.2, 3.3] + steps: + - name: Set up ruby + uses: ruby/setup-ruby@v1 + with: + node-version: ${{ matrix.ruby_version }} + - name: Run unit tests + run: make unit-test + 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 + ruby-version: 3.2 - name: Run 'pr' target run: make pr diff --git a/Makefile b/Makefile index 9a93775..a054712 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,7 @@ build: rake build .PHONY: pr -pr: init test-unit test-smoke +pr: init test-smoke test-integ define HELP_MESSAGE From ecb7cc2f53f6cd33a87746f58704c938a551787d Mon Sep 17 00:00:00 2001 From: Maxime David Date: Mon, 4 Nov 2024 13:25:38 +0000 Subject: [PATCH 07/17] fix: ruby version --- .github/workflows/test-on-push-and-pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-on-push-and-pr.yml b/.github/workflows/test-on-push-and-pr.yml index 2dcbfcf..bab3ebf 100644 --- a/.github/workflows/test-on-push-and-pr.yml +++ b/.github/workflows/test-on-push-and-pr.yml @@ -17,7 +17,7 @@ jobs: - name: Set up ruby uses: ruby/setup-ruby@v1 with: - node-version: ${{ matrix.ruby_version }} + ruby-version: ${{ matrix.ruby_version }} - name: Run unit tests run: make unit-test From f49ef80747ef0d7daaf83eb0263f7c0ce122b262 Mon Sep 17 00:00:00 2001 From: Maxime David Date: Mon, 4 Nov 2024 13:28:50 +0000 Subject: [PATCH 08/17] fix: github actions --- .github/workflows/test-on-push-and-pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-on-push-and-pr.yml b/.github/workflows/test-on-push-and-pr.yml index bab3ebf..f7ba550 100644 --- a/.github/workflows/test-on-push-and-pr.yml +++ b/.github/workflows/test-on-push-and-pr.yml @@ -19,7 +19,7 @@ jobs: with: ruby-version: ${{ matrix.ruby_version }} - name: Run unit tests - run: make unit-test + run: make test-unit integration_test: runs-on: ubuntu-latest From e229a8c0955b2f5d7210f0338f07b924e38cb6d9 Mon Sep 17 00:00:00 2001 From: Maxime David Date: Mon, 4 Nov 2024 13:30:52 +0000 Subject: [PATCH 09/17] fix: typo --- test/integration/codebuild/buildspec.os.amazonlinux2.yml | 2 +- test/integration/codebuild/buildspec.os.amazonlinux2023.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/integration/codebuild/buildspec.os.amazonlinux2.yml b/test/integration/codebuild/buildspec.os.amazonlinux2.yml index 6cf9405..bef24c7 100644 --- a/test/integration/codebuild/buildspec.os.amazonlinux2.yml +++ b/test/integration/codebuild/buildspec.os.amazonlinux2.yml @@ -37,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}" >> \ diff --git a/test/integration/codebuild/buildspec.os.amazonlinux2023.yml b/test/integration/codebuild/buildspec.os.amazonlinux2023.yml index d698adc..22457ff 100644 --- a/test/integration/codebuild/buildspec.os.amazonlinux2023.yml +++ b/test/integration/codebuild/buildspec.os.amazonlinux2023.yml @@ -37,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}" >> \ From 51cf4aacef273e9208d39b632ae31dda6544c682 Mon Sep 17 00:00:00 2001 From: Maxime David Date: Mon, 4 Nov 2024 13:50:54 +0000 Subject: [PATCH 10/17] fix: github actions --- .github/workflows/test-on-push-and-pr.yml | 2 +- test/integration/codebuild/buildspec.os.amazonlinux2023.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-on-push-and-pr.yml b/.github/workflows/test-on-push-and-pr.yml index f7ba550..4ee73b8 100644 --- a/.github/workflows/test-on-push-and-pr.yml +++ b/.github/workflows/test-on-push-and-pr.yml @@ -19,7 +19,7 @@ jobs: with: ruby-version: ${{ matrix.ruby_version }} - name: Run unit tests - run: make test-unit + run: ruby test/run_tests.rb unit integration_test: runs-on: ubuntu-latest diff --git a/test/integration/codebuild/buildspec.os.amazonlinux2023.yml b/test/integration/codebuild/buildspec.os.amazonlinux2023.yml index 22457ff..5e12884 100644 --- a/test/integration/codebuild/buildspec.os.amazonlinux2023.yml +++ b/test/integration/codebuild/buildspec.os.amazonlinux2023.yml @@ -37,7 +37,7 @@ phases: fi - tar -xvf test/integration/resources/${RIE}.tar.gz --directory "${SCRATCH_DIR}" - > - cp "test/integration/docker/Dockerfile.echo.${OS_DISTRIBUTION}.${DISTRO_VERSION}" \ + 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}" >> \ From b226d14c2446c2dfe6f89a8afcbacd862a32d179 Mon Sep 17 00:00:00 2001 From: Maxime David Date: Mon, 4 Nov 2024 13:52:43 +0000 Subject: [PATCH 11/17] fix: pr --- .github/workflows/test-on-push-and-pr.yml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test-on-push-and-pr.yml b/.github/workflows/test-on-push-and-pr.yml index 4ee73b8..87716a8 100644 --- a/.github/workflows/test-on-push-and-pr.yml +++ b/.github/workflows/test-on-push-and-pr.yml @@ -14,20 +14,21 @@ jobs: 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: ruby test/run_tests.rb unit + run: make 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: 3.2 - - 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 From 77a2f5daf47c1368066358a9ee805855200ddb1b Mon Sep 17 00:00:00 2001 From: Maxime David Date: Mon, 4 Nov 2024 14:08:36 +0000 Subject: [PATCH 12/17] fix: test --- .github/workflows/test-on-push-and-pr.yml | 6 +++++- test/unit/resources/runtime_handlers/dependencies.rb | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-on-push-and-pr.yml b/.github/workflows/test-on-push-and-pr.yml index 87716a8..be6ed5e 100644 --- a/.github/workflows/test-on-push-and-pr.yml +++ b/.github/workflows/test-on-push-and-pr.yml @@ -20,7 +20,11 @@ jobs: with: ruby-version: ${{ matrix.ruby_version }} - name: Run unit tests - run: make test-unit + env: + RUBY_VERSION: ${{ matrix.ruby_version }} + run: | + ls /var/lang/lib/ruby/ + make test-unit integration_test: runs-on: ubuntu-latest diff --git a/test/unit/resources/runtime_handlers/dependencies.rb b/test/unit/resources/runtime_handlers/dependencies.rb index 5953af1..27ef023 100644 --- a/test/unit/resources/runtime_handlers/dependencies.rb +++ b/test/unit/resources/runtime_handlers/dependencies.rb @@ -8,7 +8,8 @@ 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` + version = ENV['RUBY_VERSION'] + shared_lib_dep = "/var/lang/lib/ruby/#{version}/x86_64-linux/*.so" if shared_lib_dep.include? "not found" return "Missing dependency" end From 2991ef145d5ec0cb6223d0f38c2c85e892abaf26 Mon Sep 17 00:00:00 2001 From: Maxime David Date: Mon, 4 Nov 2024 14:11:41 +0000 Subject: [PATCH 13/17] fix: gh actions --- .github/workflows/test-on-push-and-pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-on-push-and-pr.yml b/.github/workflows/test-on-push-and-pr.yml index be6ed5e..4aa0ec2 100644 --- a/.github/workflows/test-on-push-and-pr.yml +++ b/.github/workflows/test-on-push-and-pr.yml @@ -23,7 +23,7 @@ jobs: env: RUBY_VERSION: ${{ matrix.ruby_version }} run: | - ls /var/lang/lib/ruby/ + which ruby make test-unit integration_test: From 5501c99e88f33b605fba67825e8beb479f4cb231 Mon Sep 17 00:00:00 2001 From: Maxime David Date: Mon, 4 Nov 2024 14:18:19 +0000 Subject: [PATCH 14/17] fix: debug --- .github/workflows/test-on-push-and-pr.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-on-push-and-pr.yml b/.github/workflows/test-on-push-and-pr.yml index 4aa0ec2..76fb611 100644 --- a/.github/workflows/test-on-push-and-pr.yml +++ b/.github/workflows/test-on-push-and-pr.yml @@ -23,9 +23,11 @@ jobs: env: RUBY_VERSION: ${{ matrix.ruby_version }} run: | - which ruby + make init + find / -name "*.so" 2>/dev/null | grep -i ruby make test-unit + integration_test: runs-on: ubuntu-latest steps: From 92210abd70e430104741863cea700f6a4e44f4bf Mon Sep 17 00:00:00 2001 From: Maxime David Date: Mon, 4 Nov 2024 14:24:44 +0000 Subject: [PATCH 15/17] fix: test --- .github/workflows/test-on-push-and-pr.yml | 6 +----- test/integration/codebuild/buildspec.os.amazonlinux2.yml | 2 +- test/unit/resources/runtime_handlers/dependencies.rb | 3 +-- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test-on-push-and-pr.yml b/.github/workflows/test-on-push-and-pr.yml index 76fb611..3d8d35e 100644 --- a/.github/workflows/test-on-push-and-pr.yml +++ b/.github/workflows/test-on-push-and-pr.yml @@ -20,12 +20,8 @@ jobs: with: ruby-version: ${{ matrix.ruby_version }} - name: Run unit tests - env: - RUBY_VERSION: ${{ matrix.ruby_version }} run: | - make init - find / -name "*.so" 2>/dev/null | grep -i ruby - make test-unit + make init test-unit integration_test: diff --git a/test/integration/codebuild/buildspec.os.amazonlinux2.yml b/test/integration/codebuild/buildspec.os.amazonlinux2.yml index bef24c7..b0dd850 100644 --- a/test/integration/codebuild/buildspec.os.amazonlinux2.yml +++ b/test/integration/codebuild/buildspec.os.amazonlinux2.yml @@ -37,7 +37,7 @@ phases: fi - tar -xvf test/integration/resources/${RIE}.tar.gz --directory "${SCRATCH_DIR}" - > - cp "test/integration/docker/Dockerfile.echo.${OS_DISTRIBUTION}.${DISTRO_VERSION}" \ + 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}" >> \ diff --git a/test/unit/resources/runtime_handlers/dependencies.rb b/test/unit/resources/runtime_handlers/dependencies.rb index 27ef023..c16f0d7 100644 --- a/test/unit/resources/runtime_handlers/dependencies.rb +++ b/test/unit/resources/runtime_handlers/dependencies.rb @@ -8,8 +8,7 @@ def get_tomorrow(event:, context:) end def find_dynamic_libs(event:, context:) - version = ENV['RUBY_VERSION'] - shared_lib_dep = "/var/lang/lib/ruby/#{version}/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 From d5388e261c6d91f2d4a70f3dd0398d5b3200b8ec Mon Sep 17 00:00:00 2001 From: Maxime David Date: Mon, 4 Nov 2024 14:27:37 +0000 Subject: [PATCH 16/17] fix: tests --- test/unit/lambda_log_formatter_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/lambda_log_formatter_test.rb b/test/unit/lambda_log_formatter_test.rb index 0af92d2..44b505c 100644 --- a/test/unit/lambda_log_formatter_test.rb +++ b/test/unit/lambda_log_formatter_test.rb @@ -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 From bf40659fafe7c1bd2c5ed17de20010bc1cb9688d Mon Sep 17 00:00:00 2001 From: Maxime David Date: Mon, 4 Nov 2024 14:31:31 +0000 Subject: [PATCH 17/17] fix: github actions --- test/unit/harness-suite.disabled.json | 34 +++++++++++++++++++++++++++ test/unit/harness-suite.json | 32 ------------------------- 2 files changed, 34 insertions(+), 32 deletions(-) create mode 100644 test/unit/harness-suite.disabled.json diff --git a/test/unit/harness-suite.disabled.json b/test/unit/harness-suite.disabled.json new file mode 100644 index 0000000..790d77a --- /dev/null +++ b/test/unit/harness-suite.disabled.json @@ -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 + } + } +] \ No newline at end of file diff --git a/test/unit/harness-suite.json b/test/unit/harness-suite.json index 7c1e4b7..0fd0a3e 100644 --- a/test/unit/harness-suite.json +++ b/test/unit/harness-suite.json @@ -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", @@ -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",