diff --git a/test/Makefile.am b/test/Makefile.am index 4413f94e..7c30122e 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -53,6 +53,7 @@ EXTRA_DIST += start-stop-sysv.sh EXTRA_DIST += start-stop-serv.sh EXTRA_DIST += signal-service.sh EXTRA_DIST += testserv.sh +EXTRA_DIST += unexpected-restart.sh AM_TESTS_ENVIRONMENT = SYSROOT='$(abs_builddir)/sysroot/'; AM_TESTS_ENVIRONMENT += export SYSROOT; @@ -98,6 +99,7 @@ TESTS += signal-service.sh if TESTSERV TESTS += testserv.sh endif +TESTS += unexpected-restart.sh check-recursive: setup-chroot diff --git a/test/unexpected-restart.sh b/test/unexpected-restart.sh new file mode 100755 index 00000000..c15b54d0 --- /dev/null +++ b/test/unexpected-restart.sh @@ -0,0 +1,70 @@ +#!/bin/sh +# A service (B) going into flux, 'initctl reload' with no changes to +# activate, should do not cause ripple effects removing any service +# conditions, e.g., . During reload all services +# are paused while Finit checks for any service3 changes to activate, +# which may mean stopping or restarting existing services. +# +# Issue #382 +set -e + +#DEBUG=true +TEST_DIR=$(dirname "$0") + +test_setup() +{ + run "cat >> $FINIT_CONF" < name:B serv -np -i B -N 0 -- B needs A +service log:stdout notify:systemd name:C serv -np -i C -N 0 -- C needs B(service) +service log:stdout notify:systemd name:D serv -np -i D -N 0 -- D needs B(pid) +task name:allup /sbin/initctl cond set allup -- Everything is up +EOF + say "Test start $(date)" +} + +test_teardown() +{ + say "Test done $(date)" +} + +pidof() +{ + texec initctl status $1 -j|jq .pid +} + +. "$TEST_DIR/lib/setup.sh" + + +sep +say "finit config:" +run "cat $FINIT_CONF" +sep +run "initctl reload" + +say "waiting for primary startup to complete" +retry 'assert_status allup "done"' 100 1 +assert_status C "running" +oldpid=$(pidof C) +assert_status D "running" +doldpid=$(pidof D) + +say "pre-reload status" +run "initctl status" +sep + +# toggle_finit_debug +say "Reload Finit, who gets restarted?" +run "initctl reload" +sleep 2 + +assert_status A "running" +assert_status B "running" +assert_status C "running" +assert_status D "running" + +newpid=$(pidof C) +assert "C was not restarted" $oldpid -eq $newpid + +dnewpid=$(pidof D) +assert "D was not restarted" $doldpid -eq $dnewpid