blob: 68845997810c5241be141f214bc82f47e37d7294 [file] [log] [blame]
Frédéric Lécaillefd9655c2018-06-07 14:57:30 +02001 +---------------------------------------------+
2 | HAProxy regression testing with varnishtest |
3 +---------------------------------------------+
4
5
6The information found in this file are a short starting guide to help you to
7write VTC (Varnish Test Case) scripts (or VTC files) for haproxy regression testing.
8Such VTC files are currently used to test Varnish cache application developed by
9Poul-Henning Kamp. A very big thanks you to him for having helped you to add
10our haproxy C modules to varnishtest tool.
11
12A lot of general information about how to write VTC files may be found in 'man/vtc.7'
13manual. It is *highly* recommended to read this manual before asking. This
14documentation only deals with the varnishtest support for haproxy.
15
16
17varnishtest installation
18------------------------
19
20To use varnishtest you will have to download and compile the recent Varnish cache
21sources found at https://github.com/varnishcache/varnish-cache.
22
23To compile Varnish cache :
24
25 $ ./autogen.sh
26 $ ./configure
27 $ make
28
29The varnishtest sources may be found in 'bin/varnishtest' directory.
30'bin/varnishtest/tests' is plenty of VTC files for Varnish cache. After having
31compiled these sources, the varnishtest executable location is
32'bin/varnishtest/varnishtest'.
33
34varnishtest is able to search for the haproxy executable file it is supposed to
35launch in the PATH environment variable. To force the executable to be used by
36varnishtest, the HAPROXY_PROGRAM environment variable for varnishtest may be
37typically set as follows:
38
39 $ HAPROXY_PROGRAM=~/srcs/haproxy/haproxy varnishtest ...
40
41
42varnistest exectution
43---------------------
44
45varnishtest program comes with interesting options. The most interesting are:
46
47 -t Timeout in seconds to abort the test if some launched program
48 -v By default, varnishtest does not dump the outputs of processus it launched
49 when the test passes. With this option the outputs are dumped even
50 when the test passes.
51 -L to always keep the temporary VTC directories.
52 -l to keep the temporary VTC directories only when the test fails.
53
54About haproxy when launched by varnishtest, -d option is enabled by default.
55
56
57How to write VTC files
58----------------------
59
60A VTC file must start with a "varnishtest" command line followed by a descriptive
61line enclosed by double quotes. This is not specific to the VTC files for haproxy.
62
63The VTC files for haproxy must also contain a "feature ignore_unknown_macro" line
64if any macro is used for haproxy in this file. This is due to the fact that
65varnishtest parser code for haproxy commands generates macros the varnishtest
66parser code for varnish has no knowledge of. This line prevents varnishtest from
67failing in such cases.
68
69To make varnishtest capable of testing haproxy, two new VTC commands have been
70implemented: "haproxy" and "syslog". "haproxy" is used to start haproxy processus.
71"syslog" is used to start syslog servers (at this time, only used by haproxy).
72
73As haproxy cannot work without configuration file, a VTC file for haproxy must
74embed the configuration files contents for the haproxy instances it declares.
75This may be done using the following intuitive syntax construction: -conf {...}.
76Here -conf is an argument of "haproxy" VTC command to declare the configuration
77file of the haproxy instances it also declares (see "Basic HAProxy test" VTC file
78below).
79
80As for varnish VTC files, the parser of VTC files for haproxy automatically
81generates macros for the declared frontends to be reused by the clients later
82in the script, so after having written the "haproxy" command sections.
83The syntax "fd@${my_frontend_fd_name}" must be used to bind the frontend
84listeners to localhost address and random ports (see "Environment variables"
85section of haproxy documentation). This is mandatory.
86
87Each time the haproxy command parser finds a "fd@${xyz}" string in a 'ABC'
88"haproxy" command section, it generates three macros: 'ABC_xyz_addr', 'ABC_xyz_port'
89and 'ABC_xyz_sock', with 'ABC_xyz_sock' being resolved as 'ABC_xyz_addr
90ABC_xyz_port' typically used by clients -connect parameter.
91
92Each haproxy instance works in their own temporary working directories located
93at '/tmp/vtc.<varnitest PID>.XXXXXXXX/<haproxy_instance_name>' (with XXXXXXXX
94a random 8 digits hexadecimal integer. This is in this temporary directory that
95the configuration file is temporarily written.
96
97A 'stats.sock' UNIX socket is also created in this directory. There is no need
98to declare such stats sockets in the -conf {...} section. The name of the parent
99directory of the haproxy instances working directories is stored in 'tmpdir'. In
100fact this is the working directory of the current varnishtest processus.
101
102There also exists 'testdir' macro which is the parent directory of the VTC file.
103It may be useful to use other files located in the same directory than the current
104VTC file.
105
106
107
108VTC file examples
109-----------------
110
111The following first VTC file is a real regression test case file for a bug which has
112been fixed by 84c844e commit. We declare a basic configuration for a 'h1' haproxy
113instance.
114
115 varnishtest "SPOE bug: missing configuration file"
116
117 #commit 84c844eb12b250aa86f2aadaff77c42dfc3cb619
118 #Author: Christopher Faulet <cfaulet@haproxy.com>
119 #Date: Fri Mar 23 14:37:14 2018 +0100
120
121 # BUG/MINOR: spoe: Initialize variables used during conf parsing before any check
122
123 # Some initializations must be done at the beginning of parse_spoe_flt to avoid
124 # segmentaion fault when first errors are catched, when the "filter spoe" line is
125 # parsed.
126
127 haproxy h1 -conf-BAD {} {
128 defaults
129 timeout connect 5000ms
130 timeout client 50000ms
131 timeout server 50000ms
132
133 frontend my-front
134 filter spoe
135 }
136
137
138-conf-BAD haproxy command argument is used. Its role it to launch haproxy with
139-c option (configuration file checking) and check that 'h1' exit(3) with 1 as
140status. Here is the output when running this VTC file:
141
142
143 **** top 0.0 extmacro def pwd=/home/fred/src/haproxy
144 **** top 0.0 extmacro def localhost=127.0.0.1
145 **** top 0.0 extmacro def bad_backend=127.0.0.1 39564
146 **** top 0.0 extmacro def bad_ip=192.0.2.255
147 **** top 0.0 macro def testdir=//home/fred/src/varnish-cache-haproxy
148 **** top 0.0 macro def tmpdir=/tmp/vtc.6377.64329194
149 * top 0.0 TEST /home/fred/src/varnish-cache-haproxy/spoe_bug.vtc starting
150 ** top 0.0 === varnishtest "SPOE bug: missing configuration file"
151 * top 0.0 TEST SPOE bug: missing configuration file
152 ** top 0.0 === haproxy h1 -conf-BAD {} {
153 **** h1 0.0 conf| global
154 **** h1 0.0 conf|\tstats socket /tmp/vtc.6377.64329194/h1/stats.sock level admin mode 600
155 **** h1 0.0 conf|
156 **** h1 0.0 conf|\tdefaults
157 **** h1 0.0 conf| timeout connect 5000ms
158 **** h1 0.0 conf| timeout client 50000ms
159 **** h1 0.0 conf| timeout server 50000ms
160 **** h1 0.0 conf|
161 **** h1 0.0 conf|\tfrontend my-front
162 **** h1 0.0 conf|\t\tfilter spoe
163 **** h1 0.0 conf|
164 ** h1 0.0 haproxy_start
165 **** h1 0.0 opt_worker 0 opt_daemon 0 opt_check_mode 1
166 **** h1 0.0 argv|exec /home/fred/src/haproxy/haproxy -c -f /tmp/vtc.6377.64329194/h1/cfg
167 **** h1 0.0 XXX 5 @277
168 *** h1 0.0 PID: 6395
169 **** h1 0.0 macro def h1_pid=6395
170 **** h1 0.0 macro def h1_name=/tmp/vtc.6377.64329194/h1
171 ** h1 0.0 Wait
172 ** h1 0.0 Stop HAproxy pid=6395
173 **** h1 0.0 STDOUT poll 0x10
174 ** h1 0.0 WAIT4 pid=6395 status=0x008b (user 0.000000 sys 0.000000)
175 * h1 0.0 Expected exit: 0x1 signal: 0 core: 0
176 ---- h1 0.0 Bad exit status: 0x008b exit 0x0 signal 11 core 128
177 * top 0.0 RESETTING after /home/fred/src/varnish-cache-haproxy/spoe_bug.vtc
178 ** h1 0.0 Reset and free h1 haproxy 6395
179 ** h1 0.0 Wait
180 ---- h1 0.0 Assert error in haproxy_wait(), vtc_haproxy.c line 326: Condition(*(&h->fds[1]) >= 0) not true.
181
182 * top 0.0 failure during reset
183 # top TEST /home/fred/src/varnish-cache-haproxy/spoe_bug.vtc FAILED (0.008) exit=2
184
185
186'h1' exited with (128 + 11) status and a core file was produced in
187/tmp/vtc.6377.64329194/h1 directory.
188With the patch provided by 84c844e commit, varnishtest makes this VTC file pass
189as expected (verbose mode execution):
190
191 **** top 0.0 extmacro def pwd=/home/fred/src/haproxy
192 **** top 0.0 extmacro def localhost=127.0.0.1
193 **** top 0.0 extmacro def bad_backend=127.0.0.1 42264
194 **** top 0.0 extmacro def bad_ip=192.0.2.255
195 **** top 0.0 macro def testdir=//home/fred/src/varnish-cache-haproxy
196 **** top 0.0 macro def tmpdir=/tmp/vtc.25540.59b6ec5d
197 * top 0.0 TEST /home/fred/src/varnish-cache-haproxy/spoe_bug.vtc starting
198 ** top 0.0 === varnishtest "SPOE bug: missing configuration file"
199 * top 0.0 TEST SPOE bug: missing configuration file
200 ** top 0.0 === haproxy h1 -conf-BAD {} {
201 **** h1 0.0 conf| global
202 **** h1 0.0 conf|\tstats socket /tmp/vtc.25540.59b6ec5d/h1/stats.sock level admin mode 600
203 **** h1 0.0 conf|
204 **** h1 0.0 conf|\tdefaults
205 **** h1 0.0 conf| timeout connect 5000ms
206 **** h1 0.0 conf| timeout client 50000ms
207 **** h1 0.0 conf| timeout server 50000ms
208 **** h1 0.0 conf|
209 **** h1 0.0 conf|\tfrontend my-front
210 **** h1 0.0 conf|\t\tfilter spoe
211 **** h1 0.0 conf|
212 ** h1 0.0 haproxy_start
213 **** h1 0.0 opt_worker 0 opt_daemon 0 opt_check_mode 1
214 **** h1 0.0 argv|exec /home/fred/src/haproxy/haproxy -c -f /tmp/vtc.25540.59b6ec5d/h1/cfg
215 **** h1 0.0 XXX 5 @277
216 *** h1 0.0 PID: 25558
217 **** h1 0.0 macro def h1_pid=25558
218 **** h1 0.0 macro def h1_name=/tmp/vtc.25540.59b6ec5d/h1
219 ** h1 0.0 Wait
220 ** h1 0.0 Stop HAproxy pid=25558
221 *** h1 0.0 debug|[ALERT] 157/135318 (25558) : parsing [/tmp/vtc.25540.59b6ec5d/h1/cfg:10] : 'filter' : ''spoe' : missing config file'
222 *** h1 0.0 debug|[ALERT] 157/135318 (25558) : Error(s) found in configuration file : /tmp/vtc.25540.59b6ec5d/h1/cfg
223 *** h1 0.0 debug|[ALERT] 157/135318 (25558) : Fatal errors found in configuration.
224 **** h1 0.0 STDOUT poll 0x10
225 ** h1 0.0 WAIT4 pid=25558 status=0x0100 (user 0.000000 sys 0.000000)
226 ** h1 0.0 Found expected ''
227 * top 0.0 RESETTING after /home/fred/src/varnish-cache-haproxy/spoe_bug.vtc
228 ** h1 0.0 Reset and free h1 haproxy -1
229 * top 0.0 TEST /home/fred/src/varnish-cache-haproxy/spoe_bug.vtc completed
230 # top TEST /home/fred/src/varnish-cache-haproxy/spoe_bug.vtc passed (0.004)
231
232
233The following VTC file does almost nothing except running a shell to list
234the contents of 'tmpdir' directory after having launched a haproxy instance
235and 's1' HTTP server. This shell also prints the content of 'cfg' 'h1' configuration
236file.
237
238 varnishtest "List the contents of 'tmpdir'"
239 feature ignore_unknown_macro
240
241 server s1 {
242 } -start
243
244 haproxy h1 -conf {
245 defaults
246 mode http
247 timeout connect 5s
248 timeout server 30s
249 timeout client 30s
250
251 backend be1
252 server srv1 ${s1_addr}:${s1_port}
253
254 frontend http1
255 use_backend be1
256 bind "fd@${my_frontend_fd}"
257 } -start
258
259 shell {
260 echo "${tmpdir} working directory content:"
261 ls -lR ${tmpdir}
262 cat ${tmpdir}/h1/cfg
263 }
264
265We give only the ouput of the shell to illustrate this example:
266
267 .
268 .
269 .
270 ** top 0.0 === shell {
271 **** top 0.0 shell_cmd|exec 2>&1 ;
272 **** top 0.0 shell_cmd| echo "tmpdir: /tmp/vtc.32092.479d521e"
273 **** top 0.0 shell_cmd| ls -lR /tmp/vtc.32092.479d521e
274 **** top 0.0 shell_cmd| cat /tmp/vtc.32092.479d521e/h1/cfg
275 .
276 .
277 .
278 **** top 0.0 shell_out|/tmp/vtc.3808.448cbfe0 working directory content:
279 **** top 0.0 shell_out|/tmp/vtc.32092.479d521e:
280 **** top 0.0 shell_out|total 8
281 **** top 0.0 shell_out|drwxr-xr-x 2 users 4096 Jun 7 11:09 h1
282 **** top 0.0 shell_out|-rw-r--r-- 1 me users 84 Jun 7 11:09 INFO
283 **** top 0.0 shell_out|
284 **** top 0.0 shell_out|/tmp/vtc.32092.479d521e/h1:
285 **** top 0.0 shell_out|total 4
286 **** top 0.0 shell_out|-rw-r----- 1 fred users 339 Jun 7 11:09 cfg
287 **** top 0.0 shell_out|srw------- 1 fred users 0 Jun 7 11:09 stats.sock
288 **** top 0.0 shell_out| global
289 **** top 0.0 shell_out|\tstats socket /tmp/vtc.32092.479d521e/h1/stats.sock level admin mode 600
290 **** top 0.0 shell_out|
291 **** top 0.0 shell_out| defaults
292 **** top 0.0 shell_out| mode http
293 **** top 0.0 shell_out| timeout connect 5s
294 **** top 0.0 shell_out| timeout server 30s
295 **** top 0.0 shell_out| timeout client 30s
296 **** top 0.0 shell_out|
297 **** top 0.0 shell_out| backend be1
298 **** top 0.0 shell_out| server srv1 127.0.0.1:36984
299 **** top 0.0 shell_out|
300 **** top 0.0 shell_out| frontend http1
301 **** top 0.0 shell_out| use_backend be1
302 **** top 0.0 shell_out| bind "fd@${my_frontend_fd}"
303 **** top 0.0 shell_status = 0x0000
304
305
306The following example illustrate how to run a basic HTTP transaction between 'c1'
307client and 's1' server with 'http1' as haproxy frontend. This frontend listen
308on TCP socket with 'my_frontend_fd' as file descriptor.
309
310 # Mandatory line
311 varnishtest "Basic HAproxy test"
312
313 # As some macros for haproxy are used in this file, this line is mandatory.
314 feature ignore_unknown_macro
315
316 server s1 {
317 rxreq
318 txresp -body "s1 >>> Hello world!"
319 } -start
320
321 haproxy h1 -conf {
322 # Configuration file of 'h1' haproxy instance.
323 defaults
324 mode http
325 timeout connect 5s
326 timeout server 30s
327 timeout client 30s
328
329 backend be1
330 # declare 'srv1' server to point to 's1' server instance declare above.
331 server srv1 ${s1_addr}:${s1_port}
332
333 frontend http1
334 use_backend be1
335 bind "fd@${my_frontend_fd}"
336 } -start
337
338 client c1 -connect ${h1_my_frontend_fd_sock} {
339 txreq -url "/"
340 rxresp
341 expect resp.status == 200
342 expect resp.body == "s1 >>> Hello world!"
343 } -run
344
345
346It is possible to shorten the previous VTC file haproxy command section as follows:
347
348 haproxy h1 -conf {
349 # Configuration file of 'h1' haproxy instance.
350 defaults
351 mode http
352 timeout connect 5s
353 timeout server 30s
354 timeout client 30s
355 }
356
357In this latter example, "backend" and "frontend" sections are automatically
358generated depending on the declarations of server instances.
359
360
361Another interesting real regression test case is the following: we declare one
362server 's1', a syslog server 'Slg_1' and a basic haproxy configuration for 'h1'
363haproxy instance. Here we want to check that the syslog message are correctly
364formatted thanks to "expect" "syslog" command (see syslog Slg_1 {...} command)
365below.
366
367 varnishtest "Wrong ip/port logging"
368 feature ignore_unknown_macro
369
370 #commit d02286d6c866e5c0a7eb6fbb127fa57f3becaf16
371 #Author: Willy Tarreau <w@1wt.eu>
372 #Date: Fri Jun 23 11:23:43 2017 +0200
373 #
374 # BUG/MINOR: log: pin the front connection when front ip/ports are logged
375 #
376 # Mathias Weiersmueller reported an interesting issue with logs which Lukas
377 # diagnosed as dating back from commit 9b061e332 (1.5-dev9). When front
378 # connection information (ip, port) are logged in TCP mode and the log is
379 # emitted at the end of the connection (eg: because %B or any log tag
380 # requiring LW_BYTES is set), the log is emitted after the connection is
381 # closed, so the address and ports cannot be retrieved anymore.
382 #
383 # It could be argued that we'd make a special case of these to immediatly
384 # retrieve the source and destination addresses from the connection, but it
385 # seems cleaner to simply pin the front connection, marking it "tracked" by
386 # adding the LW_XPRT flag to mention that we'll need some of these elements
387 # at the last moment. Only LW_FRTIP and LW_CLIP are affected. Note that after
388 # this change, LW_FRTIP could simply be removed as it's not used anywhere.
389
390 # Note that the problem doesn't happen when using %[src] or %[dst] since
391 # all sample expressions set LW_XPRT.
392
393
394 server s1 {
395 rxreq
396 txresp
397 } -start
398
399 syslog Slg_1 -level notice {
400 recv
401 recv
402 recv info
403 expect ~ \"dip\":\"${h1_fe_1_addr}\",\"dport\":\"${h1_fe_1_port}.*\"ts\":\"cD\",\"
404 } -start
405
406 haproxy h1 -conf {
407 global
408 log ${Slg_1_addr}:${Slg_1_port} local0
409
410 defaults
411 log global
412 timeout connect 3000
413 timeout client 5
414 timeout server 10000
415
416 frontend fe1
417 bind "fd@${fe_1}"
418 mode tcp
419 log-format {\"dip\":\"%fi\",\"dport\":\"%fp\",\"c_ip\":\"%ci\",\"c_port\":\"%cp\",\"fe_name\":\"%ft\",\"be_name\":\"%b\",\"s_name\":\"%s\",\"ts\":\"%ts\",\"bytes_read\":\"%B\"}
420 default_backend be_app
421
422 backend be_app
423 server app1 ${s1_addr}:${s1_port} check
424 } -start
425
426 client c1 -connect ${h1_fe_1_sock} {
427 txreq -url "/"
428 delay 0.02
429 } -run
430
431 syslog Slg_1 -wait
432
433
434Here is the output produced by varnishtest with the latter VTC file:
435
436 **** top 0.0 extmacro def pwd=/home/fred/src/haproxy
437 **** top 0.0 extmacro def localhost=127.0.0.1
438 **** top 0.0 extmacro def bad_backend=127.0.0.1 40386
439 **** top 0.0 extmacro def bad_ip=192.0.2.255
440 **** top 0.0 macro def testdir=//home/fred/src/varnish-cache-haproxy
441 **** top 0.0 macro def tmpdir=/tmp/vtc.15752.560ca66b
442 * top 0.0 TEST /home/fred/src/varnish-cache-haproxy/d02286d.vtc starting
443 ** top 0.0 === varnishtest "HAPEE bug 2788"
444 * top 0.0 TEST HAPEE bug 2788
445 ** top 0.0 === feature ignore_unknown_macro
446 ** top 0.0 === server s1 {
447 ** s1 0.0 Starting server
448 **** s1 0.0 macro def s1_addr=127.0.0.1
449 **** s1 0.0 macro def s1_port=35564
450 **** s1 0.0 macro def s1_sock=127.0.0.1 35564
451 * s1 0.0 Listen on 127.0.0.1 35564
452 ** top 0.0 === syslog Slg_1 -level notice {
453 ** Slg_1 0.0 Starting syslog server
454 ** s1 0.0 Started on 127.0.0.1 35564
455 **** Slg_1 0.0 macro def Slg_1_addr=127.0.0.1
456 **** Slg_1 0.0 macro def Slg_1_port=33012
457 **** Slg_1 0.0 macro def Slg_1_sock=127.0.0.1 33012
458 * Slg_1 0.0 Bound on 127.0.0.1 33012
459 ** top 0.0 === haproxy h1 -conf {
460 ** Slg_1 0.0 Started on 127.0.0.1 33012 (level: 5)
461 ** Slg_1 0.0 === recv
462 **** h1 0.0 macro def h1_fe_1_sock=::1 51782
463 **** h1 0.0 macro def h1_fe_1_addr=::1
464 **** h1 0.0 macro def h1_fe_1_port=51782
465 **** h1 0.0 setenv(fe_1, 7)
466 **** h1 0.0 conf| global
467 **** h1 0.0 conf|\tstats socket /tmp/vtc.15752.560ca66b/h1/stats.sock level admin mode 600
468 **** h1 0.0 conf|
469 **** h1 0.0 conf| global
470 **** h1 0.0 conf| log 127.0.0.1:33012 local0
471 **** h1 0.0 conf|
472 **** h1 0.0 conf| defaults
473 **** h1 0.0 conf| log global
474 **** h1 0.0 conf| timeout connect 3000
475 **** h1 0.0 conf| timeout client 5
476 **** h1 0.0 conf| timeout server 10000
477 **** h1 0.0 conf|
478 **** h1 0.0 conf| frontend fe1
479 **** h1 0.0 conf| bind "fd@${fe_1}"
480 **** h1 0.0 conf| mode tcp
481 **** h1 0.0 conf| log-format {\"dip\":\"%fi\",\"dport\":\"%fp\",\"c_ip\":\"%ci\",\"c_port\":\"%cp\",\"fe_name\":\"%ft\",\"be_name\":\"%b\",\"s_name\":\"%s\",\"ts\":\"%ts\",\"bytes_read\":\"%B\"}
482 **** h1 0.0 conf| default_backend be_app
483 **** h1 0.0 conf|
484 **** h1 0.0 conf| backend be_app
485 **** h1 0.0 conf| server app1 127.0.0.1:35564 check
486 ** h1 0.0 haproxy_start
487 **** h1 0.0 opt_worker 0 opt_daemon 0 opt_check_mode 0
488 **** h1 0.0 argv|exec /home/fred/src/haproxy/haproxy -d -f /tmp/vtc.15752.560ca66b/h1/cfg
489 **** h1 0.0 XXX 9 @277
490 *** h1 0.0 PID: 15787
491 **** h1 0.0 macro def h1_pid=15787
492 **** h1 0.0 macro def h1_name=/tmp/vtc.15752.560ca66b/h1
493 ** top 0.0 === client c1 -connect ${h1_fe_1_sock} {
494 ** c1 0.0 Starting client
495 ** c1 0.0 Waiting for client
496 *** c1 0.0 Connect to ::1 51782
497 *** c1 0.0 connected fd 8 from ::1 46962 to ::1 51782
498 ** c1 0.0 === txreq -url "/"
499 **** c1 0.0 txreq|GET / HTTP/1.1\r
500 **** c1 0.0 txreq|Host: 127.0.0.1\r
501 **** c1 0.0 txreq|\r
502 ** c1 0.0 === delay 0.02
503 *** c1 0.0 delaying 0.02 second(s)
504 *** h1 0.0 debug|Note: setting global.maxconn to 2000.
505 *** h1 0.0 debug|Available polling systems :
506 *** h1 0.0 debug| epoll :
507 *** h1 0.0 debug|pref=300,
508 *** h1 0.0 debug| test result OK
509 *** h1 0.0 debug| poll : pref=200, test result OK
510 *** h1 0.0 debug| select :
511 *** h1 0.0 debug|pref=150, test result FAILED
512 *** h1 0.0 debug|Total: 3 (2 usable), will use epoll.
513 *** h1 0.0 debug|
514 *** h1 0.0 debug|Available filters :
515 *** h1 0.0 debug|\t[SPOE] spoe
516 *** h1 0.0 debug|\t[COMP] compression
517 *** h1 0.0 debug|\t[TRACE] trace
518 **** Slg_1 0.0 syslog|<133>Jun 7 14:12:51 haproxy[15787]: Proxy fe1 started.
519 ** Slg_1 0.0 === recv
520 **** Slg_1 0.0 syslog|<133>Jun 7 14:12:51 haproxy[15787]: Proxy be_app started.
521 ** Slg_1 0.0 === recv info
522 *** h1 0.0 debug|00000000:fe1.accept(0007)=000a from [::1:46962]
523 *** s1 0.0 accepted fd 6 127.0.0.1 56770
524 ** s1 0.0 === rxreq
525 **** s1 0.0 rxhdr|GET / HTTP/1.1\r
526 **** s1 0.0 rxhdr|Host: 127.0.0.1\r
527 **** s1 0.0 rxhdr|\r
528 **** s1 0.0 rxhdrlen = 35
529 **** s1 0.0 http[ 0] |GET
530 **** s1 0.0 http[ 1] |/
531 **** s1 0.0 http[ 2] |HTTP/1.1
532 **** s1 0.0 http[ 3] |Host: 127.0.0.1
533 **** s1 0.0 bodylen = 0
534 ** s1 0.0 === txresp
535 **** s1 0.0 txresp|HTTP/1.1 200 OK\r
536 **** s1 0.0 txresp|Content-Length: 0\r
537 **** s1 0.0 txresp|\r
538 *** s1 0.0 shutting fd 6
539 ** s1 0.0 Ending
540 *** h1 0.0 debug|00000000:be_app.srvcls[000a:000c]
541 *** h1 0.0 debug|00000000:be_app.clicls[000a:000c]
542 *** h1 0.0 debug|00000000:be_app.closed[000a:000c]
543 **** Slg_1 0.0 syslog|<134>Jun 7 14:12:51 haproxy[15787]: {"dip":"","dport":"0","c_ip":"::1","c_port":"46962","fe_name":"fe1","be_name":"be_app","s_name":"app1","ts":"cD","bytes_read":"38"}
544 ** Slg_1 0.0 === expect ~ \"dip\":\"${h1_fe_1_addr}\",\"dport\":\"${h1_fe_1_p...
545 ---- Slg_1 0.0 EXPECT FAILED ~ "\"dip\":\"::1\",\"dport\":\"51782.*\"ts\":\"cD\",\""
546 *** c1 0.0 closing fd 8
547 ** c1 0.0 Ending
548 * top 0.0 RESETTING after /home/fred/src/varnish-cache-haproxy/d02286d.vtc
549 ** h1 0.0 Reset and free h1 haproxy 15787
550 ** h1 0.0 Wait
551 ** h1 0.0 Stop HAproxy pid=15787
552 **** h1 0.0 Kill(2)=0: Success
553 **** h1 0.0 STDOUT poll 0x10
554 ** h1 0.1 WAIT4 pid=15787 status=0x0002 (user 0.000000 sys 0.004000)
555 ** s1 0.1 Waiting for server (4/-1)
556 ** Slg_1 0.1 Waiting for syslog server (5)
557 * top 0.1 TEST /home/fred/src/varnish-cache-haproxy/d02286d.vtc FAILED
558 # top TEST /home/fred/src/varnish-cache-haproxy/d02286d.vtc FAILED (0.131) exit=2
559
560This test does not pass without the bug fix of d02286d commit. Indeed the third syslog
561message received by 'Slg_1' syslog server does not match the regular expression
562of the "syslog" "expect" command:
563
564 expect ~ \"dip\":\"${h1_fe_1_addr}\",\"dport\":\"${h1_fe_1_port}.*\"ts\":\"cD\",\"
565
566(the IP address and port are missing), contrary to what happens with the correct bug fix:
567
568 **** top 0.0 extmacro def pwd=/home/fred/src/haproxy
569 **** top 0.0 extmacro def localhost=127.0.0.1
570 **** top 0.0 extmacro def bad_backend=127.0.0.1 37284
571 **** top 0.0 extmacro def bad_ip=192.0.2.255
572 **** top 0.0 macro def testdir=//home/fred/src/varnish-cache-haproxy
573 **** top 0.0 macro def tmpdir=/tmp/vtc.12696.186b28b0
574 * top 0.0 TEST /home/fred/src/varnish-cache-haproxy/d02286d.vtc starting
575 ** top 0.0 === varnishtest "HAPEE bug 2788"
576 * top 0.0 TEST HAPEE bug 2788
577 ** top 0.0 === feature ignore_unknown_macro
578 ** top 0.0 === server s1 {
579 ** s1 0.0 Starting server
580 **** s1 0.0 macro def s1_addr=127.0.0.1
581 **** s1 0.0 macro def s1_port=53384
582 **** s1 0.0 macro def s1_sock=127.0.0.1 53384
583 * s1 0.0 Listen on 127.0.0.1 53384
584 ** top 0.0 === syslog Slg_1 -level notice {
585 ** Slg_1 0.0 Starting syslog server
586 **** Slg_1 0.0 macro def Slg_1_addr=127.0.0.1
587 ** s1 0.0 Started on 127.0.0.1 53384
588 **** Slg_1 0.0 macro def Slg_1_port=36195
589 **** Slg_1 0.0 macro def Slg_1_sock=127.0.0.1 36195
590 * Slg_1 0.0 Bound on 127.0.0.1 36195
591 ** top 0.0 === haproxy h1 -conf {
592 ** Slg_1 0.0 Started on 127.0.0.1 36195 (level: 5)
593 ** Slg_1 0.0 === recv
594 **** h1 0.0 macro def h1_fe_1_sock=::1 39264
595 **** h1 0.0 macro def h1_fe_1_addr=::1
596 **** h1 0.0 macro def h1_fe_1_port=39264
597 **** h1 0.0 setenv(fe_1, 7)
598 **** h1 0.0 conf| global
599 **** h1 0.0 conf|\tstats socket /tmp/vtc.12696.186b28b0/h1/stats.sock level admin mode 600
600 **** h1 0.0 conf|
601 **** h1 0.0 conf| global
602 **** h1 0.0 conf| log 127.0.0.1:36195 local0
603 **** h1 0.0 conf|
604 **** h1 0.0 conf| defaults
605 **** h1 0.0 conf| log global
606 **** h1 0.0 conf| timeout connect 3000
607 **** h1 0.0 conf| timeout client 5
608 **** h1 0.0 conf| timeout server 10000
609 **** h1 0.0 conf|
610 **** h1 0.0 conf| frontend fe1
611 **** h1 0.0 conf| bind "fd@${fe_1}"
612 **** h1 0.0 conf| mode tcp
613 **** h1 0.0 conf| log-format {\"dip\":\"%fi\",\"dport\":\"%fp\",\"c_ip\":\"%ci\",\"c_port\":\"%cp\",\"fe_name\":\"%ft\",\"be_name\":\"%b\",\"s_name\":\"%s\",\"ts\":\"%ts\",\"bytes_read\":\"%B\"}
614 **** h1 0.0 conf| default_backend be_app
615 **** h1 0.0 conf|
616 **** h1 0.0 conf| backend be_app
617 **** h1 0.0 conf| server app1 127.0.0.1:53384 check
618 ** h1 0.0 haproxy_start
619 **** h1 0.0 opt_worker 0 opt_daemon 0 opt_check_mode 0
620 **** h1 0.0 argv|exec /home/fred/src/haproxy/haproxy -d -f /tmp/vtc.12696.186b28b0/h1/cfg
621 **** h1 0.0 XXX 9 @277
622 *** h1 0.0 PID: 12728
623 **** h1 0.0 macro def h1_pid=12728
624 **** h1 0.0 macro def h1_name=/tmp/vtc.12696.186b28b0/h1
625 ** top 0.0 === client c1 -connect ${h1_fe_1_sock} {
626 ** c1 0.0 Starting client
627 ** c1 0.0 Waiting for client
628 *** c1 0.0 Connect to ::1 39264
629 *** c1 0.0 connected fd 8 from ::1 41245 to ::1 39264
630 ** c1 0.0 === txreq -url "/"
631 **** c1 0.0 txreq|GET / HTTP/1.1\r
632 **** c1 0.0 txreq|Host: 127.0.0.1\r
633 **** c1 0.0 txreq|\r
634 ** c1 0.0 === delay 0.02
635 *** c1 0.0 delaying 0.02 second(s)
636 *** h1 0.0 debug|Note: setting global.maxconn to 2000.
637 *** h1 0.0 debug|Available polling systems :
638 *** h1 0.0 debug| epoll : pref=300,
639 *** h1 0.0 debug| test result OK
640 *** h1 0.0 debug| poll : pref=200, test result OK
641 *** h1 0.0 debug| select : pref=150, test result FAILED
642 *** h1 0.0 debug|Total: 3 (2 usable), will use epoll.
643 *** h1 0.0 debug|
644 *** h1 0.0 debug|Available filters :
645 *** h1 0.0 debug|\t[SPOE] spoe
646 *** h1 0.0 debug|\t[COMP] compression
647 *** h1 0.0 debug|\t[TRACE] trace
648 *** h1 0.0 debug|Using epoll() as the polling mechanism.
649 **** Slg_1 0.0 syslog|<133>Jun 7 14:10:18 haproxy[12728]: Proxy fe1 started.
650 ** Slg_1 0.0 === recv
651 **** Slg_1 0.0 syslog|<133>Jun 7 14:10:18 haproxy[12728]: Proxy be_app started.
652 ** Slg_1 0.0 === recv info
653 *** h1 0.0 debug|00000000:fe1.accept(0007)=000c from [::1:41245] ALPN=<none>
654 *** s1 0.0 accepted fd 6 127.0.0.1 49946
655 ** s1 0.0 === rxreq
656 **** s1 0.0 rxhdr|GET / HTTP/1.1\r
657 **** s1 0.0 rxhdr|Host: 127.0.0.1\r
658 **** s1 0.0 rxhdr|\r
659 **** s1 0.0 rxhdrlen = 35
660 **** s1 0.0 http[ 0] |GET
661 **** s1 0.0 http[ 1] |/
662 **** s1 0.0 http[ 2] |HTTP/1.1
663 **** s1 0.0 http[ 3] |Host: 127.0.0.1
664 **** s1 0.0 bodylen = 0
665 ** s1 0.0 === txresp
666 **** s1 0.0 txresp|HTTP/1.1 200 OK\r
667 **** s1 0.0 txresp|Content-Length: 0\r
668 **** s1 0.0 txresp|\r
669 *** s1 0.0 shutting fd 6
670 ** s1 0.0 Ending
671 *** h1 0.0 debug|00000000:be_app.srvcls[000c:adfd]
672 *** h1 0.0 debug|00000000:be_app.clicls[000c:adfd]
673 *** h1 0.0 debug|00000000:be_app.closed[000c:adfd]
674 **** Slg_1 0.0 syslog|<134>Jun 7 14:10:18 haproxy[12728]: {"dip":"::1","dport":"39264","c_ip":"::1","c_port":"41245","fe_name":"fe1","be_name":"be_app","s_name":"app1","ts":"cD","bytes_read":"38"}
675 ** Slg_1 0.0 === expect ~ \"dip\":\"${h1_fe_1_addr}\",\"dport\":\"${h1_fe_1_p...
676 **** Slg_1 0.0 EXPECT MATCH ~ "\"dip\":\"::1\",\"dport\":\"39264.*\"ts\":\"cD\",\""
677 *** Slg_1 0.0 shutting fd 5
678 ** Slg_1 0.0 Ending
679 *** c1 0.0 closing fd 8
680 ** c1 0.0 Ending
681 ** top 0.0 === syslog Slg_1 -wait
682 ** Slg_1 0.0 Waiting for syslog server (-1)
683 * top 0.0 RESETTING after /home/fred/src/varnish-cache-haproxy/d02286d.vtc
684 ** h1 0.0 Reset and free h1 haproxy 12728
685 ** h1 0.0 Wait
686 ** h1 0.0 Stop HAproxy pid=12728
687 **** h1 0.0 Kill(2)=0: Success
688 **** h1 0.0 STDOUT poll 0x10
689 ** h1 0.1 WAIT4 pid=12728 status=0x0002 (user 0.000000 sys 0.004000)
690 ** s1 0.1 Waiting for server (4/-1)
691 * top 0.1 TEST /home/fred/src/varnish-cache-haproxy/d02286d.vtc completed
692 # top TEST /home/fred/src/varnish-cache-haproxy/d02286d.vtc passed (0.128)
693
694In this latter execution the third syslog message is correct:
695
696 **** Slg_1 0.0 syslog|<134>Jun 7 14:10:18 haproxy[12728]: {"dip":"::1","dport":"39264","c_ip":"::1","c_port":"41245","fe_name":"fe1","be_name":"be_app","s_name":"app1","ts":"cD","bytes_read":"38"}