Skip to content

Commit ea79d64

Browse files
committed
tests: fix tests with the tranfering logic
1 parent 0a2d024 commit ea79d64

File tree

6 files changed

+44
-51
lines changed

6 files changed

+44
-51
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,4 @@ jobs:
9999
- name: bootupctl generate-update-metadata
100100
run: |
101101
set -xeuo pipefail
102-
sudo podman run --rm -v $PWD:/run/src -w /run/src --privileged localhost/bootupd:latest tests/tests/move-content-to-usr.sh
102+
sudo podman run --rm -v $PWD:/run/src -w /run/src --privileged localhost/bootupd:latest tests/tests/generate-update-metadata.sh

tests/e2e-update/e2e-update-in-vm.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ if ! test -f ${stampfile}; then
1818
fatal "already at ${TARGET_COMMIT}"
1919
fi
2020

21-
current_grub=$(rpm -q --queryformat='%{nevra}\n' ${TARGET_GRUB_NAME})
22-
if test "${current_grub}" == "${TARGET_GRUB_PKG}"; then
23-
fatal "Current grub ${current_grub} is same as target ${TARGET_GRUB_PKG}"
21+
current_grub=$(rpm -q --queryformat='%{evr}\n' ${TARGET_GRUB_NAME})
22+
if test "${current_grub}" == "${TARGET_GRUB_EVR}"; then
23+
fatal "Current grub ${current_grub} is same as target ${TARGET_GRUB_EVR}"
2424
fi
2525

2626
# FIXME
@@ -44,20 +44,20 @@ if test "$semode" != Enforcing; then
4444
fatal "SELinux mode is ${semode}"
4545
fi
4646

47-
if ! test -n "${TARGET_GRUB_PKG}"; then
48-
fatal "Missing TARGET_GRUB_PKG"
47+
if ! test -n "${TARGET_GRUB_EVR}"; then
48+
fatal "Missing TARGET_GRUB_EVR"
4949
fi
5050

5151
bootupctl validate
5252
ok validate
5353

5454
bootupctl status | tee out.txt
5555
assert_file_has_content_literal out.txt 'Component EFI'
56-
assert_file_has_content_literal out.txt ' Installed: grub2-efi-x64-'
57-
assert_not_file_has_content out.txt ' Installed:.*test-bootupd-payload'
58-
assert_not_file_has_content out.txt ' Installed:.*'"${TARGET_GRUB_PKG}"
59-
assert_file_has_content out.txt 'Update: Available:.*'"${TARGET_GRUB_PKG}"
60-
assert_file_has_content out.txt 'Update: Available:.*test-bootupd-payload-1.0'
56+
assert_file_has_content_literal out.txt ' Installed: grub2-1:'
57+
assert_not_file_has_content out.txt ' Installed:.*test_bootupd_payload'
58+
assert_not_file_has_content out.txt ' Installed:.*'"${TARGET_GRUB_EVR}"
59+
assert_file_has_content out.txt 'Update: Available:.*'"${TARGET_GRUB_EVR}"
60+
assert_file_has_content out.txt 'Update: Available:.*test_bootupd_payload-1.0'
6161
bootupctl status --print-if-available > out.txt
6262
assert_file_has_content_literal 'out.txt' 'Updates available: BIOS EFI'
6363
ok update avail
@@ -74,7 +74,7 @@ assert_file_has_content err.txt "error: .*synthetic failpoint"
7474

7575
bootupctl update -vvv | tee out.txt
7676
assert_file_has_content out.txt "Previous EFI: .*"
77-
assert_file_has_content out.txt "Updated EFI: ${TARGET_GRUB_PKG}.*,test-bootupd-payload-1.0"
77+
assert_file_has_content out.txt "Updated EFI: .*${TARGET_GRUB_EVR}.*,test_bootupd_payload-1.0"
7878

7979
assert_file_has_content ${tmpefimount}/EFI/fedora/test-bootupd.efi test-payload
8080

