summaryrefslogtreecommitdiff
path: root/test/TEST-03-JOBS/test-jobs.sh
diff options
context:
space:
mode:
authorMichal Schmidt <mschmidt@redhat.com>2013-01-25 20:10:00 +0100
committerMichal Schmidt <mschmidt@redhat.com>2013-01-25 22:29:56 +0100
commitb5da077ddf01546c4a85688624d6957766d6c00c (patch)
treea92ac9334a425fe96e80bbafd1ab8858cb44d3a5 /test/TEST-03-JOBS/test-jobs.sh
parentc90feab4ff8bc23d88d4f9c67d9652ba189cb51b (diff)
test: add test for jobs
Add a test case for job merging with --ignore-dependencies. test.sh is copied from TEST-01-*, only lightly modified (this should be refactored better in the future). test-jobs.sh is the core of this test.
Diffstat (limited to 'test/TEST-03-JOBS/test-jobs.sh')
-rwxr-xr-xtest/TEST-03-JOBS/test-jobs.sh28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/TEST-03-JOBS/test-jobs.sh b/test/TEST-03-JOBS/test-jobs.sh
new file mode 100755
index 0000000000..98746c5363
--- /dev/null
+++ b/test/TEST-03-JOBS/test-jobs.sh
@@ -0,0 +1,28 @@
+#!/bin/bash -x
+
+# Test merging of a --ignore-dependencies job into a previously
+# installed job.
+
+systemctl start --no-block hello-after-sleep.target
+# sleep is now running, hello/start is waiting. Verify that:
+systemctl list-jobs > /root/list-jobs.txt
+grep 'sleep\.service.*running' /root/list-jobs.txt || exit 1
+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')
+systemctl start --ignore-dependencies hello
+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
+
+# TODO: add more job queueing/merging tests here.
+
+touch /testok
+exit 0