]>
Commit | Line | Data |
---|---|---|
b5da077d MS |
1 | #!/bin/bash -x |
2 | ||
903e7c37 | 3 | # Test merging of a --job-mode=ignore-dependencies job into a previously |
b5da077d MS |
4 | # installed job. |
5 | ||
6 | systemctl start --no-block hello-after-sleep.target | |
b46f4ef1 | 7 | |
b5da077d | 8 | systemctl list-jobs > /root/list-jobs.txt |
b46f4ef1 EV |
9 | while ! grep 'sleep\.service.*running' /root/list-jobs.txt; do |
10 | systemctl list-jobs > /root/list-jobs.txt | |
11 | done | |
12 | ||
b5da077d MS |
13 | grep 'hello\.service.*waiting' /root/list-jobs.txt || exit 1 |
14 | ||
15 | # This is supposed to finish quickly, not wait for sleep to finish. | |
16 | START_SEC=$(date -u '+%s') | |
903e7c37 | 17 | systemctl start --job-mode=ignore-dependencies hello |
b5da077d MS |
18 | END_SEC=$(date -u '+%s') |
19 | ELAPSED=$(($END_SEC-$START_SEC)) | |
20 | ||
21 | [ "$ELAPSED" -lt 3 ] || exit 1 | |
22 | ||
23 | # sleep should still be running, hello not. | |
24 | systemctl list-jobs > /root/list-jobs.txt | |
25 | grep 'sleep\.service.*running' /root/list-jobs.txt || exit 1 | |
26 | grep 'hello\.service' /root/list-jobs.txt && exit 1 | |
06c1c4f9 MS |
27 | systemctl stop sleep.service hello-after-sleep.target || exit 1 |
28 | ||
59ef392e | 29 | # Test for a crash when enqueuing a JOB_NOP when other job already exists |
06c1c4f9 MS |
30 | systemctl start --no-block hello-after-sleep.target || exit 1 |
31 | # hello.service should still be waiting, so these try-restarts will collapse | |
32 | # into NOPs. | |
903e7c37 | 33 | systemctl try-restart --job-mode=fail hello.service || exit 1 |
06c1c4f9 MS |
34 | systemctl try-restart hello.service || exit 1 |
35 | systemctl stop hello.service sleep.service hello-after-sleep.target || exit 1 | |
b5da077d MS |
36 | |
37 | # TODO: add more job queueing/merging tests here. | |
38 | ||
d710d363 MS |
39 | # Test for irreversible jobs |
40 | systemctl start unstoppable.service || exit 1 | |
41 | ||
42 | # This is expected to fail with 'job cancelled' | |
43 | systemctl stop unstoppable.service && exit 1 | |
44 | # But this should succeed | |
903e7c37 | 45 | systemctl stop --job-mode=replace-irreversibly unstoppable.service || exit 1 |
d710d363 MS |
46 | |
47 | # We're going to shutdown soon. Let's see if it succeeds when | |
48 | # there's an active service that tries to be unstoppable. | |
49 | # Shutdown of the container/VM will hang if not. | |
50 | systemctl start unstoppable.service || exit 1 | |
51 | ||
b5da077d MS |
52 | touch /testok |
53 | exit 0 |