2013-01-25 23:10:00 +04:00
#!/bin/bash -x
2015-05-18 07:58:24 +03:00
# Test merging of a --job-mode=ignore-dependencies job into a previously
2013-01-25 23:10:00 +04:00
# installed job.
systemctl start --no-block hello-after-sleep.target
2016-01-17 06:21:52 +03:00
2013-01-25 23:10:00 +04:00
systemctl list-jobs > /root/list-jobs.txt
2016-01-17 06:21:52 +03:00
while ! grep 'sleep\.service.*running' /root/list-jobs.txt; do
systemctl list-jobs > /root/list-jobs.txt
done
2013-01-25 23:10:00 +04:00
grep 'hello\.service.*waiting' /root/list-jobs.txt || exit 1
# This is supposed to finish quickly, not wait for sleep to finish.
START_SEC = $( date -u '+%s' )
2015-05-18 07:58:24 +03:00
systemctl start --job-mode= ignore-dependencies hello
2013-01-25 23:10:00 +04:00
END_SEC = $( date -u '+%s' )
ELAPSED = $(( $END_SEC - $START_SEC ))
[ " $ELAPSED " -lt 3 ] || exit 1
# sleep should still be running, hello not.
systemctl list-jobs > /root/list-jobs.txt
grep 'sleep\.service.*running' /root/list-jobs.txt || exit 1
grep 'hello\.service' /root/list-jobs.txt && exit 1
2014-11-26 18:33:40 +03:00
systemctl stop sleep.service hello-after-sleep.target || exit 1
2015-11-06 22:01:21 +03:00
# Test for a crash when enqueuing a JOB_NOP when other job already exists
2014-11-26 18:33:40 +03:00
systemctl start --no-block hello-after-sleep.target || exit 1
# hello.service should still be waiting, so these try-restarts will collapse
# into NOPs.
2015-05-18 07:58:24 +03:00
systemctl try-restart --job-mode= fail hello.service || exit 1
2014-11-26 18:33:40 +03:00
systemctl try-restart hello.service || exit 1
systemctl stop hello.service sleep.service hello-after-sleep.target || exit 1
2013-01-25 23:10:00 +04:00
# TODO: add more job queueing/merging tests here.
2013-02-22 21:59:07 +04:00
# Test for irreversible jobs
systemctl start unstoppable.service || exit 1
# This is expected to fail with 'job cancelled'
systemctl stop unstoppable.service && exit 1
# But this should succeed
2015-05-18 07:58:24 +03:00
systemctl stop --job-mode= replace-irreversibly unstoppable.service || exit 1
2013-02-22 21:59:07 +04:00
# We're going to shutdown soon. Let's see if it succeeds when
# there's an active service that tries to be unstoppable.
# Shutdown of the container/VM will hang if not.
systemctl start unstoppable.service || exit 1
2013-01-25 23:10:00 +04:00
touch /testok