1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
|
summary: Upgrade the core snap and revert a few times
details: |
Check that it is possible to upgrade and revert the core and snapd snaps
in Ubuntu Core 16 and 18. Ensure the bootloader configuration is correct
and the device is scheduled for auto-reboot in all cases
# ARM devices are not supported on ubuntu-core-18 due to fw_printenv/setenv are
# not provided by the system and as the devices boot with uboot so it is not
# possible to get any grub information as it is done with non arm devices.
systems: [ubuntu-core-16-*, ubuntu-core-18-64*]
# Start early as it takes a long time.
priority: 100
environment:
# uploading the core snap triggers OOM
SNAPD_NO_MEMORY_LIMIT: 1
prepare: |
TARGET_SNAP=core
if os.query is-core18; then
TARGET_SNAP=core18
fi
snap list | awk "/^${TARGET_SNAP} / {print(\$3)}" > nextBoot
snap install test-snapd-sh
restore: |
systemctl restart snapd
if [ -f curChg ] ; then
snap abort "$(cat curChg)" || true
fi
# Remove the revisions installed during the test.
# The x1 revision is the one we use initially.
snap remove core --revision=x2
snap remove core --revision=x3
debug: |
snap list || true
"$TESTSTOOLS"/boot-state bootenv show || true
cat /proc/cmdline
execute: |
TARGET_SNAP=core
if os.query is-core18; then
TARGET_SNAP=core18
fi
# FIXME Why it starting with snap_mode=try the first time?
# Perhaps because $TARGET_SNAP is installed after seeding? Do we
# want that on pristine images?
if [ "$SPREAD_REBOOT" != 0 ]; then
echo "Waiting for snapd to clean snap_mode"
while [ "$("$TESTSTOOLS"/boot-state bootenv show snap_mode)" != "" ]; do
sleep 1
done
echo "Ensure the bootloader is correct after reboot"
test "$("$TESTSTOOLS"/boot-state bootenv show snap_core)" = "${TARGET_SNAP}_$(cat nextBoot).snap"
test "$("$TESTSTOOLS"/boot-state bootenv show snap_try_core)" = ""
test "$("$TESTSTOOLS"/boot-state bootenv show snap_mode)" = ""
fi
snap list | awk "/^${TARGET_SNAP} / {print(\$3)}" > prevBoot
# wait for ongoing change if there is one
if [ -f curChg ] ; then
snap watch "$(cat curChg)"
rm -f curChg
fi
case "$SPREAD_REBOOT" in
0) cmd="snap install --dangerous /var/lib/snapd/snaps/${TARGET_SNAP}_$(cat prevBoot).snap" ;;
1) cmd="snap revert $TARGET_SNAP" ;;
2) cmd="snap install --dangerous /var/lib/snapd/snaps/${TARGET_SNAP}_$(cat prevBoot).snap" ;;
3) cmd="snap revert $TARGET_SNAP" ;;
4) exit 0 ;;
esac
# start the op and get the change id
#shellcheck disable=SC2086
chg_id="$(eval ${cmd} --no-wait)"
# save change id to wait later or abort
echo "${chg_id}" >curChg
# wait for the link task to be done
retry -n 50 --wait 1 sh -c 'journalctl -b -u snapd | MATCH "Waiting for system reboot"'
echo "Ensure the test snap still runs"
test-snapd-sh.sh -c 'echo hello' | MATCH hello
echo "Ensure the bootloader is correct before reboot"
readlink "/snap/${TARGET_SNAP}/current" > nextBoot
test "$(cat prevBoot)" != "$(cat nextBoot)"
test "$("$TESTSTOOLS"/boot-state bootenv show snap_try_core)" = "${TARGET_SNAP}_$(cat nextBoot).snap"
test "$("$TESTSTOOLS"/boot-state bootenv show snap_mode)" = "try"
echo "Ensure the device is scheduled for auto-reboot"
output=$(dbus-send --print-reply \
--type=method_call \
--system \
--dest=org.freedesktop.login1 \
/org/freedesktop/login1 \
org.freedesktop.DBus.Properties.Get \
string:org.freedesktop.login1.Manager string:ScheduledShutdown)
if ! echo "$output" | MATCH 'string "reboot"'; then
echo "Failed to detect scheduled reboot in logind output"
exit 1
fi
REBOOT
|