Skip to content

Commit

Permalink
Test JDK version as part of PR builder [DI-317] (#816)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
JackPGreen committed Nov 5, 2024
1 parent f521dc1 commit 67da84b
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 13 deletions.
56 changes: 54 additions & 2 deletions .github/scripts/simple-smoke-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
12 changes: 7 additions & 5 deletions .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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() }}
Expand Down Expand Up @@ -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: |
Expand All @@ -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() }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ee-nlc-snapshot-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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() }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ee-nlc-tag-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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() }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ee_latest_snapshot_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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() }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/oss_latest_snapshot_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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() }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tag_image_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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() }}
Expand Down

0 comments on commit 67da84b

Please sign in to comment.