Skip to content

Commit

Permalink
kola/kernel-replace: Replace kernel based on OS_ID
Browse files Browse the repository at this point in the history
  • Loading branch information
c4rt0 committed Jul 9, 2024
1 parent dfb0b16 commit 3ec17ba
Showing 1 changed file with 37 additions and 16 deletions.
53 changes: 37 additions & 16 deletions tests/kola/rpm-ostree/kernel-replace
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
## # We've seen some OOM when 1024M is used:
## # https://github.com/coreos/fedora-coreos-tracker/issues/1506
## minMemory: 2048
## # This test only runs on FCOS due to a problem with skopeo copy on
## # RHCOS. See: https://github.com/containers/skopeo/issues/1846
## distros: fcos
## # distros: "fcos rhcos scos"
## # Needs internet access as we fetch files from koji
## # We add the "reprovision" tag here even though we aren't
## # reprovisioning as a hack so that in our pipeline the test
Expand Down Expand Up @@ -43,13 +41,18 @@ set -euxo pipefail
cd $(mktemp -d)

# TODO: It'd be much better to test this via a registry
image_dir=/var/tmp/fcos
image=oci:$image_dir

# define OS ID in order to assign appropriate kernel later
OS_ID=$(grep '^ID=' /etc/os-release | cut -d "=" -f2 | cut -d '"' -f2)

image_dir=/var/tmp/coreos
image=oci:${image_dir}
image_pull=ostree-unverified-image:$image
tmp_imagedir=/var/tmp/fcos-tmp
tmp_imagedir=${image_dir}-tmp
arch=$(arch)
kver="6.2.9-300.fc38.${arch}"

echo $(uname -r)
echo "AUTOPKGTEST_REBOOT_MARK: ${AUTOPKGTEST_REBOOT_MARK:-}"
case "${AUTOPKGTEST_REBOOT_MARK:-}" in
"")
# Take the existing ostree commit, and export it to a container image, then rebase to it.
Expand Down Expand Up @@ -80,18 +83,28 @@ case "${AUTOPKGTEST_REBOOT_MARK:-}" in
1)
# Setup
# copy the OCI dir to containers-storage for a local build
skopeo copy $image containers-storage:localhost/fcos
skopeo copy $image containers-storage:localhost/coreos
rm "${image_dir}" -rf
td=$(mktemp -d)
cd ${td}
version=$(rpm-ostree --version | grep Version)
cat > Dockerfile << EOF
FROM localhost/fcos
RUN rpm-ostree cliwrap install-to-root /
echo "Found ${OS_ID}"
if [ "${OS_ID}" = "rhcos" ] || [ "${OS_ID}" = "scos" ]; then
cat > Containerfile << EOF
FROM localhost/coreos
RUN rpm-ostree override replace \
https://koji.fedoraproject.org/koji/buildinfo?buildID=2178613 && \
https://mirror.stream.centos.org/9-stream/BaseOS/x86_64/os/Packages/kernel-{,core-,modules-,modules-core-,modules-extra-}5.14.0-472.el9.x86_64.rpm && \
rpm-ostree cleanup -m && \
ostree container commit
EOF
else
cat > Containerfile << EOF
FROM localhost/coreos
RUN rpm-ostree override replace https://kojipkgs.fedoraproject.org//packages/kernel/6.10.0/0.rc7.58.fc41/x86_64/kernel-{,core-,modules-,modules-core-,modules-extra-}6.10.0-0.rc7.58.fc41.x86_64.rpm && \
rpm-ostree cleanup -m && \
ostree container commit
EOF
fi
# Older podman found in RHEL8 blows up without /etc/resolv.conf
# which happens in our qemu path.
touched_resolv_conf=0
Expand All @@ -101,12 +114,12 @@ EOF
3.*) touched_resolv_conf=1; touch /etc/resolv.conf;;
esac
fi
podman build --net=host -t localhost/fcos-derived --squash .
podman build --net=host -t localhost/coreos-derived --squash .
if test "${touched_resolv_conf}" -eq 1; then
rm -vf /etc/resolv.conf
fi
derived=oci:$image_dir:derived
skopeo copy containers-storage:localhost/fcos-derived $derived
skopeo copy containers-storage:localhost/coreos-derived $derived
rpm-ostree --version
rpm-ostree rebase ostree-unverified-image:$derived
ostree container image list --repo=/ostree/repo
Expand All @@ -115,10 +128,18 @@ EOF
;;
2)
un=$(uname -r)
if test "$un" != "$kver"; then
echo "Expected kernel $kver but found $un"
if test "$un" == "$kver"; then
echo "Expected different version of kernel, but found $un"
exit 1
else
echo "Kernel switch to $un was successfull"
exit 0
fi
test -f /usr/lib/modules/$kver/initramfs.img
test -f /usr/lib/modules/$kver/vmlinuz
;;
*)
echo "Unknown AUTOPKGTEST_REBOOT_MARK: ${AUTOPKGTEST_REBOOT_MARK:-}"
exit 1
;;
esac

0 comments on commit 3ec17ba

Please sign in to comment.