Skip to content

Commit e8fb1ed

Browse files
committed
add bootc-install plan and test
Signed-off-by: Xiaofeng Wang <[email protected]>
0 parents  commit e8fb1ed

File tree

4 files changed

+104
-0
lines changed

4 files changed

+104
-0
lines changed

.fmf/version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1

plans/bootc-install.fmf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
summary: run bootc install to-existing-root test on tmt vm
2+
provision:
3+
how: virtual
4+
image: https://dl.fedoraproject.org/pub/fedora/linux/releases/41/Cloud/x86_64/images/Fedora-Cloud-Base-Generic-41-1.4.x86_64.qcow2
5+
prepare:
6+
- how: install
7+
package:
8+
- podman
9+
execute:
10+
how: tmt
11+
discover:
12+
how: fmf
13+
test:
14+
- /bootc-install

tests/bootc-install.fmf

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

tests/bootc-install.sh

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
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+
case ""${ID}-${VERSION_ID}"" in
12+
"centos-9")
13+
TIER1_IMAGE_URL="quay.io/centos-bootc/centos-bootc:stream9"
14+
BOOTC_COPR_REPO_DISTRO="centos-stream-9-${ARCH}"
15+
;;
16+
"centos-10")
17+
TIER1_IMAGE_URL="quay.io/centos-bootc/centos-bootc:stream10"
18+
BOOTC_COPR_REPO_DISTRO="centos-stream-10-${ARCH}"
19+
;;
20+
"fedora-"*)
21+
TIER1_IMAGE_URL="quay.io/fedora/fedora-bootc:${VERSION_ID}"
22+
BOOTC_COPR_REPO_DISTRO="fedora-${VERSION_ID}-${ARCH}"
23+
;;
24+
*)
25+
echo "Don't work with this distro"
26+
exit 1
27+
;;
28+
esac
29+
30+
ls -al /root/.ssh
31+
cat /root/.ssh/authorized_keys
32+
cp -r /root/.ssh "$TEMPDIR"
33+
34+
if [[ "$VERSION_ID" == "43" ]]; then
35+
BOOTC_COPR_REPO_DISTRO="fedora-rawhide-${ARCH}"
36+
fi
37+
38+
CONTAINERFILE=${TEMPDIR}/Containerfile
39+
tee "$CONTAINERFILE" > /dev/null << REALEOF
40+
FROM $TIER1_IMAGE_URL
41+
42+
RUN <<EORUN
43+
set -xeuo pipefail
44+
45+
mkdir -p -m 0700 /var/roothome
46+
47+
cat <<EOF >> /etc/yum.repos.d/bootc.repo
48+
[bootc]
49+
name=bootc
50+
baseurl=https://download.copr.fedorainfracloud.org/results/rhcontainerbot/bootc/${BOOTC_COPR_REPO_DISTRO}/
51+
enabled=1
52+
gpgcheck=0
53+
repo_gpgcheck=0
54+
EOF
55+
56+
dnf -y update bootc
57+
dnf -y install cloud-init rsync
58+
ln -s ../cloud-init.target /usr/lib/systemd/system/default.target.wants
59+
dnf -y clean all
60+
rm -rf /var/cache /var/lib/dnf
61+
EORUN
62+
COPY .ssh /var/roothome/.ssh
63+
REALEOF
64+
65+
cat "$CONTAINERFILE"
66+
sudo podman build --tls-verify=false -t localhost/bootc:tmt -f "$CONTAINERFILE" "$TEMPDIR"
67+
sudo podman images
68+
sudo podman run \
69+
--rm \
70+
--tls-verify=false \
71+
--privileged \
72+
--pid=host \
73+
-v /:/target \
74+
-v /dev:/dev \
75+
-v /var/lib/containers:/var/lib/containers \
76+
-v /root/.ssh:/output \
77+
--security-opt label=type:unconfined_t \
78+
"localhost/bootc:tmt" \
79+
bootc install to-existing-root --target-transport containers-storage
80+
81+
tmt-reboot
82+
elif [ "$TMT_REBOOT_COUNT" -eq 1 ]; then
83+
bootc status
84+
echo "bootc install to-existing-root succeed"
85+
exit 0
86+
fi

0 commit comments

Comments
 (0)