3 AT_SETUP([vlog - Python3])
4 AT_CAPTURE_FILE([log_file])
5 AT_CAPTURE_FILE([stderr_log])
6 AT_CHECK([$PYTHON3 $srcdir/test-vlog.py --log-file log_file \
7 -v dbg module_1:info module_2:warn syslog:off 2>stderr_log])
9 AT_CHECK([sed -e 's/.*-.*-.*T..:..:..Z |//' \
10 -e 's/File ".*", line [[0-9]][[0-9]]*,/File <name>, line <number>,/' \
11 stderr_log], [0], [dnl
12 0 | module_0 | EMER | emergency
13 1 | module_0 | ERR | error
14 2 | module_0 | WARN | warning
15 3 | module_0 | INFO | information
16 4 | module_0 | DBG | debug
17 5 | module_0 | EMER | emergency exception
18 Traceback (most recent call last):
19 File <name>, line <number>, in main
22 6 | module_0 | ERR | error exception
23 Traceback (most recent call last):
24 File <name>, line <number>, in main
27 7 | module_0 | WARN | warn exception
28 Traceback (most recent call last):
29 File <name>, line <number>, in main
32 8 | module_0 | INFO | information exception
33 Traceback (most recent call last):
34 File <name>, line <number>, in main
37 9 | module_0 | DBG | debug exception
38 Traceback (most recent call last):
39 File <name>, line <number>, in main
42 10 | module_0 | ERR | exception
43 Traceback (most recent call last):
44 File <name>, line <number>, in main
47 11 | module_1 | EMER | emergency
48 12 | module_1 | ERR | error
49 13 | module_1 | WARN | warning
50 14 | module_1 | INFO | information
51 16 | module_1 | EMER | emergency exception
52 Traceback (most recent call last):
53 File <name>, line <number>, in main
56 17 | module_1 | ERR | error exception
57 Traceback (most recent call last):
58 File <name>, line <number>, in main
61 18 | module_1 | WARN | warn exception
62 Traceback (most recent call last):
63 File <name>, line <number>, in main
66 19 | module_1 | INFO | information exception
67 Traceback (most recent call last):
68 File <name>, line <number>, in main
71 21 | module_1 | ERR | exception
72 Traceback (most recent call last):
73 File <name>, line <number>, in main
76 22 | module_2 | EMER | emergency
77 23 | module_2 | ERR | error
78 24 | module_2 | WARN | warning
79 27 | module_2 | EMER | emergency exception
80 Traceback (most recent call last):
81 File <name>, line <number>, in main
84 28 | module_2 | ERR | error exception
85 Traceback (most recent call last):
86 File <name>, line <number>, in main
89 29 | module_2 | WARN | warn exception
90 Traceback (most recent call last):
91 File <name>, line <number>, in main
94 32 | module_2 | ERR | exception
95 Traceback (most recent call last):
96 File <name>, line <number>, in main
103 m4_divert_push([PREPARE_TESTS])
105 sed 's/.*\(opened log file\).*/\1/
108 m4_divert_pop([PREPARE_TESTS])
110 AT_SETUP([vlog - vlog/reopen - C])
111 # This test won't work as-is on Windows because Windows doesn't allow
112 # files that are open to be renamed.
113 AT_SKIP_IF([test "$IS_WIN32" = "yes"])
114 on_exit 'kill `cat test-unixctl.pid`'
116 AT_CAPTURE_FILE([log])
117 AT_CAPTURE_FILE([log.old])
118 AT_CHECK([ovstest test-unixctl --log-file=`pwd`/log --pidfile --detach --no-chdir],
120 AT_CHECK([vlog_filt stderr], [0],
124 AT_CHECK([APPCTL -t test-unixctl log message])
126 AT_CHECK([APPCTL -t test-unixctl log message2])
127 AT_CHECK([APPCTL -t test-unixctl vlog/reopen])
128 AT_CHECK([APPCTL -t test-unixctl log message3])
129 AT_CHECK([APPCTL -t test-unixctl exit])
131 AT_CHECK([vlog_filt log.old], [0], [dnl
138 AT_CHECK([vlog_filt log], [0], [dnl
144 AT_SETUP([vlog - vlog/reopen - Python3])
145 # This test won't work as-is on Windows because Windows doesn't allow
146 # files that are open to be renamed.
147 AT_SKIP_IF([test "$IS_WIN32" = "yes"])
148 on_exit 'kill `cat test-unixctl.py.pid`'
150 AT_CAPTURE_FILE([log])
151 AT_CAPTURE_FILE([log.old])
152 AT_CHECK([$PYTHON3 $srcdir/test-unixctl.py --log-file=`pwd`/log --pidfile --detach --no-chdir])
154 AT_CHECK([APPCTL -t test-unixctl.py log message])
156 AT_CHECK([APPCTL -t test-unixctl.py log message2])
157 AT_CHECK([APPCTL -t test-unixctl.py vlog/reopen])
158 AT_CHECK([APPCTL -t test-unixctl.py log message3])
159 AT_CHECK([APPCTL -t test-unixctl.py exit])
161 AT_CHECK([sed 's/.*|//' log.old], [0], [dnl
166 AT_CHECK([sed 's/.*|//' log], [0], [dnl
171 AT_SETUP([vlog - vlog/reopen without log file - C])
172 on_exit 'kill `cat test-unixctl.pid`'
174 AT_CHECK([ovstest test-unixctl --pidfile --detach --no-chdir])
176 AT_CHECK([APPCTL -t test-unixctl vlog/reopen], [2], [],
177 [Logging to file not configured
178 ovs-appctl: test-unixctl: server returned an error
180 OVS_APP_EXIT_AND_WAIT([test-unixctl])
183 AT_SETUP([vlog - vlog/reopen without log file - Python3])
184 on_exit 'kill `cat test-unixctl.py.pid`'
186 AT_CHECK([$PYTHON3 $srcdir/test-unixctl.py --pidfile --detach --no-chdir])
188 AT_CHECK([APPCTL -t test-unixctl.py vlog/reopen], [0],
189 [Logging to file not configured
193 dnl This checks that if vlog/reopen can't reopen the log file,
194 dnl nothing particularly bad (e.g. a crash) happens.
195 AT_SETUP([vlog - vlog/reopen can't reopen log file - C])
196 # Verify that /dev/full is a character device that fails writes.
197 AT_SKIP_IF([test ! -c /dev/full])
198 AT_SKIP_IF([echo > /dev/full])
200 on_exit 'kill `cat test-unixctl.pid`'
202 AT_CHECK([ovstest test-unixctl --log-file=`pwd`/log --pidfile --detach --no-chdir],
204 AT_CHECK([vlog_filt stderr], [0], [opened log file
207 AT_CHECK([APPCTL -t test-unixctl log message])
210 AT_CHECK([APPCTL -t test-unixctl vlog/reopen])
211 AT_CHECK([APPCTL -t test-unixctl log message2])
213 AT_CHECK([APPCTL -t test-unixctl vlog/reopen])
214 AT_CHECK([APPCTL -t test-unixctl log message3])
215 AT_CHECK([APPCTL -t test-unixctl exit])
216 AT_CHECK([vlog_filt log.old], [0], [dnl
222 AT_CHECK([vlog_filt log], [0], [dnl
228 dnl This checks that if vlog/reopen can't reopen the log file,
229 dnl nothing particularly bad (e.g. Python throws an exception and
230 dnl aborts the program) happens.
231 AT_SETUP([vlog - vlog/reopen can't reopen log file - Python3])
233 # Verify that /dev/full is a character device that fails writes.
234 AT_SKIP_IF([test ! -c /dev/full])
235 AT_SKIP_IF([echo > /dev/full])
237 on_exit 'kill `cat test-unixctl.py.pid`'
239 AT_CHECK([$PYTHON3 $srcdir/test-unixctl.py --log-file=`pwd`/log --pidfile --detach --no-chdir])
240 AT_CHECK([APPCTL -t test-unixctl.py log message])
243 AT_CHECK([APPCTL -t test-unixctl.py vlog/reopen])
244 AT_CHECK([APPCTL -t test-unixctl.py log message2])
246 AT_CHECK([APPCTL -t test-unixctl.py vlog/reopen])
247 AT_CHECK([APPCTL -t test-unixctl.py log message3])
248 AT_CHECK([APPCTL -t test-unixctl.py exit])
249 AT_CHECK([sed 's/.*|//' log.old], [0], [dnl
253 AT_CHECK([sed 's/.*|//' log], [0], [dnl
258 AT_SETUP([vlog - vlog/close - C])
259 on_exit 'kill `cat test-unixctl.pid`'
261 AT_CAPTURE_FILE([log])
262 AT_CAPTURE_FILE([log.old])
263 AT_CHECK([ovstest test-unixctl --log-file=`pwd`/log --pidfile --detach --no-chdir],
265 AT_CHECK([vlog_filt log], [0], [opened log file
269 AT_CHECK([APPCTL -t test-unixctl log message])
270 AT_CHECK([APPCTL -t test-unixctl log message2])
272 # After closing the log file, message3 won't appear anywhere.
273 AT_CHECK([APPCTL -t test-unixctl vlog/close])
275 AT_CHECK([APPCTL -t test-unixctl log message3])
277 # Closing the log file again is harmless.
278 AT_CHECK([APPCTL -t test-unixctl vlog/close])
279 AT_CHECK([APPCTL -t test-unixctl log message4])
281 # After reopening the log file, further messages start appearing again.
282 AT_CHECK([APPCTL -t test-unixctl vlog/reopen])
283 AT_CHECK([APPCTL -t test-unixctl log message5])
284 AT_CHECK([APPCTL -t test-unixctl exit])
286 AT_CHECK([vlog_filt log.old], [0], [dnl
292 AT_CHECK([vlog_filt log], [0], [dnl
298 AT_SETUP([vlog - vlog/close - Python3])
299 on_exit 'kill `cat test-unixctl.py.pid`'
301 AT_CAPTURE_FILE([log])
302 AT_CAPTURE_FILE([log.old])
303 AT_CHECK([$PYTHON3 $srcdir/test-unixctl.py --log-file=`pwd`/log --pidfile --detach --no-chdir])
305 AT_CHECK([APPCTL -t test-unixctl.py log message])
306 AT_CHECK([APPCTL -t test-unixctl.py log message2])
308 # After closing the log file, message3 won't appear anywhere.
309 AT_CHECK([APPCTL -t test-unixctl.py vlog/close])
311 AT_CHECK([APPCTL -t test-unixctl.py log message3])
313 # Closing the log file again is harmless.
314 AT_CHECK([APPCTL -t test-unixctl.py vlog/close])
315 AT_CHECK([APPCTL -t test-unixctl.py log message4])
317 # After reopening the log file, further messages start appearing again.
318 AT_CHECK([APPCTL -t test-unixctl.py vlog/reopen])
319 AT_CHECK([APPCTL -t test-unixctl.py log message5])
320 AT_CHECK([APPCTL -t test-unixctl.py exit])
322 AT_CHECK([sed 's/.*|//' log.old], [0], [dnl
327 AT_CHECK([sed 's/.*|//' log], [0], [dnl
332 AT_SETUP([vlog - vlog/set and vlog/list - C])
333 on_exit 'kill `cat test-unixctl.pid`'
335 AT_CAPTURE_FILE([log])
336 AT_CHECK([ovstest test-unixctl --log-file=`pwd`/log --pidfile --detach --no-chdir],
338 AT_CHECK([vlog_filt log], [0], [opened log file
342 AT_CHECK([APPCTL -t test-unixctl vlog/list | sed -n '1,2p
343 /test_unixctl /p; /daemon /p'], [0], [dnl
345 ------- ------ ------
347 test_unixctl OFF INFO INFO
350 AT_CHECK([APPCTL -t test-unixctl vlog/set daemon:syslog:err])
351 AT_CHECK([APPCTL -t test-unixctl vlog/set file:dbg])
352 AT_CHECK([APPCTL -t test-unixctl vlog/set nonexistent], [2], [],
353 [no destination, level, or module "nonexistent"
354 ovs-appctl: test-unixctl: server returned an error
356 AT_CHECK([APPCTL -t test-unixctl vlog/list | sed -n '1,2p
357 /test_unixctl /p; /daemon /p'], [0], [dnl
359 ------- ------ ------
361 test_unixctl OFF INFO DBG
364 AT_CHECK([APPCTL -t test-unixctl vlog/set pattern], [2], [],
366 ovs-appctl: test-unixctl: server returned an error
368 AT_CHECK([APPCTL -t test-unixctl vlog/set pattern:nonexistent], [2], [],
369 [unknown destination "nonexistent"
370 ovs-appctl: test-unixctl: server returned an error
372 AT_CHECK([APPCTL -t test-unixctl vlog/set pattern:file:'I<3OVS|%m'])
373 AT_CHECK([APPCTL -t test-unixctl log patterntest])
374 AT_CHECK([grep -q 'I<3OVS' log])
375 OVS_APP_EXIT_AND_WAIT([test-unixctl])
378 AT_SETUP([vlog - vlog/set and vlog/list - Python3])
379 on_exit 'kill `cat test-unixctl.py.pid`'
381 AT_CAPTURE_FILE([log])
382 AT_CHECK([$PYTHON3 $srcdir/test-unixctl.py --log-file=`pwd`/log --pidfile --detach --no-chdir])
384 AT_CHECK([APPCTL -t test-unixctl.py vlog/list], [0], [dnl
386 ------- ------ ------
387 daemon info info info
388 fatal-signal info info info
389 jsonrpc info info info
390 poller info info info
391 reconnect info info info
392 socket_util info info info
393 stream info info info
394 test-unixctl info info info
395 unixctl_server info info info
398 AT_CHECK([APPCTL -t test-unixctl.py vlog/set daemon:syslog:err])
399 AT_CHECK([APPCTL -t test-unixctl.py vlog/set file:dbg])
400 AT_CHECK([APPCTL -t test-unixctl.py vlog/set nonexistent], [0],
401 [no destination, level, or module "nonexistent"
403 AT_CHECK([APPCTL -t test-unixctl.py vlog/list], [0], [dnl
405 ------- ------ ------
407 fatal-signal info info dbg
408 jsonrpc info info dbg
410 reconnect info info dbg
411 socket_util info info dbg
413 test-unixctl info info dbg
414 unixctl_server info info dbg
417 AT_CHECK([APPCTL -t test-unixctl.py vlog/set pattern], [0],
418 [Please supply a valid pattern and destination
420 AT_CHECK([APPCTL -t test-unixctl.py vlog/set pattern:nonexistent], [0],
421 [Destination nonexistent does not exist
423 AT_CHECK([APPCTL -t test-unixctl.py vlog/set pattern:file:'I<3OVS|%m'])
424 AT_CHECK([APPCTL -t test-unixctl.py log patterntest])
425 AT_CHECK([grep -q 'I<3OVS' log])
428 AT_SETUP([vlog - RFC5424 facility])
429 on_exit 'kill `cat ovsdb-server.pid`'
432 touch .conf.db.~lock~
433 AT_CHECK([ovsdb-tool create conf.db $abs_top_srcdir/vswitchd/vswitch.ovsschema])
435 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile \
436 --remote=punix:$OVS_RUNDIR/db.sock -vPATTERN:file:"<%B>1 %A %m" \
437 --log-file], [0], [], [stderr])
438 OVS_APP_EXIT_AND_WAIT([ovsdb-server])
440 # A default facility of LOG_LOCAL0 while writing to file.
441 AT_CHECK([head -1 ovsdb-server.log | awk '{print $1}'], [0], [<133>1
445 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile \
446 --remote=punix:$OVS_RUNDIR/db.sock -vPATTERN:file:"<%B>1 %A %m" \
447 -vFACILITY:daemon --log-file], [0], [], [stderr])
449 AT_CHECK([head -1 ovsdb-server.log | awk '{print $1}'], [0], [<29>1
452 AT_CHECK([ovs-appctl -t ovsdb-server vlog/set FACILITY:invalid], [2], [],
454 ovs-appctl: ovsdb-server: server returned an error
457 AT_CHECK([ovs-appctl -t ovsdb-server vlog/set FACILITY:local7])
458 AT_CHECK([ovs-appctl -t ovsdb-server vlog/set ANY:file:DBG])
459 OVS_APP_EXIT_AND_WAIT([ovsdb-server])
461 AT_CHECK([tail -1 ovsdb-server.log | awk '{print $1}'], [0], [<191>1
465 AT_SETUP([vlog - RFC5424 facility - Python3])
466 on_exit 'kill `cat test-unixctl.py.pid`'
468 AT_CHECK([$PYTHON3 $srcdir/test-unixctl.py --log-file=`pwd`/log --pidfile \
469 -vFACILITY:invalid --detach --no-chdir], [1], [], [test-unixctl.py: processing "FACILITY:invalid": Facility invalid is invalid
472 AT_CHECK([$PYTHON3 $srcdir/test-unixctl.py --log-file=`pwd`/log --pidfile \
473 -vFACILITY:daemon --detach --no-chdir])
475 AT_CHECK([ovs-appctl -t test-unixctl.py vlog/set FACILITY:invalid], [0],
476 [Facility invalid is invalid
479 AT_CHECK([ovs-appctl -t test-unixctl.py vlog/set FACILITY:local0])