Skip to content

Commit c9fbf77

Browse files
committed
add bootc switch
Signed-off-by: Xiaofeng Wang <[email protected]>
1 parent e8fb1ed commit c9fbf77

File tree

3 files changed

+82
-0
lines changed

3 files changed

+82
-0
lines changed

plans/bootc-switch.fmf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
summary: run bootc switch test on tmt image mode vm
2+
provision:
3+
how: virtual
4+
image: http://images.osci.redhat.com/RHEL-9.6.0-image-mode-x86_64.qcow2
5+
execute:
6+
how: tmt
7+
discover:
8+
how: fmf
9+
test:
10+
- /bootc-switch

tests/bootc-switch.fmf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
summary: Run bootc-switch test
2+
test: ./bootc-switch.sh
3+
duration: 1h

tests/bootc-switch.sh

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/bin/bash
2+
set -exuo pipefail
3+
4+
if [ "$TMT_REBOOT_COUNT" -eq 0 ]; then
5+
ARCH=$(uname -m)
6+
TEMPDIR=$(mktemp -d)
7+
trap 'rm -rf -- "$TEMPDIR"' EXIT
8+
9+
# Get OS data.
10+
# source /etc/os-release
11+
ID=fedora
12+
VERSION_ID=42
13+
case ""${ID}-${VERSION_ID}"" in
14+
"centos-9")
15+
TIER1_IMAGE_URL="quay.io/centos-bootc/centos-bootc:stream9"
16+
BOOTC_COPR_REPO_DISTRO="centos-stream-9-${ARCH}"
17+
;;
18+
"centos-10")
19+
TIER1_IMAGE_URL="quay.io/centos-bootc/centos-bootc:stream10"
20+
BOOTC_COPR_REPO_DISTRO="centos-stream-10-${ARCH}"
21+
;;
22+
"fedora-"*)
23+
TIER1_IMAGE_URL="quay.io/fedora/fedora-bootc:${VERSION_ID}"
24+
BOOTC_COPR_REPO_DISTRO="fedora-${VERSION_ID}-${ARCH}"
25+
;;
26+
*)
27+
echo "Don't work with this distro"
28+
exit 1
29+
;;
30+
esac
31+
32+
if [[ "$VERSION_ID" == "43" ]]; then
33+
BOOTC_COPR_REPO_DISTRO="fedora-rawhide-${ARCH}"
34+
fi
35+
36+
CONTAINERFILE=${TEMPDIR}/Containerfile
37+
tee "$CONTAINERFILE" > /dev/null << REALEOF
38+
FROM $TIER1_IMAGE_URL
39+
40+
RUN <<EORUN
41+
set -xeuo pipefail
42+
43+
cat <<EOF >> /etc/yum.repos.d/bootc.repo
44+
[bootc]
45+
name=bootc
46+
baseurl=https://download.copr.fedorainfracloud.org/results/rhcontainerbot/bootc/${BOOTC_COPR_REPO_DISTRO}/
47+
enabled=1
48+
gpgcheck=0
49+
repo_gpgcheck=0
50+
EOF
51+
52+
dnf -y update bootc
53+
dnf -y install rsync
54+
dnf -y clean all
55+
rm -rf /var/cache /var/lib/dnf
56+
EORUN
57+
REALEOF
58+
59+
cat "$CONTAINERFILE"
60+
sudo podman build --tls-verify=false -t localhost/bootc:tmt -f "$CONTAINERFILE" "$TEMPDIR"
61+
sudo podman images
62+
sudo bootc switch --transport containers-storage localhost/bootc:tmt
63+
64+
tmt-reboot
65+
elif [ "$TMT_REBOOT_COUNT" -eq 1 ]; then
66+
bootc status
67+
echo "bootc switch succeed"
68+
exit 0
69+
fi

0 commit comments

Comments
 (0)