blob: 4dc4bbe8808b3256baa7a6895a52d0aedbaacdde [file] [log] [blame]
Christopher Faulet16b37512021-04-07 14:37:07 +02001varnishtest "A test for the abortonclose option (H1 only)"
2feature ignore_unknown_macro
3
4# NOTE : This test may fail if too many vtest are running in parallel because
5# the port reserved for closed s1 server may be reused by another vtest
6
Tim Duesterhus5efc48d2021-06-11 19:56:15 +02007feature cmd "$HAPROXY_PROGRAM -cc 'version_atleast(2.5-dev0)'"
Christopher Faulet16b37512021-04-07 14:37:07 +02008#REGTEST_TYPE=slow
9
Christopher Faulet96816b02022-05-17 15:08:22 +020010# b0 : Wait s1 was detected as DOWN to be sure it is stopped
Christopher Faulet16b37512021-04-07 14:37:07 +020011# b1 : Don't send /c4 before /c3 was received by s2 server
12# b2 : Don't finish c2 before c1 and c3 before c4 (from syslog POV)
13# b3 : finish c3 before s2
14
Christopher Faulet96816b02022-05-17 15:08:22 +020015barrier b0 cond 2 -cyclic
Christopher Faulet16b37512021-04-07 14:37:07 +020016barrier b1 cond 2 -cyclic
17barrier b2 cond 2 -cyclic
18barrier b3 cond 2 -cyclic
19
20server s1 {
21} -start
22server s1 -break
23
24server s2 {
25 rxreq
26
27 # unlock c4
28 barrier b1 sync
29
30 # wait end of c3
31 barrier b3 sync
32
33 expect_close
34} -start
35
36syslog S -level info {
Christopher Faulet96816b02022-05-17 15:08:22 +020037 recv alert
38 expect ~ "[^:\\[ ]*\\[[0-9]*\\]: Server check/srv1 is DOWN.*"
39 barrier b0 sync
40
Christopher Faulet16b37512021-04-07 14:37:07 +020041 recv
Christopher Faulet96816b02022-05-17 15:08:22 +020042 expect ~ "[^:\\[ ]*\\[[0-9]*\\]: .* .* fe1 be1_1/srv1 [0-9]*/[0-9]*/-1/-1/[0-9]* 503 .* - - SC-- .* .* \"GET /c1 HTTP/1\\.1\""
Christopher Faulet16b37512021-04-07 14:37:07 +020043 barrier b2 sync
44 recv
Christopher Faulet96816b02022-05-17 15:08:22 +020045 expect ~ "[^:\\[ ]*\\[[0-9]*\\]: .* .* fe1 be1_2/srv1 [0-9]*/[0-9]*/-1/-1/[0-9]* -1 .* - - CC-- .* .* \"GET /c2 HTTP/1\\.1\""
Christopher Faulet16b37512021-04-07 14:37:07 +020046
47 recv
Christopher Faulet3b9cb602021-06-02 17:23:47 +020048 expect ~ "[^:\\[ ]*\\[[0-9]*\\]: .* .* fe2 be2/<NOSRV> [0-9]*/[0-9]*/-1/-1/[0-9]* -1 .* - - CQ-- .* .* \"GET /c4 HTTP/1\\.1\""
Christopher Faulet16b37512021-04-07 14:37:07 +020049 barrier b2 sync
50 recv
51 expect ~ "[^:\\[ ]*\\[[0-9]*\\]: .* .* fe2 be2/srv1 [0-9]*/[0-9]*/[0-9]*/-1/[0-9]* 400 .* - - CH-- .* .* \"GET /c3 HTTP/1\\.1\""
52} -start
53
54haproxy h1 -conf {
Willy Tarreaue1465c12021-05-09 14:41:41 +020055 global
56 # WT: limit false-positives causing "HTTP header incomplete" due to
57 # idle server connections being randomly used and randomly expiring
58 # under us.
59 tune.idle-pool.shared off
60
Christopher Faulet16b37512021-04-07 14:37:07 +020061 defaults
62 mode http
Christopher Faulet16b37512021-04-07 14:37:07 +020063 option abortonclose
Willy Tarreau419c1172021-11-18 17:15:59 +010064 retries 1
Christopher Faulet16b37512021-04-07 14:37:07 +020065 timeout client 10s
66 timeout server 10s
67 timeout connect 100ms
68 timeout queue 5s
69
70 frontend fe1
71 option httplog
72 log ${S_addr}:${S_port} local0 debug err
73 bind "fd@${fe1}"
Christopher Faulet96816b02022-05-17 15:08:22 +020074 use_backend be1_1 if { path /c1 }
75 use_backend be1_2 if { path /c2 }
Christopher Faulet16b37512021-04-07 14:37:07 +020076
77 frontend fe2
78 option httplog
79 log ${S_addr}:${S_port} local0 debug err
80 bind "fd@${fe2}"
81 use_backend be2
82
Christopher Faulet96816b02022-05-17 15:08:22 +020083 backend be1_1
84 server srv1 ${s1_addr}:${s1_port}
85
86 backend be1_2
87 timeout connect 1s
88 retries 10
Christopher Faulet16b37512021-04-07 14:37:07 +020089 server srv1 ${s1_addr}:${s1_port}
90
91 backend be2
92 server srv1 ${s2_addr}:${s2_port} maxconn 1
Christopher Faulet96816b02022-05-17 15:08:22 +020093
94 backend check
95 server srv1 ${s1_addr}:${s1_port} check
96 log ${S_addr}:${S_port} local0 debug alert
Christopher Faulet16b37512021-04-07 14:37:07 +020097} -start
98
Christopher Faulet96816b02022-05-17 15:08:22 +020099# Wait s1 was detected as DOWN
100barrier b0 sync
101
Christopher Faulet16b37512021-04-07 14:37:07 +0200102# No server, wait all connection retries : SC--
103client c1 -connect ${h1_fe1_sock} {
104 txreq -url /c1
Willy Tarreau1713eec2021-08-20 11:12:47 +0200105 rxresp
106 expect resp.status == 503
Christopher Faulet16b37512021-04-07 14:37:07 +0200107} -run
108
109# Wait c1 log entry
110barrier b2 sync
111
112# No server, abort during connections retries : CC--
113client c2 -connect ${h1_fe1_sock} {
114 txreq -url /c2
115} -run
116
117# server with maxconn=1, abort waiting the server reply : CH--
118client c3 -connect ${h1_fe2_sock} {
119 txreq -url /c3
120
121 # Wait c4 log entry
122 barrier b2 sync
123} -start
124
125# server with maxconn=1, abort waiting in the queue (c3 still attached) : CQ--
126client c4 -connect ${h1_fe2_sock} {
127 # Wait s2 receives c3 request
128 barrier b1 sync
129
130 txreq -url /c4
131 delay .2
132} -run
133
134client c3 -wait
135
136# unlock s2
137barrier b3 sync
138
139syslog S -wait