Skip to content

Commit 71f8364

Browse files
committed
add 2 new scenarios to test latest released bootc image from konflux
1 parent d19232d commit 71f8364

File tree

4 files changed

+172
-8
lines changed

4 files changed

+172
-8
lines changed

test/assets/common_versions.sh.template

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,50 @@ get_vrel_from_rpm() {{
6868
echo ""
6969
}}
7070

71+
get_redhat_bootc_image_url() {{
72+
local -r registry="$1"
73+
local -r release_version="$2"
74+
local image_url=""
75+
76+
# get arch
77+
local arch=""
78+
case ${{UNAME_M}} in
79+
x86_64)
80+
arch="amd64"
81+
;;
82+
aarch64)
83+
arch="arm64"
84+
;;
85+
esac
86+
87+
sha_id=$(skopeo inspect --raw "docker://${{registry}}/openshift4/microshift-bootc-rhel9:v${{release_version}}" | \
88+
jq -r ".manifests[] | select(.platform.architecture==\"${{arch}}\") | .digest" 2>/dev/null)
89+
if [ "${{sha_id}}" ] && [[ "${{sha_id}}" != "" ]] && [[ "${{sha_id}}" =~ ^sha256:[0-9a-f]{{64}}$ ]]; then
90+
image_url="registry.redhat.io/openshift4/microshift-bootc-rhel9@${{sha_id}}"
91+
fi
92+
echo "${{image_url}}"
93+
}}
94+
95+
get_lrel_release_image_url() {{
96+
local -r release_type="$1"
97+
local -r release_version="$2"
98+
local image_url=""
99+
100+
if [[ "${{release_type}}" == "ec" ]]; then
101+
image_url="https://mirror.openshift.com/pub/openshift-v4/${{UNAME_M}}/microshift/ocp-dev-preview/${{release_version}}/el9/os"
102+
elif [[ "${{release_type}}" == "rc" ]]; then
103+
image_url="https://mirror.openshift.com/pub/openshift-v4/${{UNAME_M}}/microshift/ocp/${{release_version}}/el9/os"
104+
elif [[ "${{release_type}}" == "zstream" ]]; then
105+
for registry in "registry.redhat.io" "registry.stage.redhat.io"; do
106+
image_url="$(get_redhat_bootc_image_url "${{registry}}" "${{release_version}}")"
107+
if [ -n "${{image_url}}" ]; then
108+
break
109+
fi
110+
done
111+
fi
112+
echo "${{image_url}}"
113+
}}
114+
71115
# The current release minor version (e.g. '17' for '4.17') affects
72116
# the definition of previous and fake next versions.
73117
export MINOR_VERSION={minor_version}
@@ -155,12 +199,16 @@ export BREW_RC_RELEASE_VERSION
155199
export BREW_EC_RELEASE_VERSION
156200
export BREW_NIGHTLY_RELEASE_VERSION
157201

158-
# Set the release type to ec, rc or zstream
159-
LATEST_RELEASE_TYPE="{LATEST_RELEASE_TYPE}"
160-
export LATEST_RELEASE_TYPE
202+
# Latest Release info
203+
LATEST_RELEASE_TYPE="ec" # ec, rc or zstream
204+
BREW_LREL_RELEASE_VERSION="${{BREW_EC_RELEASE_VERSION}}" # BREW_EC_RELEASE_VERSION, BREW_RC_RELEASE_VERSION or BREW_Y0_RELEASE_VERSION
205+
LATEST_RELEASE_VERSION="$(echo "${{BREW_LREL_RELEASE_VERSION}}" | sed -E 's/(.*)-.*/\1/' | sed -E 's/(.*)~(.*)/\1-\2/')" # example: 4.19.7 or 4.20.0-rc.3
206+
LREL_RELEASE_IMAGE_URL="$(get_lrel_release_image_url "${{LATEST_RELEASE_TYPE}}" "${{LATEST_RELEASE_VERSION}}")"
161207

