Skip to content

Commit 818d599

Browse files
committed
add 2 new scenarios to test latest released bootc image from konflux
1 parent 3a503a6 commit 818d599

File tree

5 files changed

+102
-33
lines changed

5 files changed

+102
-33
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: 47 additions & 6 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
@@ -159,15 +203,12 @@ export BREW_NIGHTLY_RELEASE_VERSION
159203
LATEST_RELEASE_TYPE="ec" # ec, rc or zstream
160204
BREW_LREL_RELEASE_VERSION="${BREW_EC_RELEASE_VERSION}" # BREW_EC_RELEASE_VERSION, BREW_RC_RELEASE_VERSION or BREW_Y0_RELEASE_VERSION
161205
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
162-
if [[ "${LATEST_RELEASE_TYPE}" == "ec" ]]; then
163-
KONFLUX_LREL_RELEASE_IMAGE_URL="https://mirror.openshift.com/pub/openshift-v4/$(uname -m)/microshift/ocp-dev-preview/${LATEST_RELEASE_VERSION}/el9/bootc-pullspec.txt"
164-
else
165-
KONFLUX_LREL_RELEASE_IMAGE_URL="https://mirror.openshift.com/pub/openshift-v4/$(uname -m)/microshift/ocp/${LATEST_RELEASE_VERSION}/el9/bootc-pullspec.txt"
166-
fi
206+
LREL_RELEASE_IMAGE_URL="$(get_lrel_release_image_url "${LATEST_RELEASE_TYPE}" "${LATEST_RELEASE_VERSION}")"
207+
167208
export LATEST_RELEASE_TYPE
168209
export BREW_LREL_RELEASE_VERSION
169210
export LATEST_RELEASE_VERSION
170-
export KONFLUX_LREL_RELEASE_IMAGE_URL
211+
export LREL_RELEASE_IMAGE_URL
171212

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

test/bin/scenario.sh

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -898,17 +898,6 @@ remove_vm() {
898898
fi
899899
}
900900

901-
# Check if the VM exists
902-
# Returns ERROR if the VM does not exist
903-
check_vm_exists() {
904-
local -r vmname="$1"
905-
local -r full_vmname="$(full_vm_name "${vmname}")"
906-
if ! sudo virsh dominfo "${full_vmname}" >/dev/null 2>&1; then
907-
echo "ERROR: VM '${vmname}' does not exist"
908-
exit 1
909-
fi
910-
}
911-
912901
# Configure the firewall in the VM based on the instructions in the documentation.
913902
configure_vm_firewall() {
914903
local -r vmname="$1"

test/scenarios-bootc/releases/[email protected]

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,16 @@
33
# Sourced from scenario.sh and uses functions defined there.
44

55
# Enable container signature verification for published MicroShift images.
6-
# These are ec / rc / z-stream, thus guaranteed to be signed.
6+
# These are ec / rc / zstream, thus guaranteed to be signed.
77
# shellcheck disable=SC2034 # used elsewhere
88
IMAGE_SIGSTORE_ENABLED=true
99

1010
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
11+
if [ -z "${KONFLUX_LREL_RELEASE_IMAGE_URL}" ] || [[ "${KONFLUX_LREL_RELEASE_IMAGE_URL}" != "" ]] ; then
1312
echo "ERROR: Failed to retrieve a bootc pull spec from '${KONFLUX_LREL_RELEASE_IMAGE_URL}'"
1413
exit 1
1514
fi
16-
prepare_kickstart host1 kickstart-bootc.ks.template "${bootc_spec}"
15+
prepare_kickstart host1 kickstart-bootc.ks.template "${KONFLUX_LREL_RELEASE_IMAGE_URL}"
1716
launch_vm --boot_blueprint rhel96-bootc
1817

1918
# Open the firewall ports. Other scenarios get this behavior by embedding
@@ -24,14 +23,10 @@ scenario_create_vms() {
2423
}
2524

2625
scenario_remove_vms() {
27-
check_vm_exists host1
28-
2926
remove_vm host1
3027
}
3128

3229
scenario_run_tests() {
33-
check_vm_exists host1
34-
3530
run_tests host1 \
3631
--variable "EXPECTED_OS_VERSION:9.6" \
3732
--variable "IMAGE_SIGSTORE_ENABLED:True" \

test/scenarios-bootc/releases/[email protected]

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,10 @@ scenario_create_vms() {
2424
}
2525

2626
scenario_remove_vms() {
27-
check_vm_exists host1
28-
2927
remove_vm host1
3028
}
3129

3230
scenario_run_tests() {
33-
check_vm_exists host1
34-
3531
run_tests host1 \
3632
--variable "IMAGE_SIGSTORE_ENABLED:True" \
3733
suites/standard2/

0 commit comments

Comments
 (0)