zeek/auxil/zeekctl/testing/command/stop-crash-shutdown.test
Patrick Kelley 8fd444092b initial
2025-05-07 15:35:15 -04:00

55 lines
1.4 KiB
Plaintext

# Test that the stop command reports a node that crashed during shutdown,
# and verify that zeekctl does not clean the crashed node's working directory
# and does not send a crash report.
#
# @TEST-EXEC: bash %INPUT
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-status-output btest-diff status1.out
# @TEST-EXEC: btest-diff stop.out
# @TEST-EXEC: btest-diff status2.out
. zeekctl-test-setup
while read line; do installfile $line; done << EOF
etc/zeekctl.cfg__test_sendmail
etc/node.cfg__cluster
bin/zeek__test
bin/sendmail__test --new
EOF
replaceprefix etc/zeekctl.cfg
cat > $ZEEKCTL_INSTALL_PREFIX/zeekctltest.cfg << EOF
crashshutdown=worker-1
EOF
zeekctl install
zeekctl start
# verify that all nodes started
zeekctl status > status1.out
# test the stop command
zeekctl stop > stop.out
# verify that the crashed node is in the crashed state
! zeekctl status > status2.out
# the stop command should not cleanup the crashed node directory
while read line; do
test -e $ZEEKCTL_INSTALL_PREFIX/$line
done << EOF
spool/worker-1/.cmdline
spool/worker-1/.env_vars
spool/worker-1/.pid
spool/worker-1/.startup
spool/worker-1/stderr.log
spool/worker-1/stdout.log
EOF
# the crashed node should not be logged as "stopped" in stats.log
grep stopped $ZEEKCTL_INSTALL_PREFIX/spool/stats.log > tmp
! grep worker-1 tmp
# verify that a crash report was not sent
test ! -e $ZEEKCTL_INSTALL_PREFIX/sendmail.out