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
|
summary: verify the output of 'snap services' command
details: |
The "snap services" command shows all the services provided by all the
snaps, their state at present, their automatic startup as well as auxiliary
properties such as being bus-activated or belonging to the user session
instead of the system.
The test installs a number of snaps and observers the output of the
aforementioned command.
systems:
# TODO: dbus issue
- -ubuntu-core-22-*
prepare: |
snap set system experimental.user-daemons=true
restore: |
snap remove --purge test-snapd-service || true
snap remove --purge socket-activation || true
snap remove --purge test-snapd-timer-service || true
snap remove --purge test-snapd-dbus-service || true
snap remove --purge test-snapd-user-service || true
snap unset system experimental.user-daemons
execute: |
# precondition check of systemctl behavior for non-existing services;
# it is expected that the returned UnitFileState is empty.
systemctl show --property=Id foo.service | MATCH "foo.service"
systemctl show --property=ActiveState foo.service | MATCH "inactive"
UNIT_FILE_STATE=$(systemctl show --property=UnitFileState foo.service)
if [[ "$UNIT_FILE_STATE" != "UnitFileState=" ]]; then
echo "unexpected value of UnitFileState for non-existing service: $UNIT_FILE_STATE"
systemctl --version
exit 1
fi
"$TESTSTOOLS"/snaps-state install-local test-snapd-service
"$TESTSTOOLS"/snaps-state install-local socket-activation
"$TESTSTOOLS"/snaps-state install-local test-snapd-timer-service
snap services test-snapd-timer-service > timer-service.out
MATCH '^test-snapd-timer-service.random-timer\s+ enabled\s+ (in)?active\s+ timer-activated$' < timer-service.out
MATCH '^test-snapd-timer-service.regular-timer\s+ enabled\s+ (in)?active\s+ timer-activated$' < timer-service.out
snap services socket-activation > socket-activation.out
MATCH '^socket-activation.sleep-daemon\s+ enabled\s+ inactive\s+ socket-activated$' < socket-activation.out
snap services test-snapd-service > test-snapd-service.out
MATCH '^test-snapd-service.test-snapd-service\s+ enabled\s+ active\s+ -$' < test-snapd-service.out
if [[ "$SPREAD_SYSTEM" != ubuntu-14.04-* ]]; then
"$TESTSTOOLS"/snaps-state install-local test-snapd-user-service
snap services test-snapd-user-service > test-snapd-user-service.out
MATCH '^test-snapd-user-service.test-snapd-user-service\s+ enabled\s+ -\s+ user$' < test-snapd-user-service.out
fi
if tests.session has-system-systemd-and-dbus; then
# Only run this part of the test on systems supporting systemd
# activation on the D-Bus system bus
snap install --edge test-snapd-dbus-service
snap services test-snapd-dbus-service > dbus-service.out
MATCH '^test-snapd-dbus-service.system\s+ enabled\s+ (in)?active\s+ dbus-activated$' < dbus-service.out
MATCH '^test-snapd-dbus-service.session\s+ enabled\s+ -\s+ user,dbus-activated$' < dbus-service.out
fi
|