Skip to content

Commit 138dc6b

Browse files
committed
test: Add Packit and gating test
Use 'system-reinstall-bootc' to re-install TF runner from package mode to image mode Signed-off-by: Xiaofeng Wang <[email protected]>
1 parent 9a6df09 commit 138dc6b

File tree

8 files changed

+295
-30
lines changed

8 files changed

+295
-30
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ jobs:
207207

208208
- name: Run all TMT tests
209209
run: |
210-
just test-tmt-nobuild
210+
just test-tmt-nobuild plans --name /tmt/plans/integration
211211
212212
- name: Archive TMT logs
213213
if: always()

.packit.yaml

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -64,21 +64,18 @@ jobs:
6464
failure_comment:
6565
message: "bootc Copr build failed for {commit_sha}. @admin check logs {logs_url} and packit dashboard {packit_dashboard_url}"
6666

67-
# TODO: Readd some tmt tests that install the built RPM and e.g. test out system-reinstall-bootc
68-
# - job: tests
69-
# trigger: pull_request
70-
# targets:
71-
# - centos-stream-9-x86_64
72-
# - centos-stream-9-aarch64
73-
# - centos-stream-10-x86_64
74-
# - centos-stream-10-aarch64
75-
# - fedora-42-x86_64
76-
# - fedora-42-aarch64
77-
# - fedora-rawhide-x86_64
78-
# - fedora-rawhide-aarch64
79-
# tmt_plan: /integration
80-
# skip_build: true
81-
# identifier: integration-test
67+
- job: tests
68+
trigger: pull_request
69+
targets:
70+
- centos-stream-9-x86_64
71+
- centos-stream-9-aarch64
72+
- centos-stream-10-x86_64
73+
- centos-stream-10-aarch64
74+
- fedora-42-x86_64
75+
- fedora-42-aarch64
76+
- fedora-rawhide-x86_64
77+
- fedora-rawhide-aarch64
78+
tmt_plan: /packit/
8279

8380
- job: propose_downstream
8481
trigger: release

