File: start-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 (56 lines) | stat: -rw-r--r-- 1,661 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
# Test that the start command reports to the user that a node crashed,
# and does not log the crashed node in the stats.log file.
# Test that the start command can start a node in the crashed state, and
# that it sends a crash report.  Test that the start command returns nonzero
# exit status when not all nodes start successfully.
#
# @TEST-EXEC: bash %INPUT
# @TEST-EXEC: btest-diff start1.out
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-status-output btest-diff status1.out
# @TEST-EXEC: btest-diff start2.out
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-status-output 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

# start all nodes, and one will crash
! zeekctl start > start1.out 2> tmp.out
cat tmp.out >> start1.out

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

# verify that a node is in the crashed state
! zeekctl status > status1.out

# this time we don't want it to crash
rm -f $ZEEKCTL_INSTALL_PREFIX/zeekctltest.cfg

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

# try to start a node in the "crashed" state
zeekctl start > start2.out

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

# verify that all nodes are running
zeekctl status > status2.out

zeekctl stop