1 AT_BANNER([OVSDB -- ovsdb-tool])
3 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
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.
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
15 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
16 m4_define([OVSDB_CHECK_EXECUTION],
18 AT_KEYWORDS([ovsdb file positive $5])
22 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
23 m4_foreach([txn], [$3],
24 [AT_CHECK([ovsdb-tool transact db 'txn'], [0], [stdout], [ignore])
27 AT_CHECK([perl $srcdir/uuidfilt.pl output], [0], [$4])
32 AT_SETUP([transaction comments])
33 AT_KEYWORDS([ovsdb file positive])
34 AT_DATA([schema], [ORDINAL_SCHEMA
37 AT_CHECK([ovsdb-tool create db schema], [0], [], [ignore])
38 AT_CHECK([[ovsdb-tool transact db '
42 "row": {"name": "five", "number": 5}},
44 "comment": "add row for 5"}]']], [0], [stdout], [ignore])
45 AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0],
46 [[[{"uuid":["uuid","<0>"]},{}]
48 AT_CHECK([grep -q "add row for 5" db])
51 AT_SETUP([ovsdb-tool compact])
52 AT_KEYWORDS([ovsdb file positive])
53 AT_DATA([schema], [ORDINAL_SCHEMA
56 AT_CHECK([ovsdb-tool create db schema], [0], [], [ignore])
57 dnl Do a bunch of random transactions that put crap in the database log.
59 [[for pair in 'zero 0' 'one 1' 'two 2' 'three 3' 'four 4' 'five 5'; do
61 ovsdb-tool transact db '
65 "row": {"name": "'$1'", "number": '$2'}},
67 "comment": "add row for '"$pair"'"}]'
68 ovsdb-tool transact db '
72 "where": [["number", "==", '$2']]},
74 "comment": "delete row for '"$2"'"}]'
75 ovsdb-tool transact db '
79 "row": {"name": "'$1'", "number": '$2'}},
81 "comment": "add back row for '"$pair"'"}]'
83 [0], [stdout], [ignore])
84 dnl Check that all the crap is in fact in the database log.
85 AT_CHECK([[perl $srcdir/uuidfilt.pl db | grep -v ^OVSDB | sed 's/"_date":[0-9]*/"_date":0/' | test-json --multiple -]], [0],
86 [[{"name":"ordinals","tables":{"ordinals":{"columns":{"name":{"type":"string"},"number":{"type":"integer"}}}}}
87 {"_comment":"add row for zero 0","_date":0,"ordinals":{"<0>":{"name":"zero"}}}
88 {"_comment":"delete row for 0","_date":0,"ordinals":{"<0>":null}}
89 {"_comment":"add back row for zero 0","_date":0,"ordinals":{"<1>":{"name":"zero"}}}
90 {"_comment":"add row for one 1","_date":0,"ordinals":{"<2>":{"name":"one","number":1}}}
91 {"_comment":"delete row for 1","_date":0,"ordinals":{"<2>":null}}
92 {"_comment":"add back row for one 1","_date":0,"ordinals":{"<3>":{"name":"one","number":1}}}
93 {"_comment":"add row for two 2","_date":0,"ordinals":{"<4>":{"name":"two","number":2}}}
94 {"_comment":"delete row for 2","_date":0,"ordinals":{"<4>":null}}
95 {"_comment":"add back row for two 2","_date":0,"ordinals":{"<5>":{"name":"two","number":2}}}
96 {"_comment":"add row for three 3","_date":0,"ordinals":{"<6>":{"name":"three","number":3}}}
97 {"_comment":"delete row for 3","_date":0,"ordinals":{"<6>":null}}
98 {"_comment":"add back row for three 3","_date":0,"ordinals":{"<7>":{"name":"three","number":3}}}
99 {"_comment":"add row for four 4","_date":0,"ordinals":{"<8>":{"name":"four","number":4}}}
100 {"_comment":"delete row for 4","_date":0,"ordinals":{"<8>":null}}
101 {"_comment":"add back row for four 4","_date":0,"ordinals":{"<9>":{"name":"four","number":4}}}
102 {"_comment":"add row for five 5","_date":0,"ordinals":{"<10>":{"name":"five","number":5}}}
103 {"_comment":"delete row for 5","_date":0,"ordinals":{"<10>":null}}
104 {"_comment":"add back row for five 5","_date":0,"ordinals":{"<11>":{"name":"five","number":5}}}
106 dnl Dump out and check the actual database contents.
107 AT_CHECK([[ovsdb-server --unixctl=$PWD/unixctl --remote=punix:socket --run "ovsdb-client dump unix:socket ordinals" db]],
108 [0], [stdout], [ignore])
109 AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0], [dnl
112 ------------------------------------ ----- ------
120 dnl Now compact the database in-place.
122 AT_CHECK([[ovsdb-tool compact db]], [0], [], [ignore])
123 dnl We can't fully re-check the contents of the database log, because the
124 dnl order of the records is not predictable, but there should only be 4 lines
126 AT_CAPTURE_FILE([db])
127 AT_CHECK([wc -l < db], [0], [4
129 dnl And check that the dumped data is the same too:
130 AT_CHECK([[ovsdb-server --unixctl=$PWD/unixctl --remote=punix:socket --run "ovsdb-client dump unix:socket ordinals" db]],
131 [0], [stdout], [ignore])
132 AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0], [dnl
135 ------------------------------------ ----- ------
145 AT_SETUP([ovsdb-tool convert -- removing a column])
146 AT_KEYWORDS([ovsdb file positive])
147 AT_DATA([schema], [ORDINAL_SCHEMA
149 AT_DATA([new-schema],
150 [[{"name": "ordinals",
154 "number": {"type": "integer"}}}}}
157 AT_CHECK([ovsdb-tool create db schema], [0], [], [ignore])
158 dnl Put some data in the database.
160 [[for pair in 'zero 0' 'one 1' 'two 2' 'three 3' 'four 4' 'five 5'; do
162 ovsdb-tool transact db '
166 "row": {"name": "'$1'", "number": '$2'}},
168 "comment": "add row for '"$pair"'"}]'
170 [0], [stdout], [ignore])
171 dnl Dump out and check the actual database contents.
172 AT_CHECK([[ovsdb-server --unixctl=$PWD/unixctl --remote=punix:socket --run "ovsdb-client dump unix:socket ordinals" db]],
173 [0], [stdout], [ignore])
174 AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0], [dnl
177 ------------------------------------ ----- ------
185 dnl Now convert the database in-place.
187 AT_CHECK([[ovsdb-tool convert db new-schema]], [0], [], [ignore])
188 dnl We can't fully re-check the contents of the database log, because the
189 dnl order of the records is not predictable, but there should only be 4 lines
191 AT_CAPTURE_FILE([db])
192 AT_CHECK([wc -l < db], [0], [4
194 dnl And check that the dumped data is the same except for the removed column:
195 AT_CHECK([[ovsdb-server --unixctl=$PWD/unixctl --remote=punix:socket --run "ovsdb-client dump unix:socket ordinals" db]],
196 [0], [stdout], [ignore])
197 AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0], [dnl
200 ------------------------------------ ------
210 AT_SETUP([ovsdb-tool convert -- adding a column])
211 AT_KEYWORDS([ovsdb file positive])
213 [[{"name": "ordinals",
217 "number": {"type": "integer"}}}}}
219 AT_DATA([new-schema], [ORDINAL_SCHEMA
222 AT_CHECK([ovsdb-tool create db schema], [0], [], [ignore])
223 dnl Put some data in the database.
225 [[for number in 0 1 2 3 4 5; do
226 ovsdb-tool transact db '
230 "row": {"number": '$number'}},
232 "comment": "add row for '"$number"'"}]'
234 [0], [stdout], [ignore])
235 dnl Dump out and check the actual database contents.
236 AT_CHECK([[ovsdb-server --unixctl=$PWD/unixctl --remote=punix:socket --run "ovsdb-client dump unix:socket ordinals" db]],
237 [0], [stdout], [ignore])
238 AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0], [dnl
241 ------------------------------------ ------
249 dnl Now convert the database in-place.
251 AT_CHECK([[ovsdb-tool convert db new-schema]], [0], [], [ignore])
252 dnl We can't fully re-check the contents of the database log, because the
253 dnl order of the records is not predictable, but there should only be 4 lines
255 AT_CAPTURE_FILE([db])
256 AT_CHECK([wc -l < db], [0], [4
258 dnl And check that the dumped data is the same except for the added column:
259 AT_CHECK([[ovsdb-server --unixctl=$PWD/unixctl --remote=punix:socket --run "ovsdb-client dump unix:socket ordinals" db]],
260 [0], [stdout], [ignore])
261 AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0], [dnl
264 ------------------------------------ ---- ------