summaryrefslogtreecommitdiffstats
path: root/ctdb/tests/UNIT/cunit/tmon_test_001.sh
blob: 96f706c2415ed13218bb34f2a05b9515c452414a (plain)
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#!/bin/sh

. "${TEST_SCRIPTS_DIR}/unit.sh"

epipe=$(errcode EPIPE)
eio=$(errcode EIO)
etimedout=$(errcode ETIMEDOUT)

test_case "No pings, only child monitors, so gets EPIPE"
ok <<EOF
parent: async wait start 5
child: async wait start 10
parent: async wait end
child: pipe closed
EOF
unit_test tmon_ping_test false 0 5 0 0 false 0 10 0 "$epipe"

test_case "No pings, only parent monitors, so gets EPIPE"
ok <<EOF
parent: async wait start 10
child: async wait start 5
child: async wait end
parent: pipe closed
EOF
unit_test tmon_ping_test false 0 10 0 "$epipe" false 0 5 0 0

test_case "No pings, Child exits first, parent notices"
ok <<EOF
parent: async wait start 10
child: async wait start 1
child: async wait end
parent: pipe closed
EOF
unit_test tmon_ping_test false 0 10 0 "$epipe" false 0 1 0 0

test_case "No pings, parent exits first, child notices"
ok <<EOF
parent: async wait start 1
child: async wait start 10
parent: async wait end
child: pipe closed
EOF
unit_test tmon_ping_test false 0 1 0 0 false 0 10 0 "$epipe"

test_case "Parent pings, child doesn't expect them, EIO"
ok <<EOF
parent: async wait start 5
child: async wait start 5
child: error ($eio)
parent: pipe closed
EOF
unit_test tmon_ping_test true 0 5 0 "$epipe" false 0 5 0 "$eio"

test_case "Child pings, parent doesn't expect them, EIO"
ok <<EOF
parent: async wait start 5
child: async wait start 5
parent: error ($eio)
child: pipe closed
EOF
unit_test tmon_ping_test false 0 5 0 "$eio" true 0 5 0 "$epipe"

test_case "Both ping, child doesn't expect them, EIO"
ok <<EOF
parent: async wait start 5
child: async wait start 5
child: error ($eio)
parent: pipe closed
EOF
unit_test tmon_ping_test true 3 5 0 "$epipe" true 0 5 0 "$eio"

test_case "Both ping, parent doesn't expect them, EIO"
ok <<EOF
parent: async wait start 5
child: async wait start 5
parent: error ($eio)
child: pipe closed
EOF
unit_test tmon_ping_test true 0 5 0 "$eio" true 3 5 0 "$epipe"

test_case "Child pings, no ping timeout error, child exits first"
ok <<EOF
parent: async wait start 10
child: async wait start 5
child: async wait end
parent: pipe closed
EOF
unit_test tmon_ping_test false 3 10 0 "$epipe" true 0 5 0 0

test_case "Parent pings, no ping timeout error, parent exits first"
ok <<EOF
parent: async wait start 5
child: async wait start 10
parent: async wait end
child: pipe closed
EOF
unit_test tmon_ping_test true 0 5 0 0 false 3 10 0 "$epipe"

test_case "Both ping, no ping timeout error, parent exits first"
ok <<EOF
parent: async wait start 5
child: async wait start 10
parent: async wait end
child: pipe closed
EOF
unit_test tmon_ping_test true 3 5 0 0 true 3 10 0 "$epipe"

test_case "Both ping, no ping timeout error, child exits first"
ok <<EOF
parent: async wait start 10
child: async wait start 5
child: async wait end
parent: pipe closed
EOF
unit_test tmon_ping_test true 3 10 0 "$epipe" true 3 5 0 0

test_case "Both ping, child blocks, parent ping timeout error"
ok <<EOF
parent: async wait start 20
child: blocking sleep start 7
parent: ping timeout
child: blocking sleep end
EOF
unit_test tmon_ping_test true 3 20 0 "$etimedout" true 3 0 7 0

test_case "Both ping, parent blocks, child ping timeout error"
ok <<EOF
parent: blocking sleep start 7
child: async wait start 20
child: ping timeout
parent: blocking sleep end
EOF
unit_test tmon_ping_test true 3 0 7 0 true 3 20 0 "$etimedout"

test_case "Both ping, child waits, child blocks, parent ping timeout error"
ok <<EOF
parent: async wait start 20
child: async wait start 2
child: async wait end
child: blocking sleep start 7
parent: ping timeout
child: blocking sleep end
EOF
unit_test tmon_ping_test true 3 20 0 "$etimedout" true 3 2 7 0

test_case "Both ping, parent waits, parent blocks, child ping timeout error"
ok <<EOF
parent: async wait start 2
child: async wait start 20
parent: async wait end
parent: blocking sleep start 7
child: ping timeout
parent: blocking sleep end
EOF
unit_test tmon_ping_test true 3 2 7 0 true 3 20 0 "$etimedout"

test_case "Both ping, child blocks for less than ping timeout"
ok <<EOF
parent: async wait start 20
child: blocking sleep start 3
child: blocking sleep end
parent: pipe closed
EOF
unit_test tmon_ping_test true 7 20 0 "$epipe" true 7 0 3 0

test_case "Both ping, parent blocks for less than ping timeout"
ok <<EOF
parent: blocking sleep start 3
child: async wait start 20
parent: blocking sleep end
child: pipe closed
EOF
unit_test tmon_ping_test true 7 0 3 0 true 7 20 3 "$epipe"

test_case "Both ping, child waits, child blocks for less than ping timeout"
ok <<EOF
parent: async wait start 20
child: async wait start 2
child: async wait end
child: blocking sleep start 3
child: blocking sleep end
parent: pipe closed
EOF
unit_test tmon_ping_test true 7 20 0 "$epipe" true 7 2 3 0

test_case "Both ping, parent waits, parent blocks for less than ping timeout"
ok <<EOF
parent: async wait start 2
child: async wait start 20
parent: async wait end
parent: blocking sleep start 3
parent: blocking sleep end
child: pipe closed
EOF
unit_test tmon_ping_test true 7 2 3 0 true 7 20 0 "$epipe"