aboutsummaryrefslogtreecommitdiff
path: root/tests/vlog.at
blob: 957d872275e26535b3cd4db57c0cd0ca80609166 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
AT_BANNER([vlog])

AT_SETUP([vlog - Python])
AT_SKIP_IF([test $HAVE_PYTHON = no])
AT_CAPTURE_FILE([log_file])
AT_CAPTURE_FILE([stderr_log])
AT_CHECK([$PYTHON $srcdir/test-vlog.py --log-file log_file \
-v dbg module_1:info module_2:warn syslog:off 2>stderr_log])

AT_CHECK([diff log_file stderr_log])

AT_CHECK([sed -e 's/.*-.*-.*T..:..:..Z|//' \
-e 's/File ".*", line [[0-9]][[0-9]]*,/File <name>, line <number>,/' \
stderr_log], [0], [dnl
0|module_0|EMER|emergency
1|module_0|ERR|error
2|module_0|WARN|warning
3|module_0|INFO|information
4|module_0|DBG|debug
5|module_0|EMER|emergency exception
Traceback (most recent call last):
  File <name>, line <number>, in main
    assert fail
AssertionError
6|module_0|ERR|error exception
Traceback (most recent call last):
  File <name>, line <number>, in main
    assert fail
AssertionError
7|module_0|WARN|warn exception
Traceback (most recent call last):
  File <name>, line <number>, in main
    assert fail
AssertionError
8|module_0|INFO|information exception
Traceback (most recent call last):
  File <name>, line <number>, in main
    assert fail
AssertionError
9|module_0|DBG|debug exception
Traceback (most recent call last):
  File <name>, line <number>, in main
    assert fail
AssertionError
10|module_0|ERR|exception
Traceback (most recent call last):
  File <name>, line <number>, in main
    assert fail
AssertionError
11|module_1|EMER|emergency
12|module_1|ERR|error
13|module_1|WARN|warning
14|module_1|INFO|information
16|module_1|EMER|emergency exception
Traceback (most recent call last):
  File <name>, line <number>, in main
    assert fail
AssertionError
17|module_1|ERR|error exception
Traceback (most recent call last):
  File <name>, line <number>, in main
    assert fail
AssertionError
18|module_1|WARN|warn exception
Traceback (most recent call last):
  File <name>, line <number>, in main
    assert fail
AssertionError
19|module_1|INFO|information exception
Traceback (most recent call last):
  File <name>, line <number>, in main
    assert fail
AssertionError
21|module_1|ERR|exception
Traceback (most recent call last):
  File <name>, line <number>, in main
    assert fail
AssertionError
22|module_2|EMER|emergency
23|module_2|ERR|error
24|module_2|WARN|warning
27|module_2|EMER|emergency exception
Traceback (most recent call last):
  File <name>, line <number>, in main
    assert fail
AssertionError
28|module_2|ERR|error exception
Traceback (most recent call last):
  File <name>, line <number>, in main
    assert fail
AssertionError
29|module_2|WARN|warn exception
Traceback (most recent call last):
  File <name>, line <number>, in main
    assert fail
AssertionError
32|module_2|ERR|exception
Traceback (most recent call last):
  File <name>, line <number>, in main
    assert fail
AssertionError
])

AT_CLEANUP

AT_SETUP([vlog - vlog/reopen - Python])
AT_SKIP_IF([test $HAVE_PYTHON = no])
OVS_RUNDIR=`pwd`; export OVS_RUNDIR
OVS_LOGDIR=`pwd`; export OVS_LOGDIR
OVS_DBDIR=`pwd`; export OVS_DBDIR
OVS_SYSCONFDIR=`pwd`; export OVS_SYSCONFDIR
ON_EXIT([kill `cat test-unixctl.py.pid`])

AT_CAPTURE_FILE([log])
AT_CAPTURE_FILE([log.old])
AT_CHECK([$PYTHON $srcdir/test-unixctl.py --log-file=`pwd`/log --pidfile --detach])

AT_CHECK([APPCTL -t test-unixctl.py log message])
mv log log.old
AT_CHECK([APPCTL -t test-unixctl.py log message2])
AT_CHECK([APPCTL -t test-unixctl.py vlog/reopen])
AT_CHECK([APPCTL -t test-unixctl.py log message3])
AT_CHECK([APPCTL -t test-unixctl.py exit])

