# Test that the cleanup command can cleanup a crashed node in a cluster # (which includes resetting the crashed node's state to "stopped"), # but does not clean the tmpdir unless "--all" is specified. # # @TEST-EXEC: bash %INPUT # @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-status-output btest-diff status1.out # @TEST-EXEC: btest-diff cleanup.out # @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-status-output btest-diff status2.out # @TEST-EXEC: btest-diff status3.out # @TEST-EXEC: btest-diff cleanup-stopped.out # @TEST-EXEC: btest-diff status4.out # @TEST-EXEC: btest-diff cleanup-onenode.out # @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff cleanup-all.out # @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff cleanup-all-onenode.out . zeekctl-test-setup while read line; do installfile $line; done << EOF etc/zeekctl.cfg__no_email etc/node.cfg__cluster bin/zeek__test EOF cat > $ZEEKCTL_INSTALL_PREFIX/zeekctltest.cfg << EOF crash=worker-1 EOF zeekctl install ! zeekctl start touch $ZEEKCTL_INSTALL_PREFIX/spool/tmp/testfile touch $ZEEKCTL_INSTALL_PREFIX/spool/worker-1/testfile # verify one node crashed and all others are running ! zeekctl status > status1.out ######################### # test cleanup (without any node arguments) zeekctl cleanup > cleanup.out # verify that the crashed node's state was reset to "stopped" ! zeekctl status > status2.out # the node testfile should not exist test ! -e $ZEEKCTL_INSTALL_PREFIX/spool/worker-1/testfile # the tmpdir testfile should still exist test -e $ZEEKCTL_INSTALL_PREFIX/spool/tmp/testfile ######################### # test cleanup when no nodes are running (without any node arguments) # stop all nodes and restart only the crashing node zeekctl stop ! zeekctl start worker-1 # verify one node crashed and all others are stopped ! zeekctl status > status3.out zeekctl cleanup > cleanup-stopped.out # verify that the crashed node's state was reset to "stopped" ! zeekctl status > status4.out ! zeekctl start touch $ZEEKCTL_INSTALL_PREFIX/spool/worker-1/testfile ######################### # test cleanup (with a node argument) zeekctl cleanup worker-1 > cleanup-onenode.out # the node testfile should not exist test ! -e $ZEEKCTL_INSTALL_PREFIX/spool/worker-1/testfile # the tmpdir testfile should still exist test -e $ZEEKCTL_INSTALL_PREFIX/spool/tmp/testfile zeekctl stop ! zeekctl start touch $ZEEKCTL_INSTALL_PREFIX/spool/worker-1/testfile ######################## # test "cleanup --all" (without a node argument) zeekctl cleanup --all > cleanup-all.out # the node testfile should be gone test ! -e $ZEEKCTL_INSTALL_PREFIX/spool/worker-1/testfile # the tmpdir testfile should be gone test ! -e $ZEEKCTL_INSTALL_PREFIX/spool/tmp/testfile zeekctl stop ! zeekctl start touch $ZEEKCTL_INSTALL_PREFIX/spool/worker-1/testfile touch $ZEEKCTL_INSTALL_PREFIX/spool/tmp/testfile ######################## # test "cleanup --all" (with a node argument) zeekctl cleanup --all worker-1 > cleanup-all-onenode.out # the node testfile should be gone test ! -e $ZEEKCTL_INSTALL_PREFIX/spool/worker-1/testfile # the tmpdir testfile should be gone test ! -e $ZEEKCTL_INSTALL_PREFIX/spool/tmp/testfile zeekctl stop