haproxy/reg-tests/checks/http-check.vtc
Christopher Faulet b381a505c1 BUG/MAJOR: tcpcheck: Allocate input and output buffers from the buffer pool
Historically, the input and output buffers of a check are allocated by hand
during the startup, with a specific size (not necessarily the same than
other buffers). But since the recent refactoring of the checks to rely
exclusively on the tcp-checks and to use the underlying mux layer, this part
is totally buggy. Indeed, because these buffers are now passed to a mux,
they maybe be swapped if a zero-copy is possible. In fact, for now it is
only possible in h2_rcv_buf(). Thus the bug concretely only exists if a h2
health-check is performed. But, it is a latent bug for other muxes.

Another problem is the size of these buffers. because it may differ for the
other buffer size, it might be source of bugs.

Finally, for configurations with hundreds of thousands of servers, having 2
buffers per check always allocated may be an issue.

To fix the bug, we now allocate these buffers when required using the buffer
pool. Thus not-running checks don't waste memory and muxes may swap them if
possible. The only drawback is the check buffers have now always the same
size than buffers used by the streams. This deprecates indirectly the
"tune.chksize" global option.

In addition, the http-check regtest have been update to perform some h2
health-checks.

Many thanks to @VigneshSP94 for its help on this bug.

This patch should solve the issue #936. It relies on the commit "MINOR:
tcpcheck: Don't handle anymore in-progress send rules in tcpcheck_main".
Both must be backport as far as 2.2.

bla
2020-11-27 10:29:41 +01:00

158 lines
4.9 KiB
Plaintext

varnishtest "Health-checks: some http-check tests"
feature ignore_unknown_macro
#REQUIRE_VERSION=2.2
#REGTEST_TYPE=slow
# This script tests HTTP health-checks.
server s1 {
rxreq
expect req.method == OPTIONS
expect req.url == /
expect req.proto == HTTP/1.0
txresp
} -start
server s2 {
rxreq
expect req.method == GET
expect req.url == /status
expect req.proto == HTTP/1.1
txresp
} -start
server s3 {
rxreq
expect req.method == GET
expect req.url == /status
expect req.proto == HTTP/1.1
txresp
} -start
server s4 {
rxreq
expect req.method == GET
expect req.url == /req1
expect req.proto == HTTP/1.1
expect req.http.x-test == "server=srv"
expect req.http.x-haproxy-server-state ~ "UP.+name=be4/srv"
expect req.bodylen == 0
txresp
accept
rxreq
expect req.method == GET
expect req.url == /req2
expect req.proto == HTTP/1.1
expect req.http.x-test == "server="
expect req.http.x-haproxy-server-state ~ "UP.+name=be4/srv"
expect req.http.content-length == 17
expect req.bodylen == 17
expect req.body == "health-check body"
txresp
accept
rxreq
expect req.method == GET
expect req.url == /req3
expect req.proto == HTTP/1.0
expect req.http.x-test == <undef>
expect req.http.x-haproxy-server-state ~ "UP.+name=be4/srv"
expect req.bodylen == 0
txresp
accept
rxreq
expect req.method == GET
expect req.url == /
expect req.proto == HTTP/1.0
expect req.http.x-test == <undef>
expect req.http.x-haproxy-server-state ~ "UP.+name=be4/srv"
expect req.bodylen == 23
expect req.body == "health-check on be4-srv"
txresp
} -start
syslog S1 -level notice {
recv
expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be[0-9]/srv succeeded.*code: 200"
recv
expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be[0-9]/srv succeeded.*code: 200"
recv
expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be[0-9]/srv succeeded.*code: 200"
recv
expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be[0-9]/srv succeeded.*code: 200"
recv
expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be[0-9]/srv succeeded.*code: 200"
recv
expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be[0-9]/srv succeeded.*code: 200"
} -start
haproxy h1 -conf {
defaults
mode http
timeout client 1s
timeout server 1s
timeout connect 100ms
option log-health-checks
backend be1
log ${S1_addr}:${S1_port} len 2048 local0
option httpchk
server srv ${s1_addr}:${s1_port} check inter 100ms rise 1 fall 1
backend be2
log ${S1_addr}:${S1_port} len 2048 local0
option httpchk GET /status HTTP/1.1
server srv ${s2_addr}:${s2_port} check inter 100ms rise 1 fall 1
backend be3
log ${S1_addr}:${S1_port} len 2048 local0
option httpchk
http-check send meth GET uri /status ver HTTP/1.1
server srv ${s3_addr}:${s3_port} check inter 100ms rise 1 fall 1
backend be4
mode tcp
log ${S1_addr}:${S1_port} len 2048 local0
option httpchk
http-check send-state
http-check connect addr ${s4_addr}:${s4_port}
http-check set-var(check.server) "str(srv)"
http-check set-var(check.path) "str(/req1)"
http-check send meth GET uri-lf "%[var(check.path)]" ver HTTP/1.1 hdr x-test "server=%[var(check.server)]"
http-check expect status 200
http-check connect addr ${s4_addr} port ${s4_port}
http-check unset-var(check.server)
http-check set-var(check.path) "str(/req2)"
http-check send meth GET uri-lf "%[var(check.path)]" ver HTTP/1.1 hdr x-test "server=%[var(check.server)]" body "health-check body"
http-check expect rstatus "^2[0-9]{2}"
http-check connect addr ${s4_addr} port ${s4_port}
http-check set-var(check.path) "str(/req3)"
http-check send meth GET uri-lf "%[var(check.path)]"
http-check expect rstatus "^2[0-9]{2}"
http-check connect addr ${s4_addr} port ${s4_port}
http-check unset-var(check.path)
http-check send meth GET uri-lf "%[var(check.path)]" body-lf "health-check on %[be_name]-%[srv_name]"
## implicit expect rule
server srv ${s1_addr}:${s1_port} check inter 100ms rise 1 fall 1
backend be5
log ${S1_addr}:${S1_port} len 2048 local0
option httpchk
server srv ${h1_li1_addr}:${h1_li1_port} proto h2 check inter 100ms rise 1 fall 1
backend be6
log ${S1_addr}:${S1_port} len 2048 local0
option httpchk GET /status HTTP/1.1
server srv ${h1_li1_addr}:${h1_li1_port} check check-proto h2 inter 100ms rise 1 fall 1
listen li1
mode http
bind "fd@${li1}" proto h2
http-request return status 200
} -start
syslog S1 -wait