3 # Test merging of a --job-mode=ignore-dependencies job into a previously
6 systemctl start
--no-block hello-after-sleep.target
7 # sleep is now running, hello/start is waiting. Verify that:
8 systemctl list-jobs
> /root
/list-jobs.txt
9 grep 'sleep\.service.*running' /root
/list-jobs.txt ||
exit 1
10 grep 'hello\.service.*waiting' /root
/list-jobs.txt ||
exit 1
12 # This is supposed to finish quickly, not wait for sleep to finish.
13 START_SEC
=$
(date -u '+%s')
14 systemctl start
--job-mode=ignore-dependencies hello
15 END_SEC
=$
(date -u '+%s')
16 ELAPSED
=$
(($END_SEC-$START_SEC))
18 [ "$ELAPSED" -lt 3 ] ||
exit 1
20 # sleep should still be running, hello not.
21 systemctl list-jobs
> /root
/list-jobs.txt
22 grep 'sleep\.service.*running' /root
/list-jobs.txt ||
exit 1
23 grep 'hello\.service' /root
/list-jobs.txt
&& exit 1
24 systemctl stop
sleep.service hello-after-sleep.target ||
exit 1
26 # Test for a crash when enqueuing a JOB_NOP when other job already exists
27 systemctl start
--no-block hello-after-sleep.target ||
exit 1
28 # hello.service should still be waiting, so these try-restarts will collapse
30 systemctl try-restart
--job-mode=fail hello.service ||
exit 1
31 systemctl try-restart hello.service ||
exit 1
32 systemctl stop hello.service
sleep.service hello-after-sleep.target ||
exit 1
34 # TODO: add more job queueing/merging tests here.
36 # Test for irreversible jobs
37 systemctl start unstoppable.service ||
exit 1
39 # This is expected to fail with 'job cancelled'
40 systemctl stop unstoppable.service
&& exit 1
41 # But this should succeed
42 systemctl stop
--job-mode=replace-irreversibly unstoppable.service ||
exit 1
44 # We're going to shutdown soon. Let's see if it succeeds when
45 # there's an active service that tries to be unstoppable.
46 # Shutdown of the container/VM will hang if not.
47 systemctl start unstoppable.service ||
exit 1