Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions test/bin/common_versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,24 @@ export CNCF_SYSTEMD_LOGS_VERSION=v0.4
export GITOPS_VERSION=1.16

# The brew release versions needed for release regression testing
BREW_Y0_RELEASE_VERSION="$(get_vrel_from_rpm "${BREW_RPM_SOURCE}/4.${MINOR_VERSION}-zstream/${UNAME_M}/")"
BREW_Y1_RELEASE_VERSION="$(get_vrel_from_rpm "${BREW_RPM_SOURCE}/4.${PREVIOUS_MINOR_VERSION}-zstream/${UNAME_M}/")"
BREW_Y2_RELEASE_VERSION="$(get_vrel_from_rpm "${BREW_RPM_SOURCE}/4.${YMINUS2_MINOR_VERSION}-zstream/${UNAME_M}/")"
BREW_RC_RELEASE_VERSION="$(get_vrel_from_rpm "${BREW_RPM_SOURCE}/4.${MINOR_VERSION}-rc/${UNAME_M}/")"
BREW_EC_RELEASE_VERSION="$(get_vrel_from_rpm "${BREW_RPM_SOURCE}/4.${MINOR_VERSION}-ec/${UNAME_M}/")"
BREW_Y0_VERSION=$(./test/bin/manage_brew_rpms.sh find_package "4.${MINOR_VERSION}" "zstream" "0" "0" | cut -d'-' -f2)
BREW_Y1_VERSION=$(./test/bin/manage_brew_rpms.sh find_package "4.${MINOR_VERSION}" "zstream" "1" "0" | cut -d'-' -f2)
BREW_Y2_VERSION=$(./test/bin/manage_brew_rpms.sh find_package "4.${MINOR_VERSION}" "zstream" "2" "0" | cut -d'-' -f2)
BREW_Z1_VERSION=$(./test/bin/manage_brew_rpms.sh find_package "4.${MINOR_VERSION}" "zstream" "0" "1" | cut -d'-' -f2)
BREW_RC_VERSION=$(./test/bin/manage_brew_rpms.sh find_package "4.${MINOR_VERSION}" "rc" "0" "0" | cut -d'-' -f2)
BREW_EC_VERSION=$(./test/bin/manage_brew_rpms.sh find_package "4.${MINOR_VERSION}" "ec" "0" "0" | cut -d'-' -f2)

BREW_Y0_RELEASE_VERSION="$(get_vrel_from_rpm "${BREW_RPM_SOURCE}/${BREW_Y0_VERSION}/${UNAME_M}/")"
BREW_Y1_RELEASE_VERSION="$(get_vrel_from_rpm "${BREW_RPM_SOURCE}/${BREW_Y1_VERSION}/${UNAME_M}/")"
BREW_Y2_RELEASE_VERSION="$(get_vrel_from_rpm "${BREW_RPM_SOURCE}/${BREW_Y2_VERSION}/${UNAME_M}/")"
BREW_Z1_RELEASE_VERSION="$(get_vrel_from_rpm "${BREW_RPM_SOURCE}/${BREW_Z1_VERSION}/${UNAME_M}/")"
BREW_RC_RELEASE_VERSION="$(get_vrel_from_rpm "${BREW_RPM_SOURCE}/${BREW_RC_VERSION}/${UNAME_M}/")"
BREW_EC_RELEASE_VERSION="$(get_vrel_from_rpm "${BREW_RPM_SOURCE}/${BREW_EC_VERSION}/${UNAME_M}/")"

export BREW_Y0_RELEASE_VERSION
export BREW_Y1_RELEASE_VERSION
export BREW_Y2_RELEASE_VERSION
export BREW_Z1_RELEASE_VERSION
export BREW_RC_RELEASE_VERSION
export BREW_EC_RELEASE_VERSION

Expand Down
110 changes: 90 additions & 20 deletions test/bin/manage_brew_rpms.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# its execution in a containerized environment with limited set of tools.

usage() {
echo "Usage: $(basename "$0") [access | download <version> <path> [version_type]]"
echo "Usage: $(basename "$0") [access | download <version> <path> [version_type] [ver_prev_y] [ver_prev_z]]"
echo " download: Download the RPM version to the path as specified"
echo " - version: the X.Y version. Example: 4.19"
echo " - path: the output directory. Example: /_output/test-images/brew-rpms"
echo " - version_type: Optional. Valid values: rc, ec and zstream. Default: ec"
echo " - ver_prev_y: Optional. How far back from the current Y version to look for the previous Y version. Example: 2 (for 4.20 is 4.18)"
echo " - ver_prev_z: Optional. How far back from the current Z version to look for the previous Z version. Example: 2 (for 4.20.3 is 4.20.1)"
echo " access: Exit with non-zero status if brew cannot be accessed"
}

