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