File: log_profiles.vtc

package info (click to toggle)
haproxy 3.2.11-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 23,928 kB
  • sloc: ansic: 268,119; sh: 3,466; xml: 1,756; python: 1,345; makefile: 1,155; perl: 168; cpp: 21
file content (285 lines) | stat: -rw-r--r-- 6,588 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
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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
varnishtest "Test log-profile feature"
feature cmd "$HAPROXY_PROGRAM -cc 'version_atleast(3.1-dev0)'"
feature ignore_unknown_macro

barrier b1 cond 4 -cyclic
barrier b2 cond 4 -cyclic
barrier b3 cond 3 -cyclic
barrier b4 cond 3 -cyclic
barrier b5 cond 2 -cyclic

server s1 {
    rxreq
	txresp
} -repeat 6 -start

syslog Slg1 -level info {
    recv
    #rfc5424, no profile and option httplog:
    expect ~ ".* haproxy ${h1_pid} .* \"GET / HTTP/1.1\""
    barrier b1 sync

    recv
    #rfc5424, no profile, tcp and option logasap
    expect ~ ".* haproxy ${h1_pid} .* \\+0"
    barrier b2 sync
} -start

syslog Slg2 -level info {
    recv
    #rfc5424, logprof1 httplog
    expect ~ ".* haproxy ${h1_pid} .* sdclose close"
    recv
    #rfc5424, logprof2 httplog
    expect ~ ".* custom ${h1_pid} .* - txn_close"
    barrier b1 sync

    recv
    #rfc5424, logprof1 tcp logasap
    expect ~ ".* haproxy ${h1_pid} .* \\+0"
    barrier b2 sync

    recv
    #rfc5424, logprof1 tcp
    expect ~ ".* haproxy ${h1_pid} .* sdclose close"
    barrier b3 sync
} -start

syslog Slg3 -level info {
    recv
    #rfc3164, logprof1 and option httplog
    expect ~ "[^:\\[ ]\\[${h1_pid}\\]: close"
    barrier b1 sync

    recv
    #rfc5424, logprof2, tcp and option logasap
    expect ~ ".* custom ${h1_pid} .* - txn_connect"
    barrier b2 sync

    recv
    #rfc5424, logprof2 tcp
    expect ~ ".* custom ${h1_pid} .* - txn_close"
    barrier b3 sync

    recv
    #rfc5424, logprof2, tcp error
    expect ~ ".* custom ${h1_pid} .* error"
    barrier b4 sync
} -start

syslog Slg4 -level info {
    recv
    #rfc5424, logprof3, tcp error (other steps should be dropped)
    expect ~ ".* haproxy ${h1_pid} .* error"
    barrier b4 sync
} -start

syslog Slg5 -level info {
    #rfc5424, logprof4, http connect, close
    recv
    expect ~ ".* haproxy ${h1_pid} .* connect"
    recv
    expect ~ ".* haproxy ${h1_pid} .* close"
    barrier b5 sync

    #rfc5424, logprof4, http all steps
    recv
    expect ~ ".* haproxy ${h1_pid} .* accept"
    recv
    expect ~ ".* haproxy ${h1_pid} .* request"
    recv
    expect ~ ".* haproxy ${h1_pid} .* connect"
    recv
    expect ~ ".* haproxy ${h1_pid} .* response"
    recv
    expect ~ ".* haproxy ${h1_pid} .* close"
} -start

syslog Slg6 -level info {
    #rfc5424, logprof5:
    # tcp-req-conn, http-req, http-res, http-after-res, txn.close
    recv
    expect ~ ".* haproxy ${h1_pid} .* start:tcp-req-conn"
    recv
    expect ~ ".* haproxy ${h1_pid} .* http-req"
    recv
    expect ~ ".* haproxy ${h1_pid} .* http-res"
    recv
    expect ~ ".* haproxy ${h1_pid} .* http-after-res"
    recv
    expect ~ ".* haproxy ${h1_pid} .* txn_close"
} -start

