File: cleanup-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 (106 lines) | stat: -rw-r--r-- 3,234 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# Test that the cleanup command can cleanup a crashed node in a cluster
# (which includes resetting the crashed node's state to "stopped"),
# but does not clean the tmpdir unless "--all" is specified.
#
# @TEST-EXEC: bash %INPUT
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-status-output btest-diff status1.out
# @TEST-EXEC: btest-diff cleanup.out
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-status-output btest-diff status2.out
# @TEST-EXEC: btest-diff status3.out
# @TEST-EXEC: btest-diff cleanup-stopped.out
# @TEST-EXEC: btest-diff status4.out
# @TEST-EXEC: btest-diff cleanup-onenode.out
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff cleanup-all.out
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff cleanup-all-onenode.out

. zeekctl-test-setup

while read line; do installfile $line; done << EOF
etc/zeekctl.cfg__no_email
etc/node.cfg__cluster
bin/zeek__test
EOF

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

zeekctl install
! zeekctl start
touch $ZEEKCTL_INSTALL_PREFIX/spool/tmp/testfile
touch $ZEEKCTL_INSTALL_PREFIX/spool/worker-1/testfile

# verify one node crashed and all others are running
! zeekctl status > status1.out

#########################
# test cleanup (without any node arguments)
zeekctl cleanup > cleanup.out

# verify that the crashed node's state was reset to "stopped"
! zeekctl status > status2.out

# the node testfile should not exist
test ! -e $ZEEKCTL_INSTALL_PREFIX/spool/worker-1/testfile

# the tmpdir testfile should still exist
test -e $ZEEKCTL_INSTALL_PREFIX/spool/tmp/testfile

#########################
# test cleanup when no nodes are running (without any node arguments)

# stop all nodes and restart only the crashing node
zeekctl stop
! zeekctl start worker-1

# verify one node crashed and all others are stopped
! zeekctl status > status3.out

zeekctl cleanup > cleanup-stopped.out

# verify that the crashed node's state was reset to "stopped"
! zeekctl status > status4.out

! zeekctl start
touch $ZEEKCTL_INSTALL_PREFIX/spool/worker-1/testfile

#########################
# test cleanup (with a node argument)
zeekctl cleanup worker-1 > cleanup-onenode.out

# the node testfile should not exist
test ! -e $ZEEKCTL_INSTALL_PREFIX/spool/worker-1/testfile

# the tmpdir testfile should still exist
test -e $ZEEKCTL_INSTALL_PREFIX/spool/tmp/testfile

zeekctl stop
! zeekctl start
touch $ZEEKCTL_INSTALL_PREFIX/spool/worker-1/testfile

########################
# test "cleanup --all" (without a node argument)
zeekctl cleanup --all > cleanup-all.out

# the node testfile should be gone
test ! -e $ZEEKCTL_INSTALL_PREFIX/spool/worker-1/testfile

# the tmpdir testfile should be gone
test ! -e $ZEEKCTL_INSTALL_PREFIX/spool/tmp/testfile

zeekctl stop
! zeekctl start
touch $ZEEKCTL_INSTALL_PREFIX/spool/worker-1/testfile
touch $ZEEKCTL_INSTALL_PREFIX/spool/tmp/testfile

########################
# test "cleanup --all" (with a node argument)
zeekctl cleanup --all worker-1 > cleanup-all-onenode.out

# the node testfile should be gone
test ! -e $ZEEKCTL_INSTALL_PREFIX/spool/worker-1/testfile

# the tmpdir testfile should be gone
test ! -e $ZEEKCTL_INSTALL_PREFIX/spool/tmp/testfile

zeekctl stop