]>
Commit | Line | Data |
---|---|---|
1e19e50e BP |
1 | AT_BANNER([OVSDB -- ovsdb-tool]) |
2 | ||
3 | # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS]) | |
4 | # | |
5 | # Creates a database with the given SCHEMA and runs each of the | |
6 | # TRANSACTIONS (which should be a quoted list of quoted strings) | |
7 | # against it with ovsdb-tool one at a time. | |
8 | # | |
9 | # Checks that the overall output is OUTPUT, but UUIDs in the output | |
10 | # are replaced by markers of the form <N> where N is a number. The | |
11 | # first unique UUID is replaced by <0>, the next by <1>, and so on. | |
12 | # If a given UUID appears more than once it is always replaced by the | |
13 | # same marker. | |
14 | # | |
15 | # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS. | |
16 | m4_define([OVSDB_CHECK_EXECUTION], | |
17 | [AT_SETUP([$1]) | |
18 | AT_KEYWORDS([ovsdb file positive $5]) | |
39ab07af | 19 | $2 > schema |
1e19e50e BP |
20 | touch .db.~lock~ |
21 | AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore]) | |
22 | m4_foreach([txn], [$3], | |
23 | [AT_CHECK([ovsdb-tool transact db 'txn'], [0], [stdout], [ignore]) | |
24 | cat stdout >> output | |
25 | ]) | |
c724bd67 | 26 | AT_CHECK([uuidfilt output], [0], [$4]) |
1e19e50e BP |
27 | AT_CLEANUP]) |
28 | ||
29 | EXECUTION_EXAMPLES | |
30 | ||
31 | AT_SETUP([transaction comments]) | |
32 | AT_KEYWORDS([ovsdb file positive]) | |
39ab07af | 33 | ordinal_schema > schema |
1e19e50e BP |
34 | touch .db.~lock~ |
35 | AT_CHECK([ovsdb-tool create db schema], [0], [], [ignore]) | |
36 | AT_CHECK([[ovsdb-tool transact db ' | |
37 | ["ordinals", | |
38 | {"op": "insert", | |
39 | "table": "ordinals", | |
40 | "row": {"name": "five", "number": 5}}, | |
41 | {"op": "comment", | |
42 | "comment": "add row for 5"}]']], [0], [stdout], [ignore]) | |
c724bd67 | 43 | AT_CHECK([uuidfilt stdout], [0], |
1e19e50e BP |
44 | [[[{"uuid":["uuid","<0>"]},{}] |
45 | ]]) | |
00961f7c | 46 | AT_CHECK([grep "add row for 5" db], [0], [ignore]) |
1e19e50e BP |
47 | AT_CLEANUP |
48 | ||
49 | AT_SETUP([ovsdb-tool compact]) | |
50 | AT_KEYWORDS([ovsdb file positive]) | |
39ab07af | 51 | ordinal_schema > schema |
a35ae81c BP |
52 | dnl Make sure that "ovsdb-tool create" works with a dangling symlink, |
53 | dnl creating the target of the symlink rather than replacing the symlink | |
54 | dnl with a regular file, and that the lockfile gets created relative to | |
55 | dnl the symlink's target. | |
56 | mkdir dir | |
57 | : > dir/.db.~lock~ | |
1ae1933f AS |
58 | if test "$IS_WIN32" = "no"; then |
59 | ln -s dir/db db | |
60 | AT_SKIP_IF([test ! -h db]) | |
61 | fi | |
1e19e50e | 62 | AT_CHECK([ovsdb-tool create db schema], [0], [], [ignore]) |
1ae1933f AS |
63 | if test "$IS_WIN32" = "no"; then |
64 | AT_CHECK([test ! -e .db.~lock]) | |
65 | AT_CHECK([test -h db]) | |
66 | AT_CHECK([test -f dir/db]) | |
67 | fi | |
1e19e50e BP |
68 | dnl Do a bunch of random transactions that put crap in the database log. |
69 | AT_CHECK( | |
70 | [[for pair in 'zero 0' 'one 1' 'two 2' 'three 3' 'four 4' 'five 5'; do | |
71 | set -- $pair | |
72 | ovsdb-tool transact db ' | |
73 | ["ordinals", | |
74 | {"op": "insert", | |
75 | "table": "ordinals", | |
76 | "row": {"name": "'$1'", "number": '$2'}}, | |
77 | {"op": "comment", | |
78 | "comment": "add row for '"$pair"'"}]' | |
79 | ovsdb-tool transact db ' | |
80 | ["ordinals", | |
81 | {"op": "delete", | |
82 | "table": "ordinals", | |
83 | "where": [["number", "==", '$2']]}, | |
84 | {"op": "comment", | |
85 | "comment": "delete row for '"$2"'"}]' | |
86 | ovsdb-tool transact db ' | |
87 | ["ordinals", | |
88 | {"op": "insert", | |
89 | "table": "ordinals", | |
90 | "row": {"name": "'$1'", "number": '$2'}}, | |
91 | {"op": "comment", | |
92 | "comment": "add back row for '"$pair"'"}]' | |
93 | done]], | |
94 | [0], [stdout], [ignore]) | |
95 | dnl Check that all the crap is in fact in the database log. | |
2ccd66f5 IM |
96 | AT_CHECK([[uuidfilt db | grep -v ^OVSDB | sed 's/"_date":[0-9]*/"_date":0/' | \ |
97 | sed 's/"_is_diff":true,//' | ovstest test-json --multiple -]], [0], | |
6910a6e6 | 98 | [[{"cksum":"12345678 9","name":"ordinals","tables":{"ordinals":{"columns":{"name":{"type":"string"},"number":{"type":"integer"}},"indexes":[["number"]]}},"version":"5.1.3"} |
e86dd676 BP |
99 | {"_comment":"add row for zero 0","_date":0,"ordinals":{"<0>":{"name":"zero"}}} |
100 | {"_comment":"delete row for 0","_date":0,"ordinals":{"<0>":null}} | |
101 | {"_comment":"add back row for zero 0","_date":0,"ordinals":{"<1>":{"name":"zero"}}} | |
102 | {"_comment":"add row for one 1","_date":0,"ordinals":{"<2>":{"name":"one","number":1}}} | |
103 | {"_comment":"delete row for 1","_date":0,"ordinals":{"<2>":null}} | |
104 | {"_comment":"add back row for one 1","_date":0,"ordinals":{"<3>":{"name":"one","number":1}}} | |
105 | {"_comment":"add row for two 2","_date":0,"ordinals":{"<4>":{"name":"two","number":2}}} | |
106 | {"_comment":"delete row for 2","_date":0,"ordinals":{"<4>":null}} | |
107 | {"_comment":"add back row for two 2","_date":0,"ordinals":{"<5>":{"name":"two","number":2}}} | |
108 | {"_comment":"add row for three 3","_date":0,"ordinals":{"<6>":{"name":"three","number":3}}} | |
109 | {"_comment":"delete row for 3","_date":0,"ordinals":{"<6>":null}} | |
110 | {"_comment":"add back row for three 3","_date":0,"ordinals":{"<7>":{"name":"three","number":3}}} | |
111 | {"_comment":"add row for four 4","_date":0,"ordinals":{"<8>":{"name":"four","number":4}}} | |
112 | {"_comment":"delete row for 4","_date":0,"ordinals":{"<8>":null}} | |
113 | {"_comment":"add back row for four 4","_date":0,"ordinals":{"<9>":{"name":"four","number":4}}} | |
114 | {"_comment":"add row for five 5","_date":0,"ordinals":{"<10>":{"name":"five","number":5}}} | |
115 | {"_comment":"delete row for 5","_date":0,"ordinals":{"<10>":null}} | |
116 | {"_comment":"add back row for five 5","_date":0,"ordinals":{"<11>":{"name":"five","number":5}}} | |
1e19e50e | 117 | ]]) |
1ae1933f | 118 | |
1e19e50e | 119 | dnl Dump out and check the actual database contents. |
1ae1933f AS |
120 | on_exit 'kill `cat ovsdb-server.pid`' |
121 | AT_CHECK([[ovsdb-server --detach --pidfile --no-chdir --remote=punix:socket db]], | |
5a0e4aec | 122 | [0], [stdout], [ignore]) |
1ae1933f | 123 | AT_CHECK([[ovsdb-client dump unix:socket ordinals]], |
5a0e4aec | 124 | [0], [stdout], [ignore]) |
1ae1933f AS |
125 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) |
126 | ||
c724bd67 | 127 | AT_CHECK([uuidfilt stdout], [0], [dnl |
370a11b9 BP |
128 | ordinals table |
129 | _uuid name number | |
1e19e50e | 130 | ------------------------------------ ----- ------ |
e51d0a1d BP |
131 | <0> five 5 |
132 | <1> four 4 | |
133 | <2> one 1 | |
134 | <3> three 3 | |
135 | <4> two 2 | |
136 | <5> zero 0 | |
1e19e50e BP |
137 | ]) |
138 | dnl Now compact the database in-place. | |
139 | touch .db.tmp.~lock~ | |
140 | AT_CHECK([[ovsdb-tool compact db]], [0], [], [ignore]) | |
a35ae81c BP |
141 | dnl Make sure that "db" is still a symlink to dir/db instead of getting |
142 | dnl replaced by a regular file. | |
1ae1933f AS |
143 | if test "$IS_WIN32" = "no"; then |
144 | AT_CHECK([test ! -e .db.~lock]) | |
145 | AT_CHECK([test -h db]) | |
146 | AT_CHECK([test -f dir/db]) | |
147 | fi | |
1e19e50e BP |
148 | dnl We can't fully re-check the contents of the database log, because the |
149 | dnl order of the records is not predictable, but there should only be 4 lines | |
150 | dnl in it now. | |
151 | AT_CAPTURE_FILE([db]) | |
e0c7697c | 152 | AT_CHECK([test `wc -l < db` -eq 4]) |
1e19e50e | 153 | dnl And check that the dumped data is the same too: |
1ae1933f | 154 | AT_CHECK([[ovsdb-server --detach --pidfile --no-chdir --remote=punix:socket db]], |
5a0e4aec | 155 | [0], [stdout], [ignore]) |
1ae1933f | 156 | AT_CHECK([[ovsdb-client dump unix:socket ordinals]], |
5a0e4aec | 157 | [0], [stdout], [ignore]) |
1ae1933f AS |
158 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) |
159 | ||
c724bd67 | 160 | AT_CHECK([uuidfilt stdout], [0], [dnl |
370a11b9 BP |
161 | ordinals table |
162 | _uuid name number | |
1e19e50e | 163 | ------------------------------------ ----- ------ |
e51d0a1d BP |
164 | <0> five 5 |
165 | <1> four 4 | |
166 | <2> one 1 | |
167 | <3> three 3 | |
168 | <4> two 2 | |
169 | <5> zero 0 | |
1e19e50e BP |
170 | ]) |
171 | AT_CLEANUP | |
172 | ||
173 | AT_SETUP([ovsdb-tool convert -- removing a column]) | |
174 | AT_KEYWORDS([ovsdb file positive]) | |
39ab07af | 175 | ordinal_schema > schema |
1e19e50e BP |
176 | AT_DATA([new-schema], |
177 | [[{"name": "ordinals", | |
178 | "tables": { | |
179 | "ordinals": { | |
180 | "columns": { | |
181 | "number": {"type": "integer"}}}}} | |
182 | ]]) | |
183 | touch .db.~lock~ | |
184 | AT_CHECK([ovsdb-tool create db schema], [0], [], [ignore]) | |
185 | dnl Put some data in the database. | |
186 | AT_CHECK( | |
187 | [[for pair in 'zero 0' 'one 1' 'two 2' 'three 3' 'four 4' 'five 5'; do | |
188 | set -- $pair | |
189 | ovsdb-tool transact db ' | |
190 | ["ordinals", | |
191 | {"op": "insert", | |
192 | "table": "ordinals", | |
193 | "row": {"name": "'$1'", "number": '$2'}}, | |
194 | {"op": "comment", | |
195 | "comment": "add row for '"$pair"'"}]' | |
196 | done]], | |
197 | [0], [stdout], [ignore]) | |
198 | dnl Dump out and check the actual database contents. | |
10c119c3 GS |
199 | AT_CHECK([[ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket db]], |
200 | [0]) | |
201 | AT_CHECK([ovsdb-client dump unix:socket ordinals], [0], [stdout], [ignore]) | |
c724bd67 | 202 | AT_CHECK([uuidfilt stdout], [0], [dnl |
370a11b9 BP |
203 | ordinals table |
204 | _uuid name number | |
1e19e50e | 205 | ------------------------------------ ----- ------ |
e51d0a1d BP |
206 | <0> five 5 |
207 | <1> four 4 | |
208 | <2> one 1 | |
209 | <3> three 3 | |
210 | <4> two 2 | |
211 | <5> zero 0 | |
1e19e50e | 212 | ]) |
10c119c3 | 213 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) |
1e19e50e BP |
214 | dnl Now convert the database in-place. |
215 | touch .db.tmp.~lock~ | |
216 | AT_CHECK([[ovsdb-tool convert db new-schema]], [0], [], [ignore]) | |
217 | dnl We can't fully re-check the contents of the database log, because the | |
218 | dnl order of the records is not predictable, but there should only be 4 lines | |
219 | dnl in it now. | |
220 | AT_CAPTURE_FILE([db]) | |
e0c7697c | 221 | AT_CHECK([test `wc -l < db` -eq 4]) |
1e19e50e | 222 | dnl And check that the dumped data is the same except for the removed column: |
10c119c3 GS |
223 | AT_CHECK([[ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket db]], |
224 | [0]) | |
225 | AT_CHECK([ovsdb-client dump unix:socket ordinals], [0], [stdout], [ignore]) | |
c724bd67 | 226 | AT_CHECK([uuidfilt stdout], [0], [dnl |
370a11b9 BP |
227 | ordinals table |
228 | _uuid number | |
1e19e50e | 229 | ------------------------------------ ------ |
e51d0a1d BP |
230 | <0> 0 |
231 | <1> 1 | |
232 | <2> 2 | |
233 | <3> 3 | |
234 | <4> 4 | |
235 | <5> 5 | |
1e19e50e | 236 | ]) |
10c119c3 | 237 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) |
1e19e50e BP |
238 | AT_CLEANUP |
239 | ||
240 | AT_SETUP([ovsdb-tool convert -- adding a column]) | |
241 | AT_KEYWORDS([ovsdb file positive]) | |
242 | AT_DATA([schema], | |
243 | [[{"name": "ordinals", | |
244 | "tables": { | |
245 | "ordinals": { | |
246 | "columns": { | |
247 | "number": {"type": "integer"}}}}} | |
248 | ]]) | |
39ab07af | 249 | ordinal_schema > new-schema |
1e19e50e BP |
250 | touch .db.~lock~ |
251 | AT_CHECK([ovsdb-tool create db schema], [0], [], [ignore]) | |
252 | dnl Put some data in the database. | |
253 | AT_CHECK( | |
254 | [[for number in 0 1 2 3 4 5; do | |
255 | ovsdb-tool transact db ' | |
256 | ["ordinals", | |
257 | {"op": "insert", | |
258 | "table": "ordinals", | |
259 | "row": {"number": '$number'}}, | |
260 | {"op": "comment", | |
261 | "comment": "add row for '"$number"'"}]' | |
262 | done]], | |
263 | [0], [stdout], [ignore]) | |
264 | dnl Dump out and check the actual database contents. | |
10c119c3 GS |
265 | AT_CHECK([[ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket db]], |
266 | [0]) | |
267 | AT_CHECK([ovsdb-client dump unix:socket ordinals], [0], [stdout], [ignore]) | |
c724bd67 | 268 | AT_CHECK([uuidfilt stdout], [0], [dnl |
370a11b9 BP |
269 | ordinals table |
270 | _uuid number | |
1e19e50e | 271 | ------------------------------------ ------ |
e51d0a1d BP |
272 | <0> 0 |
273 | <1> 1 | |
274 | <2> 2 | |
275 | <3> 3 | |
276 | <4> 4 | |
277 | <5> 5 | |
1e19e50e | 278 | ]) |
10c119c3 | 279 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) |
1e19e50e BP |
280 | dnl Now convert the database in-place. |
281 | touch .db.tmp.~lock~ | |
282 | AT_CHECK([[ovsdb-tool convert db new-schema]], [0], [], [ignore]) | |
283 | dnl We can't fully re-check the contents of the database log, because the | |
284 | dnl order of the records is not predictable, but there should only be 4 lines | |
285 | dnl in it now. | |
286 | AT_CAPTURE_FILE([db]) | |
e0c7697c | 287 | AT_CHECK([test `wc -l < db` -eq 4]) |
1e19e50e | 288 | dnl And check that the dumped data is the same except for the added column: |
10c119c3 GS |
289 | AT_CHECK([[ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket db]], |
290 | [0]) | |
291 | AT_CHECK([ovsdb-client dump unix:socket ordinals], [0], [stdout], [ignore]) | |
c724bd67 | 292 | AT_CHECK([uuidfilt stdout], [0], [dnl |
370a11b9 BP |
293 | ordinals table |
294 | _uuid name number | |
1e19e50e | 295 | ------------------------------------ ---- ------ |
e51d0a1d BP |
296 | <0> "" 0 |
297 | <1> "" 1 | |
298 | <2> "" 2 | |
299 | <3> "" 3 | |
300 | <4> "" 4 | |
301 | <5> "" 5 | |
1e19e50e | 302 | ]) |
10c119c3 | 303 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) |
1e19e50e | 304 | AT_CLEANUP |
8159b984 | 305 | |
1b1d2e6d BP |
306 | AT_SETUP([ovsdb-tool unsupported cluster operations]) |
307 | AT_KEYWORDS([ovsdb file negative compact query transact convert]) | |
308 | ordinal_schema > schema | |
309 | AT_CHECK([ovsdb-tool create-cluster db schema unix:s1.raft]) | |
310 | AT_CHECK([ovsdb-tool compact db], [1], [], [ovsdb-tool: ovsdb error: db: cannot apply this operation to clustered database file | |
311 | ]) | |
312 | AT_CHECK([ovsdb-tool convert db schema], [1], [], [ovsdb-tool: ovsdb error: db: cannot apply this operation to clustered database file | |
313 | ]) | |
314 | AT_CHECK([ovsdb-tool needs-conversion db schema], [1], [], [ovsdb-tool: ovsdb error: db: cannot apply this operation to clustered database file | |
315 | ]) | |
316 | AT_CHECK([ovsdb-tool query db '[[]]'], [1], [], [ovsdb-tool: ovsdb error: db: cannot apply this operation to clustered database file | |
317 | ]) | |
318 | AT_CHECK([ovsdb-tool transact db '[[]]'], [1], [], [ovsdb-tool: ovsdb error: db: cannot apply this operation to clustered database file | |
319 | ]) | |
320 | AT_CLEANUP | |
321 | ||
439902cb BP |
322 | AT_SETUP([ovsdb-tool schema-version, schema-cksum, schema-name]) |
323 | AT_KEYWORDS([ovsdb file positive schema-version schema-cksum]) | |
39ab07af | 324 | ordinal_schema > schema |
8159b984 BP |
325 | AT_CHECK([ovsdb-tool schema-version schema], [0], [5.1.3 |
326 | ]) | |
6aa09313 BP |
327 | AT_CHECK([ovsdb-tool schema-cksum schema], [0], [12345678 9 |
328 | ]) | |
439902cb BP |
329 | AT_CHECK([ovsdb-tool schema-name schema], [0], [ordinals |
330 | ]) | |
6aa09313 BP |
331 | AT_CLEANUP |
332 | ||
1b1d2e6d BP |
333 | AT_SETUP([ovsdb-tool database inspection commands - standalone]) |
334 | AT_KEYWORDS([ovsdb file positive db-version db-cksum db-name db-cid db-sid db-local-address]) | |
39ab07af | 335 | ordinal_schema > schema |
6aa09313 BP |
336 | touch .db.~lock~ |
337 | AT_CHECK([ovsdb-tool create db schema], [0], [], [ignore]) | |
439902cb BP |
338 | AT_CHECK([ovsdb-tool db-version db], [0], [5.1.3 |
339 | ]) | |
6aa09313 BP |
340 | AT_CHECK([ovsdb-tool db-cksum db], [0], [12345678 9 |
341 | ]) | |
439902cb BP |
342 | AT_CHECK([ovsdb-tool db-name db], [0], [ordinals |
343 | ]) | |
1b1d2e6d BP |
344 | AT_CHECK([ovsdb-tool db-cid db], [1], [], [ovsdb-tool: db: not a clustered database |
345 | ]) | |
346 | AT_CHECK([ovsdb-tool db-sid db], [1], [], [ovsdb-tool: db: not a clustered database | |
347 | ]) | |
348 | AT_CHECK([ovsdb-tool db-local-address db], [1], [], [ovsdb-tool: db: not a clustered database | |
349 | ]) | |
350 | AT_CLEANUP | |
351 | ||
352 | AT_SETUP([ovsdb-tool database inspection commands - clustered]) | |
353 | AT_KEYWORDS([ovsdb file negative db-version db-cksum db-name db-cid db-sid db-local-address cluster]) | |
354 | ordinal_schema > schema | |
355 | touch .db.~lock~ | |
356 | AT_CHECK([ovsdb-tool create-cluster db schema tcp:1.2.3.4:1234]) | |
357 | AT_CHECK([ovsdb-tool db-version db], [1], [], [ovsdb-tool: ovsdb error: db: cannot apply this operation to clustered database file | |
358 | ]) | |
359 | AT_CHECK([ovsdb-tool db-cksum db], [1], [], [ovsdb-tool: ovsdb error: db: cannot apply this operation to clustered database file | |
360 | ]) | |
361 | AT_CHECK([ovsdb-tool db-name db], [0], [ordinals | |
362 | ]) | |
363 | AT_CHECK([(ovsdb-tool db-cid db; ovsdb-tool db-sid db) | uuidfilt], [0], [<0> | |
364 | <1> | |
365 | ]) | |
366 | AT_CHECK([ovsdb-tool db-local-address db], [0], [tcp:1.2.3.4:1234 | |
367 | ]) | |
368 | AT_CLEANUP | |
369 | ||
370 | AT_SETUP([ovsdb-tool database inspection commands - joining a cluster]) | |
371 | AT_KEYWORDS([ovsdb file positive db-version db-cksum db-name db-cid db-sid db-local-address cluster join joining]) | |
372 | ordinal_schema > schema | |
373 | touch .db.~lock~ | |
374 | for cid in '' 520cf525-3772-43cc-8268-23bf5b548cf4; do | |
375 | if test -z "$cid"; then | |
376 | cid_option= | |
377 | else | |
378 | cid_option=--cid=$cid | |
379 | fi | |
380 | AT_CHECK([rm -f db && ovsdb-tool $cid_option join-cluster db ordinals tcp:1.2.3.4:1234 tcp:2.3.4.5:1234], [0], [], [ignore]) | |
381 | AT_CHECK([ovsdb-tool db-version db], [1], [], [ovsdb-tool: ovsdb error: db: cannot apply this operation to clustered database file | |
382 | ]) | |
383 | AT_CHECK([ovsdb-tool db-cksum db], [1], [], [ovsdb-tool: ovsdb error: db: cannot apply this operation to clustered database file | |
384 | ]) | |
385 | AT_CHECK([ovsdb-tool db-name db], [0], [ordinals | |
386 | ]) | |
387 | if test -z "$cid"; then | |
388 | AT_CHECK([ovsdb-tool db-cid db], [2], [], [db: cluster ID not yet known | |
389 | ]) | |
390 | else | |
391 | AT_CHECK_UNQUOTED([ovsdb-tool db-cid db], [0], [$cid | |
392 | ]) | |
393 | fi | |
394 | AT_CHECK([ovsdb-tool db-sid db | uuidfilt], [0], [<0> | |
395 | ]) | |
396 | AT_CHECK([ovsdb-tool db-local-address db], [0], [tcp:1.2.3.4:1234 | |
397 | ]) | |
398 | done | |
6aa09313 | 399 | AT_CLEANUP |
403e3a25 BP |
400 | |
401 | AT_SETUP([ovsdb-tool needs-conversion (no conversion needed)]) | |
402 | AT_KEYWORDS([ovsdb file positive]) | |
39ab07af | 403 | ordinal_schema > schema |
403e3a25 BP |
404 | touch .db.~lock~ |
405 | AT_CHECK([ovsdb-tool create db schema], [0], [], [ignore]) | |
406 | AT_CHECK([ovsdb-tool needs-conversion db schema], [0], [no | |
407 | ]) | |
408 | AT_CLEANUP | |
409 | ||
410 | AT_SETUP([ovsdb-tool needs-conversion (conversion needed)]) | |
411 | AT_KEYWORDS([ovsdb file positive]) | |
39ab07af | 412 | ordinal_schema > schema |
403e3a25 BP |
413 | touch .db.~lock~ |
414 | AT_CHECK([ovsdb-tool create db schema], [0], [], [ignore]) | |
415 | sed 's/5\.1\.3/5.1.4/' < schema > schema2 | |
416 | AT_CHECK([diff schema schema2], [1], [ignore]) | |
417 | AT_CHECK([ovsdb-tool needs-conversion db schema2], [0], [yes | |
418 | ]) | |
419 | AT_CLEANUP | |
1b1d2e6d BP |
420 | |
421 | AT_SETUP([ovsdb-tool create-cluster with initial data]) | |
422 | AT_KEYWORDS([ovsdb file positive]) | |
423 | ||
424 | # Create a standalone database and put some data in it. | |
425 | ordinal_schema > schema | |
426 | ovsdb-tool create db1 schema | |
427 | AT_CHECK( | |
428 | [[for pair in 'zero 0' 'one 1' 'two 2' 'three 3' 'four 4' 'five 5'; do | |
429 | set -- $pair | |
430 | ovsdb-tool transact db1 ' | |
5a0e4aec BP |
431 | ["ordinals", |
432 | {"op": "insert", | |
433 | "table": "ordinals", | |
434 | "row": {"name": "'$1'", "number": '$2'}}, | |
435 | {"op": "comment", | |
436 | "comment": "add row for '"$pair"'"}]' | |
1b1d2e6d BP |
437 | done | uuidfilt]], [0], |
438 | [[[{"uuid":["uuid","<0>"]},{}] | |
439 | [{"uuid":["uuid","<1>"]},{}] | |
440 | [{"uuid":["uuid","<2>"]},{}] | |
441 | [{"uuid":["uuid","<3>"]},{}] | |
442 | [{"uuid":["uuid","<4>"]},{}] | |
443 | [{"uuid":["uuid","<5>"]},{}] | |
444 | ]], [ignore]) | |
445 | ||
446 | # Dump the data. | |
3915a9d3 | 447 | AT_CHECK([ovsdb-server -vfile -vvlog:off --detach --no-chdir --pidfile --log-file --remote=punix:db.sock db1]) |
1b1d2e6d BP |
448 | AT_CHECK([ovsdb-client dump > expout]) |
449 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
450 | ||
451 | # Create a clustered database from the standalone one. | |
452 | ovsdb-tool create-cluster db2 db1 unix:s1.raft | |
453 | ||
454 | # Dump the data. | |
3915a9d3 | 455 | AT_CHECK([ovsdb-server -vconsole:off -vfile -vvlog:off --detach --no-chdir --pidfile --log-file --remote=punix:db.sock db2]) |
d97af428 | 456 | AT_CHECK([ovsdb_client_wait ordinals connected]) |
1b1d2e6d BP |
457 | AT_CHECK([ovsdb-client dump > dump2]) |
458 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
459 | ||
460 | # Make sure that the clustered data matched the standalone data. | |
461 | AT_CHECK([cat dump2], [0], [expout]) | |
462 | AT_CLEANUP | |
00de46f9 AG |
463 | |
464 | AT_SETUP([ovsdb-tool convert-to-standalone]) | |
465 | AT_KEYWORDS([ovsdb file positive]) | |
466 | ordinal_schema > schema | |
467 | AT_CHECK([ovsdb-tool create-cluster db schema unix:s1.raft], [0], [stdout], [ignore]) | |
468 | AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket --log-file db >/dev/null 2>&1]) | |
469 | for txn in m4_foreach([txn], [[[["ordinals", | |
470 | {"op": "insert", | |
471 | "table": "ordinals", | |
472 | "row": {"number": 0, "name": "zero"}}, | |
473 | {"op": "insert", | |
474 | "table": "ordinals", | |
475 | "row": {"number": 1, "name": "one"}}, | |
476 | {"op": "insert", | |
477 | "table": "ordinals", | |
478 | "row": {"number": 2, "name": "two"}}]]]], ['txn' ]); do | |
479 | AT_CHECK([ovsdb-client transact unix:socket "$txn"], [0], [ignore], [ignore]) | |
480 | done | |
481 | AT_CHECK([ovsdb-client transact unix:socket '[["ordinals"]]'], [0], | |
482 | [ignore], [ignore]) | |
483 | AT_CHECK([ovsdb-client dump unix:socket > clusterdump]) | |
484 | AT_CHECK([ovs-appctl -t ovsdb-server -e exit], [0], [ignore], [ignore]) | |
485 | ||
486 | # Convert to standalone database from clustered database. | |
487 | AT_CHECK(ovsdb-tool cluster-to-standalone db1 db) | |
488 | ||
489 | # Check its standalone db | |
490 | AT_CHECK([ovsdb-tool db-is-standalone db1]) | |
491 | ||
492 | # Dump the standalone db data. | |
493 | AT_CHECK([ovsdb-server -vconsole:off -vfile -vvlog:off --detach --no-chdir --pidfile --log-file --remote=punix:db.sock db1]) | |
494 | AT_CHECK([ovsdb_client_wait ordinals connected]) | |
495 | AT_CHECK([ovsdb-client dump > standalonedump]) | |
496 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
497 | ||
498 | # Make sure both standalone and cluster db data matches. | |
499 | AT_CHECK([diff standalonedump clusterdump]) | |
500 | AT_CLEANUP |