AT_CHECK([sed 's/.*|//' log.old], [0], [dnl
Entering run loop.
message
message2
])
AT_CHECK([sed 's/.*|//' log], [0], [dnl
message3
])
AT_CLEANUP

AT_SETUP([vlog - vlog/reopen without log file - Python])
AT_SKIP_IF([test $HAVE_PYTHON = no])
OVS_RUNDIR=`pwd`; export OVS_RUNDIR
OVS_LOGDIR=`pwd`; export OVS_LOGDIR
OVS_DBDIR=`pwd`; export OVS_DBDIR
OVS_SYSCONFDIR=`pwd`; export OVS_SYSCONFDIR
ON_EXIT([kill `cat test-unixctl.py.pid`])

AT_CHECK([$PYTHON $srcdir/test-unixctl.py --pidfile --detach])

AT_CHECK([APPCTL -t test-unixctl.py vlog/reopen], [0],
  [Logging to file not configured
])
AT_CLEANUP

dnl This checks that if vlog/reopen can't reopen the log file,
dnl nothing particularly bad (e.g. Python throws an exception and
dnl aborts the program) happens.
AT_SETUP([vlog - vlog/reopen can't reopen log file - Python])
AT_SKIP_IF([test $HAVE_PYTHON = no])

# Verify that /dev/full is a character device that fails writes.
AT_SKIP_IF([test ! -c /dev/full])
AT_SKIP_IF([echo > /dev/full])

OVS_RUNDIR=`pwd`; export OVS_RUNDIR
OVS_LOGDIR=`pwd`; export OVS_LOGDIR
OVS_DBDIR=`pwd`; export OVS_DBDIR
OVS_SYSCONFDIR=`pwd`; export OVS_SYSCONFDIR
ON_EXIT([kill `cat test-unixctl.py.pid`])

AT_CHECK([$PYTHON $srcdir/test-unixctl.py --log-file=`pwd`/log --pidfile --detach])
AT_CHECK([APPCTL -t test-unixctl.py log message])
mv log log.old
ln -s /dev/full log
AT_CHECK([APPCTL -t test-unixctl.py vlog/reopen])
AT_CHECK([APPCTL -t test-unixctl.py log message2])
rm log
AT_CHECK([APPCTL -t test-unixctl.py vlog/reopen])
AT_CHECK([APPCTL -t test-unixctl.py log message3])
AT_CHECK([APPCTL -t test-unixctl.py exit])
AT_CHECK([sed 's/.*|//' log.old], [0], [dnl
Entering run loop.
message
])
AT_CHECK([sed 's/.*|//' log], [0], [dnl
message3
])
AT_CLEANUP

AT_SETUP([vlog - vlog/set and vlog/list - Python])
AT_SKIP_IF([test $HAVE_PYTHON = no])
OVS_RUNDIR=`pwd`; export OVS_RUNDIR
OVS_LOGDIR=`pwd`; export OVS_LOGDIR
OVS_DBDIR=`pwd`; export OVS_DBDIR
OVS_SYSCONFDIR=`pwd`; export OVS_SYSCONFDIR
ON_EXIT([kill `cat test-unixctl.py.pid`])

AT_CAPTURE_FILE([log])
AT_CHECK([$PYTHON $srcdir/test-unixctl.py --log-file=`pwd`/log --pidfile --detach])

AT_CHECK([APPCTL -t test-unixctl.py vlog/list], [0], [dnl
                 console    syslog    file
                 -------    ------    ------
daemon            info       info       info
fatal-signal      info       info       info
jsonrpc           info       info       info
poller            info       info       info
reconnect         info       info       info
socket_util       info       info       info
stream            info       info       info
test-unixctl      info       info       info
unixctl_server    info       info       info
])

AT_CHECK([APPCTL -t test-unixctl.py vlog/set daemon:syslog:err])
AT_CHECK([APPCTL -t test-unixctl.py vlog/set file:dbg])
AT_CHECK([APPCTL -t test-unixctl.py vlog/set nonexistent], [0],
  [no facility, level, or module "nonexistent"
])
AT_CHECK([APPCTL -t test-unixctl.py vlog/list], [0], [dnl
                 console    syslog    file
                 -------    ------    ------
daemon            info        err        dbg
fatal-signal      info       info        dbg
jsonrpc           info       info        dbg
poller            info       info        dbg
reconnect         info       info        dbg
socket_util       info       info        dbg
stream            info       info        dbg
test-unixctl      info       info        dbg
unixctl_server    info       info        dbg
])
AT_CLEANUP