Patrick Kelley 8fd444092b initial
2025-05-07 15:35:15 -04:00

57 lines
1.7 KiB
Plaintext

# Test that the cleanup command does not cleanup any running nodes, and
# does not cleanup tmpdir unless the "--all" option is specified.
#
# @TEST-EXEC: bash %INPUT
# @TEST-EXEC: btest-diff cleanup.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
zeekctl install
zeekctl start
touch $ZEEKCTL_INSTALL_PREFIX/spool/worker-1/testfile
touch $ZEEKCTL_INSTALL_PREFIX/spool/tmp/testfile
#########################
# test the cleanup command (with and without a node argument)
zeekctl cleanup > cleanup.out
zeekctl cleanup worker-1 > cleanup-onenode.out
# the node testfile should still 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 --all" (without a node argument)
zeekctl cleanup --all > cleanup-all.out
# the node testfile should still exist
test -e $ZEEKCTL_INSTALL_PREFIX/spool/worker-1/testfile
# the tmpdir testfile should be gone
test ! -e $ZEEKCTL_INSTALL_PREFIX/spool/tmp/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 still exist
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