blob: e27f4b4f8003951fa42cae882c46a3264bc4ae75 [file] [log] [blame]
Frederic Lecaille9be34892018-12-13 22:15:06 +01001varnishtest "Health-check test"
2feature ignore_unknown_macro
3
4#REQUIRE_VERSION=1.8
Frédéric Lécaille15685c72018-12-20 09:55:45 +01005#EXCLUDE_TARGETS=freebsd
Frédéric Lécailledc1a3bd2019-03-29 15:07:24 +01006#REGTEST_TYPE=slow
Frederic Lecaille9be34892018-12-13 22:15:06 +01007
8# This script test health-checks for four backends with one server by backend.
9# A syslog server is attached to each backend to check the syslog messages
10# in the righ order.
11
12# First, we check a health-check has passed for all the servers thanks to the syslog
13# messages. Then each server is disabled. The health-check status are checked.
14# Then each server is re-enabled. Finally health-check status
15# verifications for each server terminate the execution of this script.
16
17# Note that the CLI is synchronized with the syslog servers so that
18# to be sure to receive the passed health-checks status messages before
19# disabling the servers. Same thing, when we check that the servers are down
20# before enabling the servers.
21
22# Cyclic barrier to synchonize the CLI with the syslog servers
Frédéric Lécaille3b3a8832018-12-20 09:55:42 +010023barrier b1 cond 5 -cyclic
Frederic Lecaille9be34892018-12-13 22:15:06 +010024
25# These servers are there only for the health-check test.
26server s1 {
27} -start
28
29server s2 {
30} -start
31
32server s3 {
33} -start
34
35server s4 {
36} -start
37
38syslog S1 -level notice {
39 recv
40 expect ~ "Proxy be1 started"
41 recv
42 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be1/srv1 succeeded, reason: Layer4 check passed, check duration: [[:digit:]]+ms, status: 1/1 UP"
43 barrier b1 sync
44 recv alert
45 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Server be1/srv1 is going DOWN for maintenance. 0 active and 0 backup servers left. [01] sessions active, 0 requeued, 0 remaining in queue."
46 recv emerg
47 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: backend be1 has no server available!"
48 barrier b1 sync
49 recv
50 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: (Server be1/srv1 is UP/READY \\(leaving forced maintenance\\).|Health check for server be1/srv1 succeeded, reason: Layer4 check passed, check duration: [[:digit:]]+ms, status: 1/1 UP)"
51 barrier b1 sync
52} -start
53
54syslog S2 -level notice {
55 recv
56 expect ~ "Proxy be2 started"
57 recv
58 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be2/srv2 succeeded, reason: Layer4 check passed, check duration: [[:digit:]]+ms, status: 1/1 UP"
59 barrier b1 sync
60 recv alert
61 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Server be2/srv2 is going DOWN for maintenance. 0 active and 0 backup servers left. [01] sessions active, 0 requeued, 0 remaining in queue."
62 recv emerg
63 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: backend be2 has no server available!"
64 barrier b1 sync
65 recv
66 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: (Server be2/srv2 is UP/READY \\(leaving forced maintenance\\).|Health check for server be2/srv2 succeeded, reason: Layer4 check passed, check duration: [[:digit:]]+ms, status: 1/1 UP)"
67 barrier b1 sync
68} -start
69
70syslog S3 -level notice {
71 recv
72 expect ~ "Proxy be3 started"
73 recv
74 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be3/srv3 succeeded, reason: Layer4 check passed, check duration: [[:digit:]]+ms, status: 1/1 UP"
75 barrier b1 sync
76 recv alert
77 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Server be3/srv3 is going DOWN for maintenance. 0 active and 0 backup servers left. [01] sessions active, 0 requeued, 0 remaining in queue."
78 recv emerg
79 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: backend be3 has no server available!"
80 barrier b1 sync
81 recv
82 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: (Server be3/srv3 is UP/READY \\(leaving forced maintenance\\).|Health check for server be3/srv3 succeeded, reason: Layer4 check passed, check duration: [[:digit:]]+ms, status: 1/1 UP)"
83 barrier b1 sync
84} -start
85
86syslog S4 -level notice {
87 recv
88 expect ~ "Proxy be4 started"
89 recv
90 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be4/srv4 succeeded, reason: Layer4 check passed, check duration: [[:digit:]]+ms, status: 1/1 UP"
91 barrier b1 sync
92 recv alert
93 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Server be4/srv4 is going DOWN for maintenance. 0 active and 0 backup servers left. [01] sessions active, 0 requeued, 0 remaining in queue."
94 recv emerg
95 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: backend be4 has no server available!"
96 barrier b1 sync
97 recv
98 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: (Server be4/srv4 is UP/READY \\(leaving forced maintenance\\).|Health check for server be4/srv4 succeeded, reason: Layer4 check passed, check duration: [[:digit:]]+ms, status: 1/1 UP)"
99 barrier b1 sync
100} -start
101
102
103haproxy h1 -conf {
104 defaults
105 timeout client 1s
106 timeout server 1s
107 timeout connect 1s
108 default-server check downinter 1s rise 1 fall 1
109
110 frontend fe1
111 bind "fd@${fe1}"
112 use_backend be1
113
114 frontend fe2
115 bind "fd@${fe2}"
116 use_backend be2
117
118 frontend fe3
119 bind "fd@${fe3}"
120 use_backend be3
121
122 frontend fe4
123 bind "fd@${fe4}"
124 use_backend be4
125
126 backend be1
127 option log-health-checks
128 log ${S1_addr}:${S1_port} daemon
129 server srv1 ${s1_addr}:${s1_port}
130
131 backend be2
132 option log-health-checks
133 log ${S2_addr}:${S2_port} daemon
134 server srv2 ${s2_addr}:${s2_port}
135
136 backend be3
137 option log-health-checks
138 log ${S3_addr}:${S3_port} daemon
139 server srv3 ${s3_addr}:${s3_port}
140
141 backend be4
142 option log-health-checks
143 log ${S4_addr}:${S4_port} daemon
144 server srv4 ${s4_addr}:${s4_port}
145} -start
146
147haproxy h1 -cli {
148 barrier b1 sync
149 send "show servers state"
Willy Tarreauf42fa7b2019-08-01 09:51:29 +0200150 expect ~ "# be_id be_name srv_id srv_name srv_addr srv_op_state srv_admin_state srv_uweight srv_iweight srv_time_since_last_change srv_check_status srv_check_result srv_check_health srv_check_state srv_agent_state bk_f_forced_id srv_f_forced_id srv_fqdn srv_port srvrecord\n6 be1 1 srv1 ${s1_addr} 2 0 1 1 [[:digit:]]+ 6 3 1 [67] 0 0 0 - ${s1_port} -\n7 be2 1 srv2 ${s2_addr} 2 0 1 1 [[:digit:]]+ 6 3 1 [67] 0 0 0 - ${s2_port} -\n8 be3 1 srv3 ${s3_addr} 2 0 1 1 [[:digit:]]+ 6 3 1 [67] 0 0 0 - ${s3_port} -\n9 be4 1 srv4 ${s4_addr} 2 0 1 1 [[:digit:]]+ 6 3 1 [67] 0 0 0 - ${s4_port} -"
Frederic Lecaille9be34892018-12-13 22:15:06 +0100151}
152
153haproxy h1 -cli {
154 send "disable server be1/srv1"
155 expect ~ .*
156}
157
158haproxy h1 -cli {
159 send "disable server be2/srv2"
160 expect ~ .*
161}
162
163haproxy h1 -cli {
164 send "disable server be3/srv3"
165 expect ~ .*
166}
167
168haproxy h1 -cli {
169 send "disable server be4/srv4"
170 expect ~ .*
171}
172
173haproxy h1 -cli {
174 barrier b1 sync
175 send "show servers state"
Willy Tarreauf42fa7b2019-08-01 09:51:29 +0200176 expect ~ "# be_id be_name srv_id srv_name srv_addr srv_op_state srv_admin_state srv_uweight srv_iweight srv_time_since_last_change srv_check_status srv_check_result srv_check_health srv_check_state srv_agent_state bk_f_forced_id srv_f_forced_id srv_fqdn srv_port srvrecord\n6 be1 1 srv1 ${s1_addr} 0 1 1 1 [[:digit:]]+ 6 3 [01] 1[45] 0 0 0 - ${s1_port} -\n7 be2 1 srv2 ${s2_addr} 0 1 1 1 [[:digit:]]+ 6 3 [01] 1[45] 0 0 0 - ${s2_port} -\n8 be3 1 srv3 ${s3_addr} 0 1 1 1 [[:digit:]]+ 6 3 [01] 1[45] 0 0 0 - ${s3_port} -\n9 be4 1 srv4 ${s4_addr} 0 1 1 1 [[:digit:]]+ 6 3 [01] 1[45] 0 0 0 - ${s4_port} -"
Frederic Lecaille9be34892018-12-13 22:15:06 +0100177}
178
179haproxy h1 -cli {
180 send "enable server be1/srv1"
181 expect ~ .*
182}
183
184haproxy h1 -cli {
185 send "enable server be2/srv2"
186 expect ~ .*
187}
188
189haproxy h1 -cli {
190 send "enable server be3/srv3"
191 expect ~ .*
192}
193
194haproxy h1 -cli {
195 send "enable server be4/srv4"
196 expect ~ .*
197}
198
199haproxy h1 -cli {
200 barrier b1 sync
201 send "show servers state"
202 expect ~ "# be_id be_name srv_id srv_name srv_addr srv_op_state srv_admin_state srv_uweight srv_iweight srv_time_since_last_change srv_check_status srv_check_result srv_check_health srv_check_state srv_agent_state bk_f_forced_id srv_f_forced_id srv_fqdn srv_port srvrecord\n6 be1 1 srv1 ${s1_addr} 2 0 1 1 [[:digit:]]+ 6 [03] 1 [67] 0 0 0 - ${s1_port} -\n7 be2 1 srv2 ${s2_addr} 2 0 1 1 [[:digit:]]+ 6 [03] 1 [67] 0 0 0 - ${s2_port} -\n8 be3 1 srv3 ${s3_addr} 2 0 1 1 [[:digit:]]+ 6 [03] 1 [67] 0 0 0 - ${s3_port} -\n9 be4 1 srv4 ${s4_addr} 2 0 1 1 [[:digit:]]+ 6 [03] 1 [67] 0 0 0 - ${s4_port} -"
203}
204
205syslog S1 -wait
206syslog S2 -wait
207syslog S3 -wait
208syslog S4 -wait
209