diff --git a/.github/scripts/simple-smoke-test.sh b/.github/scripts/simple-smoke-test.sh index eb3deea5..0f022ed5 100755 --- a/.github/scripts/simple-smoke-test.sh +++ b/.github/scripts/simple-smoke-test.sh @@ -59,5 +59,57 @@ function install_clc() { clc config add default cluster.name=dev cluster.address=localhost } -install_clc -test_docker_image "$@" +function get_hz_logs() { + docker logs "${container_name}" +} + +function stop_container() { + echo "Stopping container ${container_name}" + docker stop "${container_name}" +} + +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 +} + +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 + +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 623dac03..3ef598de 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 + 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 + .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() }} @@ -165,7 +167,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 + .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: | @@ -183,7 +185,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 + .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 529dce77..27c278f9 100644 --- a/.github/workflows/ee-nlc-snapshot-push.yml +++ b/.github/workflows/ee-nlc-snapshot-push.yml @@ -76,7 +76,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 + .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 12997c06..25b8a6d6 100644 --- a/.github/workflows/ee-nlc-tag-push.yml +++ b/.github/workflows/ee-nlc-tag-push.yml @@ -90,7 +90,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 + .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 bcfb097f..63bc0869 100644 --- a/.github/workflows/ee_latest_snapshot_push.yml +++ b/.github/workflows/ee_latest_snapshot_push.yml @@ -78,7 +78,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 + .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 22b5b419..c852cfd9 100644 --- a/.github/workflows/oss_latest_snapshot_push.yml +++ b/.github/workflows/oss_latest_snapshot_push.yml @@ -86,7 +86,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 + .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 5a6e87cc..e3132de3 100644 --- a/.github/workflows/tag_image_push.yml +++ b/.github/workflows/tag_image_push.yml @@ -150,7 +150,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 + .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: | @@ -173,7 +173,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 + .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() }}