diff --git a/tests/kola/rpm-ostree/kernel-replace b/tests/kola/rpm-ostree/kernel-replace index 6985e6a8c..3c2215ee6 100755 --- a/tests/kola/rpm-ostree/kernel-replace +++ b/tests/kola/rpm-ostree/kernel-replace @@ -45,41 +45,13 @@ cd $(mktemp -d) OS_ID=$(. /etc/os-release; echo $ID) imagepath=/var/tmp/coreos.ociarchive imagespec="oci-archive:${imagepath}" +derived_imagepath=/var/tmp/coreos-derived.ociarchive +derived_imagespec="oci-archive:${derived_imagepath}" arch=$(arch) -# we only want to query repos once but need the info on multiple boots, so write out state to /var -if [ ! -f /var/kola-kernel.evr ]; then - case "$OS_ID" in - rhcos|scos|rhel|centos) - c9s_mirror="https://mirror.stream.centos.org/9-stream/BaseOS/${arch}/os" - # we're probably already on CentOS and running the latest kernel. so - # here we need to instead pick whatever the latest that's *not* the same - kver=$(dnf repoquery kernel --qf '%{EVR}' --repofrompath=tmp,"${c9s_mirror}" --disablerepo '*' --enablerepo tmp | \ - grep -v "$(rpm -q kernel --qf '%{EVR}')" | tail -n1) - kver="${kver}.${arch}" - url="${c9s_mirror}/Packages/kernel" - ;; - fedora) - # to get the version to use: koji latest-pkg f40 kernel - # XXX: once we can rely on dnf in FCOS, use repoquery also here - kver="6.8.5-301.fc40.${arch}" - url="https://kojipkgs.fedoraproject.org//packages/kernel/6.8.5/301.fc40/${arch}/kernel" - ;; - *) - echo "Unknown OS_ID: ${OS_ID}" - exit 1 - ;; - esac - echo "$kver" > /var/kola-kernel.evr - echo "$url" > /var/kola-kernel.url -else - kver=$(cat /var/kola-kernel.evr) - url=$(cat /var/kola-kernel.url) -fi -case "${AUTOPKGTEST_REBOOT_MARK:-}" in - "") - # Take the existing ostree commit, and export it to a container image, then rebase to it. +build_base_ociarchive() { + # Take the existing ostree commit, and export it to a container image/ociarchive rpm-ostree status --json > status.json checksum=$(jq -r '.deployments[0].checksum' < status.json) v0=$(jq -r '.deployments[0].version' < status.json) @@ -96,17 +68,41 @@ case "${AUTOPKGTEST_REBOOT_MARK:-}" in # Since we're switching OS update stream, turn off zincati systemctl mask --now zincati ostree container encapsulate "${encapsulate_args[@]}" --repo=/ostree/repo ${checksum} "${imagespec}" - # This one keeps --experimental, but we also test without it below - rpm-ostree rebase --experimental "ostree-unverified-image:${imagespec}" - ostree container image list --repo=/ostree/repo | tee imglist.txt - # Test rebasing back to ostree https://github.com/coreos/rpm-ostree/issues/3677 - rpm-ostree rebase "$checksum" - rpm-ostree rebase "ostree-unverified-image:${imagespec}" - /tmp/autopkgtest-reboot 1 - ;; - 1) +} + +build_derived_ociarchive() { + # we only want to query repos once but need the info on multiple boots, so write out state to /var + if [ ! -f /var/kola-kernel.evr ]; then + case "$OS_ID" in + rhcos|scos|rhel|centos) + c9s_mirror="https://mirror.stream.centos.org/9-stream/BaseOS/${arch}/os" + # we're probably already on CentOS and running the latest kernel. so + # here we need to instead pick whatever the latest that's *not* the same + kver=$(dnf repoquery kernel --qf '%{EVR}' --repofrompath=tmp,"${c9s_mirror}" --disablerepo '*' --enablerepo tmp | \ + grep -v "$(rpm -q kernel --qf '%{EVR}')" | tail -n1) + kver="${kver}.${arch}" + url="${c9s_mirror}/Packages/kernel" + ;; + fedora) + # to get the version to use: koji latest-pkg f40 kernel + # XXX: once we can rely on dnf in FCOS, use repoquery also here + kver="6.8.5-301.fc40.${arch}" + url="https://kojipkgs.fedoraproject.org//packages/kernel/6.8.5/301.fc40/${arch}/kernel" + ;; + *) + echo "Unknown OS_ID: ${OS_ID}" + exit 1 + ;; + esac + echo "$kver" > /var/kola-kernel.evr + echo "$url" > /var/kola-kernel.url + else + kver=$(cat /var/kola-kernel.evr) + url=$(cat /var/kola-kernel.url) + fi + td=$(mktemp -d) - cd ${td} + pushd ${td} cat > Containerfile << EOF FROM $imagespec RUN rpm-ostree override replace \ @@ -114,9 +110,31 @@ RUN rpm-ostree override replace \ rpm-ostree cleanup -m && \ ostree container commit EOF - derived_imagepath=/var/tmp/coreos-derived.ociarchive - derived_imagespec="oci-archive:${derived_imagepath}" podman build --net=host -t "${derived_imagespec}" --squash . + popd +} + +case "${AUTOPKGTEST_REBOOT_MARK:-}" in + "") + # First thing, let's create the base and derived OCI archive image files + build_base_ociarchive + build_derived_ociarchive + + # Since we're switching OS update streams, turn off zincati + systemctl mask --now zincati + + # Rebase a few times to test the mechanisms + # + # This one keeps --experimental, but we also test without it below + rpm-ostree rebase --experimental "ostree-unverified-image:${imagespec}" + ostree container image list --repo=/ostree/repo | tee imglist.txt + # Test rebasing back to ostree https://github.com/coreos/rpm-ostree/issues/3677 + rpm-ostree rebase "$checksum" + rpm-ostree rebase "ostree-unverified-image:${imagespec}" + /tmp/autopkgtest-reboot 1 + ;; + 1) + # Now test rebasing to the derived kernel-replaced image rpm-ostree --version rpm-ostree rebase "ostree-unverified-image:$derived_imagespec" ostree container image list --repo=/ostree/repo