mirror of
https://github.com/systemd/systemd.git
synced 2025-01-11 09:18:07 +03:00
TEST-68: enhance testing of chained commands
The test would fail when the the same handler was used for multiple *failing* units. We need to call 'reset-failed' to let the manager forget about the earlier ones. systemd-analyze log-target console is removed, because it's easier to follow the logs if logging it to the journal.
This commit is contained in:
parent
ff7b9a2693
commit
f086cca248
@ -24,7 +24,6 @@ wait_on_state_or_fail () {
|
||||
}
|
||||
|
||||
systemd-analyze log-level debug
|
||||
systemd-analyze log-target console
|
||||
|
||||
# Trigger testservice-failure-exit-handler-68.service
|
||||
cat >/run/systemd/system/testservice-failure-68.service <<EOF
|
||||
@ -70,7 +69,7 @@ cat >/tmp/check_on_success.sh <<"EOF"
|
||||
#!/bin/sh
|
||||
|
||||
set -ex
|
||||
env
|
||||
env | sort
|
||||
if [ "$MONITOR_SERVICE_RESULT" != "success" ]; then
|
||||
echo "MONITOR_SERVICE_RESULT was '$MONITOR_SERVICE_RESULT', expected 'success'"
|
||||
exit 1
|
||||
@ -130,7 +129,7 @@ cat >/tmp/check_on_failure.sh <<"EOF"
|
||||
#!/bin/sh
|
||||
|
||||
set -ex
|
||||
env
|
||||
env | sort
|
||||
if [ "$MONITOR_SERVICE_RESULT" != "exit-code" ]; then
|
||||
echo "MONITOR_SERVICE_RESULT was '$MONITOR_SERVICE_RESULT', expected 'exit-code'"
|
||||
exit 1
|
||||
@ -187,23 +186,40 @@ EOF
|
||||
|
||||
systemctl daemon-reload
|
||||
|
||||
: "-------I----------------------------------------------------"
|
||||
systemctl start testservice-failure-68.service
|
||||
wait_on_state_or_fail "testservice-failure-exit-handler-68.service" "inactive" "10"
|
||||
|
||||
: "-------II---------------------------------------------------"
|
||||
systemctl start testservice-success-68.service
|
||||
wait_on_state_or_fail "testservice-success-exit-handler-68.service" "inactive" "10"
|
||||
|
||||
# Let's get rid of the failed units so the tests below don't fail, and daemon-reload
|
||||
# to force garbace collection of the units.
|
||||
systemctl reset-failed
|
||||
systemctl daemon-reload
|
||||
|
||||
# Test some transient units since these exit very quickly.
|
||||
: "-------III--------------------------------------------------"
|
||||
systemd-run --unit=testservice-transient-success-68 --property=OnSuccess=testservice-success-exit-handler-68.service sh -c "exit 0"
|
||||
wait_on_state_or_fail "testservice-success-exit-handler-68.service" "inactive" "10"
|
||||
|
||||
: "-------IIII-------------------------------------------------"
|
||||
systemd-run --unit=testservice-transient-failure-68 --property=OnFailure=testservice-failure-exit-handler-68.service sh -c "exit 1"
|
||||
wait_on_state_or_fail "testservice-failure-exit-handler-68.service" "inactive" "10"
|
||||
|
||||
systemctl reset-failed
|
||||
systemctl daemon-reload
|
||||
|
||||
# Test template handlers too
|
||||
systemctl start testservice-failure-68-template.service
|
||||
wait_on_state_or_fail "testservice-failure-exit-handler-68-template@testservice-failure-68-template.service.service" "inactive" "10"
|
||||
: "-------V---------------------------------------------------"
|
||||
systemctl start testservice-success-68-template.service
|
||||
wait_on_state_or_fail "testservice-success-exit-handler-68-template@testservice-success-68-template.service.service" "inactive" "10"
|
||||
|
||||
: "-------VI----------------------------------------------------"
|
||||
systemctl start testservice-failure-68-template.service
|
||||
wait_on_state_or_fail "testservice-failure-exit-handler-68-template@testservice-failure-68-template.service.service" "inactive" "10"
|
||||
|
||||
systemd-analyze log-level info
|
||||
echo OK >/testok
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user