From 4811f7629424a33a5fc6281c88f009c3b9236e6a Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Mon, 7 Mar 2022 15:50:23 +0100 Subject: [PATCH] test: refactor service kill/respawn test - Allow service to be respawned immediately (hidden option) - Stress test by killing 1000 times Signed-off-by: Joachim Wiberg --- test/start-kill-service.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/test/start-kill-service.sh b/test/start-kill-service.sh index e1373288..16457d29 100755 --- a/test/start-kill-service.sh +++ b/test/start-kill-service.sh @@ -22,16 +22,26 @@ say "Test start $(date)" cp "$TEST_DIR"/common/service.sh "$TENV_ROOT"/test_assets/ say "Add service stanza in $FINIT_CONF" -texec sh -c "echo 'service [2345] kill:20 log /test_assets/service.sh -- Test service' > $FINIT_CONF" +texec sh -c "echo 'service [2345] respawn log /test_assets/service.sh -- Test service' > $FINIT_CONF" say 'Reload Finit' texec sh -c "initctl reload" #texec sh -c "initctl status" retry 'assert_num_children 1 service.sh' +texec sh -c "initctl status service.sh" say 'Simulate service crash (kill -9 ..)' -texec sh -c "kill -9 \$(cat /run/service.pid)" +i=0 +laps=1000 +while [ $i -lt $laps ]; do + i=$((i + 1)) + say "Lap $i/$laps, killing service ..." # we have this, no sleep needed + # texec sh -c "echo \"PID is \$(initctl status service.sh |awk '/PID : /{ print \$3; }')\"; echo \"PID file says \$(cat /run/service.pid)\"; kill -9 \$(cat /run/service.pid)" + #texec sh -c "initctl status service.sh" + #texec sh -c "initctl signal service.sh KILL" + texec sh -c "kill -9 \$(cat /run/service.pid)" +done retry 'assert_new_pid service.sh /run/service.pid' retry 'assert_num_children 1 service.sh'