From 05d60ab0780de5a16036bfe57a60333266864efd Mon Sep 17 00:00:00 2001 From: Jack Green Date: Tue, 5 Nov 2024 12:43:36 +0000 Subject: [PATCH] Test JDK version as part of PR builder [DI-317] (#816) Adds additional assertion to the PR builder smoke test that the JDK is the version expected for the image. This is currently a _manual, post release_ check, moving earlier in the cycle to catch defects earlier. Fixes: [DI-317](https://hazelcast.atlassian.net/browse/DI-317) Post merge actions: - [ ] backport - [ ] _Discuss_ if we remove the manual, post-release check? [DI-317]: https://hazelcast.atlassian.net/browse/DI-317?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ --- .github/scripts/simple-smoke-test.sh | 53 ++++++++++++++----- .github/workflows/build-pr.yml | 12 +++-- .github/workflows/ee-nlc-snapshot-push.yml | 2 +- .github/workflows/ee-nlc-tag-push.yml | 2 +- .github/workflows/ee_latest_snapshot_push.yml | 2 +- .../workflows/oss_latest_snapshot_push.yml | 2 +- .github/workflows/tag_image_push.yml | 4 +- 7 files changed, 53 insertions(+), 24 deletions(-) diff --git a/.github/scripts/simple-smoke-test.sh b/.github/scripts/simple-smoke-test.sh index 73c9a5ce..4cfa0a2d 100755 --- a/.github/scripts/simple-smoke-test.sh +++ b/.github/scripts/simple-smoke-test.sh @@ -88,21 +88,48 @@ function test_map_read_write() { fi } -function install_clc() { - while ! curl https://hazelcast.com/clc/install.sh | bash - do - echo "Retrying clc installation..." - sleep 3 - done - export PATH=${PATH}:${HOME}/.hazelcast/bin - clc config add default cluster.name=dev cluster.address=localhost +function check_java_version() { + local expected_major_version=$1 + local actual_major_version + actual_major_version=$(docker run --rm "${image}" sh -c 'java -version 2>&1 | head -n 1 | awk -F "\"" "{print \$2}" | awk -F "." "{print \$1}"') + + if [[ "${expected_major_version}" == "${actual_major_version}" ]]; then + echo "Expected Java version (${expected_distribution_type}) identified." + else + echoerr "Expected Java version '${expected_major_version}' but got '${actual_major_version}'" + exit 1; + fi } -# Prints the given message to stderr -function echoerr() { - echo "ERROR - $*" 1>&2; +function derive_expected_distribution_type() { + local input_distribution_type=$1 + + case "${input_distribution_type}" in + "oss") + echo "Hazelcast Platform" + ;; + "ee") + echo "Hazelcast Enterprise" + ;; + *) + echoerr "Unrecognized distribution type ${input_distribution_type}" + exit 1 + ;; + esac } +image=$1 +container_name=$2 +input_distribution_type=$3 +expected_version=$4 +expected_java_major_version=$5 + + +remove_container_if_exists +start_container + +trap stop_container EXIT -install_clc -test_docker_image "$@" +expected_distribution_type=$(derive_expected_distribution_type "${input_distribution_type}") +test_package "${expected_distribution_type}" "${expected_version}" +check_java_version "${expected_java_major_version}" diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index 67bc5815..64289444 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -85,8 +85,9 @@ jobs: - name: Run smoke test against OSS image timeout-minutes: 2 - run: | - .github/scripts/simple-smoke-test.sh hazelcast-oss:test ${{ env.test_container_name_oss }} oss ${{ needs.prepare.outputs.HZ_VERSION_OSS }} + run: | + . .github/scripts/docker.functions.sh + .github/scripts/simple-smoke-test.sh hazelcast-oss:test ${{ env.test_container_name_oss }} oss ${{ needs.prepare.outputs.HZ_VERSION_OSS }} "$(get_default_jdk hazelcast-oss)" - name: Build Test EE image run: | @@ -102,8 +103,9 @@ jobs: - name: Run smoke test against EE image timeout-minutes: 2 run: | + . .github/scripts/docker.functions.sh export HZ_LICENSEKEY=${{ secrets.HZ_ENTERPRISE_LICENSE }} - .github/scripts/simple-smoke-test.sh hazelcast-ee:test ${{ env.test_container_name_ee }} ee ${{ needs.prepare.outputs.HZ_VERSION_EE }} + .github/scripts/simple-smoke-test.sh hazelcast-ee:test ${{ env.test_container_name_ee }} ee ${{ needs.prepare.outputs.HZ_VERSION_EE }} "$(get_default_jdk hazelcast-enterprise)" - name: Get docker logs if: ${{ always() }} @@ -162,7 +164,7 @@ jobs: - name: Run smoke test against OSS image timeout-minutes: 2 run: | - .github/scripts/simple-smoke-test.sh hazelcast-oss:test ${{ env.test_container_name_oss }} oss ${{ needs.prepare.outputs.HZ_VERSION_OSS }} + .github/scripts/simple-smoke-test.sh hazelcast-oss:test ${{ env.test_container_name_oss }} oss ${{ needs.prepare.outputs.HZ_VERSION_OSS }} ${{ matrix.jdk }} - name: Build Test EE image run: | @@ -180,7 +182,7 @@ jobs: timeout-minutes: 2 run: | export HZ_LICENSEKEY=${{ secrets.HZ_ENTERPRISE_LICENSE }} - .github/scripts/simple-smoke-test.sh hazelcast-ee:test ${{ env.test_container_name_ee }} ee ${{ needs.prepare.outputs.HZ_VERSION_EE }} + .github/scripts/simple-smoke-test.sh hazelcast-ee:test ${{ env.test_container_name_ee }} ee ${{ needs.prepare.outputs.HZ_VERSION_EE }} ${{ matrix.jdk }} - name: Get docker logs if: ${{ always() }} diff --git a/.github/workflows/ee-nlc-snapshot-push.yml b/.github/workflows/ee-nlc-snapshot-push.yml index d4357af2..8942938d 100644 --- a/.github/workflows/ee-nlc-snapshot-push.yml +++ b/.github/workflows/ee-nlc-snapshot-push.yml @@ -73,7 +73,7 @@ jobs: timeout-minutes: 2 run: | export HZ_INSTANCETRACKING_FILENAME=instance-tracking.txt - .github/scripts/simple-smoke-test.sh hazelcast-nlc:test ${{ env.test_container_name_ee }} ee ${HZ_VERSION} + .github/scripts/simple-smoke-test.sh hazelcast-nlc:test ${{ env.test_container_name_ee }} ee ${HZ_VERSION} ${{ matrix.jdk }} - name: Get docker logs if: ${{ always() }} diff --git a/.github/workflows/ee-nlc-tag-push.yml b/.github/workflows/ee-nlc-tag-push.yml index 147c6591..7f16c5b8 100644 --- a/.github/workflows/ee-nlc-tag-push.yml +++ b/.github/workflows/ee-nlc-tag-push.yml @@ -87,7 +87,7 @@ jobs: timeout-minutes: 2 run: | export HZ_INSTANCETRACKING_FILENAME=instance-tracking.txt - .github/scripts/simple-smoke-test.sh hazelcast-nlc:test ${{ env.test_container_name_ee }} ee ${HZ_VERSION} + .github/scripts/simple-smoke-test.sh hazelcast-nlc:test ${{ env.test_container_name_ee }} ee ${HZ_VERSION} ${{ matrix.jdk }} - name: Get docker logs if: ${{ always() }} diff --git a/.github/workflows/ee_latest_snapshot_push.yml b/.github/workflows/ee_latest_snapshot_push.yml index 63ffb3ed..393d3159 100644 --- a/.github/workflows/ee_latest_snapshot_push.yml +++ b/.github/workflows/ee_latest_snapshot_push.yml @@ -75,7 +75,7 @@ jobs: timeout-minutes: 2 run: | export HZ_LICENSEKEY=${{ secrets.HZ_ENTERPRISE_LICENSE }} - .github/scripts/simple-smoke-test.sh hazelcast-ee:test ${{ env.test_container_name_ee }} ee ${HZ_VERSION} + .github/scripts/simple-smoke-test.sh hazelcast-ee:test ${{ env.test_container_name_ee }} ee ${HZ_VERSION} ${{ matrix.jdk }} - name: Get docker logs if: ${{ always() }} diff --git a/.github/workflows/oss_latest_snapshot_push.yml b/.github/workflows/oss_latest_snapshot_push.yml index f79cddf7..befa48ba 100644 --- a/.github/workflows/oss_latest_snapshot_push.yml +++ b/.github/workflows/oss_latest_snapshot_push.yml @@ -83,7 +83,7 @@ jobs: - name: Run smoke test against OSS image timeout-minutes: 2 run: | - .github/scripts/simple-smoke-test.sh hazelcast-oss:test ${{ env.test_container_name_oss }} oss ${HZ_VERSION} + .github/scripts/simple-smoke-test.sh hazelcast-oss:test ${{ env.test_container_name_oss }} oss ${HZ_VERSION} ${{ matrix.jdk }} - name: Get docker logs if: ${{ always() }} diff --git a/.github/workflows/tag_image_push.yml b/.github/workflows/tag_image_push.yml index 368c0895..99cba73e 100644 --- a/.github/workflows/tag_image_push.yml +++ b/.github/workflows/tag_image_push.yml @@ -147,7 +147,7 @@ jobs: if: needs.prepare.outputs.should_build_oss == 'yes' timeout-minutes: 2 run: | - .github/scripts/simple-smoke-test.sh hazelcast-oss:test ${{ env.test_container_name_oss }} oss ${{ env.HZ_VERSION }} + .github/scripts/simple-smoke-test.sh hazelcast-oss:test ${{ env.test_container_name_oss }} oss ${{ env.HZ_VERSION }} ${{ matrix.jdk }} - name: Get EE dist ZIP URL run: | @@ -170,7 +170,7 @@ jobs: timeout-minutes: 2 run: | export HZ_LICENSEKEY=${{ secrets.HZ_ENTERPRISE_LICENSE }} - .github/scripts/simple-smoke-test.sh hazelcast-ee:test ${{ env.test_container_name_ee }} ee ${{ env.HZ_VERSION }} + .github/scripts/simple-smoke-test.sh hazelcast-ee:test ${{ env.test_container_name_ee }} ee ${{ env.HZ_VERSION }} ${{ matrix.jdk }} - name: Get docker logs if: ${{ always() }}