tests/e2e-update/e2e-update.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export test_tmpdir=${testtmp}
2525
# This is new content for our update
2626
test_bootupd_payload_file=/boot/efi/EFI/fedora/test-bootupd.efi
2727
test_bootupd_payload_file1=/boot/efi/EFI/BOOT/test-bootupd1.efi
28-
build_rpm test-bootupd-payload \
28+
build_rpm test_bootupd_payload \
2929
files "${test_bootupd_payload_file}
3030
${test_bootupd_payload_file1}" \
3131
install "mkdir -p %{buildroot}/$(dirname ${test_bootupd_payload_file})
@@ -56,9 +56,9 @@ if test -z "${e2e_skip_build:-}"; then
5656
runv cosa build
5757
runv cosa osbuild qemu
5858
prev_image=$(runv cosa meta --image-path qemu)
59-
# Modify manifest to include `test-bootupd-payload` RPM
59+
# Modify manifest to include `test_bootupd_ayload` RPM
6060
runv git -C src/config checkout manifest.yaml # first make sure it's clean
61-
echo "packages: [test-bootupd-payload]" >> src/config/manifest.yaml
61+
echo "packages: [test_bootupd_payload]" >> src/config/manifest.yaml
6262
rm -f ${overrides}/rpm/*.rpm
6363
echo "Building update ostree"
6464
# Latest (current) version in F42
@@ -77,7 +77,7 @@ case $(arch) in
7777
*) fatal "Unhandled arch $(arch)";;
7878
esac
7979
target_grub_name=grub2-efi-${grubarch}
80-
target_grub_pkg=$(rpm -qp --queryformat='%{nevra}\n' ${overrides}/rpm/${target_grub_name}-2*.rpm)
80+
target_grub_evr=$(rpm -qp --queryformat='%{evr}\n' ${overrides}/rpm/${target_grub_name}-2*.rpm)
8181
target_commit=$(cosa meta --get-value ostree-commit)
8282
echo "Target commit: ${target_commit}"
8383
# For some reason 9p can't write to tmpfs
@@ -97,7 +97,7 @@ systemd:
9797
RemainAfterExit=yes
9898
Environment=TARGET_COMMIT=${target_commit}
9999
Environment=TARGET_GRUB_NAME=${target_grub_name}
100-
Environment=TARGET_GRUB_PKG=${target_grub_pkg}
100+
Environment=TARGET_GRUB_EVR=${target_grub_evr}
101101
Environment=SRCDIR=/run/bootupd-source
102102
# Run via shell because selinux denies systemd writing to 9p apparently
103103
ExecStart=/bin/sh -c '/run/bootupd-source/${testprefix}/e2e-update-in-vm.sh &>>/run/testtmp/out.txt; test -f /run/rebooting || poweroff -ff'

tests/kola/test-bootupd

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ prepare_efi_update() {
4141
}
4242

4343
bootupctl status > out.txt
44+
evr=$(rpm -q grub2-common --qf '%{EVR}')
4445
assert_file_has_content_literal out.txt 'Component EFI'
45-
assert_file_has_content_literal out.txt ' Installed: grub2-efi-x64-'
46+
assert_file_has_content_literal out.txt ' Installed: grub2-'"${evr}"
4647
assert_file_has_content_literal out.txt 'Update: At latest version'
4748
assert_file_has_content out.txt '^CoreOS aleph version:'
4849
ok status
@@ -78,21 +79,21 @@ mv new.json ${bootupdir}/EFI.json
7879

7980
bootupctl status | tee out.txt
8081
assert_file_has_content_literal out.txt 'Component EFI'
81-
assert_file_has_content_literal out.txt ' Installed: grub2-efi-x64-'
82-
assert_not_file_has_content out.txt ' Installed: grub2-efi-x64.*,test'
82+
assert_file_has_content_literal out.txt ' Installed: grub2-'"${evr}"
83+
assert_not_file_has_content out.txt ' Installed: grub2-.*,test'
8384
assert_file_has_content_literal out.txt 'Update: Available:'
8485
ok update avail
8586

8687
bootupctl status --json > status.json
8788
jq -r '.components.EFI.installed.version' < status.json > installed.txt
88-
assert_file_has_content installed.txt '^grub2-efi-x64'
89+
assert_file_has_content installed.txt '^grub2-'"${evr}"
8990

9091
bootupctl update | tee out.txt
91-
assert_file_has_content out.txt 'Updated EFI: grub2-efi-x64.*,test'
92+
assert_file_has_content out.txt 'Updated EFI: grub2-.*,test'
9293

9394
bootupctl status > out.txt
9495
assert_file_has_content_literal out.txt 'Component EFI'
95-
assert_file_has_content out.txt ' Installed: grub2-efi-x64.*,test'
96+
assert_file_has_content out.txt ' Installed: grub2-.*,test'
9697
assert_file_has_content_literal out.txt 'Update: At latest version'
9798
ok status after update
9899

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
set -xeuo pipefail
3+
4+
updates=/usr/lib/bootupd/updates
5+
rm -fv ${updates}/{BIOS,EFI}.json
6+
if [ -d "/usr/lib/efi" ]; then
7+
rm -rfv ${updates}/EFI
8+
else
9+
mv ${updates}/EFI /usr/lib/ostree-boot/efi
10+
fi
11+
# Run generate-update-metadata
12+
bootupctl backend generate-update-metadata -vvv
13+
cat ${updates}/EFI.json | jq
14+
15+
# Verify the bootupd EFI has more than one component installed
16+
version=$(cat ${updates}/EFI.json | jq -r .version | tr ',' ' ')
17+
array=($version)
18+
[ ${#array[*]} -gt 1 ]
19+
20+
[ $(cat ${updates}/EFI.json | jq '.versions | length') -gt 1 ]

tests/tests/move-content-to-usr.sh

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)