mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-11 05:54:39 +00:00
f673923629
With the CI occasionally slowing down, we're starting to see again some spurious failures despite the long 1-second timeouts. This reports false positives that are disturbing and doesn't provide as much value as this could. However at this delay it already becomes a pain for developers to wait for the tests to complete. This commit adds support for the new environment variable HAPROXY_TEST_TIMEOUT that will allow anyone to modify the connect, client and server timeouts. It was set to 5 seconds by default, which should be plenty for quite some time in the CI. All relevant values that were 200ms or above were replaced by this one. A few larger values were left as they are special. One test for the set-timeout action that used to rely on a fixed 1-sec value was extended to a fixed 5-sec, as the timeout is normally not reached, but it needs to be known to compare the old and new values.
158 lines
4.9 KiB
Plaintext
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 "${HAPROXY_TEST_TIMEOUT-5s}"
|
|
timeout server "${HAPROXY_TEST_TIMEOUT-5s}"
|
|
timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
|
|
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
|