1 AT_BANNER([OVSDB -- interface description language (IDL)])
3 # OVSDB_CHECK_IDL_C(TITLE, [PRE-IDL-TXN], TRANSACTIONS, OUTPUT, [KEYWORDS],
6 # Creates a database with a schema derived from idltest.ovsidl, runs
7 # each PRE-IDL-TXN (if any), starts an ovsdb-server on that database,
8 # and runs "test-ovsdb idl" passing each of the TRANSACTIONS along.
10 # Checks that the overall output is OUTPUT. Before comparison, the
11 # output is sorted (using "sort") and UUIDs in the output are replaced
12 # by markers of the form <N> where N is a number. The first unique
13 # UUID is replaced by <0>, the next by <1>, and so on. If a given
14 # UUID appears more than once it is always replaced by the same
15 # marker. If FILTER is supplied then the output is also filtered
16 # through the specified program.
18 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
19 m4_define([OVSDB_CHECK_IDL_C],
21 AT_KEYWORDS([ovsdb server idl positive $5])
22 AT_CHECK([ovsdb-tool create db $abs_srcdir/idltest.ovsschema],
23 [0], [stdout], [ignore])
24 AT_CHECK([ovsdb-server '-vPATTERN:console:ovsdb-server|%c|%m' --detach --no-chdir --pidfile="`pwd`"/pid --remote=punix:socket --unixctl="`pwd`"/unixctl db], [0], [ignore], [ignore])
26 [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore], [kill `cat pid`])])
27 AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 idl unix:socket $3],
28 [0], [stdout], [ignore], [kill `cat pid`])
29 AT_CHECK([sort stdout | perl $srcdir/uuidfilt.pl]m4_if([$6],,, [[| $6]]),
30 [0], [$4], [], [kill `cat pid`])
34 # same as OVSDB_CHECK_IDL but uses the Python IDL implementation.
35 m4_define([OVSDB_CHECK_IDL_PY],
36 [AT_SETUP([$1 - Python])
37 AT_SKIP_IF([test $HAVE_PYTHON = no])
38 AT_KEYWORDS([ovsdb server idl positive Python $5])
39 AT_CHECK([ovsdb-tool create db $abs_srcdir/idltest.ovsschema],
40 [0], [stdout], [ignore])
41 AT_CHECK([ovsdb-server '-vPATTERN:console:ovsdb-server|%c|%m' --detach --no-chdir --pidfile="`pwd`"/pid --remote=punix:socket --unixctl="`pwd`"/unixctl db], [0], [ignore], [ignore])
43 [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore], [kill `cat pid`])])
44 AT_CHECK([$PYTHON $srcdir/test-ovsdb.py -t10 idl $srcdir/idltest.ovsschema unix:socket $3],
45 [0], [stdout], [ignore], [kill `cat pid`])
46 AT_CHECK([sort stdout | perl $srcdir/uuidfilt.pl]m4_if([$6],,, [[| $6]]),
47 [0], [$4], [], [kill `cat pid`])
51 # same as OVSDB_CHECK_IDL but uses the Python IDL implementation with tcp
52 m4_define([OVSDB_CHECK_IDL_TCP_PY],
53 [AT_SETUP([$1 - Python tcp])
54 AT_SKIP_IF([test $HAVE_PYTHON = no])
55 AT_KEYWORDS([ovsdb server idl positive Python with tcp socket $5])
56 AT_CHECK([ovsdb-tool create db $abs_srcdir/idltest.ovsschema],
57 [0], [stdout], [ignore])
58 AT_CHECK([perl $srcdir/choose-port.pl], [0], [stdout])
60 AT_CHECK([ovsdb-server '-vPATTERN:console:ovsdb-server|%c|%m' --detach --no-chdir --pidfile="`pwd`"/pid --remote=ptcp:$TCP_PORT:127.0.0.1 --unixctl="`pwd`"/unixctl db], [0], [ignore], [ignore])
62 [AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT $2], [0], [ignore], [ignore], [kill `cat pid`])])
63 AT_CHECK([$PYTHON $srcdir/test-ovsdb.py -t10 idl $srcdir/idltest.ovsschema tcp:127.0.0.1:$TCP_PORT $3],
64 [0], [stdout], [ignore], [kill `cat pid`])
65 AT_CHECK([sort stdout | perl $srcdir/uuidfilt.pl]m4_if([$6],,, [[| $6]]),
66 [0], [$4], [], [kill `cat pid`])
70 m4_define([OVSDB_CHECK_IDL],
71 [OVSDB_CHECK_IDL_C($@)
72 OVSDB_CHECK_IDL_PY($@)
73 OVSDB_CHECK_IDL_TCP_PY($@)])
75 OVSDB_CHECK_IDL([simple idl, initially empty, no ops],
82 OVSDB_CHECK_IDL([simple idl, initially empty, various ops],
91 "u": ["uuid", "84f5c8f5-ac76-4dbc-a24f-8860eb407fc1"],
92 "ia": ["set", [1, 2, 3]],
93 "ra": ["set", [-0.5]],
94 "ba": ["set", [true]],
95 "sa": ["set", ["abc", "def"]],
96 "ua": ["set", [["uuid", "69443985-7806-45e2-b35f-574a04e720f9"],
97 ["uuid", "aad11ef0-816a-4b01-93e6-03b8b4256b98"]]]}},
105 "row": {"b": true}}]' \
110 "row": {"r": 123.5}}]' \
119 "ra": ["set", [1.5]],
120 "ba": ["set", [false]],
122 "ua": ["set", []]}}]' \
126 "where": [["i", "<", 1]],
127 "row": {"s": "newstring"}}]' \
131 "where": [["i", "==", 0]]}]' \
134 001: {"error":null,"result":[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}]}
135 002: i=0 r=0 b=false s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
136 002: i=1 r=2 b=true s=mystring u=<3> ia=[1 2 3] ra=[-0.5] ba=[true] sa=[abc def] ua=[<4> <5>] uuid=<0>
137 003: {"error":null,"result":[{"count":2}]}
138 004: i=0 r=0 b=true s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
139 004: i=1 r=2 b=true s=mystring u=<3> ia=[1 2 3] ra=[-0.5] ba=[true] sa=[abc def] ua=[<4> <5>] uuid=<0>
140 005: {"error":null,"result":[{"count":2}]}
141 006: i=0 r=123.5 b=true s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
142 006: i=1 r=123.5 b=true s=mystring u=<3> ia=[1 2 3] ra=[-0.5] ba=[true] sa=[abc def] ua=[<4> <5>] uuid=<0>
143 007: {"error":null,"result":[{"uuid":["uuid","<6>"]}]}
144 008: i=-1 r=125 b=false s= u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
145 008: i=0 r=123.5 b=true s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
146 008: i=1 r=123.5 b=true s=mystring u=<3> ia=[1 2 3] ra=[-0.5] ba=[true] sa=[abc def] ua=[<4> <5>] uuid=<0>
147 009: {"error":null,"result":[{"count":2}]}
148 010: i=-1 r=125 b=false s=newstring u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
149 010: i=0 r=123.5 b=true s=newstring u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
150 010: i=1 r=123.5 b=true s=mystring u=<3> ia=[1 2 3] ra=[-0.5] ba=[true] sa=[abc def] ua=[<4> <5>] uuid=<0>
151 011: {"error":null,"result":[{"count":1}]}
152 012: i=-1 r=125 b=false s=newstring u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
153 012: i=1 r=123.5 b=true s=mystring u=<3> ia=[1 2 3] ra=[-0.5] ba=[true] sa=[abc def] ua=[<4> <5>] uuid=<0>
155 014: i=-1 r=125 b=false s=newstring u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
156 014: i=1 r=123.5 b=true s=mystring u=<3> ia=[1 2 3] ra=[-0.5] ba=[true] sa=[abc def] ua=[<4> <5>] uuid=<0>
160 OVSDB_CHECK_IDL([simple idl, initially populated],
168 "u": ["uuid", "84f5c8f5-ac76-4dbc-a24f-8860eb407fc1"],
169 "ia": ["set", [1, 2, 3]],
170 "ra": ["set", [-0.5]],
171 "ba": ["set", [true]],
172 "sa": ["set", ["abc", "def"]],
173 "ua": ["set", [["uuid", "69443985-7806-45e2-b35f-574a04e720f9"],
174 ["uuid", "aad11ef0-816a-4b01-93e6-03b8b4256b98"]]]}},
182 "row": {"b": true}}]']],
183 [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
184 000: i=1 r=2 b=true s=mystring u=<2> ia=[1 2 3] ra=[-0.5] ba=[true] sa=[abc def] ua=[<3> <4>] uuid=<5>
185 001: {"error":null,"result":[{"count":2}]}
186 002: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
187 002: i=1 r=2 b=true s=mystring u=<2> ia=[1 2 3] ra=[-0.5] ba=[true] sa=[abc def] ua=[<3> <4>] uuid=<5>
191 OVSDB_CHECK_IDL([simple idl, writing via IDL],
199 "u": ["uuid", "84f5c8f5-ac76-4dbc-a24f-8860eb407fc1"],
200 "ia": ["set", [1, 2, 3]],
201 "ra": ["set", [-0.5]],
202 "ba": ["set", [true]],
203 "sa": ["set", ["abc", "def"]],
204 "ua": ["set", [["uuid", "69443985-7806-45e2-b35f-574a04e720f9"],
205 ["uuid", "aad11ef0-816a-4b01-93e6-03b8b4256b98"]]]}},
209 [['verify 0 b, verify 1 r, set 0 b 1, set 1 r 3.5' \
210 'insert 2, verify 2 i, verify 1 b, delete 1']],
211 [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
212 000: i=1 r=2 b=true s=mystring u=<2> ia=[1 2 3] ra=[-0.5] ba=[true] sa=[abc def] ua=[<3> <4>] uuid=<5>
213 001: commit, status=success
214 002: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
215 002: i=1 r=3.5 b=true s=mystring u=<2> ia=[1 2 3] ra=[-0.5] ba=[true] sa=[abc def] ua=[<3> <4>] uuid=<5>
216 003: commit, status=success
217 004: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
218 004: i=2 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<6>
222 OVSDB_CHECK_IDL([simple idl, handling verification failure],
235 "where": [["i", "==", 1]],
236 "row": {"r": 5.0}}]' \
237 '+verify 1 r, set 1 r 3' \
238 'verify 1 r, set 1 r 3' \
240 [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
241 000: i=1 r=2 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
242 001: commit, status=success
243 002: {"error":null,"result":[{"count":1}]}
244 003: commit, status=try again
245 004: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
246 004: i=1 r=5 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
247 005: commit, status=success
248 006: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
249 006: i=1 r=3 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
253 OVSDB_CHECK_IDL([simple idl, increment operation],
258 [['set 0 r 2.0, increment 0']],
259 [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
260 001: commit, status=success, increment=1
261 002: i=1 r=2 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
265 OVSDB_CHECK_IDL([simple idl, aborting],
270 [['set 0 r 2.0, abort' \
272 [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
273 001: commit, status=aborted
274 002: commit, status=success
275 003: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
279 OVSDB_CHECK_IDL([simple idl, destroy without commit or abort],
284 [['set 0 r 2.0, destroy' \
286 [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
288 002: commit, status=success
289 003: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
293 OVSDB_CHECK_IDL([self-linking idl, consistent ops],
298 "row": {"i": 0, "k": ["named-uuid", "self"]},
299 "uuid-name": "self"}]' \
303 "row": {"i": 1, "k": ["named-uuid", "row2"]},
304 "uuid-name": "row1"},
307 "row": {"i": 2, "k": ["named-uuid", "row1"]},
308 "uuid-name": "row2"}]' \
312 "where": [["i", "==", 1]],
313 "row": {"k": ["uuid", "#1#"]}}]' \
318 "row": {"k": ["uuid", "#0#"]}}]']],
320 001: {"error":null,"result":[{"uuid":["uuid","<0>"]}]}
321 002: i=0 k=0 ka=[] l2= uuid=<0>
322 003: {"error":null,"result":[{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]}]}
323 004: i=0 k=0 ka=[] l2= uuid=<0>
324 004: i=1 k=2 ka=[] l2= uuid=<1>
325 004: i=2 k=1 ka=[] l2= uuid=<2>
326 005: {"error":null,"result":[{"count":1}]}
327 006: i=0 k=0 ka=[] l2= uuid=<0>
328 006: i=1 k=1 ka=[] l2= uuid=<1>
329 006: i=2 k=1 ka=[] l2= uuid=<2>
330 007: {"error":null,"result":[{"count":3}]}
331 008: i=0 k=0 ka=[] l2= uuid=<0>
332 008: i=1 k=0 ka=[] l2= uuid=<1>
333 008: i=2 k=0 ka=[] l2= uuid=<2>
337 OVSDB_CHECK_IDL([self-linking idl, inconsistent ops],
342 "row": {"i": 0, "k": ["uuid", "cf197cc5-c8c9-42f5-82d5-c71a9f2cb96b"]}}]' \
347 "row": {"i": 1, "k": ["named-uuid", "one"]}},
350 "row": {"i": 2, "k": ["named-uuid", "one"]}}]' \
355 "row": {"k": ["uuid", "c2fca39a-e69a-42a4-9c56-5eca85839ce9"]}}]' \
359 "where": [["_uuid", "==", ["uuid", "#1#"]]]}]' \
363 "where": [["_uuid", "==", ["uuid", "#2#"]]]}]' \
370 001: {"error":null,"result":[{"uuid":["uuid","<0>"]},{"details":"Table link1 column k row <0> references nonexistent row <1> in table link1.","error":"referential integrity violation"}]}
371 002: {"error":null,"result":[{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]}]}
372 003: i=1 k=1 ka=[] l2= uuid=<2>
373 003: i=2 k=1 ka=[] l2= uuid=<3>
374 004: {"error":null,"result":[{"count":2},{"details":"Table link1 column k row <x> references nonexistent row <4> in table link1.","error":"referential integrity violation"}]}
375 005: {"error":null,"result":[{"count":1},{"details":"cannot delete link1 row <2> because of 1 remaining reference(s)","error":"referential integrity violation"}]}
376 006: {"error":null,"result":[{"count":1}]}
377 007: i=1 k=1 ka=[] l2= uuid=<2>
378 008: {"error":null,"result":[{"count":1}]}
383 [[sed -e '/004:/s/row <[23]> references/row <x> references/']])
385 OVSDB_CHECK_IDL([self-linking idl, sets],
390 "row": {"i": 0, "k": ["named-uuid", "i0"], "ka": ["set", [["named-uuid", "i0"]]]},
394 "row": {"i": 1, "k": ["named-uuid", "i0"], "ka": ["set", [["named-uuid", "i1"]]]},
398 "row": {"i": 2, "k": ["named-uuid", "i0"], "ka": ["set", [["named-uuid", "i2"]]]},
402 "row": {"i": 3, "k": ["named-uuid", "i0"], "ka": ["set", [["named-uuid", "i3"]]]},
403 "uuid-name": "i3"}]' \
408 "row": {"ka": ["set", [["uuid", "#0#"], ["uuid", "#1#"], ["uuid", "#2#"], ["uuid", "#3#"]]]}}]' \
412 "where": [["i", "==", 2]],
413 "row": {"ka": ["set", [["uuid", "#0#"], ["uuid", "88702e78-845b-4a6e-ad08-cf68922ae84a"], ["uuid", "#2#"]]]}}]' \
419 001: {"error":null,"result":[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]}]}
420 002: i=0 k=0 ka=[0] l2= uuid=<0>
421 002: i=1 k=0 ka=[1] l2= uuid=<1>
422 002: i=2 k=0 ka=[2] l2= uuid=<2>
423 002: i=3 k=0 ka=[3] l2= uuid=<3>
424 003: {"error":null,"result":[{"count":4}]}
425 004: i=0 k=0 ka=[0 1 2 3] l2= uuid=<0>
426 004: i=1 k=0 ka=[0 1 2 3] l2= uuid=<1>
427 004: i=2 k=0 ka=[0 1 2 3] l2= uuid=<2>
428 004: i=3 k=0 ka=[0 1 2 3] l2= uuid=<3>
429 005: {"error":null,"result":[{"count":1},{"details":"Table link1 column ka row <2> references nonexistent row <4> in table link1.","error":"referential integrity violation"}]}
430 006: {"error":null,"result":[{"count":4}]}
435 OVSDB_CHECK_IDL([external-linking idl, consistent ops],
441 "uuid-name": "row0"},
444 "row": {"i": 1, "k": ["named-uuid", "row1"], "l2": ["set", [["named-uuid", "row0"]]]},
445 "uuid-name": "row1"}]']],
447 001: {"error":null,"result":[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}]}
448 002: i=0 l1= uuid=<0>
449 002: i=1 k=1 ka=[] l2=0 uuid=<1>
453 OVSDB_CHECK_IDL_PY([external-linking idl, insert ops],
457 001: commit, status=success
458 002: i=1 k=1 ka=[1] l2= uuid=<0>
459 002: i=2 k=1 ka=[1 2] l2= uuid=<1>
463 OVSDB_CHECK_IDL_PY([getattr idl, insert ops],
467 001: commit, status=success
468 002: i=2 k=2 ka=[] l2= uuid=<0>