mirror of
https://github.com/troglobit/finit.git
synced 2026-10-01 05:22:48 +07:00
test: verify finit restarts crashing services & registers new PID
We extend the service.sh to emulate a well behaving service that creates and removes its own PID file. The new test emulates a crash by sending SIGKILL to service.sh. We then verify that Finit restarts it, and eventually registers the new PID when the services recreates the PID file. Issue #226 Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Executable
+35
@@ -0,0 +1,35 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -eu
|
||||
|
||||
TEST_DIR=$(dirname "$0")
|
||||
|
||||
# shellcheck source=/dev/null
|
||||
. "$TEST_DIR/tenv/lib.sh"
|
||||
|
||||
test_teardown() {
|
||||
say "Test done $(date)"
|
||||
say "Running test teardown."
|
||||
|
||||
texec rm -f "$FINIT_CONF"
|
||||
texec rm -f /test_assets/service.sh
|
||||
}
|
||||
|
||||
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"
|
||||
|
||||
say 'Reload Finit'
|
||||
texec sh -c "initctl reload"
|
||||
#texec sh -c "initctl status"
|
||||
|
||||
retry 'assert_num_children 1 service.sh'
|
||||
|
||||
say 'Simulate service crash (kill -9 ..)'
|
||||
texec sh -c "kill -9 \$(cat /run/service.pid)"
|
||||
|
||||
retry 'assert_new_pid service.sh /run/service.pid'
|
||||
retry 'assert_num_children 1 service.sh'
|
||||
Reference in New Issue
Block a user