hack/Containerfile.packit

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Build image for system-reinstall-bootc test
2+
3+
# Use centos-bootc:10 as default
4+
FROM quay.io/centos-bootc/centos-bootc:stream10
5+
6+
WORKDIR /bootc-test
7+
8+
# Some rhts-*, rstrnt-* and tmt-* commands are in /usr/local/bin
9+
COPY bin /usr/local/bin
10+
# Save testing farm run files
11+
COPY ARTIFACTS /var/ARTIFACTS
12+
# Copy bootc repo
13+
COPY test-artifacts /var/share/test-artifacts
14+
15+
RUN <<EORUN
16+
set -xeuo pipefail
17+
. /usr/lib/os-release
18+
if [[ $ID == "rhel" ]]; then
19+
cp rhel.repo /etc/yum.repos.d/
20+
fi
21+
cp test-artifacts.repo /etc/yum.repos.d/
22+
dnf -y update bootc
23+
./provision-derived.sh
24+
25+
# For test-22-logically-bound-install
26+
cp -a lbi/usr/. /usr
27+
for x in curl.container curl-base.image podman.image; do
28+
ln -s /usr/share/containers/systemd/$x /usr/lib/bootc/bound-images.d/$x
29+
done
30+
31+
# Add some testing kargs into our dev builds
32+
install -D -t /usr/lib/bootc/kargs.d test-kargs/*
33+
# Also copy in some default install configs we use for testing
34+
install -D -t /usr/lib/bootc/install/ install-test-configs/*
35+
36+
# Remove bootc repo, bootc updated already
37+
rm -rf /var/share/test-artifacts /etc/yum.repos.d/test-artifacts.repo
38+
# Clean up dnf
39+
dnf -y clean all
40+
rm -rf /var/cache /var/lib/dnf
41+
42+
# Finally, test our own linting
43+
# bootc container lint --fatal-warnings
44+
EORUN

tmt/plans/integration.fmf

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,51 @@
1+
discover:
2+
how: fmf
13
provision:
24
how: virtual
35
# Build via `./tests/build.sh`
46
image: $@{test_disk_image}
57
execute:
68
how: tmt
79

8-
/readonly-tests:
10+
/test-01-readonly:
911
summary: Execute booted readonly/nondestructive tests
10-
discover:
12+
discover+:
1113
how: fmf
1214
test:
1315
- /tmt/tests/test-01-readonly
1416

1517
/test-20-local-upgrade:
1618
summary: Execute local upgrade tests
17-
discover:
18-
how: fmf
19+
discover+:
1920
test:
2021
- /tmt/tests/test-20-local-upgrade
2122

2223
/test-21-logically-bound-switch:
2324
summary: Execute logically bound images tests for switching images
24-
discover:
25-
how: fmf
25+
discover+:
2626
test:
2727
- /tmt/tests/test-21-logically-bound-switch
2828

2929
/test-22-logically-bound-install:
3030
summary: Execute logically bound images tests for switching images
31-
discover:
32-
how: fmf
31+
discover+:
3332
test:
3433
- /tmt/tests/test-22-logically-bound-install
3534

3635
/test-23-install-outside-container:
3736
summary: Execute tests for installing outside of a container
38-
discover:
39-
how: fmf
37+
discover+:
4038
test:
4139
- /tmt/tests/test-23-install-outside-container
4240

4341
/test-24-local-upgrade-reboot:
4442
summary: Execute local upgrade tests with automated reboot
45-
discover:
46-
how: fmf
43+
discover+:
4744
test:
4845
- /tmt/tests/test-24-local-upgrade-reboot
4946

5047
/test-25-soft-reboot:
5148
summary: Soft reboot support
52-
discover:
53-
how: fmf
49+
discover+:
5450
test:
5551
- /tmt/tests/test-25-soft-reboot

tmt/plans/packit.fmf

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
discover:
2+
how: fmf
3+
provision:
4+
how: virtual
5+
image: $@{test_disk_image}
6+
prepare:
7+
- how: install
8+
package:
9+
- podman
10+
- skopeo
11+
- jq
12+
execute:
13+
how: tmt
14+
exit-first: true
15+
16+
/test-01-readonly:
17+
summary: Execute booted readonly/nondestructive tests
18+
discover+:
19+
how: fmf
20+
test:
21+
- /tmt/tests/test-00-system-reinstall-bootc
22+
- /tmt/tests/test-01-readonly
23+
24+
/test-20-local-upgrade:
25+
summary: Execute local upgrade tests
26+
discover+:
27+
test:
28+
- /tmt/tests/test-00-system-reinstall-bootc
29+
- /tmt/tests/test-20-local-upgrade
30+
31+
/test-21-logically-bound-switch:
32+
summary: Execute logically bound images tests for switching images
33+
discover+:
34+
test:
35+
- /tmt/tests/test-00-system-reinstall-bootc
36+
- /tmt/tests/test-21-logically-bound-switch
37+
38+
/test-22-logically-bound-install:
39+
summary: Execute logically bound images tests for switching images
40+
discover+:
41+
test:
42+
- /tmt/tests/test-00-system-reinstall-bootc
43+
- /tmt/tests/test-22-logically-bound-install
44+
45+
/test-23-install-outside-container:
46+
summary: Execute tests for installing outside of a container
47+
discover+:
48+
test:
49+
- /tmt/tests/test-00-system-reinstall-bootc
50+
- /tmt/tests/test-23-install-outside-container
51+
52+
/test-24-local-upgrade-reboot:
53+
summary: Execute local upgrade tests with automated reboot
54+
discover+:
55+
test:
56+
- /tmt/tests/test-00-system-reinstall-bootc
57+
- /tmt/tests/test-24-local-upgrade-reboot
58+
59+
/test-25-soft-reboot:
60+
summary: Soft reboot support
61+
discover+:
62+
test:
63+
- /tmt/tests/test-00-system-reinstall-bootc
64+
- /tmt/tests/test-25-soft-reboot
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/expect -f
2+
3+
# Set a timeout
4+
set timeout 600
5+
6+
spawn system-reinstall-bootc localhost/bootc-integration
7+
8+
expect {
9+
"Then you can login as * using those keys. \\\[Y/n\\\]" {
10+
send "\r"
11+
exp_continue
12+
}
13+
"NOTICE: This will replace the installed operating system and reboot. Are you sure you want to continue? \\\[y/N\\\]" {
14+
send "y"
15+
exp_continue
16+
}
17+
"NOTICE: This will replace the installed operating system and reboot. Are you sure you want to continue? \\\[Y/n\\\]" {
18+
send "\r"
19+
exp_continue
20+
}
21+
"Press \\\<enter\\\> to continue" {
22+
send "\r"
23+
exp_continue
24+
}
25+
"Operation complete, rebooting in 10 seconds. Press Ctrl-C to cancel reboot, or press enter to continue immediately" {
26+
send "\x03"
27+
}
28+
}
29+
30+
# Wait for the program to complete
31+
expect eof
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
#!/bin/bash
2+
set -exuo pipefail
3+
4+
# Check environment
5+
printenv
6+
# Check repos
7+
ls -al /etc/yum.repos.d
8+
9+
# This script only runs on Packit and gating environment
10+
if [ "$TMT_REBOOT_COUNT" -eq 0 ]; then
11+
# temp folder to save building files and folders
12+
BOOTC_TEMPDIR=$(mktemp -d)
13+
trap 'rm -rf -- "$BOOTC_TEMPDIR"' EXIT
14+
15+
# Copy files and folders in hack to TEMPDIR
16+
cp -a ../../hack/* "$BOOTC_TEMPDIR"
17+
18+
# Keep testing farm run folder
19+
cp -r /var/ARTIFACTS "$BOOTC_TEMPDIR"
20+
21+
# Copy bootc repo
22+
cp -r /var/share/test-artifacts "$BOOTC_TEMPDIR"
23+
24+
ARCH=$(uname -m)
25+
# Get OS info
26+
source /etc/os-release
27+
28+
# Some rhts-*, rstrnt-* and tmt-* commands are in /usr/local/bin
29+
if [[ $ID == rhel ]]; then
30+
cp -r /var/lib/tmt/scripts "$BOOTC_TEMPDIR"
31+
else
32+
cp -r /usr/local/bin "$BOOTC_TEMPDIR"
33+
fi
34+
35+
case "$ID" in
36+
"centos")
37+
BASE="quay.io/centos-bootc/centos-bootc:stream${VERSION_ID}"
38+
TEST_OS="${ID}-stream-${VERSION_ID}"
39+
;;
40+
"fedora")
41+
BASE="quay.io/fedora/fedora-bootc:${VERSION_ID}"
42+
TEST_OS="${ID}-${VERSION_ID}"
43+
if [[ "$VERSION_ID" == 44 ]]; then
44+
TEST_OS="${ID}-rawhide"
45+
fi
46+
;;
47+
"rhel")
48+
# OSCI gating only
49+
BASE="images.paas.redhat.com/bootc/rhel-bootc:latest-${VERSION_ID}"
50+
CURRENT_COMPOSE_ID=$(skopeo inspect --no-tags --retry-times=5 --tls-verify=false "docker://${BASE}" | jq -r '.Labels."redhat.compose-id"')
51+
52+
if [[ -n ${CURRENT_COMPOSE_ID} ]]; then
53+
if [[ ${CURRENT_COMPOSE_ID} == *-updates-* ]]; then
54+
BATCH_COMPOSE="updates/"
55+
else
56+
BATCH_COMPOSE=""
57+
fi
58+
else
59+
BATCH_COMPOSE="updates/"
60+
CURRENT_COMPOSE_ID=latest-RHEL-$VERSION_ID
61+
fi
62+
63+
# use latest compose if specific compose is not accessible
64+
RC=$(curl -skIw '%{http_code}' -o /dev/null "http://${NIGHTLY_COMPOSE_SITE}/rhel-${VERSION_ID%%.*}/nightly/${BATCH_COMPOSE}RHEL-${VERSION_ID%%.*}/${CURRENT_COMPOSE_ID}/STATUS")
65+
if [[ $RC != "200" ]]; then
66+
CURRENT_COMPOSE_ID=latest-RHEL-${VERSION_ID%%}
67+
fi
68+
69+
# generate rhel repo
70+
tee "${BOOTC_TEMPDIR}/rhel.repo" >/dev/null <<REPOEOF
71+
[rhel-baseos]
72+
name=baseos
73+
baseurl=http://${NIGHTLY_COMPOSE_SITE}/rhel-${VERSION_ID%%.*}/nightly/${BATCH_COMPOSE}RHEL-${VERSION_ID%%.*}/${CURRENT_COMPOSE_ID}/compose/BaseOS/${ARCH}/os/
74+
enabled=1
75+
gpgcheck=0
76+
77+
[rhel-appstream]
78+
name=appstream
79+
baseurl=http://${NIGHTLY_COMPOSE_SITE}/rhel-${VERSION_ID%%.*}/nightly/${BATCH_COMPOSE}RHEL-${VERSION_ID%%.*}/${CURRENT_COMPOSE_ID}/compose/AppStream/${ARCH}/os/
80+
enabled=1
81+
gpgcheck=0
82+
REPOEOF
83+
cp "${BOOTC_TEMPDIR}/rhel.repo" /etc/yum.repos.d
84+
;;
85+
esac
86+
87+
# Fedora CI: https://github.com/fedora-ci/dist-git-pipeline/blob/master/Jenkinsfile#L145
88+
# OSCI: https://gitlab.cee.redhat.com/osci-pipelines/dist-git-pipeline/-/blob/master/Jenkinsfile?ref_type=heads#L93
89+
if [[ -v KOJI_TASK_ID ]] || [[ -v CI_KOJI_TASK_ID ]]; then
90+
# Just left those ls commands here to ring the bell for me when something changed
91+
echo "$TMT_SOURCE_DIR"
92+
ls -al "$TMT_SOURCE_DIR"
93+
ls -al "$TMT_SOURCE_DIR/SRPMS"
94+
fi
95+
96+
ls -al /etc/yum.repos.d
97+
cat /etc/yum.repos.d/test-artifacts.repo
98+
ls -al /var/share/test-artifacts
99+
100+
# copy bootc rpm repo into image building root
101+
cp /etc/yum.repos.d/test-artifacts.repo "$BOOTC_TEMPDIR"
102+
103+
# Let's check things in hack folder
104+
ls -al "$BOOTC_TEMPDIR" "${BOOTC_TEMPDIR}/bin"
105+
106+
# Do not use just because it's only available on Fedora, not on CS and RHEL
107+
podman build --jobs=4 --from "$BASE" -v "$BOOTC_TEMPDIR":/bootc-test:z -t localhost/bootc-integration -f "${BOOTC_TEMPDIR}/Containerfile.packit" "$BOOTC_TEMPDIR"
108+
109+
# Keep these in sync with what's used in hack/lbi
110+
podman pull -q --retry 5 --retry-delay 5s quay.io/curl/curl:latest quay.io/curl/curl-base:latest registry.access.redhat.com/ubi9/podman:latest
111+
112+
# Install system-reinstall-bootc
113+
dnf install -y system-reinstall-bootc expect
114+
115+
# Run system-reinstall-bootc
116+
system-reinstall/system-reinstall-bootc.exp
117+
118+
# Reboot
119+
tmt-reboot
120+
elif [ "$TMT_REBOOT_COUNT" -eq 1 ]; then
121+
# Some simple and fast checkings
122+
bootc status
123+
echo "$PATH"
124+
printenv
125+
ls -al /var/ARTIFACTS
126+
ls -al /usr/local/bin
127+
echo "Bootc system on TMT/TF runner"
128+
129+
exit 0
130+
fi
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
summary: Run system-reinstall-bootc test
2+
test: system-reinstall/test-system-reinstall-bootc.sh
3+
duration: 30m

0 commit comments

Comments
 (0)