mirror of
https://github.com/haproxy/haproxy.git
synced 2026-07-11 02:02:18 -04:00
REGTESTS: Improve script testing the set-timeout action
First, instead of using syslog to test the result, http-after-response rules are now used. It is a bit simple. In addition, all custom timeouts are tested. Some testcase were useless and were thus removed. In addition, the script was moved in "reg-tests/http-rules/" directory.
This commit is contained in:
parent
69caa53530
commit
ba6c518ee2
2 changed files with 195 additions and 217 deletions
195
reg-tests/http-rules/set_timeout.vtc
Normal file
195
reg-tests/http-rules/set_timeout.vtc
Normal file
|
|
@ -0,0 +1,195 @@
|
|||
varnishtest "http-request set-timeout test"
|
||||
|
||||
feature ignore_unknown_macro
|
||||
|
||||
server srv_h1 -repeat 6 {
|
||||
rxreq
|
||||
txresp -hdr "Connection: close"
|
||||
} -start
|
||||
|
||||
haproxy hap -conf {
|
||||
global
|
||||
.if feature(THREAD)
|
||||
thread-groups 1
|
||||
.endif
|
||||
|
||||
defaults
|
||||
timeout connect 5s
|
||||
timeout client 5s
|
||||
timeout server 5s
|
||||
timeout tunnel 5s
|
||||
timeout queue 5s
|
||||
timeout tarpit 5s
|
||||
log global
|
||||
|
||||
listen li1
|
||||
mode http
|
||||
bind "fd@${li1}"
|
||||
http-after-response set-header client-timeout "%[fe_client_timeout] %[cur_client_timeout]"
|
||||
http-after-response set-header server-timeout "%[be_server_timeout] %[cur_server_timeout]"
|
||||
http-after-response set-header connect-timeout "%[be_connect_timeout] %[cur_connect_timeout]"
|
||||
http-after-response set-header queue-timeout "%[be_queue_timeout] %[cur_queue_timeout]"
|
||||
http-after-response set-header tunnel-timeout "%[be_tunnel_timeout] %[cur_tunnel_timeout]"
|
||||
http-after-response set-header tarpit-timeout "%[be_tarpit_timeout] %[cur_tarpit_timeout]"
|
||||
server srv_h1 ${srv_h1_addr}:${srv_h1_port}
|
||||
|
||||
listen li2
|
||||
mode http
|
||||
bind "fd@${li2}"
|
||||
http-request set-timeout client 3s
|
||||
http-request set-timeout server 3s
|
||||
http-request set-timeout connect 3s
|
||||
http-request set-timeout queue 3s
|
||||
http-request set-timeout tunnel 3s
|
||||
http-request set-timeout tarpit 3s
|
||||
http-after-response set-header client-timeout "%[fe_client_timeout] %[cur_client_timeout]"
|
||||
http-after-response set-header server-timeout "%[be_server_timeout] %[cur_server_timeout]"
|
||||
http-after-response set-header connect-timeout "%[be_connect_timeout] %[cur_connect_timeout]"
|
||||
http-after-response set-header queue-timeout "%[be_queue_timeout] %[cur_queue_timeout]"
|
||||
http-after-response set-header tunnel-timeout "%[be_tunnel_timeout] %[cur_tunnel_timeout]"
|
||||
http-after-response set-header tarpit-timeout "%[be_tarpit_timeout] %[cur_tarpit_timeout]"
|
||||
server srv_h1 ${srv_h1_addr}:${srv_h1_port}
|
||||
|
||||
listen li3
|
||||
mode http
|
||||
bind "fd@${li3}"
|
||||
http-request set-timeout client 3s
|
||||
http-request set-timeout server 3s
|
||||
http-request set-timeout connect 3s
|
||||
http-request set-timeout queue 3s
|
||||
http-request set-timeout tunnel 3s
|
||||
http-request set-timeout tarpit 3s
|
||||
http-after-response set-header client-timeout "%[fe_client_timeout] %[cur_client_timeout]"
|
||||
http-after-response set-header server-timeout "%[be_server_timeout] %[cur_server_timeout]"
|
||||
http-after-response set-header connect-timeout "%[be_connect_timeout] %[cur_connect_timeout]"
|
||||
http-after-response set-header queue-timeout "%[be_queue_timeout] %[cur_queue_timeout]"
|
||||
http-after-response set-header tunnel-timeout "%[be_tunnel_timeout] %[cur_tunnel_timeout]"
|
||||
http-after-response set-header tarpit-timeout "%[be_tarpit_timeout] %[cur_tarpit_timeout]"
|
||||
default_backend be1
|
||||
|
||||
listen li4
|
||||
mode http
|
||||
bind "fd@${li4}"
|
||||
http-request set-timeout client 3s
|
||||
http-request set-timeout server 4s
|
||||
http-request set-timeout connect 4s
|
||||
http-request set-timeout queue 4s
|
||||
http-request set-timeout tunnel 4s
|
||||
http-request set-timeout tarpit 4s
|
||||
http-after-response set-header client-timeout "%[fe_client_timeout] %[cur_client_timeout]"
|
||||
http-after-response set-header server-timeout "%[be_server_timeout] %[cur_server_timeout]"
|
||||
http-after-response set-header connect-timeout "%[be_connect_timeout] %[cur_connect_timeout]"
|
||||
http-after-response set-header queue-timeout "%[be_queue_timeout] %[cur_queue_timeout]"
|
||||
http-after-response set-header tunnel-timeout "%[be_tunnel_timeout] %[cur_tunnel_timeout]"
|
||||
http-after-response set-header tarpit-timeout "%[be_tarpit_timeout] %[cur_tarpit_timeout]"
|
||||
default_backend be2
|
||||
|
||||
frontend fe5
|
||||
mode http
|
||||
bind "fd@${fe5}"
|
||||
http-after-response set-header client-timeout "%[fe_client_timeout] %[cur_client_timeout]"
|
||||
http-after-response set-header server-timeout "%[be_server_timeout] %[cur_server_timeout]"
|
||||
http-after-response set-header connect-timeout "%[be_connect_timeout] %[cur_connect_timeout]"
|
||||
http-after-response set-header queue-timeout "%[be_queue_timeout] %[cur_queue_timeout]"
|
||||
http-after-response set-header tunnel-timeout "%[be_tunnel_timeout] %[cur_tunnel_timeout]"
|
||||
http-after-response set-header tarpit-timeout "%[be_tarpit_timeout] %[cur_tarpit_timeout]"
|
||||
default_backend be1
|
||||
|
||||
frontend fe6
|
||||
mode http
|
||||
bind "fd@${fe6}"
|
||||
http-request set-timeout client int(3),mul(1000)
|
||||
http-after-response set-header client-timeout "%[fe_client_timeout] %[cur_client_timeout]"
|
||||
http-after-response set-header server-timeout "%[be_server_timeout] %[cur_server_timeout]"
|
||||
http-after-response set-header connect-timeout "%[be_connect_timeout] %[cur_connect_timeout]"
|
||||
http-after-response set-header queue-timeout "%[be_queue_timeout] %[cur_queue_timeout]"
|
||||
http-after-response set-header tunnel-timeout "%[be_tunnel_timeout] %[cur_tunnel_timeout]"
|
||||
http-after-response set-header tarpit-timeout "%[be_tarpit_timeout] %[cur_tarpit_timeout]"
|
||||
default_backend be2
|
||||
|
||||
backend be1
|
||||
mode http
|
||||
server srv_h1 ${srv_h1_addr}:${srv_h1_port}
|
||||
|
||||
backend be2
|
||||
mode http
|
||||
http-request set-timeout server 3s
|
||||
http-request set-timeout connect 3s
|
||||
http-request set-timeout queue 3s
|
||||
http-request set-timeout tunnel 3s
|
||||
http-request set-timeout tarpit 3s
|
||||
server srv_h1 ${srv_h1_addr}:${srv_h1_port}
|
||||
|
||||
} -start
|
||||
|
||||
client c1 -connect ${hap_li1_sock} {
|
||||
txreq
|
||||
rxresp
|
||||
expect resp.status == 200
|
||||
expect resp.http.client-timeout == "5000 5000"
|
||||
expect resp.http.server-timeout == "5000 5000"
|
||||
expect resp.http.connect-timeout == "5000 5000"
|
||||
expect resp.http.queue-timeout == "5000 5000"
|
||||
expect resp.http.tunnel-timeout == "5000 5000"
|
||||
expect resp.http.tarpit-timeout == "5000 5000"
|
||||
} -run
|
||||
|
||||
client c2 -connect ${hap_li2_sock} {
|
||||
txreq
|
||||
rxresp
|
||||
expect resp.status == 200
|
||||
expect resp.http.client-timeout == "5000 3000"
|
||||
expect resp.http.server-timeout == "5000 3000"
|
||||
expect resp.http.connect-timeout == "5000 3000"
|
||||
expect resp.http.queue-timeout == "5000 3000"
|
||||
expect resp.http.tunnel-timeout == "5000 3000"
|
||||
expect resp.http.tarpit-timeout == "5000 3000"
|
||||
} -run
|
||||
|
||||
client c3 -connect ${hap_li3_sock} {
|
||||
txreq
|
||||
rxresp
|
||||
expect resp.status == 200
|
||||
expect resp.http.client-timeout == "5000 3000"
|
||||
expect resp.http.server-timeout == "5000 5000"
|
||||
expect resp.http.connect-timeout == "5000 5000"
|
||||
expect resp.http.queue-timeout == "5000 5000"
|
||||
expect resp.http.tunnel-timeout == "5000 5000"
|
||||
expect resp.http.tarpit-timeout == "5000 3000"
|
||||
} -run
|
||||
|
||||
client c4 -connect ${hap_li4_sock} {
|
||||
txreq
|
||||
rxresp
|
||||
expect resp.status == 200
|
||||
expect resp.http.client-timeout == "5000 3000"
|
||||
expect resp.http.server-timeout == "5000 3000"
|
||||
expect resp.http.connect-timeout == "5000 3000"
|
||||
expect resp.http.queue-timeout == "5000 3000"
|
||||
expect resp.http.tunnel-timeout == "5000 3000"
|
||||
expect resp.http.tarpit-timeout == "5000 3000"
|
||||
} -run
|
||||
|
||||
client c5 -connect ${hap_fe5_sock} {
|
||||
txreq
|
||||
rxresp
|
||||
expect resp.status == 200
|
||||
expect resp.http.client-timeout == "5000 5000"
|
||||
expect resp.http.server-timeout == "5000 5000"
|
||||
expect resp.http.connect-timeout == "5000 5000"
|
||||
expect resp.http.queue-timeout == "5000 5000"
|
||||
expect resp.http.tunnel-timeout == "5000 5000"
|
||||
expect resp.http.tarpit-timeout == "5000 5000"
|
||||
} -run
|
||||
|
||||
client c6 -connect ${hap_fe6_sock} {
|
||||
txreq
|
||||
rxresp
|
||||
expect resp.status == 200
|
||||
expect resp.http.client-timeout == "5000 3000"
|
||||
expect resp.http.server-timeout == "5000 3000"
|
||||
expect resp.http.connect-timeout == "5000 3000"
|
||||
expect resp.http.queue-timeout == "5000 3000"
|
||||
expect resp.http.tunnel-timeout == "5000 3000"
|
||||
expect resp.http.tarpit-timeout == "5000 3000"
|
||||
} -run
|
||||
|
|
@ -1,217 +0,0 @@
|
|||
varnishtest "http-request set-timeout test"
|
||||
|
||||
feature ignore_unknown_macro
|
||||
|
||||
server srv_h1 -repeat 9 {
|
||||
rxreq
|
||||
txresp
|
||||
} -start
|
||||
|
||||
syslog Slog1 -level info {
|
||||
recv
|
||||
expect ~ "^.*timeout: 5000 5000.*$"
|
||||
} -start
|
||||
|
||||
syslog Slog2 -level info {
|
||||
recv
|
||||
expect ~ "^.*timeout: 5000 5000.*$"
|
||||
} -start
|
||||
|
||||
syslog Slog3 -level info {
|
||||
recv
|
||||
expect ~ "^.*timeout: 5000 3000.*$"
|
||||
} -start
|
||||
|
||||
syslog Slog4 -level info {
|
||||
recv
|
||||
expect ~ "^.*timeout: 5000 5000.*$"
|
||||
} -start
|
||||
|
||||
syslog Slog5 -level info {
|
||||
recv
|
||||
expect ~ "^.*timeout: 5000 3000.*$"
|
||||
} -start
|
||||
|
||||
syslog Slog6 -level info {
|
||||
recv
|
||||
expect ~ "^.*timeout: 5000 5000.*$"
|
||||
} -start
|
||||
|
||||
syslog Slog7 -level info {
|
||||
recv
|
||||
expect ~ "^.*timeout: 5000 5000.*$"
|
||||
} -start
|
||||
|
||||
syslog Slog8 -level info {
|
||||
recv
|
||||
expect ~ "^.*timeout: 5000 3000.*$"
|
||||
} -start
|
||||
|
||||
syslog Slog9 -level info {
|
||||
recv
|
||||
expect ~ "^.*timeout: 5000 3000.*$"
|
||||
} -start
|
||||
|
||||
haproxy hap -conf {
|
||||
global
|
||||
.if feature(THREAD)
|
||||
thread-groups 1
|
||||
.endif
|
||||
|
||||
defaults
|
||||
timeout connect 5s
|
||||
timeout client 5s
|
||||
timeout server 5s
|
||||
log global
|
||||
|
||||
listen li1
|
||||
mode http
|
||||
bind "fd@${li1}"
|
||||
log-format "timeout: %[be_server_timeout] %[cur_server_timeout]"
|
||||
log ${Slog1_addr}:${Slog1_port} len 2048 local0 debug err
|
||||
server srv_h1 ${srv_h1_addr}:${srv_h1_port}
|
||||
|
||||
listen li2
|
||||
mode http
|
||||
bind "fd@${li2}"
|
||||
log-format "timeout: %[be_server_timeout] %[cur_server_timeout]"
|
||||
log ${Slog2_addr}:${Slog2_port} len 2048 local0 debug err
|
||||
http-request set-timeout server 5s
|
||||
server srv_h1 ${srv_h1_addr}:${srv_h1_port}
|
||||
|
||||
listen li3
|
||||
mode http
|
||||
bind "fd@${li3}"
|
||||
log-format "timeout: %[fe_client_timeout] %[cur_client_timeout]"
|
||||
log ${Slog4_addr}:${Slog4_port} len 2048 local0 debug err
|
||||
http-request set-timeout client 5s
|
||||
server srv_h1 ${srv_h1_addr}:${srv_h1_port}
|
||||
|
||||
frontend fe1
|
||||
mode http
|
||||
bind "fd@${fe1}"
|
||||
log-format "timeout: %[be_server_timeout] %[cur_server_timeout]"
|
||||
log ${Slog3_addr}:${Slog3_port} len 2048 local0 debug err
|
||||
default_backend be1
|
||||
|
||||
backend be1
|
||||
mode http
|
||||
http-request set-timeout server int(3),mul(1000)
|
||||
server srv_h1 ${srv_h1_addr}:${srv_h1_port}
|
||||
|
||||
frontend fe2
|
||||
mode http
|
||||
bind "fd@${fe2}"
|
||||
log-format "timeout: %[fe_client_timeout] %[cur_client_timeout]"
|
||||
log ${Slog5_addr}:${Slog5_port} len 2048 local0 debug err
|
||||
http-request set-timeout client int(3),mul(1000)
|
||||
default_backend be2
|
||||
|
||||
backend be2
|
||||
mode http
|
||||
server srv_h1 ${srv_h1_addr}:${srv_h1_port}
|
||||
|
||||
listen li4
|
||||
mode http
|
||||
bind "fd@${li4}"
|
||||
log-format "timeout: %[be_server_timeout] %[cur_server_timeout]"
|
||||
log ${Slog6_addr}:${Slog6_port} len 2048 local0 debug err
|
||||
http-response set-timeout server 5s
|
||||
server srv_h1 ${srv_h1_addr}:${srv_h1_port}
|
||||
|
||||
listen li5
|
||||
mode http
|
||||
bind "fd@${li5}"
|
||||
log-format "timeout: %[fe_client_timeout] %[cur_client_timeout]"
|
||||
log ${Slog7_addr}:${Slog7_port} len 2048 local0 debug err
|
||||
http-response set-timeout client 5s
|
||||
server srv_h1 ${srv_h1_addr}:${srv_h1_port}
|
||||
|
||||
frontend fe3
|
||||
mode http
|
||||
bind "fd@${fe3}"
|
||||
log-format "timeout: %[be_server_timeout] %[cur_server_timeout]"
|
||||
log ${Slog8_addr}:${Slog8_port} len 2048 local0 debug err
|
||||
default_backend be1
|
||||
|
||||
backend be3
|
||||
mode http
|
||||
http-response set-timeout server int(3),mul(1000)
|
||||
server srv_h1 ${srv_h1_addr}:${srv_h1_port}
|
||||
|
||||
frontend fe4
|
||||
mode http
|
||||
bind "fd@${fe4}"
|
||||
log-format "timeout: %[fe_client_timeout] %[cur_client_timeout]"
|
||||
log ${Slog9_addr}:${Slog9_port} len 2048 local0 debug err
|
||||
http-response set-timeout client int(3),mul(1000)
|
||||
default_backend be2
|
||||
|
||||
backend be4
|
||||
mode http
|
||||
server srv_h1 ${srv_h1_addr}:${srv_h1_port}
|
||||
} -start
|
||||
|
||||
client c1 -connect ${hap_li1_sock} {
|
||||
txreq
|
||||
rxresp
|
||||
expect resp.status == 200
|
||||
} -run
|
||||
|
||||
client c2 -connect ${hap_li2_sock} {
|
||||
txreq
|
||||
rxresp
|
||||
expect resp.status == 200
|
||||
} -run
|
||||
|
||||
client c3 -connect ${hap_fe1_sock} {
|
||||
txreq
|
||||
rxresp
|
||||
expect resp.status == 200
|
||||
} -run
|
||||
|
||||
client c4 -connect ${hap_li3_sock} {
|
||||
txreq
|
||||
rxresp
|
||||
expect resp.status == 200
|
||||
} -run
|
||||
|
||||
client c5 -connect ${hap_fe2_sock} {
|
||||
txreq
|
||||
rxresp
|
||||
expect resp.status == 200
|
||||
} -run
|
||||
|
||||
client c6 -connect ${hap_li4_sock} {
|
||||
txreq
|
||||
rxresp
|
||||
expect resp.status == 200
|
||||
} -run
|
||||
|
||||
client c7 -connect ${hap_fe3_sock} {
|
||||
txreq
|
||||
rxresp
|
||||
expect resp.status == 200
|
||||
} -run
|
||||
|
||||
client c8 -connect ${hap_li5_sock} {
|
||||
txreq
|
||||
rxresp
|
||||
expect resp.status == 200
|
||||
} -run
|
||||
|
||||
client c9 -connect ${hap_fe4_sock} {
|
||||
txreq
|
||||
rxresp
|
||||
expect resp.status == 200
|
||||
} -run
|
||||
|
||||
syslog Slog1 -wait
|
||||
syslog Slog2 -wait
|
||||
syslog Slog3 -wait
|
||||
syslog Slog4 -wait
|
||||
syslog Slog5 -wait
|
||||
syslog Slog6 -wait
|
||||
syslog Slog7 -wait
|
||||
syslog Slog8 -wait
|
||||
syslog Slog9 -wait
|
||||
Loading…
Reference in a new issue