mirror of
https://github.com/token2/snapd.git
synced 2026-03-13 11:15:47 -07:00
* cmd/snaplock/runinhibit: save revision when snap is inhibited This is handy to be used by "snap run" to get snap info when the "current" symlink is not available (i.e. during a refresh after the snap is unlinked). An extra data JSON file is created <inhibit-dir>/<snap>.<hint>. This is needed to carry more information that is needed by "snap run" while the snap is inhibited. It can be expanded to add more data as needed. Signed-off-by: Zeyad Gouda <zeyad.gouda@canonical.com> * o/hookstate/hooks: reuse saved inhibit info in gate-auto-refresh hook Done() method Signed-off-by: Zeyad Gouda <zeyad.gouda@canonical.com> * cmd/snaplock/runinhibit: update doc comments for InhibitInfo and LockWithHint Signed-off-by: Zeyad Gouda <zeyad.gouda@canonical.com> * cmd/snaplock/runinhibit: rename InhibitInfo.Revision to InhibitInfo.Previous to make it clearer. Signed-off-by: Zeyad Gouda <zeyad.gouda@canonical.com> * cmd/snaplock/runinhibit: sync hint file write ops for more reliability Signed-off-by: Zeyad Gouda <zeyad.gouda@canonical.com> * cmd/snaplock/runinhibit: refactor Hint and InhibitInfo validation as a type method Signed-off-by: Zeyad Gouda <zeyad.gouda@canonical.com> * cmd/snaplock/runinhibit: change ioutil.WriteFile to os.WriteFile Signed-off-by: Zeyad Gouda <zeyad.gouda@canonical.com> --------- Signed-off-by: Zeyad Gouda <zeyad.gouda@canonical.com>
169 lines
6.0 KiB
YAML
169 lines
6.0 KiB
YAML
summary: Check that the refresh command works.
|
|
|
|
details: |
|
|
These tests exercise the refresh command using different store backends.
|
|
The concrete store to be used is controlled with the STORE_TYPE variant,
|
|
the defined values are fake, for a local store, or remote, for the currently
|
|
configured remote store.
|
|
When executing against the remote stores the tests rely in the existence of
|
|
a given snap with an updatable version (version string like 2.0+fake1) in the
|
|
edge channel.
|
|
|
|
# ubuntu-14.04: systemd-run not supported
|
|
systems: [-ubuntu-core-*, -ubuntu-14.04*]
|
|
|
|
environment:
|
|
SNAP_NAME/parallel_strict_fake,parallel_strict_remote: test-snapd-tools_instance
|
|
SNAP_NAME/strict_fake,strict_remote: test-snapd-tools
|
|
SNAP_NAME/classic_fake,classic_remote: test-snapd-classic-confinement
|
|
SNAP_VERSION_PATTERN: \d+\.\d+\+fake1
|
|
BLOB_DIR: $(pwd)/fake-store-blobdir
|
|
STORE_TYPE/parallel_strict_fake,strict_fake,classic_fake: fake
|
|
STORE_TYPE/parallel_strict_remote,strict_remote,classic_remote: ${REMOTE_STORE}
|
|
|
|
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
|
|
|
|
flags=
|
|
if [[ "$SNAP_NAME" =~ classic ]]; then
|
|
case "$SPREAD_SYSTEM" in
|
|
ubuntu-core-*|fedora-*|arch-*|centos-*)
|
|
exit
|
|
;;
|
|
esac
|
|
flags=--classic
|
|
fi
|
|
|
|
if [[ "$SPREAD_VARIANT" =~ parallel ]]; then
|
|
snap set system experimental.parallel-instances=true
|
|
fi
|
|
|
|
echo "Given a snap is installed"
|
|
snap install $flags "$SNAP_NAME"
|
|
|
|
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" "$SNAP_NAME"
|
|
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
|
|
|
|
if [[ "$SNAP_NAME" =~ classic ]]; then
|
|
case "$SPREAD_SYSTEM" in
|
|
ubuntu-core-*|fedora-*|arch-*|centos-*)
|
|
exit
|
|
;;
|
|
esac
|
|
fi
|
|
"$TESTSTOOLS"/store-state teardown-fake-store "$BLOB_DIR"
|
|
fi
|
|
|
|
if [[ "$SPREAD_VARIANT" =~ parallel ]]; then
|
|
snap set system experimental.parallel-instances=null
|
|
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
|
|
|
|
if [[ "$SNAP_NAME" =~ classic ]]; then
|
|
case "$SPREAD_SYSTEM" in
|
|
ubuntu-core-*|fedora-*|arch-*|centos-*)
|
|
exit
|
|
;;
|
|
esac
|
|
fi
|
|
|
|
# FIXME: currently the --list from channel doesn't work
|
|
# echo "Then the new version is available for the snap to be refreshed"
|
|
# expected="$SNAP_NAME +$SNAP_VERSION_PATTERN"
|
|
# snap refresh --list | grep -Pzq "$expected"
|
|
#
|
|
# echo "================================="
|
|
|
|
#shellcheck source=tests/lib/pkgdb.sh
|
|
if os.query is-classic && not os.query is-trusty && not os.query is-amazon-linux && not os.query is-centos 9; then
|
|
tests.pkgs install --no-install-recommends inotify-tools
|
|
tests.cleanup defer "tests.pkgs remove inotify-tools"
|
|
systemd-run \
|
|
--unit test-snapd-watch-inhibit.service \
|
|
-- \
|
|
"$(command -v inotifywait)" \
|
|
--monitor \
|
|
--recursive \
|
|
--outfile /tmp/inhibit.events \
|
|
/var/lib/snapd/inhibit
|
|
tests.cleanup defer systemctl stop test-snapd-watch-inhibit.service
|
|
fi
|
|
|
|
echo "When the snap is refreshed"
|
|
snap refresh --channel=edge "$SNAP_NAME"
|
|
|
|
if [ -f /tmp/inhibit.events ]; then
|
|
echo "During the refresh process, the inhibition lock was established and released"
|
|
MATCH "/var/lib/snapd/inhibit/ OPEN $SNAP_NAME.lock" /tmp/inhibit.events
|
|
MATCH "/var/lib/snapd/inhibit/ MODIFY $SNAP_NAME.lock" /tmp/inhibit.events
|
|
MATCH "/var/lib/snapd/inhibit/ CLOSE_WRITE,CLOSE $SNAP_NAME.lock" /tmp/inhibit.events
|
|
|
|
MATCH "/var/lib/snapd/inhibit/ CREATE $SNAP_NAME.refresh" /tmp/inhibit.events
|
|
MATCH "/var/lib/snapd/inhibit/ OPEN $SNAP_NAME.refresh" /tmp/inhibit.events
|
|
MATCH "/var/lib/snapd/inhibit/ MODIFY $SNAP_NAME.refresh" /tmp/inhibit.events
|
|
MATCH "/var/lib/snapd/inhibit/ CLOSE_WRITE,CLOSE $SNAP_NAME.refresh" /tmp/inhibit.events
|
|
MATCH "/var/lib/snapd/inhibit/ DELETE $SNAP_NAME.refresh" /tmp/inhibit.events
|
|
tests.cleanup pop # stop the inotifywait unit
|
|
tests.cleanup pop # remove inotify-tools
|
|
fi
|
|
|
|
echo "Then the new version is listed"
|
|
expected="$SNAP_NAME +$SNAP_VERSION_PATTERN"
|
|
snap list | grep -Pzq "$expected"
|
|
|
|
echo "When a snap is refreshed and has no update it exit 0"
|
|
snap refresh "$SNAP_NAME" 2>stderr.out
|
|
MATCH "snap \"$SNAP_NAME\" has no updates available" < stderr.out
|
|
|
|
echo "classic snaps "
|
|
|
|
echo "When multiple snaps have no update we have a good message"
|
|
"$TESTSTOOLS"/snaps-state install-local basic
|
|
snap refresh "$SNAP_NAME" basic 2>&1 | MATCH "All snaps up to date."
|
|
|
|
echo "When moving to stable"
|
|
snap refresh --stable "$SNAP_NAME"
|
|
snap info "$SNAP_NAME" | MATCH "tracking: +latest/stable"
|
|
|
|
snap refresh --candidate "$SNAP_NAME" 2>&1 | MATCH "$SNAP_NAME \\(candidate\\).*"
|
|
snap info "$SNAP_NAME" | MATCH "tracking: +latest/candidate"
|
|
|
|
echo "When multiple snaps are refreshed we error if we have unknown names"
|
|
if snap refresh core invälid-snap-name 2> out.err; then
|
|
echo "snap refresh invalid-snap-name should fail but it did not?"
|
|
exit 1
|
|
fi
|
|
tr '\n' ' ' < out.err | tr -s ' ' | MATCH 'cannot refresh .* is not installed'
|