File: http_reuse_be_transparent.vtc

package info (click to toggle)
haproxy 3.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 24,584 kB
  • sloc: ansic: 275,085; sh: 3,607; xml: 1,756; python: 1,345; makefile: 1,162; perl: 168; cpp: 21
file content (200 lines) | stat: -rw-r--r-- 4,661 bytes parent folder | download
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
varnishtest "Test the proper interaction between http-reuse and backend in transparent mode"
feature cmd "$HAPROXY_PROGRAM -cc 'feature(TPROXY)'"

# Verify that connections made to a backend in transparent mode with
# "http-reuse never" are only reused with that client, and those with
# "http-reuse always" are properly shared across subsequent clients.

feature ignore_unknown_macro

haproxy h1 -conf {
	global
    .if feature(THREAD)
        thread-groups 1
    .endif

		nbthread 1

	defaults
		timeout client 30s
		timeout server 30s
		timeout connect 30s
		mode http

	listen never
		bind "fd@${feN}"
		http-reuse never

		http-request set-dst hdr(dst)
		http-request set-dst-port hdr(dst-port)

		http-after-response set-header http_reuse %[bc_reused]
		server transparent 0.0.0.0

	listen always
		bind "fd@${feA}"
		http-reuse always

		http-request set-dst hdr(dst)
		http-request set-dst-port hdr(dst-port)

		http-after-response set-header http_reuse %[bc_reused]
		server transparent 0.0.0.0 pool-max-conn 10

	listen srv1
		bind "fd@${fes1}"
		http-request add-header srv-id s1
		http-request return status 200 hdr srv-id s1

	listen srv2
		bind "fd@${fes2}"
		http-request add-header srv-id s2
		http-request return status 200 hdr srv-id s2
} -start

### now the test in http-reuse never mode
# 1,1,1
client c1 -connect ${h1_feN_sock} {
	txreq -url /c1-1 \
	  -hdr "dst: ${h1_fes1_addr}" \
	  -hdr "dst-port: ${h1_fes1_port}"
	rxresp
	expect resp.http.http_reuse == "0"
	expect resp.http.srv-id == "s1"

	txreq -url /c1-2 \
	  -hdr "dst: ${h1_fes1_addr}" \
	  -hdr "dst-port: ${h1_fes1_port}"
	rxresp
	expect resp.http.http_reuse == "1"
	expect resp.http.srv-id == "s1"

	txreq -url /c1-3 \
	  -hdr "dst: ${h1_fes1_addr}" \
	  -hdr "dst-port: ${h1_fes1_port}"
	rxresp
	expect resp.http.http_reuse == "1"
	expect resp.http.srv-id == "s1"
} -run

# 2,1,2
client c2 -connect ${h1_feN_sock} {
	txreq -url /c2-1 \
	  -hdr "dst: ${h1_fes2_addr}" \
	  -hdr "dst-port: ${h1_fes2_port}"
	rxresp
	expect resp.http.http_reuse == "0"
	expect resp.http.srv-id == "s2"

	txreq -url /c2-2 \
	  -hdr "dst: ${h1_fes1_addr}" \
	  -hdr "dst-port: ${h1_fes1_port}"
	rxresp
	expect resp.http.http_reuse == "0"
	expect resp.http.srv-id == "s1"

	txreq -url /c2-3 \
	  -hdr "dst: ${h1_fes2_addr}" \
	  -hdr "dst-port: ${h1_fes2_port}"
	rxresp
	expect resp.http.http_reuse == "1"
	expect resp.http.srv-id == "s2"
} -run

# 1,1,2
client c3 -connect ${h1_feN_sock} {
	txreq -url /c3-1 \
	  -hdr "dst: ${h1_fes1_addr}" \
	  -hdr "dst-port: ${h1_fes1_port}"
	rxresp
	expect resp.http.http_reuse == "0"
	expect resp.http.srv-id == "s1"

	txreq -url /c3-2 \
	  -hdr "dst: ${h1_fes1_addr}" \
	  -hdr "dst-port: ${h1_fes1_port}"
	rxresp
	expect resp.http.http_reuse == "1"
	expect resp.http.srv-id == "s1"

	txreq -url /c3-3 \
	  -hdr "dst: ${h1_fes2_addr}" \
	  -hdr "dst-port: ${h1_fes2_port}"
	rxresp
	expect resp.http.http_reuse == "0"
	expect resp.http.srv-id == "s2"
} -run

### now the test in http-reuse safe mode

# 1,1,1
client c4 -connect ${h1_feA_sock} {
	txreq -url /c4-1 \
	  -hdr "dst: ${h1_fes1_addr}" \
	  -hdr "dst-port: ${h1_fes1_port}"
	rxresp
	expect resp.http.http_reuse == "0"
	expect resp.http.srv-id == "s1"

	txreq -url /c4-2 \
	  -hdr "dst: ${h1_fes1_addr}" \
	  -hdr "dst-port: ${h1_fes1_port}"
	rxresp
	expect resp.http.http_reuse == "1"
	expect resp.http.srv-id == "s1"

	txreq -url /c4-3 \
	  -hdr "dst: ${h1_fes1_addr}" \
	  -hdr "dst-port: ${h1_fes1_port}"
	rxresp
	expect resp.http.http_reuse == "1"
	expect resp.http.srv-id == "s1"
} -run

# 2,1,2
client c5 -connect ${h1_feA_sock} {
	txreq -url /c5-1 \
	  -hdr "dst: ${h1_fes2_addr}" \
	  -hdr "dst-port: ${h1_fes2_port}"
	rxresp
	expect resp.http.http_reuse == "0"
	expect resp.http.srv-id == "s2"

	txreq -url /c5-2 \
	  -hdr "dst: ${h1_fes1_addr}" \
	  -hdr "dst-port: ${h1_fes1_port}"
	rxresp
	expect resp.http.http_reuse == "1"
	expect resp.http.srv-id == "s1"

	txreq -url /c5-3 \
	  -hdr "dst: ${h1_fes2_addr}" \
	  -hdr "dst-port: ${h1_fes2_port}"
	rxresp
	expect resp.http.http_reuse == "0"
	expect resp.http.srv-id == "s2"
} -run

# 1,1,2
client c6 -connect ${h1_feA_sock} {
	txreq -url /c6-1 \
	  -hdr "dst: ${h1_fes1_addr}" \
	  -hdr "dst-port: ${h1_fes1_port}"
	rxresp
	expect resp.http.http_reuse == "1"
	expect resp.http.srv-id == "s1"

	txreq -url /c6-2 \
	  -hdr "dst: ${h1_fes1_addr}" \
	  -hdr "dst-port: ${h1_fes1_port}"
	rxresp
	expect resp.http.http_reuse == "1"
	expect resp.http.srv-id == "s1"

	txreq -url /c6-3 \
	  -hdr "dst: ${h1_fes2_addr}" \
	  -hdr "dst-port: ${h1_fes2_port}"
	rxresp
	expect resp.http.http_reuse == "0"
	expect resp.http.srv-id == "s2"
} -run