Skip to content

Commit 2a9b4be

Browse files
committed
tests: add tmt test to verify bootupd posttrans works
1 parent a98cdad commit 2a9b4be

File tree

4 files changed

+80
-25
lines changed

4 files changed

+80
-25
lines changed

.packit.yaml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,8 @@ jobs:
3333
- job: tests
3434
trigger: pull_request
3535
targets:
36-
- centos-stream-9-x86_64
37-
- centos-stream-9-aarch64
38-
- centos-stream-10-x86_64
39-
- centos-stream-10-aarch64
40-
- fedora-43-x86_64
41-
- fedora-43-aarch64
42-
- fedora-rawhide-x86_64
4336
- fedora-rawhide-aarch64
4437
tmt_plan: /tmt/plans/package
45-
tf_extra_params:
46-
environments:
47-
- tmt:
48-
context:
49-
running_env: "packit"
5038

5139
- job: propose_downstream
5240
trigger: release

tmt/plans/package.fmf

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,31 @@
1-
# Common settings for all plans
1+
discover:
2+
how: fmf
3+
execute:
4+
how: tmt
25
provision:
36
how: virtual
4-
image: $@{test_disk_image}
7+
hardware:
8+
boot:
9+
method: uefi
10+
image: $@{test_image}
11+
user: root
512
prepare:
6-
# Run on package mode VM running on Packit and Gating
13+
# Run on package mode VM especially on Fedora
714
- how: shell
8-
order: 98
9-
script:
10-
- mkdir -p bootc && cp /var/share/test-artifacts/*.src.rpm bootc
11-
- 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
12-
- pwd && ls -al && cd bootc/hack && ./provision-packit.sh
13-
when: running_env != image_mode
14-
execute:
15-
how: tmt
15+
order: 10
16+
adjust:
17+
- when: distro == fedora
18+
script:
19+
- echo test > /boot/efi/EFI/fedora/grub*.efi
20+
- how: install
21+
order: 20
22+
package:
23+
- bootupd
24+
1625

1726
/plan-post-install:
1827
summary: Execute post install tests
1928
discover:
2029
how: fmf
2130
test:
22-
- /tmt/tests/tests/test-post-install
31+
- /tmt/tests/tests/test-post-install
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# number: 10
2+
# tmt:
3+
# summary: Test posttrans on package mode
4+
# duration: 10m
5+
#
6+
#!/bin/bash
7+
set -eux
8+
9+
echo "Testing posttrans on package mode"
10+
11+
bootupctl --version
12+
13+
source /etc/os-release
14+
if [ $ID == "fedora" ] && [ $VERSION_ID < 44 ]; then
15+
echo "Skip on testing on F43 and older"
16+
exit 0
17+
fi
18+
19+
suffix=""
20+
get_grub_suffix() {
21+
case $(arch) in
22+
x86_64)
23+
suffix="x64"
24+
;;
25+
aarch64)
26+
suffix="aa64"
27+
;;
28+
*)
29+
echo "Unsupported arch"
30+
exit 1
31+
;;
32+
esac
33+
}
34+
35+
if [ "$TMT_REBOOT_COUNT" -eq 0 ]; then
36+
echo 'Before first reboot'
37+
get_grub_suffix
38+
grubefi=grub${suffix}.efi
39+
grub_path=$(find /usr/lib/efi/ -name ${grub_file})
40+
if [ -z "$grub_path" ]; then
41+
echo "Error: Source GRUB binary not found."
42+
exit 1
43+
fi
44+
source_checksum=$(sha256sum ${grub_path} | cut -d' ' -f1)
45+
# check grubx64.efi is updated
46+
target_checksum=$(sha256sum /boot/efi/EFI/fedora/${grub_file} | cut -d' ' -f1)
47+
[ ${source_checksum} == ${target_checksum} ]
48+
tmt-reboot
49+
elif [ "$TMT_REBOOT_COUNT" -eq 1 ]; then
50+
echo 'After the reboot'
51+
# just confirm the reboot is successful
52+
whoami
53+
fi
54+
55+
echo "Run posttrans test successfully"

tmt/tests/tests.fmf

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
/test-post-install:
22
summary: Execute installation on package mode
33
duration: 10m
4-
test: bash package/post-install.sh
4+
adjust:
5+
- when: distro != fedora
6+
enabled: false
7+
test: bash package/test-post-install.sh

0 commit comments

Comments
 (0)