diff --git a/packaging/rpm/make-rpm.sh b/packaging/rpm/make-rpm.sh index 49812044a8..f201ed03e3 100755 --- a/packaging/rpm/make-rpm.sh +++ b/packaging/rpm/make-rpm.sh @@ -22,7 +22,8 @@ GIT_SHA=$(git rev-parse HEAD) GITHUB_SHA="${GIT_SHA:0:7}" TARBALL_FILE="microshift-${GITHUB_SHA}.tar.gz" -RPMBUILD_DIR="$(git rev-parse --show-toplevel)/_output/rpmbuild/" +DEFAULT_RPMBUILD_DIR="$(git rev-parse --show-toplevel)/_output/rpmbuild/" +RPMBUILD_DIR="${RPMBUILD_DIR:-${DEFAULT_RPMBUILD_DIR}}" title() { echo -e "\E[34m\n# $1\E[00m"; @@ -87,6 +88,7 @@ if [ -n "${TARGET_ARCH}" ]; then fi # prepare the rpmbuild env +echo "Building to ${RPMBUILD_DIR}" mkdir -p "${RPMBUILD_DIR}"/{BUILD,RPMS,SOURCES,SPECS,SRPMS} case $1 in diff --git a/test/Makefile b/test/Makefile index a13bc89d54..23463c5772 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,12 +1,13 @@ REPO := $(shell git rev-parse --show-toplevel) include $(REPO)/Makefile -NEXT_MINOR = $(shell expr $(MINOR) + 1) +RPMBUILD_DIR := $(REPO)/_output/rpmbuild-fake-next-minor/ -.PHONY: fake-next-minor fake-next-minor-rpm -fake-next-minor: - @echo $(MAJOR).$(NEXT_MINOR).$(PATCH)_fake_next_minor +NEXT_MINOR = $(shell expr $(MINOR) + 1) +.PHONY: fake-next-minor-rpm fake-next-minor-rpm: + rm -rf $(RPMBUILD_DIR) MICROSHIFT_VERSION="$(MAJOR).$(NEXT_MINOR).$(PATCH)_fake_next_minor" \ + RPMBUILD_DIR=$(RPMBUILD_DIR) \ $(MAKE) -C $(REPO) rpm diff --git a/test/bin/build_images.sh b/test/bin/build_images.sh index b7859b4fdf..81b4c0fdee 100755 --- a/test/bin/build_images.sh +++ b/test/bin/build_images.sh @@ -26,13 +26,15 @@ if [ ! -d "${LOCAL_REPO}" ]; then error "Run ${SCRIPTDIR}/create_local_repo.sh before building images." exit 1 fi -release_info_rpm=$(find "${LOCAL_REPO}" -name 'microshift-release-info-*.rpm' -a -not -name '*_fake_*') +release_info_rpm=$(find "${LOCAL_REPO}" -name 'microshift-release-info-*.rpm' | sort | tail -n 1) if [ -z "${release_info_rpm}" ]; then error "Failed to find microshift-release-info RPM in ${LOCAL_REPO}" exit 1 fi SOURCE_VERSION=$(rpm -q --queryformat '%{version}' "${release_info_rpm}") -FAKE_NEXT_MINOR_VERSION=$(cd "${SCRIPTDIR}/.." && make fake-next-minor) +MINOR_VERSION=$(echo "${SOURCE_VERSION}" | cut -f2 -d.) +PREVIOUS_MINOR_VERSION=$(( "${MINOR_VERSION}" - 1 )) +FAKE_NEXT_MINOR_VERSION=$(( "${MINOR_VERSION}" + 1 )) ## TEMPLATE VARIABLES # @@ -40,8 +42,11 @@ FAKE_NEXT_MINOR_VERSION=$(cd "${SCRIPTDIR}/.." && make fake-next-minor) UNAME_M=$(uname -m) export UNAME_M export LOCAL_REPO # defined in common.sh +export NEXT_REPO # defined in common.sh export SOURCE_VERSION # defined earlier export FAKE_NEXT_MINOR_VERSION # defined earlier +export MINOR_VERSION # defined earlier +export PREVIOUS_MINOR_VERSION # defined earlier # Add our sources. It is OK to run these steps repeatedly, if the # details change they are updated in the service. @@ -53,6 +58,9 @@ for template in ${TESTDIR}/package-sources/*.toml; do echo "Rendering ${template} to ${outfile}" envsubst <"${template}" >"${outfile}" echo "Adding package source from ${outfile}" + if sudo composer-cli sources list | grep "^${name}\$"; then + sudo composer-cli sources delete "${name}" + fi sudo composer-cli sources add "${outfile}" done diff --git a/test/bin/ci_phase_iso_build.sh b/test/bin/ci_phase_iso_build.sh index 53f105262b..912e5936f1 100755 --- a/test/bin/ci_phase_iso_build.sh +++ b/test/bin/ci_phase_iso_build.sh @@ -49,7 +49,7 @@ bash -x ./bin/configure_hypervisor_firewall.sh # Re-build from source. cd ~/microshift/ -rm -rf ./_output/rpmbuild +rm -rf ./_output/rpmbuild* time make rpm time make -C test/ fake-next-minor-rpm diff --git a/test/bin/common.sh b/test/bin/common.sh index 23649e880a..cf9fb0caaf 100755 --- a/test/bin/common.sh +++ b/test/bin/common.sh @@ -29,9 +29,17 @@ VM_DISK_DIR="${IMAGEDIR}/${VM_STORAGE_POOL}" # shellcheck disable=SC2034 # used elsewhere RPM_SOURCE="${ROOTDIR}/_output/rpmbuild" +# Location of RPMs built from source +# shellcheck disable=SC2034 # used elsewhere +NEXT_RPM_SOURCE="${ROOTDIR}/_output/rpmbuild-fake-next-minor" + +# Location of local repository used by composer +# shellcheck disable=SC2034 # used elsewhere +LOCAL_REPO="${IMAGEDIR}/rpm-repos/microshift-local" + # Location of local repository used by composer # shellcheck disable=SC2034 # used elsewhere -LOCAL_REPO="${IMAGEDIR}/microshift-local" +NEXT_REPO="${IMAGEDIR}/rpm-repos/microshift-fake-next-minor" # Location of data files created by the tools for managing scenarios # as they are run. diff --git a/test/bin/create_local_repo.sh b/test/bin/create_local_repo.sh index 2d36a30e95..78d286a28a 100755 --- a/test/bin/create_local_repo.sh +++ b/test/bin/create_local_repo.sh @@ -9,23 +9,31 @@ set -euo pipefail SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" source "${SCRIPTDIR}/common.sh" -mkdir -p "${IMAGEDIR}" -cd "${IMAGEDIR}" +make_repo() { + local repodir="$1" + local builddir="$2" + + if [ -d "${repodir}" ]; then + echo "Cleaning up existing repository" + rm -rf "${repodir}" + fi + mkdir -p "${repodir}" -if [ -d "${LOCAL_REPO}" ]; then - echo "Cleaning up existing repository" - rm -rf "${LOCAL_REPO}" -fi -mkdir -p "${LOCAL_REPO}" + # Create the local RPM repository for whatever was built from source. + echo "Copying RPMs from ${builddir} to ${repodir}" + # shellcheck disable=SC2086 # no quotes for command arguments to allow word splitting + cp -R ${builddir}/{RPMS,SPECS,SRPMS} "${repodir}/" -# Create the local RPM repository for whatever was built from source. -echo "Copying RPMs from ${RPM_SOURCE} to ${LOCAL_REPO}" -# shellcheck disable=SC2086 # no quotes for command arguments to allow word splitting -cp -R ${RPM_SOURCE}/{RPMS,SPECS,SRPMS} "${LOCAL_REPO}/" + echo "Creating RPM repo at ${repodir}" + createrepo "${repodir}" -echo "Creating RPM repo at ${LOCAL_REPO}" -createrepo "${LOCAL_REPO}" + echo "Fixing permissions of RPM repo contents" + find "${repodir}" -type f -print -exec chmod a+r {} \; + find "${repodir}" -type d -exec chmod a+rx {} \; +} + +mkdir -p "${IMAGEDIR}" +cd "${IMAGEDIR}" -echo "Fixing permissions of RPM repo contents" -find "${LOCAL_REPO}" -type f -exec chmod a+r {} \; -find "${LOCAL_REPO}" -type d -exec chmod a+rx {} \; +make_repo "${LOCAL_REPO}" "${RPM_SOURCE}" +make_repo "${NEXT_REPO}" "${NEXT_RPM_SOURCE}" diff --git a/test/bin/get_latest_rpm_version.sh b/test/bin/get_latest_rpm_version.sh new file mode 100755 index 0000000000..cc0b47d6dc --- /dev/null +++ b/test/bin/get_latest_rpm_version.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# +# This script reports the version of the latest RPM in the local +# repository. + +set -euo pipefail + +SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source "${SCRIPTDIR}/common.sh" + +release_info_rpm=$(find "${LOCAL_REPO}" -name 'microshift-release-info-*.rpm' | sort | tail -n 1) +if [ -z "${release_info_rpm}" ]; then + error "Failed to find microshift-release-info RPM in ${LOCAL_REPO}" + exit 1 +fi +rpm -q --queryformat '%{version}' "${release_info_rpm}" 2>/dev/null diff --git a/test/bin/manage_vm_connections.sh b/test/bin/manage_vm_connections.sh index f82a6cea00..34887caa0b 100755 --- a/test/bin/manage_vm_connections.sh +++ b/test/bin/manage_vm_connections.sh @@ -177,6 +177,10 @@ action_cleanup() { } action_local() { + if [ ! -d "${SCENARIO_INFO_DIR}" ]; then + error "No scenario info directory at ${SCENARIO_INFO_DIR}, did you boot the VMs for a scenario?" + exit 1 + fi cd "${SCENARIO_INFO_DIR}" local api_port=6443 diff --git a/test/bin/scenario.sh b/test/bin/scenario.sh index 3f7166bafe..76c4b9db38 100755 --- a/test/bin/scenario.sh +++ b/test/bin/scenario.sh @@ -220,6 +220,30 @@ remove_vm() { rm -rf "${SCENARIO_INFO_DIR}/${SCENARIO}/vms/${vmname}" } + +# Function to report the full current version, e.g. "4.13.5" +current_version() { + "${SCRIPTDIR}/get_latest_rpm_version.sh" +} + +# Function to report only the minor portion of the current version, +# e.g. from "4.13.5" reports "13" +current_minor_version() { + current_version | cut -f2 -d. +} + +# Function to report the *previous* minor version. If the current +# version is "4.13.5", reports "12". +previous_minor_version() { + echo $(( $(current_minor_version) - 1 )) +} + +# Function to report the *next* minor version. If the current +# version is "4.14.5", reports "15". +next_minor_version() { + echo $(( $(current_minor_version) + 1 )) +} + # Run the tests for the current scenario run_tests() { local vmname="${1}" diff --git a/test/image-blueprints/rhel92-microshift-previous-minor.toml b/test/image-blueprints/rhel92-microshift-previous-minor.toml new file mode 100644 index 0000000000..d54c6348ff --- /dev/null +++ b/test/image-blueprints/rhel92-microshift-previous-minor.toml @@ -0,0 +1,30 @@ +name = "rhel-9.2-microshift-4.${PREVIOUS_MINOR_VERSION}" +description = "" +version = "0.0.1" +modules = [] +groups = [] +distro = "rhel-92" + +# FIXME: Temporarily pin the openvswitch version. +[[packages]] +name = "openvswitch3.1" +version = "3.1.0-14.el9fdp" + +[[packages]] +name = "microshift" +version = "4.${PREVIOUS_MINOR_VERSION}*" + +[[packages]] +name = "microshift-greenboot" +version = "4.${PREVIOUS_MINOR_VERSION}*" + +[[packages]] +name = "microshift-networking" +version = "4.${PREVIOUS_MINOR_VERSION}*" + +[[packages]] +name = "microshift-selinux" +version = "4.${PREVIOUS_MINOR_VERSION}*" + +[customizations.services] +enabled = ["microshift"] diff --git a/test/image-blueprints/rhel92-microshift413.toml b/test/image-blueprints/rhel92-microshift413.toml deleted file mode 100644 index 23de492b62..0000000000 --- a/test/image-blueprints/rhel92-microshift413.toml +++ /dev/null @@ -1,25 +0,0 @@ -name = "rhel-9.2-microshift-4.13" -description = "" -version = "0.0.1" -modules = [] -groups = [] -distro = "rhel-92" - -[[packages]] -name = "microshift" -version = "4.13*" - -[[packages]] -name = "microshift-greenboot" -version = "4.13*" - -[[packages]] -name = "microshift-networking" -version = "4.13*" - -[[packages]] -name = "microshift-selinux" -version = "4.13*" - -[customizations.services] -enabled = ["microshift"] diff --git a/test/image-blueprints/rhel92-source-fake-next-minor.toml b/test/image-blueprints/rhel92-source-fake-next-minor.toml index edf5b86c0c..99f7a30592 100644 --- a/test/image-blueprints/rhel92-source-fake-next-minor.toml +++ b/test/image-blueprints/rhel92-source-fake-next-minor.toml @@ -7,19 +7,19 @@ distro = "rhel-92" [[packages]] name = "microshift" -version = "${FAKE_NEXT_MINOR_VERSION}" +version = "4.${FAKE_NEXT_MINOR_VERSION}.*" [[packages]] name = "microshift-greenboot" -version = "${FAKE_NEXT_MINOR_VERSION}" +version = "4.${FAKE_NEXT_MINOR_VERSION}.*" [[packages]] name = "microshift-networking" -version = "${FAKE_NEXT_MINOR_VERSION}" +version = "4.${FAKE_NEXT_MINOR_VERSION}.*" [[packages]] name = "microshift-selinux" -version = "${FAKE_NEXT_MINOR_VERSION}" +version = "4.${FAKE_NEXT_MINOR_VERSION}.*" [customizations.services] enabled = ["microshift"] diff --git a/test/package-sources/microshift-fake-next-minor.toml b/test/package-sources/microshift-fake-next-minor.toml new file mode 100644 index 0000000000..c56a3b0c55 --- /dev/null +++ b/test/package-sources/microshift-fake-next-minor.toml @@ -0,0 +1,7 @@ +id = "microshift-fake-next-minor" +name = "MicroShift Fake Next Minor Version Repo" +type = "yum-baseurl" +url = "file://${NEXT_REPO}/" +check_gpg = false +check_ssl = false +system = false diff --git a/test/scenarios/upgrade-minor-version-healthy.sh b/test/scenarios/upgrade-minor-version-healthy.sh new file mode 100644 index 0000000000..95172e76c9 --- /dev/null +++ b/test/scenarios/upgrade-minor-version-healthy.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# Sourced from cleanup_scenario.sh and uses functions defined there. + +scenario_create_vms() { + # Determine the starting image based on the source tree current + # version, minus one. + local start_image + start_image="rhel-9.2-microshift-4.$(previous_minor_version)" + + prepare_kickstart host1 kickstart.ks.template "${start_image}" + launch_vm host1 +} + +scenario_remove_vms() { + remove_vm host1 +} + +scenario_run_tests() { + run_tests host1 \ + --variable "TARGET_REF:rhel-9.2-microshift-source" \ + suites-ostree/healthy-upgrade.robot +}