mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-03-08 20:58:20 +03:00
Merge pull request #22855 from keszybz/test-68-reload-reload
TEST-68: replace daemon-reload with separate handler units
This commit is contained in:
commit
a73c7a87ae
@ -25,10 +25,8 @@ wait_on_state_or_fail () {
|
||||
|
||||
systemd-analyze log-level debug
|
||||
|
||||
# Trigger testservice-failure-exit-handler-68.service
|
||||
cat >/run/systemd/system/testservice-failure-68.service <<EOF
|
||||
[Unit]
|
||||
Description=TEST-68-PROPAGATE-EXIT-STATUS with OnFailure= trigger
|
||||
OnFailure=testservice-failure-exit-handler-68.service
|
||||
|
||||
[Service]
|
||||
@ -37,17 +35,14 @@ EOF
|
||||
|
||||
cat >/run/systemd/system/testservice-failure-68-template.service <<EOF
|
||||
[Unit]
|
||||
Description=TEST-68-PROPAGATE-EXIT-STATUS with OnFailure= trigger (template)
|
||||
OnFailure=testservice-failure-exit-handler-68-template@%n.service
|
||||
|
||||
[Service]
|
||||
ExecStart=sh -c "exit 1"
|
||||
EOF
|
||||
|
||||
# Trigger testservice-success-exit-handler-68.service
|
||||
cat >/run/systemd/system/testservice-success-68.service <<EOF
|
||||
[Unit]
|
||||
Description=TEST-68-PROPAGATE-EXIT-STATUS with OnSuccess= trigger
|
||||
OnSuccess=testservice-success-exit-handler-68.service
|
||||
|
||||
[Service]
|
||||
@ -56,7 +51,6 @@ EOF
|
||||
|
||||
cat >/run/systemd/system/testservice-success-68-template.service <<EOF
|
||||
[Unit]
|
||||
Description=TEST-68-PROPAGATE-EXIT-STATUS with OnSuccess= trigger (template)
|
||||
OnSuccess=testservice-success-exit-handler-68-template@%n.service
|
||||
|
||||
[Service]
|
||||
@ -102,21 +96,17 @@ exit 0
|
||||
EOF
|
||||
chmod +x /tmp/check_on_success.sh
|
||||
|
||||
# Handle testservice-failure-exit-handler-68.service exiting with success.
|
||||
cat >/run/systemd/system/testservice-success-exit-handler-68.service <<EOF
|
||||
[Unit]
|
||||
Description=TEST-68-PROPAGATE-EXIT-STATUS handle service exiting in success
|
||||
|
||||
[Service]
|
||||
ExecStartPre=/tmp/check_on_success.sh
|
||||
ExecStart=/tmp/check_on_success.sh
|
||||
EOF
|
||||
|
||||
cp /run/systemd/system/testservice-success-exit-handler-68.service \
|
||||
/run/systemd/system/testservice-transient-success-exit-handler-68.service
|
||||
|
||||
# Template version.
|
||||
cat >/run/systemd/system/testservice-success-exit-handler-68-template@.service <<EOF
|
||||
[Unit]
|
||||
Description=TEST-68-PROPAGATE-EXIT-STATUS handle service exiting in success (template)
|
||||
|
||||
[Service]
|
||||
ExecStartPre=echo "triggered by %i"
|
||||
ExecStartPre=/tmp/check_on_success.sh
|
||||
@ -163,11 +153,7 @@ EOF
|
||||
chmod +x /tmp/check_on_failure.sh
|
||||
|
||||
|
||||
# Handle testservice-failure-exit-handler-68.service exiting with failure.
|
||||
cat >/run/systemd/system/testservice-failure-exit-handler-68.service <<EOF
|
||||
[Unit]
|
||||
Description=TEST-68-PROPAGATE-EXIT-STATUS handle service exiting in failure
|
||||
|
||||
[Service]
|
||||
# repeat the check to make sure that values are set correctly on repeated invocations
|
||||
Type=oneshot
|
||||
@ -178,11 +164,11 @@ ExecStart=/tmp/check_on_failure.sh
|
||||
ExecStartPost=test -z '$MONITOR_SERVICE_RESULT'
|
||||
EOF
|
||||
|
||||
cp /run/systemd/system/testservice-failure-exit-handler-68.service \
|
||||
/run/systemd/system/testservice-transient-failure-exit-handler-68.service
|
||||
|
||||
# Template version.
|
||||
cat >/run/systemd/system/testservice-failure-exit-handler-68-template@.service <<EOF
|
||||
[Unit]
|
||||
Description=TEST-68-PROPAGATE-EXIT-STATUS handle service exiting in failure (template)
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStartPre=echo "triggered by %i"
|
||||
@ -203,23 +189,19 @@ wait_on_state_or_fail "testservice-failure-exit-handler-68.service" "inactive" "
|
||||
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"
|
||||
systemd-run --unit=testservice-transient-success-68 \
|
||||
--property=OnSuccess=testservice-transient-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"
|
||||
systemd-run --unit=testservice-transient-failure-68 \
|
||||
--property=OnFailure=testservice-transient-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
|
||||
: "-------V---------------------------------------------------"
|
||||
systemctl start testservice-success-68-template.service
|
||||
|
Loading…
x
Reference in New Issue
Block a user