mirror of
https://github.com/troglobit/finit.git
synced 2026-10-16 10:39:35 +00:00
test: minor, replace 'texec sh -c' -> 'run'
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
5a9cafc2fc
commit
b6769356b2
21 files changed
+170
-165
No files matched your search
@@ -1,5 +1,6 @@
|
||||
* TODO fix pid parser, //run/foo.pid -> /var/run///run/foo.pid
|
||||
* TODO test framework refactor 'texec sh -c ...' -> 'run ...'
|
||||
** DONE test framework refactor 'texec sh -c ...' -> 'run ...'
|
||||
* TODO Clean up tests a bit
|
||||
* TODO Drop tenv or common and rename tenv-root
|
||||
* TODO rename test/lib.sh to start.sh or sth
|
||||
|
||||
@@ -10,25 +10,25 @@ TEST_DIR=$(dirname "$0")
|
||||
test_teardown()
|
||||
{
|
||||
say "Test done $(date)"
|
||||
say "Running test teardown."
|
||||
|
||||
texec rm -f "$FINIT_RCSD/service.conf"
|
||||
say "Running test teardown."
|
||||
run "rm -f $FINIT_RCSD/service.conf"
|
||||
}
|
||||
|
||||
say "Test start $(date)"
|
||||
|
||||
say "Add a dynamic service in $FINIT_RCSD/service.conf"
|
||||
texec sh -c "echo 'service [2345] kill:20 log service.sh -- Dyn serv' > $FINIT_RCSD/service.conf"
|
||||
run "echo 'service [2345] kill:20 log service.sh -- Dyn serv' > $FINIT_RCSD/service.conf"
|
||||
|
||||
say 'Reload Finit'
|
||||
texec sh -c "initctl reload"
|
||||
run "initctl reload"
|
||||
|
||||
retry 'assert_num_children 1 service.sh'
|
||||
|
||||
say 'Remove the dynamic service from /etc/finit.d/service.conf'
|
||||
texec sh -c "echo > $FINIT_RCSD/service.conf"
|
||||
run "echo > $FINIT_RCSD/service.conf"
|
||||
|
||||
say 'Reload Finit'
|
||||
texec sh -c "initctl reload"
|
||||
run "initctl reload"
|
||||
|
||||
retry 'assert_num_children 0 service.sh'
|
||||
@@ -10,25 +10,25 @@ TEST_DIR=$(dirname "$0")
|
||||
test_teardown()
|
||||
{
|
||||
say "Test done $(date)"
|
||||
say "Running test teardown."
|
||||
|
||||
texec rm -f "$FINIT_CONF"
|
||||
say "Running test teardown."
|
||||
run "rm -f $FINIT_CONF"
|
||||
}
|
||||
|
||||
say "Test start $(date)"
|
||||
|
||||
say "Add a dynamic service in $FINIT_CONF"
|
||||
texec sh -c "echo 'service [2345] kill:20 log service.sh -- Dyn service' > $FINIT_CONF"
|
||||
run "echo 'service [2345] kill:20 log service.sh -- Dyn service' > $FINIT_CONF"
|
||||
|
||||
say 'Reload Finit'
|
||||
texec sh -c "initctl reload"
|
||||
run "initctl reload"
|
||||
|
||||
retry 'assert_num_children 1 service.sh'
|
||||
|
||||
say 'Remove the dynamic service from /etc/finit.conf'
|
||||
texec sh -c "echo > $FINIT_CONF"
|
||||
run "echo > $FINIT_CONF"
|
||||
|
||||
say 'Reload Finit'
|
||||
texec sh -c "initctl reload"
|
||||
run "initctl reload"
|
||||
|
||||
retry 'assert_num_children 0 service.sh'
|
||||
+22
-22
@@ -22,7 +22,7 @@ test_teardown()
|
||||
{
|
||||
say "Test done $(date)"
|
||||
say "Running test teardown."
|
||||
texec rm -f "$TEST_CONF"
|
||||
run "rm -f $TEST_CONF"
|
||||
}
|
||||
|
||||
test_one()
|
||||
@@ -32,60 +32,60 @@ test_one()
|
||||
|
||||
sleep 5
|
||||
say 'Enable finit debug, try to figure out what is going on ...'
|
||||
texec sh -c "initctl debug"
|
||||
run "initctl debug"
|
||||
|
||||
say "Add stanza '$stanza' to $TEST_CONF ..."
|
||||
texec sh -c "echo '$stanza' > $TEST_CONF"
|
||||
run "echo '$stanza' > $TEST_CONF"
|
||||
|
||||
texec sh -c "ls -l /run/ /run/finit/"
|
||||
run "ls -l /run/ /run/finit/"
|
||||
say 'Reload Finit'
|
||||
texec sh -c "initctl ls"
|
||||
texec sh -c "initctl reload"
|
||||
texec sh -c "initctl status"
|
||||
texec sh -c "ps"
|
||||
run "initctl ls"
|
||||
run "initctl reload"
|
||||
run "initctl status"
|
||||
run "ps"
|
||||
|
||||
date
|
||||
sleep 2
|
||||
date
|
||||
texec sh -c "ls -l /run/ /run/finit/"
|
||||
run "ls -l /run/ /run/finit/"
|
||||
say 'Asserting condition'
|
||||
texec sh -c "initctl cond set $cond"
|
||||
run "initctl cond set $cond"
|
||||
|
||||
date
|
||||
sleep 2
|
||||
date
|
||||
texec sh -c "ls -l /run/ /run/finit/"
|
||||
texec sh -c "initctl status"
|
||||
texec sh -c "ps"
|
||||
texec sh -c "initctl status task.sh"
|
||||
run "ls -l /run/ /run/finit/"
|
||||
run "initctl status"
|
||||
run "ps"
|
||||
run "initctl status task.sh"
|
||||
|
||||
sleep 1
|
||||
texec sh -c "echo Hej; cat /run/task.state"
|
||||
run "echo Hej; cat /run/task.state"
|
||||
|
||||
assert_file_contains /run/task.state 1
|
||||
|
||||
say 'Reload Finit'
|
||||
texec sh -c "initctl reload"
|
||||
run "initctl reload"
|
||||
sleep 1
|
||||
say 'Ensure task has not run again ...'
|
||||
assert_file_contains /run/task.state 1
|
||||
|
||||
say 'Switch to another runlevel ...'
|
||||
texec sh -c "initctl runlevel 3"
|
||||
run "initctl runlevel 3"
|
||||
sleep 1
|
||||
say 'Ensure task has run again ...'
|
||||
assert_file_contains /run/task.state 2
|
||||
|
||||
say 'Touch task.sh .conf file and reload Finit ...'
|
||||
texec sh -c "touch $TEST_CONF"
|
||||
texec sh -c "initctl reload"
|
||||
run "touch $TEST_CONF"
|
||||
run "initctl reload"
|
||||
sleep 1
|
||||
# texec sh -c "initctl status task.sh"
|
||||
# run "initctl status task.sh"
|
||||
assert_file_contains /run/task.state 3
|
||||
|
||||
say "Done, drop stanza from $TEST_CONF ..."
|
||||
texec sh -c "rm $TEST_CONF"
|
||||
texec sh -c "initctl reload"
|
||||
run "rm $TEST_CONF"
|
||||
run "initctl reload"
|
||||
}
|
||||
|
||||
test_one "hello" "task <usr/hello> task.sh -- Hello task"
|
||||
+9
-9
@@ -13,9 +13,9 @@ test_setup()
|
||||
test_teardown()
|
||||
{
|
||||
say "Test done $(date)"
|
||||
say "Running test teardown."
|
||||
|
||||
texec rm -f "$FINIT_CONF" "/tmp/post"
|
||||
say "Running test teardown."
|
||||
run "rm -f $FINIT_CONF" "/tmp/post"
|
||||
}
|
||||
|
||||
crashit()
|
||||
@@ -28,7 +28,7 @@ crashit()
|
||||
while [ $i -lt $laps ]; do
|
||||
i=$((i + 1))
|
||||
say "Lap $i/$laps, killing service $nm ..." # we have this, no sleep needed
|
||||
if ! texec sh -c "slay $nm"; then
|
||||
if ! run "slay $nm"; then
|
||||
break;
|
||||
fi
|
||||
done
|
||||
@@ -43,27 +43,27 @@ test_one()
|
||||
args=$*
|
||||
|
||||
say "Add service stanza in $FINIT_CONF"
|
||||
texec sh -c "echo service log:stderr oncrash:script post:/bin/post.sh $nm $args > $FINIT_CONF"
|
||||
run "echo service log:stderr oncrash:script post:/bin/post.sh $nm $args > $FINIT_CONF"
|
||||
|
||||
say 'Reload Finit'
|
||||
texec sh -c "initctl reload"
|
||||
run "initctl reload"
|
||||
|
||||
if [ "$type" = "sig" ]; then
|
||||
retry "assert_num_children 1 $nm"
|
||||
texec sh -c "initctl status $nm"
|
||||
run "initctl status $nm"
|
||||
crashit "$nm"
|
||||
fi
|
||||
|
||||
retry "assert_status $nm crashed" 500
|
||||
texec cat /tmp/post
|
||||
run "cat /tmp/post"
|
||||
assert_file_contains "/tmp/post" "POST"
|
||||
texec rm -f "/tmp/post"
|
||||
run "rm -f /tmp/post"
|
||||
}
|
||||
|
||||
# shellcheck source=/dev/null
|
||||
. "$TEST_DIR/tenv/lib.sh"
|
||||
|
||||
#texec sh -c "initctl debug"
|
||||
#run "initctl debug"
|
||||
|
||||
test_one sig service.sh " -- Test crashing service.sh"
|
||||
test_one app serv "-np -c -- Test crashing serv"
|
||||
+2
-2
@@ -24,7 +24,7 @@ test_teardown()
|
||||
say "Test done $(date)"
|
||||
say "Running test teardown."
|
||||
|
||||
texec rm -f "$FINIT_CONF" "/tmp/post"
|
||||
run "rm -f $FINIT_CONF" "/tmp/post"
|
||||
}
|
||||
|
||||
# shellcheck source=/dev/null
|
||||
@@ -51,7 +51,7 @@ test_one()
|
||||
|
||||
say "Verify bar is restarted with foo is ..."
|
||||
pid=$(texec initctl |grep bar | awk '{print $1;}')
|
||||
texec initctl restart foo
|
||||
run "initctl restart foo"
|
||||
assert "bar is restarted" "$(texec initctl |grep bar | awk '{print $1;}')" != "$pid"
|
||||
|
||||
# Wait for spice to be stolen by the Harkonnen
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ test_teardown()
|
||||
say "Test done $(date)"
|
||||
say "Running test teardown."
|
||||
|
||||
texec rm -f "$FINIT_CONF" "/tmp/post"
|
||||
run "rm -f $FINIT_CONF /tmp/post"
|
||||
}
|
||||
|
||||
# Cannot run mknod as non-root even in a chroot
|
||||
|
||||
+11
-11
@@ -9,15 +9,15 @@ TEST_DIR=$(dirname "$0")
|
||||
test_setup()
|
||||
{
|
||||
say "Test start $(date)"
|
||||
texec sh -c "mkdir -p /etc/default"
|
||||
run "mkdir -p /etc/default"
|
||||
}
|
||||
|
||||
test_teardown()
|
||||
{
|
||||
say "Test done $(date)"
|
||||
say "Running test teardown."
|
||||
|
||||
texec rm -f "$FINIT_CONF"
|
||||
say "Running test teardown."
|
||||
run "rm -f $FINIT_CONF"
|
||||
}
|
||||
|
||||
# shellcheck source=/dev/null
|
||||
@@ -27,21 +27,21 @@ test_teardown()
|
||||
# if it cannot find "xyzzy", thus triggering a premature
|
||||
# exit which Finit should act on to retstart it.
|
||||
say "Setting up bogus /etc/default/serv"
|
||||
texec sh -c "echo 'SERV_ARGS=\"-e xyzzy:lives\"' > /etc/default/serv"
|
||||
run "echo 'SERV_ARGS=\"-e xyzzy:lives\"' > /etc/default/serv"
|
||||
|
||||
say "Add sysv stanza to $FINIT_CONF"
|
||||
texec sh -c "echo 'sysv restart:5 [2345] pid:!/run/serv.pid name:serv /etc/init.d/S02-serv.sh -- Crashing SysV service' > $FINIT_CONF"
|
||||
run "echo 'sysv restart:5 [2345] pid:!/run/serv.pid name:serv /etc/init.d/S02-serv.sh -- Crashing SysV service' > $FINIT_CONF"
|
||||
|
||||
#texec sh -c "initctl debug"
|
||||
#run "initctl debug"
|
||||
|
||||
say 'Reload Finit'
|
||||
texec sh -c "initctl reload"
|
||||
#texec sh -c "initctl status serv"
|
||||
#texec sh -c "ps"
|
||||
run "initctl reload"
|
||||
#run "initctl status serv"
|
||||
#run "ps"
|
||||
|
||||
say 'Pending sysv restarts by Finit ...'
|
||||
#texec sh -c "initctl status serv"
|
||||
#texec sh -c "ps"
|
||||
#run "initctl status serv"
|
||||
#run "ps"
|
||||
retry 'assert_restarts 5 serv' 20 1
|
||||
|
||||
return 0
|
||||
+15
-14
@@ -12,45 +12,46 @@ test_teardown()
|
||||
{
|
||||
say "Test done $(date)"
|
||||
|
||||
texec rm -f "$FINIT_CONF"
|
||||
say "Running test teardown."
|
||||
run "rm -f $FINIT_CONF"
|
||||
}
|
||||
|
||||
# shellcheck source=/dev/null
|
||||
. "$TEST_DIR/tenv/lib.sh"
|
||||
|
||||
#texec sh -c "initctl debug"
|
||||
#run "initctl debug"
|
||||
say "Add custom envs to $FINIT_CONF ..."
|
||||
texec sh -c "echo 'foo=bar' > $FINIT_CONF"
|
||||
texec sh -c "echo 'baz=qux' >> $FINIT_CONF"
|
||||
run "echo 'foo=bar' > $FINIT_CONF"
|
||||
run "echo 'baz=qux' >> $FINIT_CONF"
|
||||
|
||||
say "Add service stanza to $FINIT_CONF ..."
|
||||
texec sh -c "echo 'service serv -np -e foo:bar -- Verify foo=bar' >> $FINIT_CONF"
|
||||
run "echo 'service serv -np -e foo:bar -- Verify foo=bar' >> $FINIT_CONF"
|
||||
|
||||
say 'Reload Finit'
|
||||
texec sh -c "initctl reload"
|
||||
run "initctl reload"
|
||||
sleep 1
|
||||
retry 'assert_num_children 1 serv'
|
||||
|
||||
say "Modify $FINIT_CONF slightly ..."
|
||||
texec sh -c "sed -i 's/foo:bar/baz:qux/; s/foo=bar/baz=qux/' $FINIT_CONF"
|
||||
run "sed -i 's/foo:bar/baz:qux/; s/foo=bar/baz=qux/' $FINIT_CONF"
|
||||
|
||||
say 'Reload Finit'
|
||||
texec sh -c "initctl reload"
|
||||
run "initctl reload"
|
||||
sleep 1
|
||||
retry 'assert_num_children 1 serv'
|
||||
|
||||
say "Swap envs completely in $FINIT_CONF ..."
|
||||
texec sh -c "echo 'bar=foo' > $FINIT_CONF"
|
||||
texec sh -c "echo 'qux=baz' >> $FINIT_CONF"
|
||||
run "echo 'bar=foo' > $FINIT_CONF"
|
||||
run "echo 'qux=baz' >> $FINIT_CONF"
|
||||
|
||||
say "Add swapped service stanza to $FINIT_CONF ..."
|
||||
texec sh -c "echo 'service serv -np -e bar:foo -E baz -- Verify bar=foo and no baz' >> $FINIT_CONF"
|
||||
run "echo 'service serv -np -e bar:foo -E baz -- Verify bar=foo and no baz' >> $FINIT_CONF"
|
||||
|
||||
say 'Reload Finit'
|
||||
texec sh -c "initctl reload"
|
||||
run "initctl reload"
|
||||
sleep 1
|
||||
retry 'assert_num_children 1 serv'
|
||||
|
||||
say "Done, drop service from $FINIT_CONF ..."
|
||||
texec sh -c "rm $FINIT_CONF"
|
||||
texec sh -c "initctl reload"
|
||||
run "rm $FINIT_CONF"
|
||||
run "initctl reload"
|
||||
@@ -16,12 +16,13 @@ test_teardown()
|
||||
{
|
||||
say "Test done $(date)"
|
||||
|
||||
texec rm -f "$FINIT_CONF"
|
||||
say "Running test teardown."
|
||||
run "rm -f $FINIT_CONF"
|
||||
}
|
||||
|
||||
test_init()
|
||||
{
|
||||
texec sh -c "echo '# Three foo and one bar enter Finit' > $FINIT_CONF"
|
||||
run "echo '# Three foo and one bar enter Finit' > $FINIT_CONF"
|
||||
}
|
||||
|
||||
test_add_one()
|
||||
@@ -29,7 +30,7 @@ test_add_one()
|
||||
service=$1
|
||||
|
||||
say "Add service stanza '$service' to $FINIT_CONF ..."
|
||||
texec sh -c "echo '$service' >> $FINIT_CONF"
|
||||
run "echo '$service' >> $FINIT_CONF"
|
||||
}
|
||||
|
||||
# shellcheck source=/dev/null
|
||||
@@ -43,13 +44,13 @@ test_add_one "task manual:yes name:foo :3 serv -- Foo \#3"
|
||||
test_add_one "task manual:yes name:foobar serv -- Foobar"
|
||||
|
||||
say 'Reload Finit'
|
||||
#texec sh -c "initctl debug"
|
||||
texec sh -c "initctl reload"
|
||||
texec sh -c "initctl status"
|
||||
#run "initctl debug"
|
||||
run "initctl reload"
|
||||
run "initctl status"
|
||||
|
||||
#texec sh -c "initctl status"
|
||||
#texec sh -c "ps"
|
||||
#texec sh -c "initctl status serv"
|
||||
#run "initctl status"
|
||||
#run "ps"
|
||||
#run "initctl status serv"
|
||||
|
||||
assert_num_services 3 foo
|
||||
assert_desc "Foobar" foobar
|
||||
|
||||
+10
-9
@@ -12,7 +12,8 @@ test_teardown()
|
||||
{
|
||||
say "Test done $(date)"
|
||||
|
||||
texec rm -f "$FINIT_CONF"
|
||||
say "Running test teardown."
|
||||
run "rm -f $FINIT_CONF"
|
||||
}
|
||||
|
||||
test_one()
|
||||
@@ -24,35 +25,35 @@ test_one()
|
||||
postcont=$5
|
||||
|
||||
say "Add service stanza '$service' to $FINIT_CONF ..."
|
||||
texec sh -c "echo '$service' > $FINIT_CONF"
|
||||
run "echo '$service' > $FINIT_CONF"
|
||||
|
||||
say 'Reload Finit'
|
||||
texec sh -c "initctl reload"
|
||||
run "initctl reload"
|
||||
|
||||
retry 'assert_num_children 1 serv'
|
||||
if [ -n "$pre" ]; then
|
||||
assert_file_contains "$pre" "$precont"
|
||||
texec sh -c "rm -f $pre"
|
||||
run "rm -f $pre"
|
||||
fi
|
||||
|
||||
say 'Stop the service'
|
||||
texec sh -c "initctl stop serv"
|
||||
run "initctl stop serv"
|
||||
|
||||
retry 'assert_num_children 0 serv'
|
||||
if [ -n "$post" ]; then
|
||||
assert_file_contains "$post" "$postcont"
|
||||
texec sh -c "rm -f $post"
|
||||
run "rm -f $post"
|
||||
fi
|
||||
|
||||
say "Done, drop service from $FINIT_CONF ..."
|
||||
texec sh -c "rm $FINIT_CONF"
|
||||
texec sh -c "initctl reload"
|
||||
run "rm $FINIT_CONF"
|
||||
run "initctl reload"
|
||||
}
|
||||
|
||||
# shellcheck source=/dev/null
|
||||
. "$TEST_DIR/tenv/lib.sh"
|
||||
|
||||
#texec sh -c "initctl debug"
|
||||
#run "initctl debug"
|
||||
|
||||
test_one "" "" "service serv -np -- Regular fg service, no pre/post scripts" "" ""
|
||||
test_one "" "" "service env:/etc/env serv -np -e foo:bar -- serv + env, no pre/post scripts" "" ""
|
||||
|
||||
+9
-8
@@ -13,7 +13,8 @@ test_teardown()
|
||||
{
|
||||
say "Test done $(date)"
|
||||
|
||||
texec rm -f "$FINIT_CONF"
|
||||
say "Running test teardown."
|
||||
run "rm -f $FINIT_CONF"
|
||||
}
|
||||
|
||||
test_one()
|
||||
@@ -22,28 +23,28 @@ test_one()
|
||||
file=/tmp/ready
|
||||
|
||||
say "Add service stanza '$service' to $FINIT_CONF ..."
|
||||
texec sh -c "echo '$service' > $FINIT_CONF"
|
||||
run "echo '$service' > $FINIT_CONF"
|
||||
|
||||
say 'Reload Finit'
|
||||
texec sh -c "initctl reload"
|
||||
run "initctl reload"
|
||||
|
||||
retry 'assert_num_children 1 serv'
|
||||
assert_file_contains "$file" "READY"
|
||||
texec sh -c "rm -f $file"
|
||||
run "rm -f $file"
|
||||
|
||||
say 'Stop the service'
|
||||
texec sh -c "initctl stop serv"
|
||||
run "initctl stop serv"
|
||||
retry 'assert_num_children 0 serv'
|
||||
|
||||
say "Done, drop service from $FINIT_CONF ..."
|
||||
texec sh -c "rm $FINIT_CONF"
|
||||
texec sh -c "initctl reload"
|
||||
run "rm $FINIT_CONF"
|
||||
run "initctl reload"
|
||||
}
|
||||
|
||||
# shellcheck source=/dev/null
|
||||
. "$TEST_DIR/tenv/lib.sh"
|
||||
|
||||
#texec sh -c "initctl debug"
|
||||
#run "initctl debug"
|
||||
|
||||
test_one "service ready:/bin/ready.sh serv -np -- Native style notification"
|
||||
test_one "service notify:s6 ready:/bin/ready.sh serv -np -N %n -- s6 style notification"
|
||||
|
||||
@@ -7,15 +7,15 @@ TEST_DIR=$(dirname "$0")
|
||||
test_setup()
|
||||
{
|
||||
say "Test start $(date)"
|
||||
texec sh -c "mkdir -p /etc/default"
|
||||
run "mkdir -p /etc/default"
|
||||
}
|
||||
|
||||
test_teardown()
|
||||
{
|
||||
say "Test done $(date)"
|
||||
say "Running test teardown."
|
||||
|
||||
texec rm -f "$FINIT_CONF"
|
||||
say "Running test teardown."
|
||||
run "rm -f $FINIT_CONF"
|
||||
}
|
||||
|
||||
check_restarts()
|
||||
@@ -28,18 +28,18 @@ check_restarts()
|
||||
. "$TEST_DIR/tenv/lib.sh"
|
||||
|
||||
say "Add stanza to $FINIT_CONF"
|
||||
texec sh -c "echo 'service serv -np -r serv -- Restart self' > $FINIT_CONF"
|
||||
run "echo 'service serv -np -r serv -- Restart self' > $FINIT_CONF"
|
||||
|
||||
say 'Reload Finit'
|
||||
texec sh -c "initctl reload"
|
||||
run "initctl reload"
|
||||
|
||||
sleep 2
|
||||
texec sh -c "initctl status serv"
|
||||
texec sh -c "ps"
|
||||
run "initctl status serv"
|
||||
run "ps"
|
||||
|
||||
sleep 2
|
||||
texec sh -c "initctl status serv"
|
||||
texec sh -c "ps"
|
||||
run "initctl status serv"
|
||||
run "ps"
|
||||
|
||||
say 'Pending restarts by itself ...'
|
||||
retry 'check_restarts /tmp/serv-restart.cnt 3' 20 1
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ test_teardown()
|
||||
. "$TEST_DIR/tenv/lib.sh"
|
||||
|
||||
say 'Check runlevel'
|
||||
lvl=$(texec sh -c "initctl runlevel | awk '{print \$2;}'")
|
||||
lvl=$(run "initctl runlevel | awk '{print \$2;}'")
|
||||
if [ "$lvl" -eq "9" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
@@ -11,9 +11,9 @@ TEST_DIR=$(dirname "$0")
|
||||
test_teardown()
|
||||
{
|
||||
say "Test done $(date)"
|
||||
say "Running test teardown."
|
||||
|
||||
texec rm -f "$FINIT_CONF"
|
||||
say "Running test teardown."
|
||||
run "rm -f $FINIT_CONF"
|
||||
}
|
||||
|
||||
say "Test start $(date)"
|
||||
|
||||
@@ -12,24 +12,24 @@ TEST_DIR=$(dirname "$0")
|
||||
test_teardown()
|
||||
{
|
||||
say "Test done $(date)"
|
||||
say "Running test teardown."
|
||||
|
||||
texec rm -f "$FINIT_CONF"
|
||||
say "Running test teardown."
|
||||
run "rm -f $FINIT_CONF"
|
||||
}
|
||||
|
||||
say "Test start $(date)"
|
||||
rm -f "$TENV_ROOT"/oldpid
|
||||
|
||||
say "Add service stanza in $FINIT_CONF"
|
||||
texec sh -c "echo 'service [2345] respawn log:stderr service.sh -- Test service' > $FINIT_CONF"
|
||||
run "echo 'service [2345] respawn log:stderr service.sh -- Test service' > $FINIT_CONF"
|
||||
|
||||
say 'Reload Finit'
|
||||
texec sh -c "initctl reload"
|
||||
#texec sh -c "initctl status"
|
||||
#texec sh -c "initctl debug"
|
||||
run "initctl reload"
|
||||
#run "initctl status"
|
||||
#run "initctl debug"
|
||||
|
||||
retry 'assert_num_children 1 service.sh'
|
||||
texec sh -c "initctl status service.sh"
|
||||
run "initctl status service.sh"
|
||||
|
||||
say 'Simulate service crash (kill -9 ..)'
|
||||
i=0
|
||||
@@ -37,7 +37,7 @@ 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 "slay service.sh"
|
||||
run "slay service.sh"
|
||||
done
|
||||
|
||||
retry 'assert_new_pid service.sh /run/service.pid'
|
||||
|
||||
+13
-13
@@ -14,11 +14,11 @@ TEST_DIR=$(dirname "$0")
|
||||
|
||||
test_teardown()
|
||||
{
|
||||
# texec sh -c "initctl status -j serv"
|
||||
# run "initctl status -j serv"
|
||||
say "Test done $(date)"
|
||||
say "Running test teardown."
|
||||
|
||||
texec rm -f "$FINIT_CONF"
|
||||
say "Running test teardown."
|
||||
run "rm -f $FINIT_CONF"
|
||||
}
|
||||
|
||||
say "Check deps ..."
|
||||
@@ -28,37 +28,37 @@ say "Test start $(date)"
|
||||
rm -f "$TENV_ROOT"/oldpid
|
||||
|
||||
say "Add service stanza in $FINIT_CONF"
|
||||
texec sh -c "echo 'service [2345] log:stderr serv -np -- Test service' > $FINIT_CONF"
|
||||
run "echo 'service [2345] log:stderr serv -np -- Test service' > $FINIT_CONF"
|
||||
|
||||
say 'Reload Finit'
|
||||
texec sh -c "initctl reload"
|
||||
run "initctl reload"
|
||||
|
||||
say 'Verify serv is running ...'
|
||||
retry 'assert_num_children 1 serv'
|
||||
|
||||
say 'Verify reload does not change forking type of service'
|
||||
#texec sh -c "initctl status -j serv"
|
||||
texec sh -c "initctl reload"
|
||||
#texec sh -c "initctl status -j serv"
|
||||
#run "initctl status -j serv"
|
||||
run "initctl reload"
|
||||
#run "initctl status -j serv"
|
||||
assert_forking serv false
|
||||
|
||||
say 'Simulate service crash (kill -9 ..)'
|
||||
texec sh -c "initctl debug"
|
||||
run "initctl debug"
|
||||
i=0
|
||||
laps=7
|
||||
while [ $i -lt $laps ]; do
|
||||
i=$((i + 1))
|
||||
say "Lap $i/$laps, killing service ..." # we have this, no sleep needed
|
||||
texec sh -c "slay serv"
|
||||
run "slay serv"
|
||||
done
|
||||
|
||||
say 'Verify stopping service actually stops it'
|
||||
sleep 1
|
||||
texec sh -c "initctl stop serv"
|
||||
run "initctl stop serv"
|
||||
sleep 5
|
||||
#texec sh -c "initctl status serv"
|
||||
#run "initctl status serv"
|
||||
assert_status serv stopped
|
||||
|
||||
say 'Verify restarting service actually starts it'
|
||||
texec sh -c "initctl start serv"
|
||||
run "initctl start serv"
|
||||
retry 'assert_num_children 1 serv'
|
||||
+14
-14
@@ -11,9 +11,9 @@ test_setup()
|
||||
test_teardown()
|
||||
{
|
||||
say "Test done $(date)"
|
||||
say "Running test teardown."
|
||||
|
||||
texec rm -f "$FINIT_CONF"
|
||||
say "Running test teardown."
|
||||
run "rm -f $FINIT_CONF"
|
||||
}
|
||||
|
||||
test_one()
|
||||
@@ -22,34 +22,34 @@ test_one()
|
||||
service=$2
|
||||
|
||||
say "Add service stanza '$service' to $FINIT_CONF ..."
|
||||
texec sh -c "echo '$service' > $FINIT_CONF"
|
||||
run "echo '$service' > $FINIT_CONF"
|
||||
|
||||
say 'Reload Finit'
|
||||
#texec sh -c "initctl debug"
|
||||
texec sh -c "initctl reload"
|
||||
#texec sh -c "initctl status"
|
||||
#texec sh -c "ps"
|
||||
#run "initctl debug"
|
||||
run "initctl reload"
|
||||
#run "initctl status"
|
||||
#run "ps"
|
||||
|
||||
#texec sh -c "initctl status"
|
||||
#texec sh -c "ps"
|
||||
#texec sh -c "initctl status serv"
|
||||
#run "initctl status"
|
||||
#run "ps"
|
||||
#run "initctl status serv"
|
||||
|
||||
retry 'assert_num_children 1 serv'
|
||||
retry "assert_pidfile $pidfn" 1
|
||||
|
||||
say 'Stop the service'
|
||||
texec sh -c "initctl stop serv"
|
||||
run "initctl stop serv"
|
||||
|
||||
retry 'assert_num_children 0 serv'
|
||||
|
||||
say 'Start the service again'
|
||||
texec sh -c "initctl start serv"
|
||||
run "initctl start serv"
|
||||
|
||||
retry 'assert_num_children 1 serv'
|
||||
|
||||
say "Done, drop service from $FINIT_CONF ..."
|
||||
texec sh -c "rm $FINIT_CONF"
|
||||
texec sh -c "initctl reload"
|
||||
run "rm $FINIT_CONF"
|
||||
run "initctl reload"
|
||||
}
|
||||
|
||||
# shellcheck source=/dev/null
|
||||
|
||||
@@ -10,30 +10,30 @@ TEST_DIR=$(dirname "$0")
|
||||
test_teardown()
|
||||
{
|
||||
say "Test done $(date)"
|
||||
say "Running test teardown."
|
||||
|
||||
texec rm -f "$FINIT_RCSD/service.conf"
|
||||
say "Running test teardown."
|
||||
run "rm -f $FINIT_RCSD/service.conf"
|
||||
}
|
||||
|
||||
say "Test start $(date)"
|
||||
|
||||
say "Add service stanza in $FINIT_RCSD/service.conf"
|
||||
texec sh -c "echo 'service [2345] kill:20 log service.sh -- Subserv' > $FINIT_RCSD/service.conf"
|
||||
run "echo 'service [2345] kill:20 log service.sh -- Subserv' > $FINIT_RCSD/service.conf"
|
||||
|
||||
say 'Reload Finit'
|
||||
texec sh -c "initctl reload"
|
||||
run "initctl reload"
|
||||
|
||||
sleep 2
|
||||
texec sh -c "ps"
|
||||
run "ps"
|
||||
|
||||
retry 'assert_num_children 1 service.sh'
|
||||
|
||||
say 'Stop the service'
|
||||
texec sh -c "initctl stop service.sh"
|
||||
run "initctl stop service.sh"
|
||||
|
||||
retry 'assert_num_children 0 service.sh'
|
||||
|
||||
say 'Start the service again'
|
||||
texec sh -c "initctl start service.sh"
|
||||
run "initctl start service.sh"
|
||||
|
||||
retry 'assert_num_children 1 service.sh'
|
||||
@@ -10,27 +10,27 @@ TEST_DIR=$(dirname "$0")
|
||||
test_teardown()
|
||||
{
|
||||
say "Test done $(date)"
|
||||
say "Running test teardown."
|
||||
|
||||
texec rm -f "$FINIT_CONF"
|
||||
say "Running test teardown."
|
||||
run "rm -f $FINIT_CONF"
|
||||
}
|
||||
|
||||
say "Test start $(date)"
|
||||
|
||||
say "Add service stanza in $FINIT_CONF"
|
||||
texec sh -c "echo 'service [2345] kill:20 log service.sh -- Test service' > $FINIT_CONF"
|
||||
run "echo 'service [2345] kill:20 log service.sh -- Test service' > $FINIT_CONF"
|
||||
|
||||
say 'Reload Finit'
|
||||
texec sh -c "initctl reload"
|
||||
run "initctl reload"
|
||||
|
||||
retry 'assert_num_children 1 service.sh'
|
||||
|
||||
say 'Stop the service'
|
||||
texec sh -c "initctl stop service.sh"
|
||||
run "initctl stop service.sh"
|
||||
|
||||
retry 'assert_num_children 0 service.sh'
|
||||
|
||||
say 'Start the service again'
|
||||
texec sh -c "initctl start service.sh"
|
||||
run "initctl start service.sh"
|
||||
|
||||
retry 'assert_num_children 1 service.sh'
|
||||
@@ -9,29 +9,29 @@ TEST_DIR=$(dirname "$0")
|
||||
|
||||
test_teardown()
|
||||
{
|
||||
say "Test done $(date)"
|
||||
say "Running test teardown."
|
||||
say "Test done $(date)"
|
||||
|
||||
texec rm -f "$FINIT_CONF"
|
||||
say "Running test teardown."
|
||||
run "rm -f $FINIT_CONF"
|
||||
}
|
||||
|
||||
say "Test start $(date)"
|
||||
|
||||
say "Add sysv stanza in $FINIT_CONF"
|
||||
texec sh -c "echo 'sysv [2345] pid:!/run/service.pid name:service.sh /etc/init.d/S01-service.sh -- SysV test service' > $FINIT_CONF"
|
||||
run "echo 'sysv [2345] pid:!/run/service.pid name:service.sh /etc/init.d/S01-service.sh -- SysV test service' > $FINIT_CONF"
|
||||
|
||||
say 'Reload Finit'
|
||||
texec sh -c "initctl reload"
|
||||
run "initctl reload"
|
||||
|
||||
retry 'assert_num_children 1 service.sh'
|
||||
|
||||
say 'Stop the sysv service'
|
||||
texec sh -c "initctl stop service.sh"
|
||||
run "initctl stop service.sh"
|
||||
|
||||
retry 'assert_num_children 0 service.sh'
|
||||
|
||||
say 'Start the sysv service again'
|
||||
texec sh -c "initctl start service.sh"
|
||||
run "initctl start service.sh"
|
||||
|
||||
retry 'assert_num_children 1 service.sh'
|
||||
|
||||
|
||||
Reference in new issue
Block a user