Skip to content

Commit 4d2d02f

Browse files
committed
tests: update tests with the tranfering logic
1 parent 1e48a51 commit 4d2d02f

File tree

6 files changed

+64
-57
lines changed

6 files changed

+64
-57
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: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,24 @@ efisubdir=fedora
3030
efidir=${efiupdir}/${efisubdir}
3131
ostefi=${ostbaseefi}/${efisubdir}
3232
shim=shimx64.efi
33+
efilib=/usr/lib/efi
3334

3435
test -f "${efidir}/${shim}"
3536

3637
prepare_efi_update() {
3738
test -w /usr
38-
mkdir -p ${ostbaseefi}
39-
cp -a ${efiupdir}.orig/* ${ostbaseefi}/
39+
# Do not need to create ostree-boot dir after transfered
40+
if [ ! -d ${efilib} ]; then
41+
mkdir -p ${ostbaseefi}
42+
cp -a ${efiupdir}.orig/* ${ostbaseefi}/
43+
fi
4044
rm -rf ${efiupdir} ${bootupdir}/EFI.json
4145
}
4246

4347
bootupctl status > out.txt
48+
evr=$(rpm -q grub2-common --qf '%{EVR}')
4449
assert_file_has_content_literal out.txt 'Component EFI'
45-
assert_file_has_content_literal out.txt ' Installed: grub2-efi-x64-'
50+
assert_file_has_content_literal out.txt ' Installed: grub2-'"${evr}"
4651
assert_file_has_content_literal out.txt 'Update: At latest version'
4752
assert_file_has_content out.txt '^CoreOS aleph version:'
4853
ok status
@@ -61,10 +66,20 @@ test -w /usr || rpm-ostree usroverlay
6166
cp -a ${efiupdir} ${efiupdir}.orig
6267

6368
prepare_efi_update
64-
# FIXME need to synthesize an RPM for this
65-
# echo somenewfile > ${ostefi}/somenew.efi
66-
rm -v ${ostefi}/shim.efi
67-
echo bootupd-test-changes >> ${ostefi}/grubx64.efi
69+
shim=
70+
grubx64=
71+
# Change the files under usr/lib/efi after transferred
72+
if [ -d ${efilib} ]; then
73+
shim=$(find ${efilib} -name shim.efi)
74+
grubx64=$(find ${efilib} -name grubx64.efi)
75+
else
76+
# FIXME need to synthesize an RPM for this
77+
# echo somenewfile > ${ostefi}/somenew.efi
78+
shim=${ostefi}/shim.efi
79+
grubx64=${ostefi}/grubx64.efi
80+
fi
81+
rm -v ${shim}
82+
echo bootupd-test-changes >> ${grubx64}
6883
/usr/libexec/bootupd generate-update-metadata /
6984
ver=$(jq -r .version < ${bootupdir}/EFI.json)
7085
vers=$(jq -r .versions < ${bootupdir}/EFI.json)
@@ -78,21 +93,21 @@ mv new.json ${bootupdir}/EFI.json
7893

7994
bootupctl status | tee out.txt
8095
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'
96+
assert_file_has_content_literal out.txt ' Installed: grub2-'"${evr}"
97+
assert_not_file_has_content out.txt ' Installed: grub2-.*,test'
8398
assert_file_has_content_literal out.txt 'Update: Available:'
8499
ok update avail
85100

86101
bootupctl status --json > status.json
87102
jq -r '.components.EFI.installed.version' < status.json > installed.txt
88-
assert_file_has_content installed.txt '^grub2-efi-x64'
103+
assert_file_has_content installed.txt '^grub2-'"${evr}"
89104

90105
bootupctl update | tee out.txt
91-
assert_file_has_content out.txt 'Updated EFI: grub2-efi-x64.*,test'
106+
assert_file_has_content out.txt 'Updated EFI: grub2-.*,test'
92107

93108
bootupctl status > out.txt
94109
assert_file_has_content_literal out.txt 'Component EFI'
95-
assert_file_has_content out.txt ' Installed: grub2-efi-x64.*,test'
110+
assert_file_has_content out.txt ' Installed: grub2-.*,test'
96111
assert_file_has_content_literal out.txt 'Update: At latest version'
97112
ok status after update
98113

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)