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

40 lines
910 B
Plaintext

# Test that the install command writes correct values to state database.
#
# @TEST-REQUIRES: which sqlite3
# @TEST-EXEC: bash %INPUT
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-state-db btest-diff standalone
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-state-db btest-diff cluster
. zeekctl-test-setup
dump_db() {
out=$1
sqlite3 $ZEEKCTL_INSTALL_PREFIX/spool/state.db ".dump" > dump.out
# Produce "key = value" output from the database dump.
awk -F \' '{ if (NF == 5) { print $2, "=", $4 } }' dump.out | sort > $out
}
### Test using a standalone config.
test ! -e $ZEEKCTL_INSTALL_PREFIX/spool/state.db
zeekctl install
dump_db standalone
rm $ZEEKCTL_INSTALL_PREFIX/spool/state.db
### Test using a cluster config.
while read line; do installfile $line; done << EOF
etc/node.cfg__cluster
EOF
test ! -e $ZEEKCTL_INSTALL_PREFIX/spool/state.db
zeekctl install
dump_db cluster