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