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
|
summary: Check that the kernel snap can be refreshed on a core device
details: |
This test checks that the kernel snap can be refreshed from an installed
revision to a new one. It expects to find a new snap revision in the
channel pointed by the NEW_CORE_CHANNEL env var.
systems: [ubuntu-core-*-64]
manual: true
environment:
KERNEL_CHANNEL: stable
NEW_KERNEL_CHANNEL: edge
prepare: |
snap install test-snapd-sh
debug: |
grub-editenv list || true
execute: |
same=$(snap info pc-kernel | awk "
/^ ${KERNEL_CHANNEL}:/ {ch1=\$2}
/^ ${NEW_KERNEL_CHANNEL}:/ {ch2=\$2}
END { if (ch1 == ch2) print(\"same\") }")
if [ "$same" = "same" ]; then
echo "SKIPPING: kernel in edge / stable are the same"
exit 0
fi
if [ "$SPREAD_REBOOT" = 0 ]; then
# ensure we have a good starting place
# precondition
test-snapd-sh.sh -c 'echo hello' | MATCH hello
# go to known good starting place
snap refresh pc-kernel "--${KERNEL_CHANNEL}"
REBOOT
elif [ "$SPREAD_REBOOT" = 1 ]; then
# from our good starting place we refresh
"$TESTSTOOLS"/boot-state wait-core-post-boot
# save current core revision
snap list | awk "/^pc-kernel / {print(\$3)}" > prevBoot
cat /proc/version_signature > prevKernelSignature
# refresh
snap refresh pc-kernel "--${NEW_KERNEL_CHANNEL}"
# check boot env vars
snap list | awk "/^pc-kernel / {print(\$3)}" > nextBoot
test "$("$TESTSTOOLS"/boot-state bootenv show snap_kernel)" = "pc-kernel_$(cat prevBoot).snap"
if [ "$(cat prevBoot)" = "$(cat nextBoot)" ]; then
echo "WARNING: kernel in edge / stable are the same"
else
test "$("$TESTSTOOLS"/boot-state bootenv show snap_try_kernel)" = "pc-kernel_$(cat nextBoot).snap"
fi
# test-snapd-sh works
test-snapd-sh.sh -c 'echo hello' | MATCH hello
REBOOT
elif [ "$SPREAD_REBOOT" = 2 ]; then
# after refresh to NEW_CHANNEL
"$TESTSTOOLS"/boot-state wait-core-post-boot
# check boot env vars
test "$("$TESTSTOOLS"/boot-state bootenv show snap_kernel)" = "pc-kernel_$(cat nextBoot).snap"
test "$("$TESTSTOOLS"/boot-state bootenv show snap_try_kernel)" = ""
cat /proc/version_signature > nextKernelSignature
if diff -u prevKernelSignature nextKernelSignature; then
echo "SKIPPING: kernel in edge / stable are the same"
exit 0
fi
# test-snapd-sh works
test-snapd-sh.sh -c 'echo hello' | MATCH hello
# revert kernel
snap revert pc-kernel
test "$("$TESTSTOOLS"/boot-state bootenv show snap_kernel)" = "pc-kernel_$(cat nextBoot).snap"
test "$("$TESTSTOOLS"/boot-state bootenv show snap_try_kernel)" = "pc-kernel_$(cat prevBoot).snap"
REBOOT
elif [ "$SPREAD_REBOOT" = 3 ]; then
# after revert
"$TESTSTOOLS"/boot-state wait-core-post-boot
# check that we reverted
test "$("$TESTSTOOLS"/boot-state bootenv show snap_kernel)" = "pc-kernel_$(cat prevBoot).snap"
test "$("$TESTSTOOLS"/boot-state bootenv show snap_try_kernel)" = ""
echo we are back to the original kernel
diff -u /proc/version_signature prevKernelSignature
# test-snapd-sh works
test-snapd-sh.sh -c 'echo hello' | MATCH hello
fi
|