Skip to content

test: update bootc install script to support Fedora CI gating test #1282

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 3, 2025
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
7 changes: 6 additions & 1 deletion hack/provision-derived.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ case "${ID}-${VERSION_ID}" in
dnf -y install nu
dnf clean all
;;
"centos-10")
"rhel-9."*)
dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
dnf -y install nu
dnf clean all
;;
"centos-10"|"rhel-10."*)
# nu is not available in CS10
curl -kL "https://github.com/nushell/nushell/releases/download/0.103.0/nu-0.103.0-$(uname -m)-unknown-linux-gnu.tar.gz" --output nu.tar.gz
mkdir -p nu && tar zvxf nu.tar.gz --strip-components=1 -C nu
Expand Down
12 changes: 6 additions & 6 deletions tmt/plans/integration.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# local image: file:///home/foobar/image.qcow2
provision:
how: virtual
image: https://composes.stream.centos.org/stream-10/production/CentOS-Stream-10-20250331.0/compose/BaseOS/x86_64/images/CentOS-Stream-GenericCloud-10-20250331.0.x86_64.qcow2
image: fedora-rawhide
prepare:
- how: install
package:
Expand All @@ -18,23 +18,23 @@ execute:
discover:
how: fmf
test:
- /tmt/tests/test-00-bootc-install
- /tmt/tests/bootc-install-provision
- /tmt/tests/test-01-readonly

/test-20-local-upgrade:
summary: Execute local upgrade tests
discover:
how: fmf
test:
- /tmt/tests/test-00-bootc-install
- /tmt/tests/bootc-install-provision
- /tmt/tests/test-20-local-upgrade

/test-21-logically-bound-switch:
summary: Execute logically bound images tests for switching images
discover:
how: fmf
test:
- /tmt/tests/test-00-bootc-install
- /tmt/tests/bootc-install-provision
- /tmt/tests/test-21-logically-bound-switch

/test-22-logically-bound-install:
Expand All @@ -44,13 +44,13 @@ execute:
discover:
how: fmf
test:
- /tmt/tests/test-00-bootc-install
- /tmt/tests/bootc-install-provision
- /tmt/tests/test-22-logically-bound-install

/test-23-install-outside-container:
summary: Execute tests for installing outside of a container
discover:
how: fmf
test:
- /tmt/tests/test-00-bootc-install
- /tmt/tests/bootc-install-provision
- /tmt/tests/test-23-install-outside-container
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
summary: Run bootc install to-existing-root to deploy bootc image
test: ./test-00-bootc-install.sh
test: ./bootc-install-provision.sh
duration: 30m
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,19 @@ case "$ID" in
esac

if [ "$TMT_REBOOT_COUNT" -eq 0 ]; then
# Copy bootc root folder to image build root folder
cp -a ../../. "$BOOTC_TEMPDIR"
# Let's move to bootc root folder
cd ../..
# Fedora CI: https://github.com/fedora-ci/dist-git-pipeline/blob/master/Jenkinsfile#L145
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is something I keep getting hung up on. So AIUI today, Testing Farm basically does not handle the job of injecting (or building) the artifact-under-test, it's the reponsibility of a different tool. And commonly today, that different tool is Packit (which is very RPM oriented).

Would it be accurate then to say this is basically doing something similar to what Packit is doing?

Is there hookup/alignment between the fedora-ci/osci and packit or do they just overlap in this sense?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

AFAIK, the fedora ci and osci don't use Packit yet.

# OSCI: https://gitlab.cee.redhat.com/osci-pipelines/dist-git-pipeline/-/blob/master/Jenkinsfile?ref_type=heads#L93
if [[ -v KOJI_TASK_ID ]] || [[ -v CI_KOJI_TASK_ID ]]; then
# Just left those ls commands here to ring the bell for me when something changed
echo "$TMT_SOURCE_DIR"
ls -al "$TMT_SOURCE_DIR"
ls -al "$TMT_SOURCE_DIR/SRPMS"
ls -al /etc/yum.repos.d
cat /etc/yum.repos.d/test-artifacts.repo
ls -al /var/share/test-artifacts
fi

# TMT needs this key
cp -r /root/.ssh "$BOOTC_TEMPDIR"
Expand All @@ -40,34 +51,18 @@ if [ "$TMT_REBOOT_COUNT" -eq 0 ]; then
ls -al "$BOOTC_TEMPDIR"

CONTAINERFILE=${BOOTC_TEMPDIR}/Containerfile
tee "$CONTAINERFILE" > /dev/null << REALEOF
FROM $TIER1_IMAGE_URL as build

COPY contrib /contrib
COPY hack/build.sh /build.sh
RUN /build.sh && rm -v /build.sh
COPY . /build
WORKDIR /build

RUN mkdir -p /build/target/dev-rootfs
RUN --mount=type=cache,target=/build/target --mount=type=cache,target=/var/roothome make test-bin-archive && mkdir -p /out && cp target/bootc.tar.zst /out

FROM $TIER1_IMAGE_URL
COMMON_CONTAINERFILE="${BOOTC_TEMPDIR}/common_containerfile"
tee "$COMMON_CONTAINERFILE" > /dev/null << COMMONEOF
RUN <<EORUN
set -xeuo pipefail