Expand All @@ -29,52 +31,114 @@ action_access() {
return ${rc}
}

action_download() {
action_find_package() {
local -r ver=$1
local -r dir=$2
local -r main_dir=$2
local -r ver_type=${3:-ec}
local -r ver_prev_y=${4:-0}
local -r ver_prev_z=${5:-0}

if [ -z "${ver}" ] || [ -z "${dir}" ] ; then
echo "ERROR: At least two parameters (version and path) are required"
exit 1
# Validate version format
if ! [[ "${ver}" =~ ^4\.[0-9]+(\.[0-9]+)?$ ]]; then
echo "ERROR: Version '${ver}' does not match required format 4.Y or 4.Y.Z (e.g., 4.20 or 4.20.1)"
return 1
fi

if ! action_access ; then
echo "ERROR: Brew Hub site is not accessible"
exit 1
# Validate optional numeric parameters
if [ "${ver_prev_y}" -gt 0 ] && ! [[ "${ver_prev_y}" =~ ^[0-9]$ ]]; then
echo "ERROR: ver_prev_y '${ver_prev_y}' must be a non-negative integer and less than 10"
return 1
fi
"${SCRIPTDIR}/../../scripts/fetch_tools.sh" brew
if [ "${ver_prev_z}" -gt 0 ] && ! [[ "${ver_prev_z}" =~ ^[0-9]$ ]]; then
echo "ERROR: ver_prev_z '${ver_prev_z}' must be a non-negative integer and less than 10"
return 1
fi

# Extract version components
ver_x=$(echo "${ver}" | cut -d'.' -f1)
ver_y=$(echo "${ver}" | cut -d'.' -f2)

# Calculate previous X.Y version
ver_y=$((ver_y - ver_prev_y))

# Attempt downloading the specified build version
local package
case ${ver_type} in
zstream)
package=$(brew list-builds --quiet --package=microshift --state=COMPLETE | grep "^microshift-${ver}" | grep -v "~" | uniq | tail -n1) || true
package=$(brew list-builds --quiet --package=microshift --state=COMPLETE | grep "^microshift-${ver_x}.${ver_y}" | grep -v "~" | uniq) || true
;;
rc|ec)
package=$(brew list-builds --quiet --package=microshift --state=COMPLETE | grep "^microshift-${ver}.0~${ver_type}." | tail -n1) || true
package=$(brew list-builds --quiet --package=microshift --state=COMPLETE | grep "^microshift-${ver_x}.${ver_y}.0~${ver_type}." | uniq) || true
;;
*)
echo "ERROR: Invalid version_type '${ver_type}'. Valid values are: rc, ec and zstream"
exit 1
return 1
;;
esac

# If the previous version is Z-1 or Z-2, we need to find the previous package
package=$(echo "${package}" | tail -n$((1 + ver_prev_z)) | head -n1 | awk '{print $1}')

if [ -z "${package}" ] ; then
echo "ERROR: Cannot find MicroShift '${ver_x}.${ver_y}' packages in brew"
return 1
fi

echo "${package}"
}

action_download() {
local package
if ! package=$(action_find_package "$@" 2>&1); then
echo "${package}"
return 1
fi

local -r main_dir="${2}"
local -r sub_dir=$(echo "${package}" | cut -d'-' -f2)
if ! brew_cli_download "${package}" "${main_dir}" "${sub_dir}" 2>&1; then
return 1
fi
}

