File: install-state.test

package info (click to toggle)
zeekctl 2.2.0%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,544 kB
  • sloc: python: 5,639; sh: 1,374; makefile: 71; awk: 24
file content (39 lines) | stat: -rw-r--r-- 910 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# 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