Files
snapd/tests/main/revert-devmode/task.yaml
Miguel Pires a951e3f060 tests: add details to spread test (#13919)
Document the behavior of spread tests in the details field.

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2024-04-30 14:47:17 -03:00

91 lines
2.7 KiB
YAML

summary: Check that revert of a snap in devmode restores devmode
details: |
Check that reverting a refresh preserves the mode it was refreshed with
(i.e., reverting a snap refreshed with --devmode results in it being run
in devmode after being reverted).
# slow in autopkgtest (>1m)
backends: [-autopkgtest]
# ubuntu-14.04: systemd-run not supported
systems: [-ubuntu-14.04*]
environment:
STORE_TYPE/fake: fake
STORE_TYPE/remote: ${REMOTE_STORE}
BLOB_DIR: $(pwd)/fake-store-blobdir
prepare: |
if [ "$STORE_TYPE" = "fake" ]; then
if os.query is-core; then
exit
fi
if [ "$TRUST_TEST_KEYS" = "false" ]; then
echo "This test needs test keys to be trusted"
exit
fi
fi
echo "Given a snap is installed"
snap install --devmode test-snapd-tools
if [ "$STORE_TYPE" = "fake" ]; then
"$TESTSTOOLS"/store-state setup-fake-store "$BLOB_DIR"
echo "And a new version of that snap put in the controlled store"
"$TESTSTOOLS"/store-state init-fake-refreshes "$BLOB_DIR" test-snapd-tools
fi
restore: |
if [ "$STORE_TYPE" = "fake" ]; then
if os.query is-core; then
exit
fi
if [ "$TRUST_TEST_KEYS" = "false" ]; then
echo "This test needs test keys to be trusted"
exit
fi
"$TESTSTOOLS"/store-state teardown-fake-store "$BLOB_DIR"
fi
execute: |
if [ "$STORE_TYPE" = "fake" ]; then
if os.query is-core; then
exit
fi
if [ "$TRUST_TEST_KEYS" = "false" ]; then
echo "This test needs test keys to be trusted"
exit
fi
fi
echo "When a refresh is made"
snap refresh --devmode --edge test-snapd-tools
echo "Then the new version is installed"
snap list | MATCH 'test-snapd-tools +[0-9]+\.[0-9]+\+fake1'
SNAP_MOUNT_DIR="$(os.paths snap-mount-dir)"
LATEST=$(readlink "$SNAP_MOUNT_DIR"/test-snapd-tools/current)
echo "When a revert is made without --devmode flag"
snap revert test-snapd-tools
echo "Then the old version is active"
snap list | MATCH 'test-snapd-tools +[0-9]+\.[0-9]+ '
echo "And the snap runs in devmode"
snap list|MATCH 'test-snapd-tools .* devmode'
echo "When the latest revision is installed again"
snap remove --revision="$LATEST" test-snapd-tools
snap refresh --edge test-snapd-tools
if [ "$(snap debug confinement)" = strict ] ; then
echo "And revert is made with --jailmode flag"
snap revert --jailmode test-snapd-tools
echo "Then snap now runs confined (in jailmode, bah)"
snap list|MATCH 'test-snapd-tools .* jailmode'
fi