]> git.proxmox.com Git - ovs.git/blob - tests/vlog.at
pktbuf: Move from 'ofproto' to 'lib'.
[ovs.git] / tests / vlog.at
1 AT_BANNER([vlog])
2
3 AT_SETUP([vlog - Python])
4 AT_SKIP_IF([test $HAVE_PYTHON = no])
5 AT_CAPTURE_FILE([log_file])
6 AT_CAPTURE_FILE([stderr_log])
7 AT_CHECK([$PYTHON $srcdir/test-vlog.py --log-file log_file \
8 -v dbg module_1:info module_2:warn syslog:off 2>stderr_log])
9
10 AT_CHECK([sed -e 's/.*-.*-.*T..:..:..Z |//' \
11 -e 's/File ".*", line [[0-9]][[0-9]]*,/File <name>, line <number>,/' \
12 stderr_log], [0], [dnl
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
19 Traceback (most recent call last):
20 File <name>, line <number>, in main
21 assert fail
22 AssertionError
23 6 | module_0 | ERR | error exception
24 Traceback (most recent call last):
25 File <name>, line <number>, in main
26 assert fail
27 AssertionError
28 7 | module_0 | WARN | warn exception
29 Traceback (most recent call last):
30 File <name>, line <number>, in main
31 assert fail
32 AssertionError
33 8 | module_0 | INFO | information exception
34 Traceback (most recent call last):
35 File <name>, line <number>, in main
36 assert fail
37 AssertionError
38 9 | module_0 | DBG | debug exception
39 Traceback (most recent call last):
40 File <name>, line <number>, in main
41 assert fail
42 AssertionError
43 10 | module_0 | ERR | exception
44 Traceback (most recent call last):
45 File <name>, line <number>, in main
46 assert fail
47 AssertionError
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
53 Traceback (most recent call last):
54 File <name>, line <number>, in main
55 assert fail
56 AssertionError
57 17 | module_1 | ERR | error exception
58 Traceback (most recent call last):
59 File <name>, line <number>, in main
60 assert fail
61 AssertionError
62 18 | module_1 | WARN | warn exception
63 Traceback (most recent call last):
64 File <name>, line <number>, in main
65 assert fail
66 AssertionError
67 19 | module_1 | INFO | information exception
68 Traceback (most recent call last):
69 File <name>, line <number>, in main
70 assert fail
71 AssertionError
72 21 | module_1 | ERR | exception
73 Traceback (most recent call last):
74 File <name>, line <number>, in main
75 assert fail
76 AssertionError
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
81 Traceback (most recent call last):
82 File <name>, line <number>, in main
83 assert fail
84 AssertionError
85 28 | module_2 | ERR | error exception
86 Traceback (most recent call last):
87 File <name>, line <number>, in main
88 assert fail
89 AssertionError
90 29 | module_2 | WARN | warn exception
91 Traceback (most recent call last):
92 File <name>, line <number>, in main
93 assert fail
94 AssertionError
95 32 | module_2 | ERR | exception
96 Traceback (most recent call last):
97 File <name>, line <number>, in main
98 assert fail
99 AssertionError
100 ])
101
102 AT_CLEANUP
103
104 AT_SETUP([vlog - vlog/reopen - Python])
105 AT_SKIP_IF([test $HAVE_PYTHON = no])
106 on_exit 'kill `cat test-unixctl.py.pid`'
107
108 AT_CAPTURE_FILE([log])
109 AT_CAPTURE_FILE([log.old])
110 AT_CHECK([$PYTHON $srcdir/test-unixctl.py --log-file=`pwd`/log --pidfile --detach])
111
112 AT_CHECK([APPCTL -t test-unixctl.py log message])
113 mv log log.old
114 AT_CHECK([APPCTL -t test-unixctl.py log message2])
115 AT_CHECK([APPCTL -t test-unixctl.py vlog/reopen])
116 AT_CHECK([APPCTL -t test-unixctl.py log message3])
117 AT_CHECK([APPCTL -t test-unixctl.py exit])
118
119 AT_CHECK([sed 's/.*|//' log.old], [0], [dnl
120 Entering run loop.
121 message
122 message2
123 ])
124 AT_CHECK([sed 's/.*|//' log], [0], [dnl
125 message3
126 ])
127 AT_CLEANUP
128
129 AT_SETUP([vlog - vlog/reopen without log file - Python])
130 AT_SKIP_IF([test $HAVE_PYTHON = no])
131 on_exit 'kill `cat test-unixctl.py.pid`'
132
133 AT_CHECK([$PYTHON $srcdir/test-unixctl.py --pidfile --detach])
134
135 AT_CHECK([APPCTL -t test-unixctl.py vlog/reopen], [0],
136 [Logging to file not configured
137 ])
138 AT_CLEANUP
139
140 dnl This checks that if vlog/reopen can't reopen the log file,
141 dnl nothing particularly bad (e.g. Python throws an exception and
142 dnl aborts the program) happens.
143 AT_SETUP([vlog - vlog/reopen can't reopen log file - Python])
144 AT_SKIP_IF([test $HAVE_PYTHON = no])
145
146 # Verify that /dev/full is a character device that fails writes.
147 AT_SKIP_IF([test ! -c /dev/full])
148 AT_SKIP_IF([echo > /dev/full])
149
150 on_exit 'kill `cat test-unixctl.py.pid`'
151
152 AT_CHECK([$PYTHON $srcdir/test-unixctl.py --log-file=`pwd`/log --pidfile --detach])
153 AT_CHECK([APPCTL -t test-unixctl.py log message])
154 mv log log.old
155 ln -s /dev/full log
156 AT_CHECK([APPCTL -t test-unixctl.py vlog/reopen])
157 AT_CHECK([APPCTL -t test-unixctl.py log message2])
158 rm log
159 AT_CHECK([APPCTL -t test-unixctl.py vlog/reopen])
160 AT_CHECK([APPCTL -t test-unixctl.py log message3])
161 AT_CHECK([APPCTL -t test-unixctl.py exit])
162 AT_CHECK([sed 's/.*|//' log.old], [0], [dnl
163 Entering run loop.
164 message
165 ])
166 AT_CHECK([sed 's/.*|//' log], [0], [dnl
167 message3
168 ])
169 AT_CLEANUP
170
171 AT_SETUP([vlog - vlog/set and vlog/list - Python])
172 AT_SKIP_IF([test $HAVE_PYTHON = no])
173 on_exit 'kill `cat test-unixctl.py.pid`'
174
175 AT_CAPTURE_FILE([log])
176 AT_CHECK([$PYTHON $srcdir/test-unixctl.py --log-file=`pwd`/log --pidfile --detach])
177
178 AT_CHECK([APPCTL -t test-unixctl.py vlog/list], [0], [dnl
179 console syslog file
180 ------- ------ ------
181 daemon info info info
182 fatal-signal info info info
183 jsonrpc info info info
184 poller info info info
185 reconnect info info info
186 socket_util info info info
187 stream info info info
188 test-unixctl info info info
189 unixctl_server info info info
190 ])
191
192 AT_CHECK([APPCTL -t test-unixctl.py vlog/set daemon:syslog:err])
193 AT_CHECK([APPCTL -t test-unixctl.py vlog/set file:dbg])
194 AT_CHECK([APPCTL -t test-unixctl.py vlog/set nonexistent], [0],
195 [no destination, level, or module "nonexistent"
196 ])
197 AT_CHECK([APPCTL -t test-unixctl.py vlog/list], [0], [dnl
198 console syslog file
199 ------- ------ ------
200 daemon info err dbg
201 fatal-signal info info dbg
202 jsonrpc info info dbg
203 poller info info dbg
204 reconnect info info dbg
205 socket_util info info dbg
206 stream info info dbg
207 test-unixctl info info dbg
208 unixctl_server info info dbg
209 ])
210
211 AT_CHECK([APPCTL -t test-unixctl.py vlog/set pattern], [0],
212 [Please supply a valid pattern and destination
213 ])
214 AT_CHECK([APPCTL -t test-unixctl.py vlog/set pattern:nonexistent], [0],
215 [Destination nonexistent does not exist
216 ])
217 AT_CHECK([APPCTL -t test-unixctl.py vlog/set pattern:file:'I<3OVS|%m'])
218 AT_CHECK([APPCTL -t test-unixctl.py log patterntest])
219 AT_CHECK([grep -q 'I<3OVS' log])
220 AT_CLEANUP
221
222 AT_SETUP([vlog - RFC5424 facility])
223 on_exit 'kill `cat ovsdb-server.pid`'
224
225 dnl Create database.
226 touch .conf.db.~lock~
227 AT_CHECK([ovsdb-tool create conf.db $abs_top_srcdir/vswitchd/vswitch.ovsschema])
228
229 AT_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])
232 AT_CHECK([ovs-appctl -t ovsdb-server exit])
233
234 # A default facility of LOG_LOCAL0 while writing to file.
235 AT_CHECK([cat ovsdb-server.log | head -1 | awk '{print $1}'], [0], [<133>1
236 ])
237 rm ovsdb-server.log
238
239 AT_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
243 AT_CHECK([cat ovsdb-server.log | head -1 | awk '{print $1}'], [0], [<29>1
244 ])
245
246 AT_CHECK([ovs-appctl -t ovsdb-server vlog/set FACILITY:invalid], [2], [],
247 [invalid facility
248 ovs-appctl: ovsdb-server: server returned an error
249 ])
250
251 AT_CHECK([ovs-appctl -t ovsdb-server vlog/set FACILITY:local7])
252 AT_CHECK([ovs-appctl -t ovsdb-server vlog/set ANY:file:DBG])
253 AT_CHECK([ovs-appctl -t ovsdb-server exit])
254
255 AT_CHECK([cat ovsdb-server.log | tail -1 | awk '{print $1}'], [0], [<191>1
256 ])
257 AT_CLEANUP
258
259 AT_SETUP([vlog - RFC5424 facility - Python])
260 AT_SKIP_IF([test $HAVE_PYTHON = no])
261 on_exit 'kill `cat test-unixctl.py.pid`'
262
263 AT_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
267 AT_CHECK([$PYTHON $srcdir/test-unixctl.py --log-file=`pwd`/log --pidfile \
268 -vFACILITY:daemon --detach])
269
270 AT_CHECK([ovs-appctl -t test-unixctl.py vlog/set FACILITY:invalid], [0],
271 [Facility invalid is invalid
272 ])
273
274 AT_CHECK([ovs-appctl -t test-unixctl.py vlog/set FACILITY:local0])
275 AT_CLEANUP