brew_cli_download() {
local -r package=$1
local -r main_dir=$2
local -r sub_dir=$3

# Validate parameters
if [ -z "${package}" ] ; then
echo "ERROR: Cannot find MicroShift '${ver}' packages in brew"
echo "ERROR: Package is required"
exit 1
fi

if [ -z "${main_dir}" ] ; then
echo "ERROR: Main directory is required"
exit 1
fi

if [ -z "${sub_dir}" ] ; then
echo "ERROR: Sub directory is required"
exit 1
fi
# Check if brew is accessible
if ! action_access ; then
echo "ERROR: Brew Hub site is not accessible"
exit 1
fi
"${SCRIPTDIR}/../../scripts/fetch_tools.sh" brew

package=$(awk '{print $1}' <<< "${package}")
echo "Downloading '${package}' packages from brew"

# Download all the supported architectures as the required architecture
# cannot be identified easily when running in a CI job
for arch in x86_64 aarch64 ; do
local adir
adir="${dir}/${ver}-${ver_type}/${arch}"
adir="${main_dir}/${sub_dir}/${arch}"

mkdir -p "${adir}"
if ! mkdir -p "${adir}" ; then
echo "ERROR: Failed to create directory '${adir}'"
exit 1
fi
pushd "${adir}" &>/dev/null
if ! brew download-build --arch="${arch}" --arch="noarch" "${package}" ; then
echo "WARNING: Failed to download '${package}' packages using brew download-build command, using curl as a fallback mechanism"
Expand Down Expand Up @@ -132,10 +196,16 @@ case "${action}" in
[ $# -ne 1 ] && usage && exit 1
"action_${action}"
;;
find_package)
[ $# -ne 3 ] && [ $# -ne 4 ] && [ $# -ne 5 ] && [ $# -ne 6 ] && usage && exit 1
shift
args=("$1" "/dev/null" "$2" "$3" "$4")
action_"${action}" "${args[@]}"
;;
download)
[ $# -ne 3 ] && [ $# -ne 4 ] && usage && exit 1
[ $# -ne 3 ] && [ $# -ne 4 ] && [ $# -ne 5 ] && [ $# -ne 6 ] && usage && exit 1
shift
"action_${action}" "$@"
action_"${action}" "$@"
;;
-h)
usage
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# {{- if env.Getenv "BREW_Z1_RELEASE_VERSION" "" -}}
# Note: This comment makes templating add a new line before the code
FROM localhost/rhel96-test-agent:latest

# Build arguments
ARG USHIFT_RPM_REPO_NAME=microshift-brew
ARG USHIFT_RPM_REPO_PATH=/tmp/$USHIFT_RPM_REPO_NAME

# Copy the MicroShift repository contents
COPY ./rpm-repos/$USHIFT_RPM_REPO_NAME $USHIFT_RPM_REPO_PATH

# Copy repository configuration
COPY ./bootc-images/$USHIFT_RPM_REPO_NAME.repo ./bootc-images/microshift-fast-datapath-rhel9.repo ./bootc-images/microshift-rhocp-y1.repo \
/etc/yum.repos.d/

# Print repository configuration contents.
# Install MicroShift, test agent and cleanup.
RUN dnf repoinfo --enabled && \
dnf install -y firewalld systemd-resolved \
{{ range (env.Getenv "MICROSHIFT_MANDATORY_RPMS" | strings.Split " ") -}}
"{{ . }}-{{ env.Getenv "BREW_Z1_RELEASE_VERSION" }}" \
{{ end -}}
{{ range (env.Getenv "MICROSHIFT_Y1_OPTIONAL_RPMS" | strings.Split " ") -}}
"{{ . }}-{{ env.Getenv "BREW_Z1_RELEASE_VERSION" }}" \
{{ end -}}
{{ if and (env.Getenv "UNAME_M" "") (eq "x86_64" .Env.UNAME_M) -}}
{{ range (env.Getenv "MICROSHIFT_Y1_X86_64_RPMS" | strings.Split " ") -}}
"{{ . }}-{{ env.Getenv "BREW_Z1_RELEASE_VERSION" }}" \
{{ end -}}
{{ end -}}
&& \
systemctl enable microshift microshift-test-agent && \
rm -vf /etc/yum.repos.d/microshift-*.repo && \
rm -rvf $USHIFT_RPM_REPO_PATH && \
dnf clean all

# Configure firewall
RUN firewall-offline-cmd --zone=public --add-port=22/tcp && \
firewall-offline-cmd --zone=trusted --add-source=10.42.0.0/16 && \
firewall-offline-cmd --zone=trusted --add-source=169.254.169.1 && \
firewall-offline-cmd --zone=trusted --add-source=fd01::/48 && \
firewall-offline-cmd --zone=public --add-port=80/tcp && \
firewall-offline-cmd --zone=public --add-port=443/tcp && \
firewall-offline-cmd --zone=public --add-port=5353/udp && \
firewall-offline-cmd --zone=public --add-port=6443/tcp && \
firewall-offline-cmd --zone=public --add-port=8889/tcp && \
firewall-offline-cmd --zone=public --add-port=30000-32767/tcp && \
firewall-offline-cmd --zone=public --add-port=30000-32767/udp
# {{- end -}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{{- if and (env.Getenv "BREW_Z1_RELEASE_VERSION" "") (env.Getenv "BREW_Y1_RELEASE_VERSION" "") -}}
{{- /*

We wrap this template in a test so that the body of the output is
empty when there is no "current" version release. The output file
must end up completely empty, so we need to remove whitespace from
around the first and last template instructions.

*/ -}}

name = "rhel-9.6-microshift-brew-optionals-4.{{ .Env.MINOR_VERSION }}-z1"
description = "A RHEL 9.6 image with already built and released RPMs like EC, RC, or Z-stream release: {{ .Env.BREW_Z1_RELEASE_VERSION }}"
version = "0.0.1"
modules = []
groups = []
distro = "rhel-96"

# Parent specification directive recognized by test/bin/build_images.sh to be
# used with the '--parent' argument of 'osbuild-composer'
# parent = "rhel-9.6-microshift-brew-optionals-4.{{ .Env.PREVIOUS_MINOR_VERSION }}-zstream"

{{ range (env.Getenv "MICROSHIFT_MANDATORY_RPMS" | strings.Split " ") }}
[[packages]]
name = "{{ . }}"
version = "{{ env.Getenv "BREW_Z1_RELEASE_VERSION" }}"
{{ end }}

{{ range (env.Getenv "MICROSHIFT_Y1_OPTIONAL_RPMS" | strings.Split " ") }}
[[packages]]
name = "{{ . }}"
version = "{{ env.Getenv "BREW_Z1_RELEASE_VERSION" }}"
{{ end }}

{{- if and (env.Getenv "UNAME_M" "") (eq "x86_64" .Env.UNAME_M) }}
{{ range (env.Getenv "MICROSHIFT_Y1_X86_64_RPMS" | strings.Split " ") }}
[[packages]]
name = "{{ . }}"
version = "{{ env.Getenv "BREW_Z1_RELEASE_VERSION" }}"
{{ end }}
{{- end }}

[[packages]]
name = "microshift-test-agent"
version = "*"

[customizations.services]
enabled = ["microshift", "microshift-test-agent"]

[customizations.firewall]
ports = [
"22:tcp",
"80:tcp",
"443:tcp",
"5353:udp",
"6443:tcp",
"8889:tcp",
"30000-32767:tcp",
"30000-32767:udp",
]

[customizations.firewall.services]
enabled = ["mdns", "ssh", "http", "https"]

[[customizations.firewall.zones]]
name = "trusted"
sources = ["10.42.0.0/16", "169.254.169.1", "fd01::/48"]
{{- end -}}
52 changes: 52 additions & 0 deletions test/scenarios-bootc/releases/el96-z1@el96-lrel@standard1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash

# Sourced from scenario.sh and uses functions defined there.

# NOTE: Unlike most suites, these tests rely on being run IN ORDER to
# ensure MicroShift is upgraded before running standard suite tests
export TEST_RANDOMIZATION=none

start_image="rhel96-bootc-brew-z1-with-optional"
dest_image="rhel96-bootc-brew-${LATEST_RELEASE_TYPE}-with-optional"

scenario_create_vms() {
if ! does_image_exist "${start_image}"; then
echo "Image '${start_image}' not found - skipping test"
return 0
fi
if ! does_image_exist "${dest_image}"; then
echo "Image '${dest_image}' not found - skipping test"
return 0
fi
prepare_kickstart host1 kickstart-bootc.ks.template "${start_image}"
launch_vm --boot_blueprint rhel96-bootc
}

scenario_remove_vms() {
if ! does_image_exist "${start_image}"; then
echo "Image '${start_image}' not found - skipping test"
return 0
fi
if ! does_image_exist "${dest_image}"; then
echo "Image '${dest_image}' not found - skipping test"
return 0
fi
remove_vm host1
}

scenario_run_tests() {
if ! does_image_exist "${start_image}"; then
echo "Image '${start_image}' not found - skipping test"
return 0
fi
if ! does_image_exist "${dest_image}"; then
echo "Image '${dest_image}' not found - skipping test"
return 0
fi
run_tests host1 \
--variable "TARGET_REF:${dest_image}" \
--variable "BOOTC_REGISTRY:${MIRROR_REGISTRY_URL}" \
--variable "EXPECTED_OS_VERSION:9.6" \
suites/upgrade/upgrade-successful.robot \
suites/standard1/ suites/selinux/validate-selinux-policy.robot
}
Loading