ovs-appctl: dpif/show display bug fix
[sliver-openvswitch.git] / tests / ovsdb-log.at
1 AT_BANNER([OVSDB -- logging])
2
3 AT_SETUP([create empty, reread])
4 AT_KEYWORDS([ovsdb log])
5 AT_CAPTURE_FILE([log])
6 AT_CHECK(
7   [test-ovsdb log-io file create], [0], 
8   [file: open successful
9 ], [ignore])
10 AT_CHECK(
11   [test-ovsdb log-io file read-only read], [0], 
12   [file: open successful
13 file: read: end of log
14 ], [ignore])
15 AT_CHECK([test -f .file.~lock~])
16 AT_CLEANUP
17
18 AT_SETUP([write one, reread])
19 AT_KEYWORDS([ovsdb log])
20 AT_CAPTURE_FILE([file])
21 AT_CHECK(
22   [[test-ovsdb log-io file create 'write:[0]']], [0], 
23   [[file: open successful
24 file: write:[0] successful
25 ]], [ignore])
26 AT_CHECK(
27   [test-ovsdb log-io file read-only read read], [0], 
28   [[file: open successful
29 file: read: [0]
30 file: read: end of log
31 ]], [ignore])
32 AT_CHECK([test -f .file.~lock~])
33 AT_CLEANUP
34
35 AT_SETUP([check that create fails if file exists])
36 AT_KEYWORDS([ovsdb log])
37 AT_CAPTURE_FILE([file])
38 AT_CHECK(
39   [[test-ovsdb log-io file create 'write:[1]']], [0], 
40   [[file: open successful
41 file: write:[1] successful
42 ]], [ignore])
43 AT_CHECK(
44   [test-ovsdb log-io file read-only read], [0], 
45   [[file: open successful
46 file: read: [1]
47 ]], [ignore])
48 AT_CHECK(
49   [test-ovsdb log-io file create read], [1],
50   [], [test-ovsdb: I/O error: create: file failed (File exists)
51 ])
52 AT_CHECK([test -f .file.~lock~])
53 AT_CLEANUP
54
55 AT_SETUP([write one, reread])
56 AT_KEYWORDS([ovsdb log])
57 AT_CAPTURE_FILE([file])
58 AT_CHECK(
59   [[test-ovsdb log-io file create 'write:[0]' 'write:[1]' 'write:[2]']], [0], 
60   [[file: open successful
61 file: write:[0] successful
62 file: write:[1] successful
63 file: write:[2] successful
64 ]], [ignore])
65 AT_CHECK(
66   [test-ovsdb log-io file read-only read read read read], [0], 
67   [[file: open successful
68 file: read: [0]
69 file: read: [1]
70 file: read: [2]
71 file: read: end of log
72 ]], [ignore])
73 AT_CHECK([test -f .file.~lock~])
74 AT_CLEANUP
75
76 AT_SETUP([write one, reread, append])
77 AT_KEYWORDS([ovsdb log])
78 AT_CAPTURE_FILE([file])
79 AT_CHECK(
80   [[test-ovsdb log-io file create 'write:[0]' 'write:[1]' 'write:[2]']], [0], 
81   [[file: open successful
82 file: write:[0] successful
83 file: write:[1] successful
84 file: write:[2] successful
85 ]], [ignore])
86 AT_CHECK(
87   [[test-ovsdb log-io file read/write read read read 'write:["append"]']], [0], 
88   [[file: open successful
89 file: read: [0]
90 file: read: [1]
91 file: read: [2]
92 file: write:["append"] successful
93 ]], [ignore])
94 AT_CHECK(
95   [test-ovsdb log-io file read-only read read read read read], [0], 
96   [[file: open successful
97 file: read: [0]
98 file: read: [1]
99 file: read: [2]
100 file: read: ["append"]
101 file: read: end of log
102 ]], [ignore])
103 AT_CHECK([test -f .file.~lock~])
104 AT_CLEANUP
105
106 AT_SETUP([write, reread one, overwrite])
107 AT_KEYWORDS([ovsdb log])
108 AT_CAPTURE_FILE([file])
109 AT_CHECK(
110   [[test-ovsdb log-io file create 'write:[0]' 'write:[1]' 'write:[2]']], [0], 
111   [[file: open successful
112 file: write:[0] successful
113 file: write:[1] successful
114 file: write:[2] successful
115 ]], [ignore])
116 AT_CHECK(
117   [[test-ovsdb log-io file read/write read 'write:["more data"]']], [0], 
118   [[file: open successful
119 file: read: [0]
120 file: write:["more data"] successful
121 ]], [ignore])
122 AT_CHECK(
123   [test-ovsdb log-io file read-only read read read], [0], 
124   [[file: open successful
125 file: read: [0]
126 file: read: ["more data"]
127 file: read: end of log
128 ]], [ignore])
129 AT_CHECK([test -f .file.~lock~])
130 AT_CLEANUP
131
132 AT_SETUP([write, add corrupted data, read])
133 AT_KEYWORDS([ovsdb log])
134 AT_CAPTURE_FILE([file])
135 AT_CHECK(
136   [[test-ovsdb log-io file create 'write:[0]' 'write:[1]' 'write:[2]']], [0], 
137   [[file: open successful
138 file: write:[0] successful
139 file: write:[1] successful
140 file: write:[2] successful
141 ]], [ignore])
142 AT_CHECK([echo 'xxx' >> file])
143 AT_CHECK(
144   [test-ovsdb log-io file read-only read read read read], [0], 
145   [[file: open successful
146 file: read: [0]
147 file: read: [1]
148 file: read: [2]
149 file: read failed: syntax error: file: parse error at offset 174 in header line "xxx"
150 ]], [ignore])
151 AT_CHECK([test -f .file.~lock~])
152 AT_CLEANUP
153
154 AT_SETUP([write, add corrupted data, read, overwrite])
155 AT_KEYWORDS([ovsdb log])
156 AT_CAPTURE_FILE([file])
157 AT_CHECK(
158   [[test-ovsdb log-io file create 'write:[0]' 'write:[1]' 'write:[2]']], [0], 
159   [[file: open successful
160 file: write:[0] successful
161 file: write:[1] successful
162 file: write:[2] successful
163 ]], [ignore])
164 AT_CHECK([echo 'xxx' >> file])
165 AT_CHECK(
166   [[test-ovsdb log-io file read/write read read read read 'write:[3]']], [0], 
167   [[file: open successful
168 file: read: [0]
169 file: read: [1]
170 file: read: [2]
171 file: read failed: syntax error: file: parse error at offset 174 in header line "xxx"
172 file: write:[3] successful
173 ]], [ignore])
174 AT_CHECK(
175   [test-ovsdb log-io file read-only read read read read read], [0], 
176   [[file: open successful
177 file: read: [0]
178 file: read: [1]
179 file: read: [2]
180 file: read: [3]
181 file: read: end of log
182 ]], [ignore])
183 AT_CHECK([test -f .file.~lock~])
184 AT_CLEANUP
185
186 AT_SETUP([write, corrupt some data, read, overwrite])
187 AT_KEYWORDS([ovsdb log])
188 AT_CAPTURE_FILE([file])
189 AT_CHECK(
190   [[test-ovsdb log-io file create 'write:[0]' 'write:[1]' 'write:[2]']], [0], 
191   [[file: open successful
192 file: write:[0] successful
193 file: write:[1] successful
194 file: write:[2] successful
195 ]], [ignore])
196 AT_CHECK([[sed 's/\[2]/[3]/' < file > file.tmp]])
197 AT_CHECK([mv file.tmp file])
198 AT_CHECK([[grep -c '\[3]' file]], [0], [1
199 ])
200 AT_CHECK(
201   [[test-ovsdb log-io file read/write read read read 'write:["longer data"]']], [0], 
202   [[file: open successful
203 file: read: [0]
204 file: read: [1]
205 file: read failed: syntax error: file: 4 bytes starting at offset 170 have SHA-1 hash 5c031e5c0d3a9338cc127ebe40bb2748b6a67e78 but should have hash 98f55556e7ffd432381b56a19bd485b3e6446442
206 file: write:["longer data"] successful
207 ]], [ignore])
208 AT_CHECK(
209   [test-ovsdb log-io file read-only read read read read], [0], 
210   [[file: open successful
211 file: read: [0]
212 file: read: [1]
213 file: read: ["longer data"]
214 file: read: end of log
215 ]], [ignore])
216 AT_CHECK([test -f .file.~lock~])
217 AT_CLEANUP
218
219 AT_SETUP([write, truncate file, read, overwrite])
220 AT_KEYWORDS([ovsdb log])
221 AT_CAPTURE_FILE([file])
222 AT_CHECK(
223   [[test-ovsdb log-io file create 'write:[0]' 'write:[1]' 'write:[2]']], [0], 
224   [[file: open successful
225 file: write:[0] successful
226 file: write:[1] successful
227 file: write:[2] successful
228 ]], [ignore])
229 AT_CHECK([[sed 's/\[2]/2/' < file > file.tmp]])
230 AT_CHECK([mv file.tmp file])
231 AT_CHECK([[grep -c '^2$' file]], [0], [1
232 ])
233 AT_CHECK(
234   [[test-ovsdb log-io file read/write read read read 'write:["longer data"]']], [0], 
235   [[file: open successful
236 file: read: [0]
237 file: read: [1]
238 file: read failed: I/O error: file: error reading 4 bytes starting at offset 170 (End of file)
239 file: write:["longer data"] successful
240 ]], [ignore])
241 AT_CHECK(
242   [test-ovsdb log-io file read-only read read read read], [0], 
243   [[file: open successful
244 file: read: [0]
245 file: read: [1]
246 file: read: ["longer data"]
247 file: read: end of log
248 ]], [ignore])
249 AT_CHECK([test -f .file.~lock~])
250 AT_CLEANUP
251
252 AT_SETUP([write bad JSON, read, overwrite])
253 AT_KEYWORDS([ovsdb log])
254 AT_CAPTURE_FILE([file])
255 AT_CHECK(
256   [[test-ovsdb log-io file create 'write:[0]' 'write:[1]' 'write:[2]']], [0], 
257   [[file: open successful
258 file: write:[0] successful
259 file: write:[1] successful
260 file: write:[2] successful
261 ]], [ignore])
262 AT_CHECK([[printf '%s\n%s\n' 'OVSDB JSON 5 d910b02871075d3156ec8675dfc95b7d5d640aa6' 'null' >> file]])
263 AT_CHECK(
264   [[test-ovsdb log-io file read/write read read read read 'write:["replacement data"]']], [0], 
265   [[file: open successful
266 file: read: [0]
267 file: read: [1]
268 file: read: [2]
269 file: read failed: syntax error: file: 5 bytes starting at offset 228 are not valid JSON (line 0, column 4, byte 4: syntax error at beginning of input)
270 file: write:["replacement data"] successful
271 ]], [ignore])
272 AT_CHECK(
273   [test-ovsdb log-io file read-only read read read read read], [0], 
274   [[file: open successful
275 file: read: [0]
276 file: read: [1]
277 file: read: [2]
278 file: read: ["replacement data"]
279 file: read: end of log
280 ]], [ignore])
281 AT_CHECK([test -f .file.~lock~])
282 AT_CLEANUP