summaryrefslogtreecommitdiffstats
path: root/reg-tests/http-messaging/http_abortonclose.vtc
blob: ea57f3d6be19d5d0d2b49f639f2f5368305b2907 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
varnishtest "A test for the abortonclose option (H1 only)"
feature ignore_unknown_macro

# NOTE : This test may fail if too many vtest are running in parallel because
#        the port reserved for closed s1 server may be reused by another vtest

feature cmd "$HAPROXY_PROGRAM -cc 'version_atleast(2.2-dev0)'"
#REGTEST_TYPE=slow

# b0 : Wait s1 was detected as DOWN to be sure it is stopped
# b1 : Don't send /c4 before /c3 was received by s2 server
# b2 : Used to receive syslog messages in the right order
# b3 : finish c3 before s2

barrier b0 cond 3 -cyclic
barrier b1 cond 2 -cyclic
barrier b2 cond 2 -cyclic
barrier b3 cond 2 -cyclic

server s1 {
} -start
server s1 -break

server s2 {
    rxreq

    # unlock c4
    barrier b1 sync

    # wait end of c3
    barrier b3 sync

    expect_close
} -start

syslog S1 -level info {
    recv alert
    expect ~ "[^:\\[ ]*\\[[0-9]*\\]: Server check/srv1 is DOWN.*"
    barrier b0 sync

    recv
    expect ~ "[^:\\[ ]*\\[[0-9]*\\]: .* .* fe1 be1_1/srv1 [0-9]*/[0-9]*/-1/-1/[0-9]* 503 .* - - SC-- .* .* \"GET /c1 HTTP/1\\.1\""
    barrier b2 sync
    recv
    expect ~ "[^:\\[ ]*\\[[0-9]*\\]: .* .* fe1 be1_2/srv1 [0-9]*/[0-9]*/-1/-1/[0-9]* -1 .* - - CC-- .* .* \"GET /c2 HTTP/1\\.1\""
    barrier b2 sync
    recv
    expect ~ "[^:\\[ ]*\\[[0-9]*\\]: .* .* fe2 be2/<NOSRV> [0-9]*/[0-9]*/-1/-1/[0-9]* -1 .* - - CQ-- .* .* \"GET /c4 HTTP/1\\.1\""
    barrier b2 sync
    recv
    expect ~ "[^:\\[ ]*\\[[0-9]*\\]: .* .* fe2 be2/srv1 [0-9]*/[0-9]*/[0-9]*/-1/[0-9]* 400 .* - - CH-- .* .* \"GET /c3 HTTP/1\\.1\""
} -start

syslog S2 -level info {
    recv alert
    expect ~ "[^:\\[ ]*\\[[0-9]*\\]: Server check/srv1 is DOWN.*"
    barrier b0 sync

    recv
    expect ~ "[^:\\[ ]*\\[[0-9]*\\]: .* .* fe1 be1/srv1 [0-9]*/[0-9]*/-1/-1/[0-9]* -1 .* - - CC-- .* .* \"GET /c5 HTTP/1\\.1\""
    barrier b2 sync
    recv
    expect ~ "[^:\\[ ]*\\[[0-9]*\\]: .* .* fe2 be2/srv1 [0-9]*/[0-9]*/-1/-1/[0-9]* 503 .* - - SC-- .* .* \"GET /c6 HTTP/1\\.1\""
} -start

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
        option abortonclose
        retries 1
        timeout client  10s
        timeout server  10s
        timeout connect 100ms
        timeout queue   5s

    frontend fe1
        option httplog
        log ${S1_addr}:${S1_port} local0 debug err
        bind "fd@${fe1}"
        use_backend be1_1 if { path /c1 }
        use_backend be1_2 if { path /c2 }

    frontend fe2
        option httplog
        log ${S1_addr}:${S1_port} local0 debug err
        bind "fd@${fe2}"
        use_backend be2

    backend be1_1
        server srv1 ${s1_addr}:${s1_port}

    backend be1_2
        timeout connect 1s
        retries 10
        server srv1 ${s1_addr}:${s1_port}

    backend be2
        server srv1 ${s2_addr}:${s2_port} maxconn 1

    backend check
        server srv1 ${s1_addr}:${s1_port} check
        log ${S1_addr}:${S1_port} local0 debug alert
} -start


haproxy h2 -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
        retries 1
        timeout client  10s
        timeout server  10s
        timeout connect 100ms
        timeout queue   5s

    frontend fe1
        option httplog
        log ${S2_addr}:${S2_port} local0 debug err
        bind "fd@${fe1}"
        use_backend be1

    backend be1
        option abortonclose
        server srv1 ${s1_addr}:${s1_port}

    defaults
        mode http
        option abortonclose
        retries 1
        timeout client  10s
        timeout server  10s
        timeout connect 100ms
        timeout queue   5s

    frontend fe2
        option httplog
        log ${S2_addr}:${S2_port} local0 debug err
        bind "fd@${fe2}"
        use_backend be2

    backend be2
        no option abortonclose
        server srv1 ${s1_addr}:${s1_port}

    backend check
        server srv1 ${s1_addr}:${s1_port} check
        log ${S2_addr}:${S2_port} local0 debug alert
} -start


# Wait s1 was detected as DOWN
barrier b0 sync

# No server, wait all connection retries : SC--
client  c1 -connect ${h1_fe1_sock} {
    txreq -url /c1
    rxresp
    expect resp.status == 503
} -run

# Wait c1 log entry
barrier b2 sync

# No server, abort during connections retries : CC--
client  c2 -connect ${h1_fe1_sock} {
    txreq -url /c2
} -run

# Wait c2 log entry
barrier b2 sync

# server with maxconn=1, abort waiting the server reply : CH--
client  c3 -connect ${h1_fe2_sock} {
    txreq -url /c3

    # Wait c4 log entry
    barrier b2 sync
} -start

# server with maxconn=1, abort waiting in the queue (c3 still attached) : CQ--
client  c4 -connect ${h1_fe2_sock} {
    # Wait s2 receives c3 request
    barrier b1 sync

    txreq -url /c4
    delay .2
} -run

client c3 -wait

# unlock s2
barrier b3 sync

syslog S1 -wait


# No server, abort during connections retries : CC--
# abortonclose on backend only
client  c5 -connect ${h2_fe1_sock} {
    txreq -url /c5
} -run

# Wait c5 log entry
barrier b2 sync

# No server, wait all connection retries : SC--
# abortonclose in defaults section but disabled by backend
client  c6 -connect ${h2_fe2_sock} {
    txreq -url /c6
    rxresp
    expect resp.status == 503
} -run


syslog S2 -wait