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 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
|
summary: Test remodel
details: |
Check that when `snap remodel` is executed, then it uses the new model
assertion and the required snaps defined in the new model are installed.
Verify that the required snaps cannot be removed, but after remodel
back to the initial model, the required snaps are not still required
and can be removed.
# TODO:UC20: enable for UC20
systems: [ubuntu-core-16-64, ubuntu-core-18-64]
prepare: |
#shellcheck source=tests/lib/core-config.sh
. "$TESTSLIB"/core-config.sh
if [ "$SPREAD_REBOOT" = 0 ]; then
REBOOT_NEEDED=false
if os.query is-core18 && snap list snapd | NOMATCH ' x1 '; then
REBOOT_NEEDED=true
fi
systemctl stop snapd.service snapd.socket
clean_snapd_lib
# Generic setup for test account
prepare_core_model
prepare_test_account valid-for-testing
prepare_test_model valid-for-testing-pc
# kick first boot again
systemctl start snapd.service snapd.socket
if [ "$REBOOT_NEEDED" = true ] && "$TESTSTOOLS"/journal-state match-log -n 30 "Waiting for system reboot"; then
REBOOT
fi
fi
# wait for first boot to be done
wait_for_first_boot_change
# and for the serial to be available
wait_for_device_initialized_change
restore: |
#shellcheck source=tests/lib/core-config.sh
. "$TESTSLIB"/core-config.sh
if [ "$SPREAD_REBOOT" = 0 ]; then
REBOOT_NEEDED=false
if os.query is-core18 && snap list snapd | NOMATCH ' x1 '; then
REBOOT_NEEDED=true
fi
systemctl stop snapd.service snapd.socket
clean_snapd_lib
# Generic restore for test account
restore_test_account valid-for-testing
restore_test_model valid-for-testing-pc
restore_core_model
rm -f /var/lib/snapd/seed/assertions/test-snapd-with-configure_*.assert
# kick first boot again
systemctl start snapd.service snapd.socket
if [ "$REBOOT_NEEDED" = true ] && "$TESTSTOOLS"/journal-state match-log -n 30 "Waiting for system reboot"; then
REBOOT
fi
fi
# wait for first boot to be done
wait_for_first_boot_change
# extra paranoia because failure to cleanup earlier took us a long time
# to find
if [ -e /var/snap/test-snapd-tools/current ]; then
echo "Leftover test-snapd-tools data dir found, test does not "
echo "properly cleanup"
echo "see https://github.com/snapcore/snapd/pull/6620"
exit 1
fi
execute: |
#shellcheck source=tests/lib/core-config.sh
. "$TESTSLIB"/core-config.sh
#shellcheck source=tests/lib/systems.sh
. "$TESTSLIB"/systems.sh
SNAP="$(get_snap_for_system test-snapd-tools)"
# precondition check
not snap list "$SNAP"
echo "Wait for first boot to be done"
wait_for_first_boot_change
echo "We have the right model assertion"
snap debug model|MATCH "model: my-model"
echo "Now we remodel"
MODEL="$(get_test_model valid-for-testing-pc-revno-2)"
snap remodel "${TESTSLIB}/assertions/${MODEL}"
echo "and we got the new required snap"
snap list "$SNAP"
echo "and we got the new model assertion"
snap debug model|MATCH "revision: 2"
snap changes | MATCH "Refresh model assertion from revision 0 to 2"
echo "and we cannot remove the new required snap"
not snap remove --purge "$SNAP"
echo "And we can remodel again this time test-snapd-tools is no longer required"
MODEL="$(get_test_model valid-for-testing-pc-revno-3)"
snap remodel "${TESTSLIB}/assertions/${MODEL}"
snap debug model|MATCH "revision: 3"
snap changes | MATCH "Refresh model assertion from revision 2 to 3"
echo "and $SNAP is still available"
snap list "$SNAP"
echo "and we can clean it up here because it is no longer required"
snap remove --purge "$SNAP"
echo "and test that the remodel shows up in 'snap changes'"
echo "and check that this remodel has just a single task"
snap change --last=remodel > remodel.txt
MATCH "Set new model assertion" < remodel.txt
[ "$(grep -c today remodel.txt)" -eq 1 ]
|