]> git.proxmox.com Git - ovs.git/blame - tests/vlog.at
pktbuf: Move from 'ofproto' to 'lib'.
[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
BP
103
104AT_SETUP([vlog - vlog/reopen - Python])
105AT_SKIP_IF([test $HAVE_PYTHON = no])
53eb8cb8 106on_exit 'kill `cat test-unixctl.py.pid`'
8ba37945
BP
107
108AT_CAPTURE_FILE([log])
109AT_CAPTURE_FILE([log.old])
110AT_CHECK([$PYTHON $srcdir/test-unixctl.py --log-file=`pwd`/log --pidfile --detach])
111
112AT_CHECK([APPCTL -t test-unixctl.py log message])
113mv log log.old
114AT_CHECK([APPCTL -t test-unixctl.py log message2])
115AT_CHECK([APPCTL -t test-unixctl.py vlog/reopen])
116AT_CHECK([APPCTL -t test-unixctl.py log message3])
117AT_CHECK([APPCTL -t test-unixctl.py exit])
8ba37945
BP
118
119AT_CHECK([sed 's/.*|//' log.old], [0], [dnl
a5ed8fe3
DT
120 Entering run loop.
121 message
122 message2
8ba37945
BP
123])
124AT_CHECK([sed 's/.*|//' log], [0], [dnl
a5ed8fe3 125 message3
8ba37945
BP
126])
127AT_CLEANUP
128
129AT_SETUP([vlog - vlog/reopen without log file - Python])
130AT_SKIP_IF([test $HAVE_PYTHON = no])
53eb8cb8 131on_exit 'kill `cat test-unixctl.py.pid`'
8ba37945
BP
132
133AT_CHECK([$PYTHON $srcdir/test-unixctl.py --pidfile --detach])
134
135AT_CHECK([APPCTL -t test-unixctl.py vlog/reopen], [0],
136 [Logging to file not configured
137])
138AT_CLEANUP
139
140dnl This checks that if vlog/reopen can't reopen the log file,
141dnl nothing particularly bad (e.g. Python throws an exception and
142dnl aborts the program) happens.
143AT_SETUP([vlog - vlog/reopen can't reopen log file - Python])
144AT_SKIP_IF([test $HAVE_PYTHON = no])
145
146# Verify that /dev/full is a character device that fails writes.
147AT_SKIP_IF([test ! -c /dev/full])
148AT_SKIP_IF([echo > /dev/full])
149
53eb8cb8 150on_exit 'kill `cat test-unixctl.py.pid`'
8ba37945
BP
151
152AT_CHECK([$PYTHON $srcdir/test-unixctl.py --log-file=`pwd`/log --pidfile --detach])
153AT_CHECK([APPCTL -t test-unixctl.py log message])
154mv log log.old
155ln -s /dev/full log
156AT_CHECK([APPCTL -t test-unixctl.py vlog/reopen])
157AT_CHECK([APPCTL -t test-unixctl.py log message2])
158rm log
159AT_CHECK([APPCTL -t test-unixctl.py vlog/reopen])
160AT_CHECK([APPCTL -t test-unixctl.py log message3])
161AT_CHECK([APPCTL -t test-unixctl.py exit])
162AT_CHECK([sed 's/.*|//' log.old], [0], [dnl
a5ed8fe3
DT
163 Entering run loop.
164 message
8ba37945
BP
165])
166AT_CHECK([sed 's/.*|//' log], [0], [dnl
a5ed8fe3 167 message3
8ba37945
BP
168])
169AT_CLEANUP
f26ddb5b
BP
170
171AT_SETUP([vlog - vlog/set and vlog/list - Python])
172AT_SKIP_IF([test $HAVE_PYTHON = no])
53eb8cb8 173on_exit 'kill `cat test-unixctl.py.pid`'
f26ddb5b
BP
174
175AT_CAPTURE_FILE([log])
176AT_CHECK([$PYTHON $srcdir/test-unixctl.py --log-file=`pwd`/log --pidfile --detach])
177
178AT_CHECK([APPCTL -t test-unixctl.py vlog/list], [0], [dnl
179 console syslog file
180 ------- ------ ------
181daemon info info info
182fatal-signal info info info
183jsonrpc info info info
184poller info info info
185reconnect info info info
186socket_util info info info
187stream info info info
188test-unixctl info info info
189unixctl_server info info info
190])
191
192AT_CHECK([APPCTL -t test-unixctl.py vlog/set daemon:syslog:err])
193AT_CHECK([APPCTL -t test-unixctl.py vlog/set file:dbg])
194AT_CHECK([APPCTL -t test-unixctl.py vlog/set nonexistent], [0],
d5460484 195 [no destination, level, or module "nonexistent"
f26ddb5b
BP
196])
197AT_CHECK([APPCTL -t test-unixctl.py vlog/list], [0], [dnl
198 console syslog file
199 ------- ------ ------
200daemon info err dbg
201fatal-signal info info dbg
202jsonrpc info info dbg
203poller info info dbg
204reconnect info info dbg
205socket_util info info dbg
206stream info info dbg
207test-unixctl info info dbg
208unixctl_server info info dbg
209])
a5ed8fe3
DT
210
211AT_CHECK([APPCTL -t test-unixctl.py vlog/set pattern], [0],
d5460484 212 [Please supply a valid pattern and destination
a5ed8fe3
DT
213])
214AT_CHECK([APPCTL -t test-unixctl.py vlog/set pattern:nonexistent], [0],
d5460484 215 [Destination nonexistent does not exist
a5ed8fe3
DT
216])
217AT_CHECK([APPCTL -t test-unixctl.py vlog/set pattern:file:'I<3OVS|%m'])
218AT_CHECK([APPCTL -t test-unixctl.py log patterntest])
219AT_CHECK([grep -q 'I<3OVS' log])
f26ddb5b 220AT_CLEANUP
d69d61c7
GS
221
222AT_SETUP([vlog - RFC5424 facility])
53eb8cb8 223on_exit 'kill `cat ovsdb-server.pid`'
d69d61c7
GS
224
225dnl Create database.
226touch .conf.db.~lock~
227AT_CHECK([ovsdb-tool create conf.db $abs_top_srcdir/vswitchd/vswitch.ovsschema])
228
229AT_CHECK([ovsdb-server --detach --no-chdir --pidfile \
230 --remote=punix:$OVS_RUNDIR/db.sock -vPATTERN:file:"<%B>1 %A %m" \
231 --log-file], [0], [], [stderr])
232AT_CHECK([ovs-appctl -t ovsdb-server exit])
233
234# A default facility of LOG_LOCAL0 while writing to file.
235AT_CHECK([cat ovsdb-server.log | head -1 | awk '{print $1}'], [0], [<133>1
236])
237rm ovsdb-server.log
238
239AT_CHECK([ovsdb-server --detach --no-chdir --pidfile \
240 --remote=punix:$OVS_RUNDIR/db.sock -vPATTERN:file:"<%B>1 %A %m" \
241 -vFACILITY:daemon --log-file], [0], [], [stderr])
242
243AT_CHECK([cat ovsdb-server.log | head -1 | awk '{print $1}'], [0], [<29>1
244])
245
246AT_CHECK([ovs-appctl -t ovsdb-server vlog/set FACILITY:invalid], [2], [],
247[invalid facility
248ovs-appctl: ovsdb-server: server returned an error
249])
250
251AT_CHECK([ovs-appctl -t ovsdb-server vlog/set FACILITY:local7])
252AT_CHECK([ovs-appctl -t ovsdb-server vlog/set ANY:file:DBG])
253AT_CHECK([ovs-appctl -t ovsdb-server exit])
254
255AT_CHECK([cat ovsdb-server.log | tail -1 | awk '{print $1}'], [0], [<191>1
256])
257AT_CLEANUP
258
259AT_SETUP([vlog - RFC5424 facility - Python])
260AT_SKIP_IF([test $HAVE_PYTHON = no])
53eb8cb8 261on_exit 'kill `cat test-unixctl.py.pid`'
d69d61c7
GS
262
263AT_CHECK([$PYTHON $srcdir/test-unixctl.py --log-file=`pwd`/log --pidfile \
264-vFACILITY:invalid --detach], [1], [], [test-unixctl.py: processing "FACILITY:invalid": Facility invalid is invalid
265])
266
267AT_CHECK([$PYTHON $srcdir/test-unixctl.py --log-file=`pwd`/log --pidfile \
268-vFACILITY:daemon --detach])
269
270AT_CHECK([ovs-appctl -t test-unixctl.py vlog/set FACILITY:invalid], [0],
271[Facility invalid is invalid
272])
273
274AT_CHECK([ovs-appctl -t test-unixctl.py vlog/set FACILITY:local0])
275AT_CLEANUP