summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDan Streetman <ddstreet@canonical.com>2019-10-17 11:06:18 -0400
committerDan Streetman <ddstreet@canonical.com>2019-10-18 15:51:43 -0400
commitdfec314d41159117c28dffc2b980d3bdd67c3dcb (patch)
tree56eaaf78875195a6a2409dc482dae82d9c54f99c /test
parent02baf239d87295362740d961765091b778795573 (diff)
downloadsystemd-dfec314d41159117c28dffc2b980d3bdd67c3dcb.tar.gz
test: correct TEST-41 StartLimitBurst test
TEST-41 verifies that the StartLimitBurst property will correctly limit the number of unit restarts, but the test currently doesn't adjust the StartLimitIntervalSec which defaults to 10 seconds. On Ubuntu CI, running under un-accelerated qemu, it can take more than 10 seconds to perform all 3 restarts, which avoids the burst limit, and fails the test. Instead, specify a long StartLimitIntervalSec in the test, so we can be sure to correctly test StartLimitBurst even on slow testbeds. Fixes #13794.
Diffstat (limited to 'test')
-rw-r--r--test/TEST-41-ONESHOT-RESTART/blacklist-ubuntu-ci4
-rwxr-xr-xtest/TEST-41-ONESHOT-RESTART/testsuite.sh26
2 files changed, 21 insertions, 9 deletions
diff --git a/test/TEST-41-ONESHOT-RESTART/blacklist-ubuntu-ci b/test/TEST-41-ONESHOT-RESTART/blacklist-ubuntu-ci
deleted file mode 100644
index 22b34bbb0c..0000000000
--- a/test/TEST-41-ONESHOT-RESTART/blacklist-ubuntu-ci
+++ /dev/null
@@ -1,4 +0,0 @@
-This appears to be failing on Ubuntu CI due to short sleep duration
-waiting for the service-restarts to complete, but doubling the
-sleep from 5 to 10 seconds didn't appear to help, so let's blacklist
-this on Ubuntu CI while debugging the test failure.
diff --git a/test/TEST-41-ONESHOT-RESTART/testsuite.sh b/test/TEST-41-ONESHOT-RESTART/testsuite.sh
index f7423dbf9a..4465614ff3 100755
--- a/test/TEST-41-ONESHOT-RESTART/testsuite.sh
+++ b/test/TEST-41-ONESHOT-RESTART/testsuite.sh
@@ -2,14 +2,19 @@
set -ex
set -o pipefail
+# wait this many secs for each test service to succeed in what is being tested
+MAX_SECS=60
+
systemd-analyze log-level debug
systemd-analyze log-target console
-# These three commands should succeed.
+# test one: Restart=on-failure should restart the service
! systemd-run --unit=one -p Type=oneshot -p Restart=on-failure /bin/bash -c "exit 1"
-sleep 5
-
+for ((secs=0; secs<$MAX_SECS; secs++)); do
+ [[ "$(systemctl show one.service -p NRestarts --value)" -le 0 ]] || break
+ sleep 1
+done
if [[ "$(systemctl show one.service -p NRestarts --value)" -le 0 ]]; then
exit 1
fi
@@ -18,10 +23,21 @@ TMP_FILE="/test-41-oneshot-restart-test"
touch $TMP_FILE
-! systemd-run --unit=two -p StartLimitBurst=3 -p Type=oneshot -p Restart=on-failure -p ExecStart="/bin/bash -c \"printf a >> $TMP_FILE\"" /bin/bash -c "exit 1"
+# test two: make sure StartLimitBurst correctly limits the number of restarts
+# and restarts execution of the unit from the first ExecStart=
+! systemd-run --unit=two -p StartLimitIntervalSec=120 -p StartLimitBurst=3 -p Type=oneshot -p Restart=on-failure -p ExecStart="/bin/bash -c \"printf a >> $TMP_FILE\"" /bin/bash -c "exit 1"
-sleep 5
+# wait for at least 3 restarts
+for ((secs=0; secs<$MAX_SECS; secs++)); do
+ [[ $(cat $TMP_FILE) != "aaa" ]] || break
+ sleep 1
+done
+if [[ $(cat $TMP_FILE) != "aaa" ]]; then
+ exit 1
+fi
+# wait for 5 more seconds to make sure there aren't excess restarts
+sleep 5
if [[ $(cat $TMP_FILE) != "aaa" ]]; then
exit 1
fi