2021-07-29 15:34:16 +00:00
|
|
|
varnishtest "Add/Delete server via cli with check support"
|
|
|
|
|
|
|
|
feature cmd "$HAPROXY_PROGRAM -cc 'version_atleast(2.5-dev3)'"
|
|
|
|
feature cmd "$HAPROXY_PROGRAM -cc 'feature(OPENSSL)'"
|
|
|
|
feature ignore_unknown_macro
|
|
|
|
|
|
|
|
barrier b1 cond 2 -cyclic
|
|
|
|
barrier b2 cond 2 -cyclic
|
|
|
|
|
|
|
|
server s1 {
|
2021-08-06 13:34:04 +00:00
|
|
|
rxreq
|
2021-07-29 15:34:16 +00:00
|
|
|
txresp
|
|
|
|
} -start
|
|
|
|
|
|
|
|
server s2 {
|
|
|
|
} -start
|
|
|
|
|
|
|
|
# used for agent checks
|
|
|
|
server s3 {
|
|
|
|
recv 5
|
|
|
|
send "ready up\n"
|
|
|
|
barrier b2 sync
|
|
|
|
} -start
|
|
|
|
|
|
|
|
syslog S1 -level notice {
|
|
|
|
recv
|
|
|
|
expect ~ ".*Server be1/s1 is UP/READY \\(leaving forced maintenance\\)."
|
|
|
|
recv
|
|
|
|
expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be1/s1 succeeded.+reason: Layer7 check passed, code: 200, check duration: [[:digit:]]+ms.+status: 1/1 UP"
|
|
|
|
|
|
|
|
barrier b1 sync
|
|
|
|
|
|
|
|
recv
|
|
|
|
expect ~ ".*Server be1/s2 is UP/READY \\(leaving forced maintenance\\)."
|
|
|
|
recv
|
|
|
|
expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be1/s2 failed.+reason: Layer7 timeout, check duration: [[:digit:]]+ms.+status: 0/1 DOWN"
|
|
|
|
|
|
|
|
barrier b1 sync
|
|
|
|
|
|
|
|
recv
|
|
|
|
expect ~ ".*Server be1/s2 was DOWN and now enters maintenance."
|
|
|
|
|
|
|
|
recv
|
|
|
|
expect ~ ".*Server be1/s3 is UP/READY \\(leaving forced maintenance\\)."
|
|
|
|
|
|
|
|
recv
|
|
|
|
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"
|
|
|
|
|
|
|
|
barrier b1 sync
|
|
|
|
barrier b2 sync
|
2022-03-09 15:43:34 +00:00
|
|
|
|
|
|
|
recv
|
|
|
|
expect ~ ".*Server be1/s4 is UP/READY \\(leaving forced maintenance\\)."
|
|
|
|
recv
|
|
|
|
expect ~ "Health check for server be1/s4 failed"
|
|
|
|
|
|
|
|
barrier b1 sync
|
|
|
|
|
|
|
|
recv
|
|
|
|
expect ~ ".*Server be1/s5 is UP/READY \\(leaving forced maintenance\\)."
|
|
|
|
recv
|
|
|
|
expect ~ "Health check for server be1/s5 succeeded."
|
2021-07-29 15:34:16 +00:00
|
|
|
} -start
|
|
|
|
|
|
|
|
haproxy h1 -conf {
|
|
|
|
global
|
|
|
|
stats socket "${tmpdir}/h1/stats" level admin
|
|
|
|
|
|
|
|
backend be1
|
|
|
|
option log-health-checks
|
|
|
|
option httpchk GET /
|
|
|
|
log ${S1_addr}:${S1_port} daemon
|
2022-03-09 15:43:34 +00:00
|
|
|
|
|
|
|
frontend fe-proxy
|
|
|
|
mode http
|
|
|
|
bind "fd@${hapsrv}" accept-proxy
|
|
|
|
http-request return status 200
|
2021-07-29 15:34:16 +00:00
|
|
|
} -start
|
|
|
|
|
|
|
|
# check on a functional server
|
|
|
|
haproxy h1 -cli {
|
2022-03-09 14:07:31 +00:00
|
|
|
send "add server be1/s1 ${s1_addr}:${s1_port} check inter 200ms rise 1 fall 1"
|
2021-07-29 15:34:16 +00:00
|
|
|
expect ~ "New server registered."
|
|
|
|
|
|
|
|
send "enable server be1/s1"
|
|
|
|
expect ~ ".*"
|
|
|
|
send "enable health be1/s1"
|
|
|
|
expect ~ ".*"
|
|
|
|
|
|
|
|
barrier b1 sync
|
|
|
|
|
|
|
|
send "disable server be1/s1"
|
|
|
|
expect ~ ".*"
|
|
|
|
|
2022-03-09 14:07:31 +00:00
|
|
|
send "del server be1/s1"
|
2021-07-29 15:34:16 +00:00
|
|
|
expect ~ "Server deleted."
|
|
|
|
}
|
|
|
|
|
|
|
|
server s2 -break
|
|
|
|
|
|
|
|
# check on a disabled server
|
|
|
|
haproxy h1 -cli {
|
2022-03-09 14:07:31 +00:00
|
|
|
send "add server be1/s2 ${s2_addr}:${s2_port} check inter 200ms rise 1 fall 1"
|
2021-07-29 15:34:16 +00:00
|
|
|
expect ~ "New server registered."
|
|
|
|
|
|
|
|
send "enable server be1/s2"
|
|
|
|
expect ~ ".*"
|
|
|
|
send "enable health be1/s2"
|
|
|
|
expect ~ ".*"
|
|
|
|
|
|
|
|
barrier b1 sync
|
|
|
|
|
|
|
|
send "disable server be1/s2"
|
|
|
|
expect ~ ".*"
|
|
|
|
|
2022-03-09 14:07:31 +00:00
|
|
|
send "del server be1/s2"
|
2021-07-29 15:34:16 +00:00
|
|
|
expect ~ "Server deleted."
|
|
|
|
}
|
|
|
|
|
|
|
|
# agent check
|
|
|
|
haproxy h1 -cli {
|
2022-03-09 14:07:31 +00:00
|
|
|
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"
|
2021-07-29 15:34:16 +00:00
|
|
|
expect ~ "New server registered."
|
|
|
|
|
|
|
|
send "enable agent be1/s3"
|
|
|
|
expect ~ ".*"
|
|
|
|
|
|
|
|
barrier b1 sync
|
|
|
|
|
|
|
|
send "disable agent be1/s3; disable server be1/s3"
|
|
|
|
expect ~ ".*"
|
|
|
|
|
2022-03-09 14:07:31 +00:00
|
|
|
send "del server be1/s3"
|
2021-07-29 15:34:16 +00:00
|
|
|
expect ~ "Server deleted."
|
|
|
|
}
|
|
|
|
|
2022-03-09 15:43:34 +00:00
|
|
|
# check PROXY protocol interaction with checks
|
|
|
|
haproxy h1 -cli {
|
|
|
|
# no explicit check-send-proxy
|
|
|
|
# The health check should failed.
|
|
|
|
send "add server be1/s4 ${h1_hapsrv_addr}:${h1_hapsrv_port} send-proxy check rise 1 fall 1"
|
|
|
|
expect ~ "New server registered."
|
|
|
|
|
|
|
|
send "enable server be1/s4"
|
|
|
|
expect ~ ".*"
|
|
|
|
send "enable health be1/s4"
|
|
|
|
expect ~ ".*"
|
|
|
|
|
|
|
|
barrier b1 sync
|
|
|
|
|
|
|
|
# explicit check-send-proxy : health check should succeeded
|
|
|
|
send "add server be1/s5 ${h1_hapsrv_addr}:${h1_hapsrv_port} send-proxy check rise 1 fall 1 check-send-proxy"
|
|
|
|
expect ~ "New server registered."
|
|
|
|
|
|
|
|
send "enable server be1/s5"
|
|
|
|
expect ~ ".*"
|
|
|
|
send "enable health be1/s5"
|
|
|
|
expect ~ ".*"
|
|
|
|
}
|
|
|
|
|
2021-07-29 15:34:16 +00:00
|
|
|
syslog S1 -wait
|