blob: 767a18565588eda0920c251e21f4453548ae5d7d [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 Faulet3d1da9a2022-06-07 08:20:12 +02007feature cmd "$HAPROXY_PROGRAM -cc 'version_atleast(2.0-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 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
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
Christopher Faulet0f98a152022-06-02 13:56:00 +0200117# Wait c2 log entry
118barrier b2 sync
119
Christopher Faulet16b37512021-04-07 14:37:07 +0200120# server with maxconn=1, abort waiting the server reply : CH--
121client c3 -connect ${h1_fe2_sock} {
122 txreq -url /c3
123
124 # Wait c4 log entry
125 barrier b2 sync
126} -start
127
128# server with maxconn=1, abort waiting in the queue (c3 still attached) : CQ--
129client c4 -connect ${h1_fe2_sock} {
130 # Wait s2 receives c3 request
131 barrier b1 sync
132
133 txreq -url /c4
134 delay .2
135} -run
136
137client c3 -wait
138
139# unlock s2
140barrier b3 sync
141
142syslog S -wait