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

72 lines
1.6 KiB
Plaintext

# Test that the print command can print a value from a standalone node,
# all nodes in a cluster, or just a specified node.
#
# This test needs to be serialized because we are using the broker python
# bindings.
# @TEST-SERIALIZE: listen
#
# @TEST-EXEC: bash %INPUT
# @TEST-EXEC: btest-diff standalone.out
# @TEST-EXEC: btest-diff noprivatelocals.out
# @TEST-EXEC: btest-diff all.out
# @TEST-EXEC: btest-diff onenode.out
. zeekctl-test-setup
while read line; do installfile $line; done << EOF
etc/zeekctl.cfg__no_email
etc/networks.cfg__ipv4
EOF
# Test with a standalone config.
cat > $ZEEKCTL_INSTALL_PREFIX/etc/node.cfg << EOF
[zeek]
type=standalone
host=localhost
EOF
zeekctl install
zeekctl start
# Print a single-line value.
zeekctl print Log::default_rotation_interval > standalone.out
zeekctl stop
# Test with a standalone config and no default-local private space:
cat >> $ZEEKCTL_INSTALL_PREFIX/etc/zeekctl.cfg <<EOF
PrivateAddressSpaceIsLocal=0
EOF
zeekctl install
zeekctl start
zeekctl print Site::local_nets > noprivatelocals.out
zeekctl stop
# Test with a cluster config.
while read line; do installfile $line; done << EOF
etc/zeekctl.cfg__no_email
etc/node.cfg__no_netifs
EOF
zeekctl install
zeekctl start
# Print a single-line value from all nodes
zeekctl print Log::default_rotation_interval > all.out
# Print a multi-line value from one node
zeekctl print Site::local_nets worker-2 > onenode.out
zeekctl stop
# No nodes are running, so zeekctl cannot get any results
! zeekctl print Log::default_rotation_interval > stopped.out
# The file size should be zero
test ! -s stopped.out