162-
BREW_LREL_RELEASE_VERSION="${{BREW_EC_RELEASE_VERSION}}"
208+
export LATEST_RELEASE_TYPE
163209
export BREW_LREL_RELEASE_VERSION
210+
export LATEST_RELEASE_VERSION
211+
export LREL_RELEASE_IMAGE_URL
164212

165213
# Branch and commit for the openshift-tests-private repository
166214
OPENSHIFT_TESTS_PRIVATE_REPO_BRANCH="release-4.${{MINOR_VERSION}}"

test/bin/common_versions.sh

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,50 @@ get_vrel_from_rpm() {
6868
echo ""
6969
}
7070

71+
get_redhat_bootc_image_url() {
72+
local -r registry="$1"
73+
local -r release_version="$2"
74+
local image_url=""
75+
76+
# get arch
77+
local arch=""
78+
case ${UNAME_M} in
79+
x86_64)
80+
arch="amd64"
81+
;;
82+
aarch64)
83+
arch="arm64"
84+
;;
85+
esac
86+
87+
sha_id=$(skopeo inspect --raw "docker://${registry}/openshift4/microshift-bootc-rhel9:v${release_version}" | \
88+
jq -r ".manifests[] | select(.platform.architecture==\"${arch}\") | .digest" 2>/dev/null)
89+
if [ "${sha_id}" ] && [[ "${sha_id}" != "" ]] && [[ "${sha_id}" =~ ^sha256:[0-9a-f]{64}$ ]]; then
90+
image_url="registry.redhat.io/openshift4/microshift-bootc-rhel9@${sha_id}"
91+
fi
92+
echo "${image_url}"
93+
}
94+
95+
get_lrel_release_image_url() {
96+
local -r release_type="$1"
97+
local -r release_version="$2"
98+
local image_url=""
99+
100+
if [[ "${release_type}" == "ec" ]]; then
101+
image_url="https://mirror.openshift.com/pub/openshift-v4/${UNAME_M}/microshift/ocp-dev-preview/${release_version}/el9/os"
102+
elif [[ "${release_type}" == "rc" ]]; then
103+
image_url="https://mirror.openshift.com/pub/openshift-v4/${UNAME_M}/microshift/ocp/${release_version}/el9/os"
104+
elif [[ "${release_type}" == "zstream" ]]; then
105+
for registry in "registry.redhat.io" "registry.stage.redhat.io"; do
106+
image_url="$(get_redhat_bootc_image_url "${registry}" "${release_version}")"
107+
if [ -n "${image_url}" ]; then
108+
break
109+
fi
110+
done
111+
fi
112+
echo "${image_url}"
113+
}
114+
71115
# The current release minor version (e.g. '17' for '4.17') affects
72116
# the definition of previous and fake next versions.
73117
export MINOR_VERSION=21
@@ -155,12 +199,16 @@ export BREW_RC_RELEASE_VERSION
155199
export BREW_EC_RELEASE_VERSION
156200
export BREW_NIGHTLY_RELEASE_VERSION
157201

158-
# Set the release type to ec, rc or zstream
159-
LATEST_RELEASE_TYPE="ec"
160-
export LATEST_RELEASE_TYPE
202+
# Latest Release info
203+
LATEST_RELEASE_TYPE="ec" # ec, rc or zstream
204+
BREW_LREL_RELEASE_VERSION="${BREW_EC_RELEASE_VERSION}" # BREW_EC_RELEASE_VERSION, BREW_RC_RELEASE_VERSION or BREW_Y0_RELEASE_VERSION
205+
LATEST_RELEASE_VERSION="$(echo "${BREW_LREL_RELEASE_VERSION}" | sed -E 's/(.*)-.*/\1/' | sed -E 's/(.*)~(.*)/\1-\2/')" # example: 4.19.7 or 4.20.0-rc.3
206+
LREL_RELEASE_IMAGE_URL="$(get_lrel_release_image_url "${LATEST_RELEASE_TYPE}" "${LATEST_RELEASE_VERSION}")"
161207

