test: new test, issue #382

Alexander Zangerl reports that <service/foo/STATE> conditions seem to be
removed when calling `initctl reload`, even though no .conf changes have
been made.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2023-10-30 00:58:28 +01:00
parent eaef302420
commit e4163b7221
2 changed files with 72 additions and 0 deletions
+2
View File
@@ -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
+70
View File
@@ -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., <service/B/running>. 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" <<EOF
service log:stdout name:A serv -np -i A
service log:stdout notify:systemd <pid/A> name:B serv -np -i B -N 0 -- B needs A
service log:stdout notify:systemd <service/B/ready> name:C serv -np -i C -N 0 -- C needs B(service)
service log:stdout notify:systemd <pid/B> name:D serv -np -i D -N 0 -- D needs B(pid)
task <service/C/ready,service/D/ready> 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