mirror of
https://github.com/token2/snapd.git
synced 2026-03-13 11:15:47 -07:00
61 lines
3.1 KiB
YAML
61 lines
3.1 KiB
YAML
summary: Check that snap timer services work
|
|
|
|
details: |
|
|
A snap service may define a timer declaring when the service must
|
|
be run automatically. Those timers translate to systemd timer
|
|
units.
|
|
|
|
This test verifies that the installation of a snap with timers, or
|
|
enabling of the snap, will create corresponding systemd timer. It
|
|
will also verify that removal or disabling of the snap will also
|
|
remove the timer units.
|
|
|
|
execute: |
|
|
echo "When the service snap is installed"
|
|
"$TESTSTOOLS"/snaps-state install-local test-snapd-timer-service
|
|
|
|
echo "We can see the timers being active"
|
|
for service in regular-timer random-timer range-timer trivial-timer; do
|
|
systemctl show -p ActiveState snap.test-snapd-timer-service.$service.timer | MATCH "ActiveState=active"
|
|
systemctl show -p SubState snap.test-snapd-timer-service.$service.timer | MATCH "SubState=(waiting|running)"
|
|
systemctl show -p Triggers snap.test-snapd-timer-service.$service.timer | \
|
|
MATCH "snap.test-snapd-timer-service.$service.service"
|
|
systemctl show -p UnitFileState snap.test-snapd-timer-service.$service.timer | MATCH "UnitFileState=enabled"
|
|
done
|
|
# systemctl list-timers output:
|
|
# NEXT LEFT LAST PASSED UNIT ACTIVATES
|
|
# Fri 2018-02-23 11:00:00 CET 3min 25s left Fri 2018-02-23 10:45:36 CET 10min ago snap.timer-service-snap.regular-timer.timer snap.timer-service-snap.regular-timer.service
|
|
# Fri 2018-02-23 11:01:00 CET 4min 25s left Fri 2018-02-23 10:51:36 CET 4min 58s ago snap.timer-service-snap.random-timer.timer snap.timer-service-snap.random-timer.service
|
|
echo "When disabled, times are not listed by systemd"
|
|
snap disable test-snapd-timer-service
|
|
if os.query is-trusty; then
|
|
for service in regular-timer random-timer range-timer trivial-timer; do
|
|
systemctl show -p UnitFileState snap.test-snapd-timer-service.$service.timer | MATCH "UnitFileState="
|
|
done
|
|
else
|
|
systemctl list-timers | NOMATCH "test-snapd-timer-service"
|
|
fi
|
|
|
|
echo "When reenabled, the timers are present again"
|
|
snap enable test-snapd-timer-service
|
|
if os.query is-trusty; then
|
|
for service in regular-timer random-timer range-timer trivial-timer; do
|
|
systemctl show -p UnitFileState snap.test-snapd-timer-service.$service.timer | MATCH "UnitFileState=enabled"
|
|
done
|
|
else
|
|
systemctl list-timers | MATCH "test-snapd-timer-service"
|
|
fi
|
|
|
|
echo "When removed, times are not listed by systemd"
|
|
snap remove --purge test-snapd-timer-service
|
|
if os.query is-trusty; then
|
|
for service in regular-timer random-timer range-timer trivial-timer; do
|
|
systemctl show -p UnitFileState snap.test-snapd-timer-service.$service.timer | MATCH "UnitFileState="
|
|
done
|
|
else
|
|
systemctl list-timers | NOMATCH "test-snapd-timer-service"
|
|
fi
|
|
|
|
echo "No timer files are left behind"
|
|
test "$(find /etc/systemd/system -name 'snap.test-snapd-timer-service.*.timer' | wc -l)" -eq "0"
|