blob: ea57f3d6be19d5d0d2b49f639f2f5368305b2907 [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
Christopher Faulet6c903792023-11-14 09:03:15 +01007feature cmd "$HAPROXY_PROGRAM -cc 'version_atleast(2.2-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
Christopher Faulet6c903792023-11-14 09:03:15 +010012# b2 : Used to receive syslog messages in the right order
Christopher Faulet16b37512021-04-07 14:37:07 +020013# b3 : finish c3 before s2
14
Christopher Faulet6c903792023-11-14 09:03:15 +010015barrier b0 cond 3 -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
Christopher Faulet6c903792023-11-14 09:03:15 +010036syslog S1 -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 Faulet0f98a152022-06-02 13:56:00 +020046 barrier b2 sync
Christopher Faulet16b37512021-04-07 14:37:07 +020047 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
Christopher Faulet6c903792023-11-14 09:03:15 +010054syslog S2 -level info {
55 recv alert
56 expect ~ "[^:\\[ ]*\\[[0-9]*\\]: Server check/srv1 is DOWN.*"
57 barrier b0 sync
58
59 recv
60 expect ~ "[^:\\[ ]*\\[[0-9]*\\]: .* .* fe1 be1/srv1 [0-9]*/[0-9]*/-1/-1/[0-9]* -1 .* - - CC-- .* .* \"GET /c5 HTTP/1\\.1\""
61 barrier b2 sync
62 recv
63 expect ~ "[^:\\[ ]*\\[[0-9]*\\]: .* .* fe2 be2/srv1 [0-9]*/[0-9]*/-1/-1/[0-9]* 503 .* - - SC-- .* .* \"GET /c6 HTTP/1\\.1\""
64} -start
65
Christopher Faulet16b37512021-04-07 14:37:07 +020066haproxy h1 -conf {
Willy Tarreaue1465c12021-05-09 14:41:41 +020067 global
68 # WT: limit false-positives causing "HTTP header incomplete" due to
69 # idle server connections being randomly used and randomly expiring
70 # under us.
71 tune.idle-pool.shared off
72
Christopher Faulet16b37512021-04-07 14:37:07 +020073 defaults
74 mode http
Christopher Faulet16b37512021-04-07 14:37:07 +020075 option abortonclose
Willy Tarreau419c1172021-11-18 17:15:59 +010076 retries 1
Christopher Faulet16b37512021-04-07 14:37:07 +020077 timeout client 10s
78 timeout server 10s
79 timeout connect 100ms
80 timeout queue 5s
81
82 frontend fe1
83 option httplog
Christopher Faulet6c903792023-11-14 09:03:15 +010084 log ${S1_addr}:${S1_port} local0 debug err
Christopher Faulet16b37512021-04-07 14:37:07 +020085 bind "fd@${fe1}"
Christopher Faulet96816b02022-05-17 15:08:22 +020086 use_backend be1_1 if { path /c1 }
87 use_backend be1_2 if { path /c2 }
Christopher Faulet16b37512021-04-07 14:37:07 +020088
89 frontend fe2
90 option httplog
Christopher Faulet6c903792023-11-14 09:03:15 +010091 log ${S1_addr}:${S1_port} local0 debug err
Christopher Faulet16b37512021-04-07 14:37:07 +020092 bind "fd@${fe2}"
93 use_backend be2
94
Christopher Faulet96816b02022-05-17 15:08:22 +020095 backend be1_1
96 server srv1 ${s1_addr}:${s1_port}
97
98 backend be1_2
99 timeout connect 1s
100 retries 10
Christopher Faulet16b37512021-04-07 14:37:07 +0200101 server srv1 ${s1_addr}:${s1_port}
102
103 backend be2
104 server srv1 ${s2_addr}:${s2_port} maxconn 1
Christopher Faulet96816b02022-05-17 15:08:22 +0200105
106 backend check
107 server srv1 ${s1_addr}:${s1_port} check
Christopher Faulet6c903792023-11-14 09:03:15 +0100108 log ${S1_addr}:${S1_port} local0 debug alert
109} -start
110
111
112haproxy h2 -conf {
113 global
114 # WT: limit false-positives causing "HTTP header incomplete" due to
115 # idle server connections being randomly used and randomly expiring
116 # under us.
117 tune.idle-pool.shared off
118
119 defaults
120 mode http
121 retries 1
122 timeout client 10s
123 timeout server 10s
124 timeout connect 100ms
125 timeout queue 5s
126
127 frontend fe1
128 option httplog
129 log ${S2_addr}:${S2_port} local0 debug err
130 bind "fd@${fe1}"
131 use_backend be1
132
133 backend be1
134 option abortonclose
135 server srv1 ${s1_addr}:${s1_port}
136
137 defaults
138 mode http
139 option abortonclose
140 retries 1
141 timeout client 10s
142 timeout server 10s
143 timeout connect 100ms
144 timeout queue 5s
145
146 frontend fe2
147 option httplog
148 log ${S2_addr}:${S2_port} local0 debug err
149 bind "fd@${fe2}"
150 use_backend be2
151
152 backend be2
153 no option abortonclose
154 server srv1 ${s1_addr}:${s1_port}
155
156 backend check
157 server srv1 ${s1_addr}:${s1_port} check
158 log ${S2_addr}:${S2_port} local0 debug alert
Christopher Faulet16b37512021-04-07 14:37:07 +0200159} -start
160
Christopher Faulet6c903792023-11-14 09:03:15 +0100161
Christopher Faulet96816b02022-05-17 15:08:22 +0200162# Wait s1 was detected as DOWN
163barrier b0 sync
164
Christopher Faulet16b37512021-04-07 14:37:07 +0200165# No server, wait all connection retries : SC--
166client c1 -connect ${h1_fe1_sock} {
167 txreq -url /c1
Willy Tarreau1713eec2021-08-20 11:12:47 +0200168 rxresp
169 expect resp.status == 503
Christopher Faulet16b37512021-04-07 14:37:07 +0200170} -run
171
172# Wait c1 log entry
173barrier b2 sync
174
175# No server, abort during connections retries : CC--
176client c2 -connect ${h1_fe1_sock} {
177 txreq -url /c2
178} -run
179
Christopher Faulet0f98a152022-06-02 13:56:00 +0200180# Wait c2 log entry
181barrier b2 sync
182
Christopher Faulet16b37512021-04-07 14:37:07 +0200183# server with maxconn=1, abort waiting the server reply : CH--
184client c3 -connect ${h1_fe2_sock} {
185 txreq -url /c3
186
187 # Wait c4 log entry
188 barrier b2 sync
189} -start
190
191# server with maxconn=1, abort waiting in the queue (c3 still attached) : CQ--
192client c4 -connect ${h1_fe2_sock} {
193 # Wait s2 receives c3 request
194 barrier b1 sync
195
196 txreq -url /c4
197 delay .2
198} -run
199
200client c3 -wait
201
202# unlock s2
203barrier b3 sync
204
Christopher Faulet6c903792023-11-14 09:03:15 +0100205syslog S1 -wait
206
207
208# No server, abort during connections retries : CC--
209# abortonclose on backend only
210client c5 -connect ${h2_fe1_sock} {
211 txreq -url /c5
212} -run
213
214# Wait c5 log entry
215barrier b2 sync
216
217# No server, wait all connection retries : SC--
218# abortonclose in defaults section but disabled by backend
219client c6 -connect ${h2_fe2_sock} {
220 txreq -url /c6
221 rxresp
222 expect resp.status == 503
223} -run
224
225
226syslog S2 -wait