162-
BREW_LREL_RELEASE_VERSION="${BREW_EC_RELEASE_VERSION}"
208+
export LATEST_RELEASE_TYPE
163209
export BREW_LREL_RELEASE_VERSION
210+
export LATEST_RELEASE_VERSION
211+
export LREL_RELEASE_IMAGE_URL
164212

165213
# Branch and commit for the openshift-tests-private repository
166214
OPENSHIFT_TESTS_PRIVATE_REPO_BRANCH="release-4.${MINOR_VERSION}"
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
3+
# Sourced from scenario.sh and uses functions defined there.
4+
5+
# Enable container signature verification for published MicroShift images.
6+
# These are ec / rc / zstream, thus guaranteed to be signed.
7+
# shellcheck disable=SC2034 # used elsewhere
8+
IMAGE_SIGSTORE_ENABLED=true
9+
10+
scenario_create_vms() {
11+
if [ -z "${KONFLUX_LREL_RELEASE_IMAGE_URL}" ] || [[ "${KONFLUX_LREL_RELEASE_IMAGE_URL}" != "" ]] ; then
12+
echo "ERROR: Failed to retrieve a bootc pull spec from '${KONFLUX_LREL_RELEASE_IMAGE_URL}'"
13+
exit 1
14+
fi
15+
prepare_kickstart host1 kickstart-bootc.ks.template "${KONFLUX_LREL_RELEASE_IMAGE_URL}"
16+
launch_vm --boot_blueprint rhel96-bootc
17+
18+
# Open the firewall ports. Other scenarios get this behavior by embedding
19+
# settings in the blueprint, but we cannot open firewall ports in published
20+
# images. We need to do this step before running the RF suite so that suite
21+
# can assume it can reach all of the same ports as for any other test.
22+
configure_vm_firewall host1
23+
}
24+
25+
scenario_remove_vms() {
26+
remove_vm host1
27+
}
28+
29+
scenario_run_tests() {
30+
run_tests host1 \
31+
--variable "EXPECTED_OS_VERSION:9.6" \
32+
--variable "IMAGE_SIGSTORE_ENABLED:True" \
33+
suites/standard1/ suites/selinux/validate-selinux-policy.robot
34+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
3+
# Sourced from scenario.sh and uses functions defined there.
4+
5+
# Enable container signature verification for published MicroShift images.
6+
# These are ec / rc / z-stream, thus guaranteed to be signed.
7+
# shellcheck disable=SC2034 # used elsewhere
8+
IMAGE_SIGSTORE_ENABLED=true
9+
10+
scenario_create_vms() {
11+
local -r bootc_spec="$(curl -s "${KONFLUX_LREL_RELEASE_IMAGE_URL}")"
12+
if [ -z "${bootc_spec}" ] || [[ "${bootc_spec}" != quay.io/openshift* ]] ; then
13+
echo "ERROR: Failed to retrieve a bootc pull spec from '${KONFLUX_LREL_RELEASE_IMAGE_URL}'"
14+
exit 1
15+
fi
16+
prepare_kickstart host1 kickstart-bootc.ks.template "${bootc_spec}"
17+
launch_vm --boot_blueprint rhel96-bootc
18+
19+
# Open the firewall ports. Other scenarios get this behavior by embedding
20+
# settings in the blueprint, but we cannot open firewall ports in published
21+
# images. We need to do this step before running the RF suite so that suite
22+
# can assume it can reach all of the same ports as for any other test.
23+
configure_vm_firewall host1
24+
}
25+
26+
scenario_remove_vms() {
27+
remove_vm host1
28+
}
29+
30+
scenario_run_tests() {
31+
run_tests host1 \
32+
--variable "IMAGE_SIGSTORE_ENABLED:True" \
33+
suites/standard2/
34+
}

0 commit comments

Comments
 (0)