]> git.proxmox.com Git - mirror_ovs.git/blame - tests/vlog.at
vlog: Make the most common module reference more direct.
[mirror_ovs.git] / tests / vlog.at
CommitLineData
8ed182d8
EJ
1AT_BANNER([vlog])
2
3AT_SETUP([vlog - Python])
4AT_SKIP_IF([test $HAVE_PYTHON = no])
8ed182d8
EJ
5AT_CAPTURE_FILE([log_file])
6AT_CAPTURE_FILE([stderr_log])
ea523221
BP
7AT_CHECK([$PYTHON $srcdir/test-vlog.py --log-file log_file \
8-v dbg module_1:info module_2:warn syslog:off 2>stderr_log])
8ed182d8 9
a5ed8fe3 10AT_CHECK([sed -e 's/.*-.*-.*T..:..:..Z |//' \
7b7e43f5 11-e 's/File ".*", line [[0-9]][[0-9]]*,/File <name>, line <number>,/' \
8ed182d8 12stderr_log], [0], [dnl
a5ed8fe3
DT
13 0 | module_0 | EMER | emergency
14 1 | module_0 | ERR | error
15 2 | module_0 | WARN | warning
16 3 | module_0 | INFO | information
17 4 | module_0 | DBG | debug
18 5 | module_0 | EMER | emergency exception
8ed182d8
EJ
19Traceback (most recent call last):
20 File <name>, line <number>, in main
21 assert fail
22AssertionError
a5ed8fe3 23 6 | module_0 | ERR | error exception
8ed182d8
EJ
24Traceback (most recent call last):
25 File <name>, line <number>, in main
26 assert fail
27AssertionError
a5ed8fe3 28 7 | module_0 | WARN | warn exception
8ed182d8
EJ
29Traceback (most recent call last):
30 File <name>, line <number>, in main
31 assert fail
32AssertionError
a5ed8fe3 33 8 | module_0 | INFO | information exception
8ed182d8
EJ
34Traceback (most recent call last):
35 File <name>, line <number>, in main
36 assert fail
37AssertionError
a5ed8fe3 38 9 | module_0 | DBG | debug exception
8ed182d8
EJ
39Traceback (most recent call last):
40 File <name>, line <number>, in main
41 assert fail
42AssertionError
a5ed8fe3 43 10 | module_0 | ERR | exception
8ed182d8
EJ
44Traceback (most recent call last):
45 File <name>, line <number>, in main
46 assert fail
47AssertionError
a5ed8fe3
DT
48 11 | module_1 | EMER | emergency
49 12 | module_1 | ERR | error
50 13 | module_1 | WARN | warning
51 14 | module_1 | INFO | information
52 16 | module_1 | EMER | emergency exception
8ed182d8
EJ
53Traceback (most recent call last):
54 File <name>, line <number>, in main
55 assert fail
56AssertionError
a5ed8fe3 57 17 | module_1 | ERR | error exception
8ed182d8
EJ
58Traceback (most recent call last):
59 File <name>, line <number>, in main
60 assert fail
61AssertionError
a5ed8fe3 62 18 | module_1 | WARN | warn exception
8ed182d8
EJ
63Traceback (most recent call last):
64 File <name>, line <number>, in main
65 assert fail
66AssertionError
a5ed8fe3 67 19 | module_1 | INFO | information exception
8ed182d8
EJ
68Traceback (most recent call last):
69 File <name>, line <number>, in main
70 assert fail
71AssertionError
a5ed8fe3 72 21 | module_1 | ERR | exception
8ed182d8
EJ
73Traceback (most recent call last):
74 File <name>, line <number>, in main
75 assert fail
76AssertionError
a5ed8fe3
DT
77 22 | module_2 | EMER | emergency
78 23 | module_2 | ERR | error
79 24 | module_2 | WARN | warning
80 27 | module_2 | EMER | emergency exception
8ed182d8
EJ
81Traceback (most recent call last):
82 File <name>, line <number>, in main
83 assert fail
84AssertionError
a5ed8fe3 85 28 | module_2 | ERR | error exception
8ed182d8
EJ
86Traceback (most recent call last):
87 File <name>, line <number>, in main
88 assert fail
89AssertionError
a5ed8fe3 90 29 | module_2 | WARN | warn exception
8ed182d8
EJ
91Traceback (most recent call last):
92 File <name>, line <number>, in main
93 assert fail
94AssertionError
a5ed8fe3 95 32 | module_2 | ERR | exception
8ed182d8
EJ
96Traceback (most recent call last):
97 File <name>, line <number>, in main
98 assert fail
99AssertionError
100])
101
102AT_CLEANUP
8ba37945 103
3c016b8b
BP
104m4_divert_push([PREPARE_TESTS])
105vlog_filt () {
106 sed 's/.*\(opened log file\).*/\1/
107s/.*|//' "$@"
108}
109m4_divert_pop([PREPARE_TESTS])
110
111AT_SETUP([vlog - vlog/reopen - C])
112# This test won't work as-is on Windows because Windows doesn't allow
113# files that are open to be renamed.
114AT_SKIP_IF([test "$IS_WIN32" = "yes"])
115on_exit 'kill `cat test-unixctl.pid`'
116
117AT_CAPTURE_FILE([log])
118AT_CAPTURE_FILE([log.old])
119AT_CHECK([ovstest test-unixctl --log-file=`pwd`/log --pidfile --detach],
120 [0], [], [stderr])
121AT_CHECK([vlog_filt stderr], [0],
122 [opened log file
123])
124
125AT_CHECK([APPCTL -t test-unixctl log message])
126mv log log.old
127AT_CHECK([APPCTL -t test-unixctl log message2])
128AT_CHECK([APPCTL -t test-unixctl vlog/reopen])
129AT_CHECK([APPCTL -t test-unixctl log message3])
130AT_CHECK([APPCTL -t test-unixctl exit])
131
132AT_CHECK([vlog_filt log.old], [0], [dnl
133opened log file
134Entering run loop.
135message
136message2
137closing log file
138])
139AT_CHECK([vlog_filt log], [0], [dnl
140opened log file
141message3
142])
143AT_CLEANUP
144
8ba37945
BP
145AT_SETUP([vlog - vlog/reopen - Python])
146AT_SKIP_IF([test $HAVE_PYTHON = no])
53eb8cb8 147on_exit 'kill `cat test-unixctl.py.pid`'
8ba37945
BP
148
149AT_CAPTURE_FILE([log])
150AT_CAPTURE_FILE([log.old])
151AT_CHECK([$PYTHON $srcdir/test-unixctl.py --log-file=`pwd`/log --pidfile --detach])
152
153AT_CHECK([APPCTL -t test-unixctl.py log message])
154mv log log.old
155AT_CHECK([APPCTL -t test-unixctl.py log message2])
156AT_CHECK([APPCTL -t test-unixctl.py vlog/reopen])
157AT_CHECK([APPCTL -t test-unixctl.py log message3])
158AT_CHECK([APPCTL -t test-unixctl.py exit])
8ba37945
BP
159
160AT_CHECK([sed 's/.*|//' log.old], [0], [dnl
a5ed8fe3
DT
161 Entering run loop.
162 message
163 message2
8ba37945
BP
164])
165AT_CHECK([sed 's/.*|//' log], [0], [dnl
a5ed8fe3 166 message3
8ba37945
BP
167])
168AT_CLEANUP
169
3c016b8b
BP
170AT_SETUP([vlog - vlog/reopen without log file - C])
171on_exit 'kill `cat test-unixctl.pid`'
172
173AT_CHECK([ovstest test-unixctl --pidfile --detach])
174
175AT_CHECK([APPCTL -t test-unixctl vlog/reopen], [2], [],
176 [Logging to file not configured
177ovs-appctl: test-unixctl: server returned an error
178])
179AT_CLEANUP
180
8ba37945
BP
181AT_SETUP([vlog - vlog/reopen without log file - Python])
182AT_SKIP_IF([test $HAVE_PYTHON = no])
53eb8cb8 183on_exit 'kill `cat test-unixctl.py.pid`'
8ba37945
BP
184
185AT_CHECK([$PYTHON $srcdir/test-unixctl.py --pidfile --detach])
186
187AT_CHECK([APPCTL -t test-unixctl.py vlog/reopen], [0],
188 [Logging to file not configured
189])
190AT_CLEANUP
191
3c016b8b
BP
192dnl This checks that if vlog/reopen can't reopen the log file,
193dnl nothing particularly bad (e.g. a crash) happens.
194AT_SETUP([vlog - vlog/reopen can't reopen log file - C])
195# Verify that /dev/full is a character device that fails writes.
196AT_SKIP_IF([test ! -c /dev/full])
197AT_SKIP_IF([echo > /dev/full])
198
199on_exit 'kill `cat test-unixctl.pid`'
200
201AT_CHECK([ovstest test-unixctl --log-file=`pwd`/log --pidfile --detach],
202 [0], [], [stderr])
203AT_CHECK([vlog_filt stderr], [0], [opened log file
204])
205
206AT_CHECK([APPCTL -t test-unixctl log message])
207mv log log.old
208ln -s /dev/full log
209AT_CHECK([APPCTL -t test-unixctl vlog/reopen])
210AT_CHECK([APPCTL -t test-unixctl log message2])
211rm log
212AT_CHECK([APPCTL -t test-unixctl vlog/reopen])
213AT_CHECK([APPCTL -t test-unixctl log message3])
214AT_CHECK([APPCTL -t test-unixctl exit])
215AT_CHECK([vlog_filt log.old], [0], [dnl
216opened log file
217Entering run loop.
218message
219closing log file
220])
221AT_CHECK([vlog_filt log], [0], [dnl
222opened log file
223message3
224])
225AT_CLEANUP
226
8ba37945
BP
227dnl This checks that if vlog/reopen can't reopen the log file,
228dnl nothing particularly bad (e.g. Python throws an exception and
229dnl aborts the program) happens.
230AT_SETUP([vlog - vlog/reopen can't reopen log file - Python])
231AT_SKIP_IF([test $HAVE_PYTHON = no])
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
53eb8cb8 237on_exit 'kill `cat test-unixctl.py.pid`'
8ba37945
BP
238
239AT_CHECK([$PYTHON $srcdir/test-unixctl.py --log-file=`pwd`/log --pidfile --detach])
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
BP
252])
253AT_CHECK([sed 's/.*|//' log], [0], [dnl
a5ed8fe3 254 message3
8ba37945
BP
255])
256AT_CLEANUP
f26ddb5b 257
3c016b8b
BP
258AT_SETUP([vlog - vlog/set and vlog/list - C])
259on_exit 'kill `cat test-unixctl.pid`'
260
261AT_CAPTURE_FILE([log])
262AT_CHECK([ovstest test-unixctl --log-file=`pwd`/log --pidfile --detach],
263 [0], [], [stderr])
264AT_CHECK([vlog_filt stderr], [0], [opened log file
265])
266
267AT_CHECK([APPCTL -t test-unixctl vlog/list | sed -n '1,2p
268/\(test_unixctl\|daemon\) /p'], [0], [dnl
269 console syslog file
270 ------- ------ ------
271daemon OFF INFO INFO
272test_unixctl OFF INFO INFO
273])
274
275AT_CHECK([APPCTL -t test-unixctl vlog/set daemon:syslog:err])
276AT_CHECK([APPCTL -t test-unixctl vlog/set file:dbg])
277AT_CHECK([APPCTL -t test-unixctl vlog/set nonexistent], [2], [],
278 [no destination, level, or module "nonexistent"
279ovs-appctl: test-unixctl: server returned an error
280])
281AT_CHECK([APPCTL -t test-unixctl vlog/list | sed -n '1,2p
282/\(test_unixctl\|daemon\) /p'], [0], [dnl
283 console syslog file
284 ------- ------ ------
285daemon OFF ERR DBG
286test_unixctl OFF INFO DBG
287])
288
289AT_CHECK([APPCTL -t test-unixctl vlog/set pattern], [2], [],
290 [missing destination
291ovs-appctl: test-unixctl: server returned an error
292])
293AT_CHECK([APPCTL -t test-unixctl vlog/set pattern:nonexistent], [2], [],
294 [unknown destination "nonexistent"
295ovs-appctl: test-unixctl: server returned an error
296])
297AT_CHECK([APPCTL -t test-unixctl vlog/set pattern:file:'I<3OVS|%m'])
298AT_CHECK([APPCTL -t test-unixctl log patterntest])
299AT_CHECK([grep -q 'I<3OVS' log])
300AT_CLEANUP
301
f26ddb5b
BP
302AT_SETUP([vlog - vlog/set and vlog/list - Python])
303AT_SKIP_IF([test $HAVE_PYTHON = no])
53eb8cb8 304on_exit 'kill `cat test-unixctl.py.pid`'
f26ddb5b
BP
305
306AT_CAPTURE_FILE([log])
307AT_CHECK([$PYTHON $srcdir/test-unixctl.py --log-file=`pwd`/log --pidfile --detach])
308
309AT_CHECK([APPCTL -t test-unixctl.py vlog/list], [0], [dnl
310 console syslog file
311 ------- ------ ------
312daemon info info info
313fatal-signal info info info
314jsonrpc info info info
315poller info info info
316reconnect info info info
317socket_util info info info
318stream info info info
319test-unixctl info info info
320unixctl_server info info info
321])
322
323AT_CHECK([APPCTL -t test-unixctl.py vlog/set daemon:syslog:err])
324AT_CHECK([APPCTL -t test-unixctl.py vlog/set file:dbg])
325AT_CHECK([APPCTL -t test-unixctl.py vlog/set nonexistent], [0],
d5460484 326 [no destination, level, or module "nonexistent"
f26ddb5b
BP
327])
328AT_CHECK([APPCTL -t test-unixctl.py vlog/list], [0], [dnl
329 console syslog file
330 ------- ------ ------
331daemon info err dbg
332fatal-signal info info dbg
333jsonrpc info info dbg
334poller info info dbg
335reconnect info info dbg
336socket_util info info dbg
337stream info info dbg
338test-unixctl info info dbg
339unixctl_server info info dbg
340])
a5ed8fe3
DT
341
342AT_CHECK([APPCTL -t test-unixctl.py vlog/set pattern], [0],
d5460484 343 [Please supply a valid pattern and destination
a5ed8fe3
DT
344])
345AT_CHECK([APPCTL -t test-unixctl.py vlog/set pattern:nonexistent], [0],
d5460484 346 [Destination nonexistent does not exist
a5ed8fe3
DT
347])
348AT_CHECK([APPCTL -t test-unixctl.py vlog/set pattern:file:'I<3OVS|%m'])
349AT_CHECK([APPCTL -t test-unixctl.py log patterntest])
350AT_CHECK([grep -q 'I<3OVS' log])
f26ddb5b 351AT_CLEANUP
d69d61c7
GS
352
353AT_SETUP([vlog - RFC5424 facility])
53eb8cb8 354on_exit 'kill `cat ovsdb-server.pid`'
d69d61c7
GS
355
356dnl Create database.
357touch .conf.db.~lock~
358AT_CHECK([ovsdb-tool create conf.db $abs_top_srcdir/vswitchd/vswitch.ovsschema])
359
360AT_CHECK([ovsdb-server --detach --no-chdir --pidfile \
361 --remote=punix:$OVS_RUNDIR/db.sock -vPATTERN:file:"<%B>1 %A %m" \
362 --log-file], [0], [], [stderr])
363AT_CHECK([ovs-appctl -t ovsdb-server exit])
364
365# A default facility of LOG_LOCAL0 while writing to file.
38b0b29f 366AT_CHECK([head -1 ovsdb-server.log | awk '{print $1}'], [0], [<133>1
d69d61c7
GS
367])
368rm ovsdb-server.log
369
370AT_CHECK([ovsdb-server --detach --no-chdir --pidfile \
371 --remote=punix:$OVS_RUNDIR/db.sock -vPATTERN:file:"<%B>1 %A %m" \
372 -vFACILITY:daemon --log-file], [0], [], [stderr])
373
38b0b29f 374AT_CHECK([head -1 ovsdb-server.log | awk '{print $1}'], [0], [<29>1
d69d61c7
GS
375])
376
377AT_CHECK([ovs-appctl -t ovsdb-server vlog/set FACILITY:invalid], [2], [],
378[invalid facility
379ovs-appctl: ovsdb-server: server returned an error
380])
381
382AT_CHECK([ovs-appctl -t ovsdb-server vlog/set FACILITY:local7])
383AT_CHECK([ovs-appctl -t ovsdb-server vlog/set ANY:file:DBG])
384AT_CHECK([ovs-appctl -t ovsdb-server exit])
385
38b0b29f 386AT_CHECK([tail -1 ovsdb-server.log | awk '{print $1}'], [0], [<191>1
d69d61c7
GS
387])
388AT_CLEANUP
389
390AT_SETUP([vlog - RFC5424 facility - Python])
391AT_SKIP_IF([test $HAVE_PYTHON = no])
53eb8cb8 392on_exit 'kill `cat test-unixctl.py.pid`'
d69d61c7
GS
393
394AT_CHECK([$PYTHON $srcdir/test-unixctl.py --log-file=`pwd`/log --pidfile \
395-vFACILITY:invalid --detach], [1], [], [test-unixctl.py: processing "FACILITY:invalid": Facility invalid is invalid
396])
397
398AT_CHECK([$PYTHON $srcdir/test-unixctl.py --log-file=`pwd`/log --pidfile \
399-vFACILITY:daemon --detach])
400
401AT_CHECK([ovs-appctl -t test-unixctl.py vlog/set FACILITY:invalid], [0],
402[Facility invalid is invalid
403])
404
405AT_CHECK([ovs-appctl -t test-unixctl.py vlog/set FACILITY:local0])
406AT_CLEANUP