File: stop-crash.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 (69 lines) | stat: -rw-r--r-- 1,805 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Test that the stop command can cleanup a crashed node (including resetting
# its state to "stopped") and sends a crash report, and does not log the
# crashed node in the stats.log file.
#
# @TEST-EXEC: bash %INPUT
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-status-output btest-diff status1.out
# @TEST-EXEC: btest-diff stop.out
# @TEST-EXEC: btest-diff status2.out

. zeekctl-test-setup

while read line; do installfile $line; done << EOF
etc/zeekctl.cfg__test_sendmail
etc/node.cfg__cluster
bin/zeek__test
bin/sendmail__test --new
EOF

replaceprefix etc/zeekctl.cfg

cat > $ZEEKCTL_INSTALL_PREFIX/zeekctltest.cfg << EOF
crash=worker-1
EOF

zeekctl install
! zeekctl start

# the start command creates some files (these are NOT created by zeek itself)
while read line; do
    test -e $ZEEKCTL_INSTALL_PREFIX/$line
done << EOF
spool/worker-1/.cmdline
spool/worker-1/.env_vars
spool/worker-1/.pid
spool/worker-1/.startup
spool/worker-1/stderr.log
spool/worker-1/stdout.log
EOF

# verify that a node crashed
! zeekctl status > status1.out

# verify that no email has been sent
test ! -e $ZEEKCTL_INSTALL_PREFIX/sendmail.out

# test the stop command
zeekctl stop > stop.out

# the stop command should cleanup the crashed node directory
while read line; do
    test ! -e $ZEEKCTL_INSTALL_PREFIX/$line
done << EOF
spool/worker-1/.cmdline
spool/worker-1/.env_vars
spool/worker-1/.pid
spool/worker-1/.startup
spool/worker-1/stderr.log
spool/worker-1/stdout.log
EOF

# the crashed node should not be logged as "stopped" in stats.log
grep stopped $ZEEKCTL_INSTALL_PREFIX/spool/stats.log > tmp
! grep worker-1 tmp

# verify that a crash report was sent
grep -q "Crash report from worker-1" $ZEEKCTL_INSTALL_PREFIX/sendmail.out

# verify that all nodes are in the stopped state
! zeekctl status > status2.out