haproxy h1 -conf {
	defaults
		timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
		timeout client  "${HAPROXY_TEST_TIMEOUT-5s}"
		timeout server  "${HAPROXY_TEST_TIMEOUT-5s}"
		log-tag "haproxy"

	frontend fe1
		bind "fd@${fe_1}"
		mode http
		option httplog
		log udp@${Slg1_addr}:${Slg1_port} format rfc5424 local0
		log udp@${Slg2_addr}:${Slg2_port} format rfc5424 profile logprof1 local0
		log udp@${Slg2_addr}:${Slg2_port} format rfc5424 profile logprof2 local0
		log udp@${Slg3_addr}:${Slg3_port} format rfc3164 profile logprof1 local0

		default_backend be

	frontend fe2
		bind "fd@${fe_2}"
		mode tcp
		log-format "%B"
		option logasap
		log udp@${Slg1_addr}:${Slg1_port} format rfc5424 local0
		log udp@${Slg2_addr}:${Slg2_port} format rfc5424 profile logprof1 local0
		log udp@${Slg3_addr}:${Slg3_port} format rfc5424 profile logprof2 local0
		log udp@${Slg4_addr}:${Slg4_port} format rfc5424 profile logprof3 local0

		default_backend be_tcp

	frontend fe3
		bind "fd@${fe_3}"
		mode tcp
		log-format "%B"
		log udp@${Slg2_addr}:${Slg2_port} format rfc5424 profile logprof1 local0
		log udp@${Slg3_addr}:${Slg3_port} format rfc5424 profile logprof2 local0

		default_backend be_tcp

	listen fe4
		bind "fd@${fe_4}"
		timeout client 5ms
		mode http
		log-format "%B"
		log udp@${Slg3_addr}:${Slg3_port} format rfc5424 profile logprof2 local0
		log udp@${Slg4_addr}:${Slg4_port} format rfc5424 profile logprof3 local0

	listen fe5
		bind "fd@${fe_5}"
		mode http
		log-format "dummy"
		log-steps connect,close
		log udp@${Slg5_addr}:${Slg5_port} format rfc5424 profile logprof4 local0
		default_backend be

	listen fe6
		bind "fd@${fe_6}"
		mode http
		log-format "dummy"
		log-steps all
		log udp@${Slg5_addr}:${Slg5_port} format rfc5424 profile logprof4 local0
		default_backend be

	listen fe7
		bind "fd@${fe_7}"
		mode http
		log-format "dummy"
		log-steps close
		log udp@${Slg6_addr}:${Slg6_port} format rfc5424 profile logprof5 local0
		default_backend be

		tcp-request connection do-log
		http-request do-log
		http-response do-log
		http-after-response do-log

	log-profile logprof1
		on close format "close" sd "sdclose"

	log-profile logprof2
		log-tag "custom"
		on error format "error"
		on any format "%OG"

	log-profile logprof3
		on error format "error"
		on any drop

	log-profile logprof4
		on accept format "accept"
		on request format "request"
		on connect format "connect"
		on response format "response"
		on close format "close"

	log-profile logprof5
                on tcp-req-conn format "start:tcp-req-conn"
                on any format "%OG"

	backend be
		mode http
		server app1 ${s1_addr}:${s1_port}

	backend be_tcp
		mode tcp
		server app1 ${s1_addr}:${s1_port}


} -start

# requests generators (to trigger log emission)

client c1 -connect ${h1_fe_1_sock} {
    txreq -url "/"
    rxresp
    expect resp.status == 200
} -start -wait

# Wait matching log messages
barrier b1 sync

client c2 -connect ${h1_fe_2_sock} {
    txreq -url "/"
    rxresp
    expect resp.status == 200
} -start -wait

# Wait matching log messages
barrier b2 sync

client c3 -connect ${h1_fe_3_sock} {
    txreq -url "/"
    rxresp
    expect resp.status == 200
} -start -wait

# Wait matching log messages
barrier b3 sync

client c4 -connect ${h1_fe_4_sock} {
    # do nothing to trigger an error (fe_4 timeouts after 5ms)
} -start -wait

# Wait matching log messages
barrier b4 sync

client c5 -connect ${h1_fe_5_sock} {
    txreq -url "/"
    rxresp
    expect resp.status == 200
} -start -wait

# Wait matching log messages
barrier b5 sync

client c6 -connect ${h1_fe_6_sock} {
    txreq -url "/"
    rxresp
    expect resp.status == 200
} -start -wait

client c7 -connect ${h1_fe_7_sock} {
    txreq -url "/"
    rxresp
    expect resp.status == 200
} -start -wait

syslog Slg1 -wait
syslog Slg2 -wait
syslog Slg3 -wait
syslog Slg4 -wait
syslog Slg5 -wait
syslog Slg6 -wait