]> git.proxmox.com Git - mirror_ovs.git/blob - tests/vlog.at
utilities: check datapath exists before conntrack flush
[mirror_ovs.git] / tests / vlog.at
1 AT_BANNER([vlog])
2
3 m4_define([VLOG_PYN],
4 [AT_SETUP([vlog - $1])
5 AT_SKIP_IF([test $2 = no])
6 AT_CAPTURE_FILE([log_file])
7 AT_CAPTURE_FILE([stderr_log])
8 AT_CHECK([$3 $srcdir/test-vlog.py --log-file log_file \
9 -v dbg module_1:info module_2:warn syslog:off 2>stderr_log])
10
11 AT_CHECK([sed -e 's/.*-.*-.*T..:..:..Z |//' \
12 -e 's/File ".*", line [[0-9]][[0-9]]*,/File <name>, line <number>,/' \
13 stderr_log], [0], [dnl
14 0 | module_0 | EMER | emergency
15 1 | module_0 | ERR | error
16 2 | module_0 | WARN | warning
17 3 | module_0 | INFO | information
18 4 | module_0 | DBG | debug
19 5 | module_0 | EMER | emergency exception
20 Traceback (most recent call last):
21 File <name>, line <number>, in main
22 assert fail
23 AssertionError
24 6 | module_0 | ERR | error exception
25 Traceback (most recent call last):
26 File <name>, line <number>, in main
27 assert fail
28 AssertionError
29 7 | module_0 | WARN | warn exception
30 Traceback (most recent call last):
31 File <name>, line <number>, in main
32 assert fail
33 AssertionError
34 8 | module_0 | INFO | information exception
35 Traceback (most recent call last):
36 File <name>, line <number>, in main
37 assert fail
38 AssertionError
39 9 | module_0 | DBG | debug exception
40 Traceback (most recent call last):
41 File <name>, line <number>, in main
42 assert fail
43 AssertionError
44 10 | module_0 | ERR | exception
45 Traceback (most recent call last):
46 File <name>, line <number>, in main
47 assert fail
48 AssertionError
49 11 | module_1 | EMER | emergency
50 12 | module_1 | ERR | error
51 13 | module_1 | WARN | warning
52 14 | module_1 | INFO | information
53 16 | module_1 | EMER | emergency exception
54 Traceback (most recent call last):
55 File <name>, line <number>, in main
56 assert fail
57 AssertionError
58 17 | module_1 | ERR | error exception
59 Traceback (most recent call last):
60 File <name>, line <number>, in main
61 assert fail
62 AssertionError
63 18 | module_1 | WARN | warn exception
64 Traceback (most recent call last):
65 File <name>, line <number>, in main
66 assert fail
67 AssertionError
68 19 | module_1 | INFO | information exception
69 Traceback (most recent call last):
70 File <name>, line <number>, in main
71 assert fail
72 AssertionError
73 21 | module_1 | ERR | exception
74 Traceback (most recent call last):
75 File <name>, line <number>, in main
76 assert fail
77 AssertionError
78 22 | module_2 | EMER | emergency
79 23 | module_2 | ERR | error
80 24 | module_2 | WARN | warning
81 27 | module_2 | EMER | emergency exception
82 Traceback (most recent call last):
83 File <name>, line <number>, in main
84 assert fail
85 AssertionError
86 28 | module_2 | ERR | error exception
87 Traceback (most recent call last):
88 File <name>, line <number>, in main
89 assert fail
90 AssertionError
91 29 | module_2 | WARN | warn exception
92 Traceback (most recent call last):
93 File <name>, line <number>, in main
94 assert fail
95 AssertionError
96 32 | module_2 | ERR | exception
97 Traceback (most recent call last):
98 File <name>, line <number>, in main
99 assert fail
100 AssertionError
101 ])
102
103 AT_CLEANUP])
104
105 VLOG_PYN([Python2], [$HAVE_PYTHON2], [$PYTHON2])
106 VLOG_PYN([Python3], [$HAVE_PYTHON3], [$PYTHON3])
107
108 m4_divert_push([PREPARE_TESTS])
109 vlog_filt () {
110 sed 's/.*\(opened log file\).*/\1/
111 s/.*|//' "$@"
112 }
113 m4_divert_pop([PREPARE_TESTS])
114
115 AT_SETUP([vlog - vlog/reopen - C])
116 # This test won't work as-is on Windows because Windows doesn't allow
117 # files that are open to be renamed.
118 AT_SKIP_IF([test "$IS_WIN32" = "yes"])
119 on_exit 'kill `cat test-unixctl.pid`'
120
121 AT_CAPTURE_FILE([log])
122 AT_CAPTURE_FILE([log.old])
123 AT_CHECK([ovstest test-unixctl --log-file=`pwd`/log --pidfile --detach],
124 [0], [], [stderr])
125 AT_CHECK([vlog_filt stderr], [0],
126 [opened log file
127 ])
128
129 AT_CHECK([APPCTL -t test-unixctl log message])
130 mv log log.old
131 AT_CHECK([APPCTL -t test-unixctl log message2])
132 AT_CHECK([APPCTL -t test-unixctl vlog/reopen])
133 AT_CHECK([APPCTL -t test-unixctl log message3])
134 AT_CHECK([APPCTL -t test-unixctl exit])
135
136 AT_CHECK([vlog_filt log.old], [0], [dnl
137 opened log file
138 Entering run loop.
139 message
140 message2
141 closing log file
142 ])
143 AT_CHECK([vlog_filt log], [0], [dnl
144 opened log file
145 message3
146 ])
147 AT_CLEANUP
148
149 m4_define([VLOG_REOPEN_PYN],
150 [AT_SETUP([vlog - vlog/reopen - $1])
151 # This test won't work as-is on Windows because Windows doesn't allow
152 # files that are open to be renamed.
153 AT_SKIP_IF([test "$IS_WIN32" = "yes"])
154 AT_SKIP_IF([test $2 = no])
155 on_exit 'kill `cat test-unixctl.py.pid`'
156
157 AT_CAPTURE_FILE([log])
158 AT_CAPTURE_FILE([log.old])
159 AT_CHECK([$3 $srcdir/test-unixctl.py --log-file=`pwd`/log --pidfile --detach])
160
161 AT_CHECK([APPCTL -t test-unixctl.py log message])
162 mv log log.old
163 AT_CHECK([APPCTL -t test-unixctl.py log message2])
164 AT_CHECK([APPCTL -t test-unixctl.py vlog/reopen])
165 AT_CHECK([APPCTL -t test-unixctl.py log message3])
166 AT_CHECK([APPCTL -t test-unixctl.py exit])
167
168 AT_CHECK([sed 's/.*|//' log.old], [0], [dnl
169 Entering run loop.
170 message
171 message2
172 ])
173 AT_CHECK([sed 's/.*|//' log], [0], [dnl
174 message3
175 ])
176 AT_CLEANUP])
177
178 VLOG_REOPEN_PYN([Python2], [$HAVE_PYTHON2], [$PYTHON2])
179 VLOG_REOPEN_PYN([Python3], [$HAVE_PYTHON3], [$PYTHON3])
180
181 AT_SETUP([vlog - vlog/reopen without log file - C])
182 on_exit 'kill `cat test-unixctl.pid`'
183
184 AT_CHECK([ovstest test-unixctl --pidfile --detach])
185
186 AT_CHECK([APPCTL -t test-unixctl vlog/reopen], [2], [],
187 [Logging to file not configured
188 ovs-appctl: test-unixctl: server returned an error
189 ])
190 OVS_APP_EXIT_AND_WAIT([test-unixctl])
191 AT_CLEANUP
192
193 m4_define([VLOG_REOPEN_WITHOUT_FILE_PYN],
194 [AT_SETUP([vlog - vlog/reopen without log file - $1])
195 AT_SKIP_IF([test $2 = no])
196 on_exit 'kill `cat test-unixctl.py.pid`'
197
198 AT_CHECK([$3 $srcdir/test-unixctl.py --pidfile --detach])
199
200 AT_CHECK([APPCTL -t test-unixctl.py vlog/reopen], [0],
201 [Logging to file not configured
202 ])
203 AT_CLEANUP])
204
205 VLOG_REOPEN_WITHOUT_FILE_PYN([Python2], [$HAVE_PYTHON2], [$PYTHON2])
206 VLOG_REOPEN_WITHOUT_FILE_PYN([Python3], [$HAVE_PYTHON3], [$PYTHON3])
207
208 dnl This checks that if vlog/reopen can't reopen the log file,
209 dnl nothing particularly bad (e.g. a crash) happens.
210 AT_SETUP([vlog - vlog/reopen can't reopen log file - C])
211 # Verify that /dev/full is a character device that fails writes.
212 AT_SKIP_IF([test ! -c /dev/full])
213 AT_SKIP_IF([echo > /dev/full])
214
215 on_exit 'kill `cat test-unixctl.pid`'
216
217 AT_CHECK([ovstest test-unixctl --log-file=`pwd`/log --pidfile --detach],
218 [0], [], [stderr])
219 AT_CHECK([vlog_filt stderr], [0], [opened log file
220 ])
221
222 AT_CHECK([APPCTL -t test-unixctl log message])
223 mv log log.old
224 ln -s /dev/full log
225 AT_CHECK([APPCTL -t test-unixctl vlog/reopen])
226 AT_CHECK([APPCTL -t test-unixctl log message2])
227 rm log
228 AT_CHECK([APPCTL -t test-unixctl vlog/reopen])
229 AT_CHECK([APPCTL -t test-unixctl log message3])
230 AT_CHECK([APPCTL -t test-unixctl exit])
231 AT_CHECK([vlog_filt log.old], [0], [dnl
232 opened log file
233 Entering run loop.
234 message
235 closing log file
236 ])
237 AT_CHECK([vlog_filt log], [0], [dnl
238 opened log file
239 message3
240 ])
241 AT_CLEANUP
242
243 dnl This checks that if vlog/reopen can't reopen the log file,
244 dnl nothing particularly bad (e.g. Python throws an exception and
245 dnl aborts the program) happens.
246 m4_define([VLOG_CANT_REOPEN_PYN],
247 [AT_SETUP([vlog - vlog/reopen can't reopen log file - $1])
248 AT_SKIP_IF([test $2 = no])
249
250 # Verify that /dev/full is a character device that fails writes.
251 AT_SKIP_IF([test ! -c /dev/full])
252 AT_SKIP_IF([echo > /dev/full])
253
254 on_exit 'kill `cat test-unixctl.py.pid`'
255
256 AT_CHECK([$3 $srcdir/test-unixctl.py --log-file=`pwd`/log --pidfile --detach])
257 AT_CHECK([APPCTL -t test-unixctl.py log message])
258 mv log log.old
259 ln -s /dev/full log
260 AT_CHECK([APPCTL -t test-unixctl.py vlog/reopen])
261 AT_CHECK([APPCTL -t test-unixctl.py log message2])
262 rm log
263 AT_CHECK([APPCTL -t test-unixctl.py vlog/reopen])
264 AT_CHECK([APPCTL -t test-unixctl.py log message3])
265 AT_CHECK([APPCTL -t test-unixctl.py exit])
266 AT_CHECK([sed 's/.*|//' log.old], [0], [dnl
267 Entering run loop.
268 message
269 ])
270 AT_CHECK([sed 's/.*|//' log], [0], [dnl
271 message3
272 ])
273 AT_CLEANUP])
274
275 VLOG_CANT_REOPEN_PYN([Python2], [$HAVE_PYTHON2], [$PYTHON2])
276 VLOG_CANT_REOPEN_PYN([Python3], [$HAVE_PYTHON3], [$PYTHON3])
277
278 AT_SETUP([vlog - vlog/close - C])
279 on_exit 'kill `cat test-unixctl.pid`'
280
281 AT_CAPTURE_FILE([log])
282 AT_CAPTURE_FILE([log.old])
283 AT_CHECK([ovstest test-unixctl --log-file=`pwd`/log --pidfile --detach],
284 [0], [], [ignore])
285 AT_CHECK([vlog_filt log], [0], [opened log file
286 Entering run loop.
287 ])
288
289 AT_CHECK([APPCTL -t test-unixctl log message])
290 AT_CHECK([APPCTL -t test-unixctl log message2])
291
292 # After closing the log file, message3 won't appear anywhere.
293 AT_CHECK([APPCTL -t test-unixctl vlog/close])
294 mv log log.old
295 AT_CHECK([APPCTL -t test-unixctl log message3])
296
297 # Closing the log file again is harmless.
298 AT_CHECK([APPCTL -t test-unixctl vlog/close])
299 AT_CHECK([APPCTL -t test-unixctl log message4])
300
301 # After reopening the log file, further messages start appearing again.
302 AT_CHECK([APPCTL -t test-unixctl vlog/reopen])
303 AT_CHECK([APPCTL -t test-unixctl log message5])
304 AT_CHECK([APPCTL -t test-unixctl exit])
305
306 AT_CHECK([vlog_filt log.old], [0], [dnl
307 opened log file
308 Entering run loop.
309 message
310 message2
311 ])
312 AT_CHECK([vlog_filt log], [0], [dnl
313 opened log file
314 message5
315 ])
316 AT_CLEANUP
317
318 m4_define([VLOG_CLOSE_PYN],
319 [AT_SETUP([vlog - vlog/close - $1])
320 AT_SKIP_IF([test $2 = no])
321 on_exit 'kill `cat test-unixctl.py.pid`'
322
323 AT_CAPTURE_FILE([log])
324 AT_CAPTURE_FILE([log.old])
325 AT_CHECK([$3 $srcdir/test-unixctl.py --log-file=`pwd`/log --pidfile --detach])
326
327 AT_CHECK([APPCTL -t test-unixctl.py log message])
328 AT_CHECK([APPCTL -t test-unixctl.py log message2])
329
330 # After closing the log file, message3 won't appear anywhere.
331 AT_CHECK([APPCTL -t test-unixctl.py vlog/close])
332 mv log log.old
333 AT_CHECK([APPCTL -t test-unixctl.py log message3])
334
335 # Closing the log file again is harmless.
336 AT_CHECK([APPCTL -t test-unixctl.py vlog/close])
337 AT_CHECK([APPCTL -t test-unixctl.py log message4])
338
339 # After reopening the log file, further messages start appearing again.
340 AT_CHECK([APPCTL -t test-unixctl.py vlog/reopen])
341 AT_CHECK([APPCTL -t test-unixctl.py log message5])
342 AT_CHECK([APPCTL -t test-unixctl.py exit])
343
344 AT_CHECK([sed 's/.*|//' log.old], [0], [dnl
345 Entering run loop.
346 message
347 message2
348 ])
349 AT_CHECK([sed 's/.*|//' log], [0], [dnl
350 message5
351 ])
352 AT_CLEANUP])
353
354 VLOG_CLOSE_PYN([Python2], [$HAVE_PYTHON2], [$PYTHON2])
355 VLOG_CLOSE_PYN([Python3], [$HAVE_PYTHON3], [$PYTHON3])
356
357 AT_SETUP([vlog - vlog/set and vlog/list - C])
358 on_exit 'kill `cat test-unixctl.pid`'
359
360 AT_CAPTURE_FILE([log])
361 AT_CHECK([ovstest test-unixctl --log-file=`pwd`/log --pidfile --detach],
362 [0], [], [ignore])
363 AT_CHECK([vlog_filt log], [0], [opened log file
364 Entering run loop.
365 ])
366
367 AT_CHECK([APPCTL -t test-unixctl vlog/list | sed -n '1,2p
368 /test_unixctl /p; /daemon /p'], [0], [dnl
369 console syslog file
370 ------- ------ ------
371 daemon OFF INFO INFO
372 test_unixctl OFF INFO INFO
373 ])
374
375 AT_CHECK([APPCTL -t test-unixctl vlog/set daemon:syslog:err])
376 AT_CHECK([APPCTL -t test-unixctl vlog/set file:dbg])
377 AT_CHECK([APPCTL -t test-unixctl vlog/set nonexistent], [2], [],
378 [no destination, level, or module "nonexistent"
379 ovs-appctl: test-unixctl: server returned an error
380 ])
381 AT_CHECK([APPCTL -t test-unixctl vlog/list | sed -n '1,2p
382 /test_unixctl /p; /daemon /p'], [0], [dnl
383 console syslog file
384 ------- ------ ------
385 daemon OFF ERR DBG
386 test_unixctl OFF INFO DBG
387 ])
388
389 AT_CHECK([APPCTL -t test-unixctl vlog/set pattern], [2], [],
390 [missing destination
391 ovs-appctl: test-unixctl: server returned an error
392 ])
393 AT_CHECK([APPCTL -t test-unixctl vlog/set pattern:nonexistent], [2], [],
394 [unknown destination "nonexistent"
395 ovs-appctl: test-unixctl: server returned an error
396 ])
397 AT_CHECK([APPCTL -t test-unixctl vlog/set pattern:file:'I<3OVS|%m'])
398 AT_CHECK([APPCTL -t test-unixctl log patterntest])
399 AT_CHECK([grep -q 'I<3OVS' log])
400 OVS_APP_EXIT_AND_WAIT([test-unixctl])
401 AT_CLEANUP
402
403 m4_define([VLOG_SET_AND_LIST_PYN],
404 [AT_SETUP([vlog - vlog/set and vlog/list - $1])
405 AT_SKIP_IF([test $2 = no])
406 on_exit 'kill `cat test-unixctl.py.pid`'
407
408 AT_CAPTURE_FILE([log])
409 AT_CHECK([$3 $srcdir/test-unixctl.py --log-file=`pwd`/log --pidfile --detach])
410
411 AT_CHECK([APPCTL -t test-unixctl.py vlog/list], [0], [dnl
412 console syslog file
413 ------- ------ ------
414 daemon info info info
415 fatal-signal info info info
416 jsonrpc info info info
417 poller info info info
418 reconnect info info info
419 socket_util info info info
420 stream info info info
421 test-unixctl info info info
422 unixctl_server info info info
423 ])
424
425 AT_CHECK([APPCTL -t test-unixctl.py vlog/set daemon:syslog:err])
426 AT_CHECK([APPCTL -t test-unixctl.py vlog/set file:dbg])
427 AT_CHECK([APPCTL -t test-unixctl.py vlog/set nonexistent], [0],
428 [no destination, level, or module "nonexistent"
429 ])
430 AT_CHECK([APPCTL -t test-unixctl.py vlog/list], [0], [dnl
431 console syslog file
432 ------- ------ ------
433 daemon info err dbg
434 fatal-signal info info dbg
435 jsonrpc info info dbg
436 poller info info dbg
437 reconnect info info dbg
438 socket_util info info dbg
439 stream info info dbg
440 test-unixctl info info dbg
441 unixctl_server info info dbg
442 ])
443
444 AT_CHECK([APPCTL -t test-unixctl.py vlog/set pattern], [0],
445 [Please supply a valid pattern and destination
446 ])
447 AT_CHECK([APPCTL -t test-unixctl.py vlog/set pattern:nonexistent], [0],
448 [Destination nonexistent does not exist
449 ])
450 AT_CHECK([APPCTL -t test-unixctl.py vlog/set pattern:file:'I<3OVS|%m'])
451 AT_CHECK([APPCTL -t test-unixctl.py log patterntest])
452 AT_CHECK([grep -q 'I<3OVS' log])
453 AT_CLEANUP])
454
455 VLOG_SET_AND_LIST_PYN([Python2], [$HAVE_PYTHON2], [$PYTHON2])
456 VLOG_SET_AND_LIST_PYN([Python3], [$HAVE_PYTHON3], [$PYTHON3])
457
458 AT_SETUP([vlog - RFC5424 facility])
459 on_exit 'kill `cat ovsdb-server.pid`'
460
461 dnl Create database.
462 touch .conf.db.~lock~
463 AT_CHECK([ovsdb-tool create conf.db $abs_top_srcdir/vswitchd/vswitch.ovsschema])
464
465 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile \
466 --remote=punix:$OVS_RUNDIR/db.sock -vPATTERN:file:"<%B>1 %A %m" \
467 --log-file], [0], [], [stderr])
468 OVS_APP_EXIT_AND_WAIT([ovsdb-server])
469
470 # A default facility of LOG_LOCAL0 while writing to file.
471 AT_CHECK([head -1 ovsdb-server.log | awk '{print $1}'], [0], [<133>1
472 ])
473 rm ovsdb-server.log
474
475 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile \
476 --remote=punix:$OVS_RUNDIR/db.sock -vPATTERN:file:"<%B>1 %A %m" \
477 -vFACILITY:daemon --log-file], [0], [], [stderr])
478
479 AT_CHECK([head -1 ovsdb-server.log | awk '{print $1}'], [0], [<29>1
480 ])
481
482 AT_CHECK([ovs-appctl -t ovsdb-server vlog/set FACILITY:invalid], [2], [],
483 [invalid facility
484 ovs-appctl: ovsdb-server: server returned an error
485 ])
486
487 AT_CHECK([ovs-appctl -t ovsdb-server vlog/set FACILITY:local7])
488 AT_CHECK([ovs-appctl -t ovsdb-server vlog/set ANY:file:DBG])
489 OVS_APP_EXIT_AND_WAIT([ovsdb-server])
490
491 AT_CHECK([tail -1 ovsdb-server.log | awk '{print $1}'], [0], [<191>1
492 ])
493 AT_CLEANUP
494
495 m4_define([VLOG_RFC5424_PYN],
496 [AT_SETUP([vlog - RFC5424 facility - $1])
497 AT_SKIP_IF([test $2 = no])
498 on_exit 'kill `cat test-unixctl.py.pid`'
499
500 AT_CHECK([$3 $srcdir/test-unixctl.py --log-file=`pwd`/log --pidfile \
501 -vFACILITY:invalid --detach], [1], [], [test-unixctl.py: processing "FACILITY:invalid": Facility invalid is invalid
502 ])
503
504 AT_CHECK([$3 $srcdir/test-unixctl.py --log-file=`pwd`/log --pidfile \
505 -vFACILITY:daemon --detach])
506
507 AT_CHECK([ovs-appctl -t test-unixctl.py vlog/set FACILITY:invalid], [0],
508 [Facility invalid is invalid
509 ])
510
511 AT_CHECK([ovs-appctl -t test-unixctl.py vlog/set FACILITY:local0])
512 AT_CLEANUP])
513
514 VLOG_RFC5424_PYN([Python2], [$HAVE_PYTHON2], [$PYTHON2])
515 VLOG_RFC5424_PYN([Python3], [$HAVE_PYTHON3], [$PYTHON3])