COPY hack/provision-derived.sh /tmp
RUN /tmp/provision-derived.sh && rm -f /tmp/*.sh
# Provision test requirement
/code/hack/provision-derived.sh
# Also copy in some default install configs we use for testing
COPY hack/install-test-configs/* /usr/lib/bootc/install/
cp -a /code/hack/install-test-configs/* /usr/lib/bootc/install/
# And some test kargs
COPY hack/test-kargs /usr/lib/bootc/kargs.d/
# Inject our built code
COPY --from=build /out/bootc.tar.zst /tmp
RUN tar -C / --zstd -xvf /tmp/bootc.tar.zst && rm -vrf /tmp/*
# Also copy over arbitrary bits from the target root
COPY --from=build /build/target/dev-rootfs/ /

RUN <<EORUN
set -xeuo pipefail
cp -a /code/hack/test-kargs/* /usr/lib/bootc/kargs.d/

# For testing farm
mkdir -p -m 0700 /var/roothome
Expand All @@ -91,7 +86,46 @@ COPY bin /usr/local/bin

# In Testing Farm, all ssh things should be reserved for ssh command run after reboot
COPY .ssh /var/roothome/.ssh
COMMONEOF

if [[ -v KOJI_TASK_ID ]] || [[ -v CI_KOJI_TASK_ID ]]; then
FEDORA_CI_CONTAINERFILE="${BOOTC_TEMPDIR}/fedora_ci_containerfile"
tee "$FEDORA_CI_CONTAINERFILE" > /dev/null << FEDORACIEOF
FROM $TIER1_IMAGE_URL

RUN dnf -y upgrade /rpms/*.rpm
FEDORACIEOF
cat >"$CONTAINERFILE" <<REALEOF
$(cat "$FEDORA_CI_CONTAINERFILE")
$(cat "$COMMON_CONTAINERFILE")

REALEOF
else
BOOTC_CI_CONTAINERFILE="${BOOTC_TEMPDIR}/bootc_ci_containerfile"
tee "$BOOTC_CI_CONTAINERFILE" > /dev/null << BOOTCCIEOF
FROM $TIER1_IMAGE_URL as build

WORKDIR /code
RUN hack/build.sh

RUN mkdir -p /build/target/dev-rootfs
RUN --mount=type=cache,target=/build/target --mount=type=cache,target=/var/roothome make test-bin-archive && mkdir -p /out && cp target/bootc.tar.zst /out

FROM $TIER1_IMAGE_URL

# Inject our built code
COPY --from=build /out/bootc.tar.zst /tmp
RUN tar -C / --zstd -xvf /tmp/bootc.tar.zst && rm -vrf /tmp/*
# Also copy over arbitrary bits from the target root
COPY --from=build /build/target/dev-rootfs/ /

BOOTCCIEOF
cat >"$CONTAINERFILE" <<REALEOF
$(cat "$BOOTC_CI_CONTAINERFILE")
$(cat "$COMMON_CONTAINERFILE")
REALEOF
fi


if [[ -d "/var/ARTIFACTS" ]]; then
# In Testing Farm, TMT work dir /var/ARTIFACTS should be reserved
Expand All @@ -103,16 +137,36 @@ REALEOF

# For test-22-logically-bound-install
if [[ "$LBI" == "enabled" ]]; then
echo "COPY tmt/tests/lbi/usr/. /usr" >> "$CONTAINERFILE"
echo "RUN ln -s /usr/share/containers/systemd/curl.container /usr/lib/bootc/bound-images.d/curl.container && ln -s /usr/share/containers/systemd/curl-base.image /usr/lib/bootc/bound-images.d/curl-base.image && ln -s /usr/share/containers/systemd/podman.image /usr/lib/bootc/bound-images.d/podman.image" >> "$CONTAINERFILE"
echo "RUN cp -a /code/tmt/tests/lbi/usr/. /usr && ln -s /usr/share/containers/systemd/curl.container /usr/lib/bootc/bound-images.d/curl.container && ln -s /usr/share/containers/systemd/curl-base.image /usr/lib/bootc/bound-images.d/curl-base.image && ln -s /usr/share/containers/systemd/podman.image /usr/lib/bootc/bound-images.d/podman.image" >> "$CONTAINERFILE"
podman pull --retry 5 --retry-delay 5s quay.io/curl/curl:latest
podman pull --retry 5 --retry-delay 5s quay.io/curl/curl-base:latest
podman pull --retry 5 --retry-delay 5s registry.access.redhat.com/ubi9/podman:latest
fi

cat "$CONTAINERFILE"
# Retry here to avoid quay.io "502 Bad Gateway"
podman build --retry 5 --retry-delay 5s --tls-verify=false -t localhost/bootc:tmt -f "$CONTAINERFILE" "$BOOTC_TEMPDIR"
# bind mount bootc source code folder for bootc binary building and run test provision
# bind mount /var/share/test-artifacts for bootc RPM package installation in Fedora CI and OSCI
if [[ -v KOJI_TASK_ID ]] || [[ -v CI_KOJI_TASK_ID ]]; then
podman build \
--retry 5 \
--retry-delay 5s \
--tls-verify=false \
-v /var/share/test-artifacts:/rpms:z \
-v "$(pwd)":/code:z \
-t localhost/bootc:tmt \
-f "$CONTAINERFILE" \
"$BOOTC_TEMPDIR"
else
podman build \
--retry 5 \
--retry-delay 5s \
--tls-verify=false \
-v "$(pwd)":/code:z \
-t localhost/bootc:tmt \
-f "$CONTAINERFILE" \
"$BOOTC_TEMPDIR"
fi

podman images
podman run \
Expand Down