Skip to content

Commit b2e796f

Browse files
committed
tmt: add test test-bootc-install-on-ostree on FCOS
Signed-off-by: Huijing Hei <[email protected]>
1 parent fa5ce7e commit b2e796f

File tree

5 files changed

+121
-0
lines changed

5 files changed

+121
-0
lines changed

.github/workflows/ci.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,17 @@ jobs:
6262
run: sudo tune2fs -O verity $(findmnt -vno SOURCE /)
6363
- name: Install utils
6464
run: sudo apt -y install fsverity just
65+
- name: TMT test for installation on ostree
66+
run: |
67+
set -xeu
68+
env BOOTC_base=quay.io/fedora/fedora-bootc:43 just build
69+
podman image exists localhost/bootc
70+
(cd hack && podman build -t localhost/bootc-test -f Containerfile.derived)
71+
podman image exists localhost/bootc-test && \
72+
podman save -q localhost/bootc-test:latest -o tmt/tests/examples/bootc-test.tar
73+
tmt run --environment running_env=existing-ostree plans -n /tmt/plans/tests-install/plan-bootc-install-on-ostree --debug
74+
rm -f tmt/tests/examples/bootc-test.tar
75+
podman rmi localhost/bootc{,-bin} -f
6576
- name: Integration tests
6677
run: |
6778
set -xeu
@@ -106,6 +117,7 @@ jobs:
106117
sudo find /ostree/repo/objects -name '*.file' -type f | while read f; do
107118
sudo fsverity measure $f >/dev/null
108119
done
120+
109121
# Test that we can build documentation
110122
docs:
111123
runs-on: ubuntu-24.04
@@ -212,6 +224,26 @@ jobs:
212224
name: tmt-log-PR-${{ github.event.number }}-${{ matrix.test_os }}-${{ matrix.variant }}-${{ env.ARCH }}
213225
path: /var/tmp/tmt
214226

227+
test-install-on-ostree:
228+
runs-on: ubuntu-24.04
229+
230+
steps:
231+
- uses: actions/checkout@v6
232+
- name: Bootc Ubuntu Setup
233+
uses: ./.github/actions/bootc-ubuntu-setup
234+
with:
235+
libvirt: true
236+
- name: Install tmt
237+
run: pip install --user "tmt[provision-virtual]"
238+
- name: "Test install on ostree"
239+
run: |
240+
if [ "${{ matrix.variant }}" = "existing-ostree" ] && [ "${{ matrix.test_os }}" = "fedora-43" ]; then
241+
podman image exists localhost/bootc-integration && \
242+
podman save -q localhost/bootc-integration:latest -o tmt/tests/examples/bootc.tar
243+
tmt run --environment running_env=existing-ostree plans -n /tmt/plans/tests-install/plan-bootc-install-on-ostree --debug
244+
rm -f tmt/tests/examples/bootc.tar
245+
fi
246+
215247
# Sentinel job for required checks - configure this job name in repository settings
216248
required-checks:
217249
if: always()

hack/Containerfile.derived

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Build a container image that has extra testing stuff in it, such
2+
# as nushell, some preset logically bound images, etc. This expects
3+
# to create an image derived FROM localhost/bootc which was created
4+
# by the Dockerfile at top.
5+
6+
FROM scratch as context
7+
# We only need this stuff in the initial context
8+
COPY . /
9+
10+
# An intermediate layer which caches the extended RPMS
11+
FROM localhost/bootc as extended
12+
# And this layer has additional stuff for testing, such as nushell etc.
13+
RUN --mount=type=bind,from=context,target=/run/context <<EORUN
14+
set -xeuo pipefail
15+
cd /run/context/
16+
./provision-derived.sh
17+
EORUN

tmt/plans/tests-install.fmf

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
discover:
2+
how: fmf
3+
provision:
4+
how: virtual
5+
hardware:
6+
boot:
7+
method: uefi
8+
image: fedora-coreos-next
9+
user: root
10+
memory: 4096
11+
disk: 20
12+
execute:
13+
how: tmt
14+
15+
/plan-bootc-install-on-ostree:
16+
summary: Execute bootc install on ostree tests
17+
discover:
18+
how: fmf
19+
test:
20+
- /tmt/tests/install/test-bootc-install-on-ostree
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# number: 50
2+
# tmt:
3+
# summary: Test bootc install on ostree env
4+
# duration: 30m
5+
# adjust:
6+
# - when: running_env != existing-ostree
7+
# enabled: false
8+
# because: this needs to start an ostree OS firstly
9+
#
10+
#!/bin/bash
11+
set -eux
12+
13+
echo "Testing bootc install on stree"
14+
15+
bootc_img=localhost/bootc-test:latest
16+
bootc_tar=examples/bootc-test.tar
17+
18+
if [ "$TMT_REBOOT_COUNT" -eq 0 ]; then
19+
echo "Running before first reboot"
20+
pwd
21+
ls -l
22+
[ -f "${bootc_tar}" ]
23+
podman load -q -i "${bootc_tar}"
24+
podman image exists ${bootc_img}
25+
# Run bootc install
26+
podman run --rm --privileged -v /dev:/dev -v /var/lib/containers:/var/lib/containers -v /:/target \
27+
--pid=host --security-opt label=type:unconfined_t \
28+
${bootc_img} \
29+
env BOOTC_BOOTLOADER_DEBUG=1 bootc install to-existing-root \
30+
--skip-fetch-check \
31+
--acknowledge-destructive \
32+
--root-ssh-authorized-keys /target/root/.ssh/authorized_keys.d/ignition \
33+
--karg=console=ttyS0,115200n8
34+
35+
image=$(bootc status --json |jq -r ".status.otherDeployments[0].image.image.image")
36+
[ ${image} == ${bootc_img} ]
37+
38+
tmt-reboot
39+
elif [ "$TMT_REBOOT_COUNT" -eq 1 ]; then
40+
echo 'After the reboot'
41+
bootc status
42+
fi
43+
44+
echo "Run bootc install on existing ostree successfully"

tmt/tests/install.fmf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/test-bootc-install-on-ostree:
2+
summary: Test bootc install on ostree
3+
duration: 30m
4+
adjust:
5+
- when: running_env != existing-ostree
6+
enabled: false
7+
because: this needs to start an ostree OS firstly
8+
test: bash examples/test-on-ostree/test-install-on-ostree.sh

0 commit comments

Comments
 (0)