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
|
summary: Check that snaps can use stop-timeout
details: |
A service from a snap may define a stop command as well as a stop
timeout. When stopping a service, if the stop command takes more
time than the defined stop timeout, then the stop command will be
stopped and the service killed. This test verifies that the stop
timeout works correctly by running a stop command for longer than
the timeout.
# this test is expected to fail once we run the tests for SELinux
# distros in Enforce mode
# systemd on 14.04 does not really honour TimeoutStopSec
systems: [-ubuntu-14*]
restore: |
f=test-snapd-service-stop-timeout/staaap.sh
if [ -e "$f.bak" ]; then
mv -v "$f.bak" "$f"
fi
execute: |
dir=test-snapd-service-stop-timeout
stamp="/var/snap/test-snapd-service-stop-timeout/current/stamp"
snap try "$dir"
# without the sleep, stop-timeout doesn't interfere with stop-command
test ! -e "$stamp"
snap stop test-snapd-service-stop-timeout
test -e "$stamp"
# add a 'sleep 30'
sed -i.bak -e 's/^# @@@/sleep 30/' "$dir/staaap.sh"
snap start test-snapd-service-stop-timeout
# now it sleeps longer than stop-timeout, the service is killed
# before it gets to shut down cleanly
test ! -e "$stamp"
snap stop test-snapd-service-stop-timeout
test ! -e "$stamp"
|