Skip to content
Merged
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
4 changes: 3 additions & 1 deletion packaging/rpm/make-rpm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions test/Makefile
Original file line number Diff line number Diff line change
@@ -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
12 changes: 10 additions & 2 deletions test/bin/build_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,27 @@ 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
#
# Machine platform type ("x86_64")
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.
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion test/bin/ci_phase_iso_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 9 additions & 1 deletion test/bin/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
40 changes: 24 additions & 16 deletions test/bin/create_local_repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
16 changes: 16 additions & 0 deletions test/bin/get_latest_rpm_version.sh
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions test/bin/manage_vm_connections.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 24 additions & 0 deletions test/bin/scenario.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
30 changes: 30 additions & 0 deletions test/image-blueprints/rhel92-microshift-previous-minor.toml
Original file line number Diff line number Diff line change
@@ -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"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is no longer necessary due to an explicit dependency inside microshift RPM

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a published 4.13 build with that dependency in place, yet?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's merged, but I do not know if it's published.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I'd rather keep this in place for now then to ensure that the upgrade job has a chance of passing. When we have a real fix, we can remove this. I'll open a ticket to make sure we do it when we branch for 4.15.


[[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"]
25 changes: 0 additions & 25 deletions test/image-blueprints/rhel92-microshift413.toml

This file was deleted.

8 changes: 4 additions & 4 deletions test/image-blueprints/rhel92-source-fake-next-minor.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
7 changes: 7 additions & 0 deletions test/package-sources/microshift-fake-next-minor.toml
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions test/scenarios/upgrade-minor-version-healthy.sh
Original file line number Diff line number Diff line change
@@ -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
}