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