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