Skip to content

Commit f1dec83

Browse files
authored
test: Use SRPM as test code source to work with gating test (#1670)
Signed-off-by: Xiaofeng Wang <[email protected]>
1 parent de3c29f commit f1dec83

File tree

5 files changed

+34
-23
lines changed

5 files changed

+34
-23
lines changed

hack/Containerfile.packit

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ COPY ARTIFACTS /var/ARTIFACTS
1212
# Copy bootc repo
1313
COPY test-artifacts /var/share/test-artifacts
1414

15+
ARG GATING
1516
RUN <<EORUN
1617
set -xeuo pipefail
1718
. /usr/lib/os-release
@@ -22,6 +23,12 @@ cp test-artifacts.repo /etc/yum.repos.d/
2223
dnf -y update bootc
2324
./provision-derived.sh
2425

26+
if [[ "$GATING" == true ]]; then
27+
# Install Fedora CI/OSCI required packages for "Prepare dist-git sources" task
28+
dnf install -y rpm-build @buildsys-build 'dnf-command(builddep)'
29+
dnf builddep -y /var/share/test-artifacts/*.src.rpm
30+
fi
31+
2532
# For test-22-logically-bound-install
2633
cp -a lbi/usr/. /usr
2734
for x in curl.container curl-base.image podman.image; do

hack/packit-reboot.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,8 @@
55
- name: Reboot after system-reinstall-bootc
66
hosts: all
77
tasks:
8-
- name: Check system mode
9-
shell: bootc status --json | jq -r '.status.type'
10-
register: os_mode
11-
12-
# null type means package mode
138
- name: Reboot system to image mode
149
reboot:
15-
when: os_mode.stdout == 'null'
1610

1711
- name: Wait for connection to become reachable/usable
1812
wait_for_connection:

hack/provision-packit.sh

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,6 @@ set -exuo pipefail
44
# Check environment
55
printenv
66

7-
# This script only runs on Packit and gating environment
8-
# Do not run this script for image mode system
9-
if command -v bootc >/dev/null && bootc status --json | grep '"type":"bootcHost"'; then
10-
echo "This system is Image Mode."
11-
exit 0
12-
fi
13-
14-
# Install required packages
15-
dnf install -y podman skopeo jq bootc system-reinstall-bootc expect ansible-core
16-
177
# temp folder to save building files and folders
188
BOOTC_TEMPDIR=$(mktemp -d)
199
trap 'rm -rf -- "$BOOTC_TEMPDIR"' EXIT
@@ -87,6 +77,9 @@ if [[ -v KOJI_TASK_ID ]] || [[ -v CI_KOJI_TASK_ID ]]; then
8777
echo "$TMT_SOURCE_DIR"
8878
ls -al "$TMT_SOURCE_DIR"
8979
ls -al "$TMT_SOURCE_DIR/SRPMS"
80+
GATING="true"
81+
else
82+
GATING="false"
9083
fi
9184

9285
ls -al /etc/yum.repos.d
@@ -100,7 +93,7 @@ cp /etc/yum.repos.d/test-artifacts.repo "$BOOTC_TEMPDIR"
10093
ls -al "$BOOTC_TEMPDIR" "${BOOTC_TEMPDIR}/bin"
10194

10295
# Do not use just because it's only available on Fedora, not on CS and RHEL
103-
podman build --jobs=4 --from "$BASE" -v "$BOOTC_TEMPDIR":/bootc-test:z -t localhost/bootc-integration -f "${BOOTC_TEMPDIR}/Containerfile.packit" "$BOOTC_TEMPDIR"
96+
podman build --jobs=4 --from "$BASE" --build-arg GATING="$GATING" -v "$BOOTC_TEMPDIR":/bootc-test:z -t localhost/bootc-integration -f "${BOOTC_TEMPDIR}/Containerfile.packit" "$BOOTC_TEMPDIR"
10497

10598
# Keep these in sync with what's used in hack/lbi
10699
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

tests/run-tmt.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ rm -vrf /var/tmp/tmt/testcloud/images/bootc-integration-test.qcow2
2323

2424
cd target/tmt-workdir
2525
# TMT will rsync tmt-* scripts to TMT_SCRIPTS_DIR=/var/lib/tmt/scripts
26-
exec tmt --context "test_disk_image=${DISK}" run --all -e TMT_SCRIPTS_DIR=/var/lib/tmt/scripts "$@"
26+
# running_env=image_mode means running tmt on image mode system on Github CI or locally
27+
exec tmt --context "test_disk_image=${DISK}" --context "running_env=image_mode" run --all -e TMT_SCRIPTS_DIR=/var/lib/tmt/scripts "$@"

tmt/plans/integration.fmf

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,32 @@ provision:
22
how: virtual
33
image: $@{test_disk_image}
44
prepare:
5-
# Replace package mode with image mode
5+
# Install image mode system on package mode system
6+
# Do not run on image mode VM running on Github CI and Locally
7+
# Run on package mode VM running on Packit and Gating
8+
- how: install
9+
package:
10+
- podman
11+
- skopeo
12+
- jq
13+
- bootc
14+
- system-reinstall-bootc
15+
- expect
16+
- ansible-core
17+
- zstd
18+
when: running_env != image_mode
619
- how: shell
720
script:
8-
- pwd && ls -al
9-
- if [[ -d hack ]]; then cd hack && ./provision-packit.sh; fi
21+
- mkdir -p bootc && cp /var/share/test-artifacts/*.src.rpm bootc
22+
- cd bootc && rpm2cpio *.src.rpm | cpio -idmv && rm -f *-vendor.tar.zstd && zstd -d *.tar.zstd && tar -xvf *.tar -C . --strip-components=1 && ls -al
23+
- pwd && ls -al && cd bootc/hack && ./provision-packit.sh
24+
when: running_env != image_mode
1025
# tmt-reboot and reboot do not work in this case
1126
# reboot in ansible is the only way to reboot in tmt prepare
1227
- how: ansible
1328
playbook:
1429
- https://github.com/bootc-dev/bootc/raw/refs/heads/main/hack/packit-reboot.yml
30+
when: running_env != image_mode
1531
execute:
1632
how: tmt
1733

@@ -71,7 +87,7 @@ execute:
7187
test:
7288
- /tmt/tests/test-26-examples-build
7389
adjust:
74-
- when: running_env == packit
90+
- when: running_env != image_mode
7591
enabled: false
7692
because: packit tests use RPM bootc and does not install /usr/lib/bootc/initramfs-setup
7793

@@ -82,6 +98,6 @@ execute:
8298
test:
8399
- /tmt/tests/test-27-custom-selinux-policy
84100
adjust:
85-
- when: running_env == packit
101+
- when: running_env != image_mode
86102
enabled: false
87103
because: tmt-reboot does not work with systemd reboot in testing farm environment

0 commit comments

Comments
 (0)