blob: c63710c6bf5aae9ff1633f64752c0aeaeb40bc92 [file] [log] [blame]
Amaury Denoyelle3e7d4682021-07-29 17:34:16 +02001varnishtest "Add/Delete server via cli with check support"
2
3feature cmd "$HAPROXY_PROGRAM -cc 'version_atleast(2.5-dev3)'"
4feature cmd "$HAPROXY_PROGRAM -cc 'feature(OPENSSL)'"
5feature ignore_unknown_macro
6
7barrier b1 cond 2 -cyclic
8barrier b2 cond 2 -cyclic
9
10server s1 {
Amaury Denoyellea0267832021-08-06 15:34:04 +020011 rxreq
Amaury Denoyelle3e7d4682021-07-29 17:34:16 +020012 txresp
13} -start
14
15server s2 {
16} -start
17
18# used for agent checks
19server s3 {
20 recv 5
21 send "ready up\n"
Amaury Denoyelle3e7d4682021-07-29 17:34:16 +020022 barrier b2 sync
23} -start
24
25syslog S1 -level notice {
26 recv
27 expect ~ ".*Server be1/s1 is UP/READY \\(leaving forced maintenance\\)."
28 recv
29 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be1/s1 succeeded.+reason: Layer7 check passed, code: 200, check duration: [[:digit:]]+ms.+status: 1/1 UP"
30
31 barrier b1 sync
32
33 recv
34 expect ~ ".*Server be1/s2 is UP/READY \\(leaving forced maintenance\\)."
35 recv
36 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be1/s2 failed.+reason: Layer7 timeout, check duration: [[:digit:]]+ms.+status: 0/1 DOWN"
37
38 barrier b1 sync
39
40 recv
41 expect ~ ".*Server be1/s2 was DOWN and now enters maintenance."
42
43 recv
44 expect ~ ".*Server be1/s3 is UP/READY \\(leaving forced maintenance\\)."
45
46 recv
47 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Agent check for server be1/s3 succeeded.+reason: Layer7 check passed, code: 0, info: \"via agent : up\", check duration: [[:digit:]]+ms.+status: 1/1 UP"
48
49 barrier b1 sync
50 barrier b2 sync
Amaury Denoyelle3881e172022-03-09 16:43:34 +010051
52 recv
53 expect ~ ".*Server be1/s4 is UP/READY \\(leaving forced maintenance\\)."
54 recv
55 expect ~ "Health check for server be1/s4 failed"
56
57 barrier b1 sync
58
59 recv
60 expect ~ ".*Server be1/s5 is UP/READY \\(leaving forced maintenance\\)."
61 recv
62 expect ~ "Health check for server be1/s5 succeeded."
Amaury Denoyelle3e7d4682021-07-29 17:34:16 +020063} -start
64
65haproxy h1 -conf {
66 global
67 stats socket "${tmpdir}/h1/stats" level admin
68
69 backend be1
70 option log-health-checks
71 option httpchk GET /
72 log ${S1_addr}:${S1_port} daemon
Amaury Denoyelle3881e172022-03-09 16:43:34 +010073
74 frontend fe-proxy
75 mode http
76 bind "fd@${hapsrv}" accept-proxy
77 http-request return status 200
Amaury Denoyelle3e7d4682021-07-29 17:34:16 +020078} -start
79
80# check on a functional server
81haproxy h1 -cli {
Amaury Denoyelle76e8b702022-03-09 15:07:31 +010082 send "add server be1/s1 ${s1_addr}:${s1_port} check inter 200ms rise 1 fall 1"
Amaury Denoyelle3e7d4682021-07-29 17:34:16 +020083 expect ~ "New server registered."
84
85 send "enable server be1/s1"
86 expect ~ ".*"
87 send "enable health be1/s1"
88 expect ~ ".*"
89
90 barrier b1 sync
91
92 send "disable server be1/s1"
93 expect ~ ".*"
94
Amaury Denoyelle76e8b702022-03-09 15:07:31 +010095 send "del server be1/s1"
Amaury Denoyelle3e7d4682021-07-29 17:34:16 +020096 expect ~ "Server deleted."
97}
98
99server s2 -break
100
101# check on a disabled server
102haproxy h1 -cli {
Amaury Denoyelle76e8b702022-03-09 15:07:31 +0100103 send "add server be1/s2 ${s2_addr}:${s2_port} check inter 200ms rise 1 fall 1"
Amaury Denoyelle3e7d4682021-07-29 17:34:16 +0200104 expect ~ "New server registered."
105
106 send "enable server be1/s2"
107 expect ~ ".*"
108 send "enable health be1/s2"
109 expect ~ ".*"
110
111 barrier b1 sync
112
113 send "disable server be1/s2"
114 expect ~ ".*"
115
Amaury Denoyelle76e8b702022-03-09 15:07:31 +0100116 send "del server be1/s2"
Amaury Denoyelle3e7d4682021-07-29 17:34:16 +0200117 expect ~ "Server deleted."
118}
119
120# agent check
121haproxy h1 -cli {
Amaury Denoyelle76e8b702022-03-09 15:07:31 +0100122 send "add server be1/s3 ${s1_addr}:${s1_port} agent-check agent-addr ${s3_addr} agent-port ${s3_port} agent-send 'hello' agent-inter 200ms rise 1 fall 1"
Amaury Denoyelle3e7d4682021-07-29 17:34:16 +0200123 expect ~ "New server registered."
124
125 send "enable agent be1/s3"
126 expect ~ ".*"
127
128 barrier b1 sync
129
130 send "disable agent be1/s3; disable server be1/s3"
131 expect ~ ".*"
132
Amaury Denoyelle76e8b702022-03-09 15:07:31 +0100133 send "del server be1/s3"
Amaury Denoyelle3e7d4682021-07-29 17:34:16 +0200134 expect ~ "Server deleted."
135}
136
Amaury Denoyelle3881e172022-03-09 16:43:34 +0100137# check PROXY protocol interaction with checks
138haproxy h1 -cli {
139 # no explicit check-send-proxy
140 # The health check should failed.
141 send "add server be1/s4 ${h1_hapsrv_addr}:${h1_hapsrv_port} send-proxy check rise 1 fall 1"
142 expect ~ "New server registered."
143
144 send "enable server be1/s4"
145 expect ~ ".*"
146 send "enable health be1/s4"
147 expect ~ ".*"
148
149 barrier b1 sync
150
151 # explicit check-send-proxy : health check should succeeded
152 send "add server be1/s5 ${h1_hapsrv_addr}:${h1_hapsrv_port} send-proxy check rise 1 fall 1 check-send-proxy"
153 expect ~ "New server registered."
154
155 send "enable server be1/s5"
156 expect ~ ".*"
157 send "enable health be1/s5"
158 expect ~ ".*"
159}
160
Amaury Denoyelle3e7d4682021-07-29 17:34:16 +0200161syslog S1 -wait