mirror of
https://github.com/haproxy/haproxy.git
synced 2026-04-22 14:49:45 -04:00
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.
99 lines
3.6 KiB
Text
99 lines
3.6 KiB
Text
varnishtest "Test the HTTP return action"
|
|
#REQUIRE_VERSION=2.2
|
|
|
|
# This config tests the HTTP return action.
|
|
|
|
feature ignore_unknown_macro
|
|
|
|
haproxy h1 -conf {
|
|
global
|
|
# WT: limit false-positives causing "HTTP header incomplete" due to
|
|
# idle server connections being randomly used and randomly expiring
|
|
# under us.
|
|
tune.idle-pool.shared off
|
|
|
|
defaults
|
|
mode http
|
|
timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
|
|
timeout client "${HAPROXY_TEST_TIMEOUT-5s}"
|
|
timeout server "${HAPROXY_TEST_TIMEOUT-5s}"
|
|
|
|
frontend fe1
|
|
bind "fd@${fe1}"
|
|
http-request return if { path /def-1 }
|
|
http-request return hdr "x-custom-hdr" "%[url]" if { path /def-2 }
|
|
http-request return status 403 if { path /def-3 }
|
|
http-request return content-type "text/plain" if { path /def-4 }
|
|
|
|
http-request return content-type "text/plain" string "hello" hdr "x-custom-hdr" "%[url]" if { path /string }
|
|
http-request return content-type "text/plain" lf-string "path is %[url]" hdr "x-custom-hdr" "%[url]" if { path /lf-string }
|
|
http-request return content-type "text/plain" file /dev/null hdr "x-custom-hdr" "%[url]" if { path /empty-file }
|
|
http-request return content-type "text/plain" file ${testdir}/1k.txt hdr "x-custom-hdr" "%[url]" if { path /file }
|
|
http-request return content-type "text/plain" lf-file ${testdir}/lf-file.txt hdr "x-custom-hdr" "%[url]" if { path /lf-file }
|
|
} -start
|
|
|
|
client c1 -connect ${h1_fe1_sock} {
|
|
txreq -req GET -url /def-1
|
|
rxresp
|
|
expect resp.status == 200
|
|
expect resp.http.content-length == 0
|
|
expect resp.http.content-type == <undef>
|
|
expect resp.http.x-custom-hdr == <undef>
|
|
|
|
txreq -req GET -url /def-2
|
|
rxresp
|
|
expect resp.status == 200
|
|
expect resp.http.content-length == 0
|
|
expect resp.http.content-type == <undef>
|
|
expect resp.http.x-custom-hdr == "/def-2"
|
|
|
|
txreq -req GET -url /def-3
|
|
rxresp
|
|
expect resp.status == 403
|
|
expect resp.http.content-length == 0
|
|
expect resp.http.content-type == <undef>
|
|
|
|
txreq -req GET -url /def-4
|
|
rxresp
|
|
expect resp.status == 200
|
|
expect resp.http.content-length == 0
|
|
expect resp.http.content-type == <undef>
|
|
|
|
txreq -req GET -url /string
|
|
rxresp
|
|
expect resp.status == 200
|
|
expect resp.http.content-length == 5
|
|
expect resp.http.content-type == "text/plain"
|
|
expect resp.http.x-custom-hdr == "/string"
|
|
expect resp.body == "hello"
|
|
|
|
txreq -req GET -url /lf-string
|
|
rxresp
|
|
expect resp.status == 200
|
|
expect resp.http.content-length == 18
|
|
expect resp.http.content-type == "text/plain"
|
|
expect resp.http.x-custom-hdr == "/lf-string"
|
|
expect resp.body == "path is /lf-string"
|
|
|
|
txreq -req GET -url /empty-file
|
|
rxresp
|
|
expect resp.status == 200
|
|
expect resp.http.content-length == 0
|
|
expect resp.http.content-type == <undef>
|
|
expect resp.http.x-custom-hdr == "/empty-file"
|
|
|
|
txreq -req GET -url /file
|
|
rxresp
|
|
expect resp.status == 200
|
|
expect resp.http.content-length == 1024
|
|
expect resp.http.content-type == "text/plain"
|
|
expect resp.http.x-custom-hdr == "/file"
|
|
|
|
txreq -req GET -url /lf-file
|
|
rxresp
|
|
expect resp.status == 200
|
|
expect resp.http.content-length == 17
|
|
expect resp.http.content-type == "text/plain"
|
|
expect resp.http.x-custom-hdr == "/lf-file"
|
|
expect resp.body == "path is /lf-file\n"
|
|
} -run
|