1 AT_BANNER([OVSDB -- execution])
3 m4_define([ORDINAL_SCHEMA],
8 "number": {"type": "integer"},
9 "name": {"type": "string"}}}},
11 "cksum": "12345678 9"}]])
13 m4_define([CONSTRAINT_SCHEMA],
14 [[{"name": "constraints",
18 "a": {"type": "integer"},
19 "a2a": {"type": {"key": {"type": "uuid", "refTable": "a"},
20 "min": 0, "max": "unlimited"}},
21 "a2b": {"type": {"key": {"type": "uuid", "refTable": "b"},
22 "min": 0, "max": "unlimited"}}}},
25 "b": {"type": "integer"},
26 "b2a": {"type": {"key": {"type": "uuid", "refTable": "a"},
27 "min": 0, "max": "unlimited"}},
28 "b2b": {"type": {"key": {"type": "uuid", "refTable": "b"},
29 "min": 0, "max": "unlimited"}}}},
32 "positive": {"type": {"key": {"type": "integer",
36 m4_define([WEAK_SCHEMA],
41 "a": {"type": "integer"},
42 "a2a": {"type": {"key": {"type": "uuid",
45 "min": 0, "max": "unlimited"}},
46 "a2a1": {"type": {"key": {"type": "uuid",
49 "a2b": {"type": {"key": {"type": "uuid",
51 "refType": "weak"}}}}},
54 "b": {"type": "integer"},
55 "b2a": {"type": {"key": {"type": "uuid",
58 "min": 0, "max": "unlimited"}}}}}}]])
60 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
62 # Runs "test-ovsdb execute" with the given SCHEMA and each of the
63 # TRANSACTIONS (which should be a quoted list of quoted strings).
65 # Checks that the overall output is OUTPUT, but UUIDs in the output
66 # are replaced by markers of the form <N> where N is a number. The
67 # first unique UUID is replaced by <0>, the next by <1>, and so on.
68 # If a given UUID appears more than once it is always replaced by the
71 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
72 m4_define([OVSDB_CHECK_EXECUTION],
74 AT_KEYWORDS([ovsdb execute execution positive $5])
75 AT_CHECK([test-ovsdb execute '$2' m4_foreach([txn], [$3], [ 'txn'])],
77 AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0], [$4])
80 OVSDB_CHECK_EXECUTION([uuid-name must be <id>],
86 "uuid-name": "0"}]]]],
87 [[[{"details":"Parsing ovsdb operation 1 of 1 failed: Type mismatch for member 'uuid-name'.","error":"syntax error","syntax":"{\"op\":\"insert\",\"row\":{},\"table\":\"a\",\"uuid-name\":\"0\"}"}]
90 OVSDB_CHECK_EXECUTION([named-uuid must be <id>],
95 "row": {"a2a": ["named-uuid", "0"]}}]]]],
96 [[[{"details":"named-uuid string is not a valid <id>","error":"syntax error","syntax":"[\"named-uuid\",\"0\"]"}]
99 m4_define([EXECUTION_EXAMPLES], [
100 dnl At one point the "commit" code ignored new rows with all-default values,
101 dnl so this checks for that problem.
102 OVSDB_CHECK_EXECUTION([insert default row, query table],
112 [[[{"uuid":["uuid","<0>"]}]
113 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"","number":0}]}]
116 OVSDB_CHECK_EXECUTION([insert row, query table],
121 "row": {"number": 0, "name": "zero"}}]]],
126 [[[{"uuid":["uuid","<0>"]}]
127 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"zero","number":0}]}]
130 OVSDB_CHECK_EXECUTION([insert rows, query by value],
135 "row": {"number": 0, "name": "zero"}}]]],
139 "row": {"number": 1, "name": "one"}}]]],
143 "where": [["name", "==", "zero"]]}]]],
147 "where": [["name", "==", "one"]]}]]]],
148 [[[{"uuid":["uuid","<0>"]}]
149 [{"uuid":["uuid","<1>"]}]
150 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"zero","number":0}]}]
151 [{"rows":[{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}]
154 OVSDB_CHECK_EXECUTION([insert rows, query by named-uuid],
159 "row": {"number": 0, "name": "zero"},
160 "uuid-name": "first"},
163 "row": {"number": 1, "name": "one"},
164 "uuid-name": "second"},
167 "where": [["_uuid", "==", ["named-uuid", "first"]]]},
170 "where": [["_uuid", "==", ["named-uuid", "second"]]]}]]]],
171 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"zero","number":0}]},{"rows":[{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}]
174 OVSDB_CHECK_EXECUTION([insert rows, update rows by value],
179 "row": {"number": 0, "name": "zero"},
180 "uuid-name": "first"}]]],
184 "row": {"number": 1, "name": "one"},
185 "uuid-name": "first"}]]],
189 "where": [["name", "==", "zero"]],
190 "row": {"name": "nought"}}]]],
195 "sort": ["number"]}]]]],
196 [[[{"uuid":["uuid","<0>"]}]
197 [{"uuid":["uuid","<1>"]}]
199 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"nought","number":0},{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}]
202 OVSDB_CHECK_EXECUTION([insert rows, mutate rows],
207 "row": {"number": 0, "name": "zero"},
208 "uuid-name": "first"}]]],
212 "row": {"number": 1, "name": "one"},
213 "uuid-name": "first"}]]],
217 "where": [["name", "==", "zero"]],
218 "mutations": [["number", "+=", 2]]}]]],
223 "sort": ["number"]}]]]],
224 [[[{"uuid":["uuid","<0>"]}]
225 [{"uuid":["uuid","<1>"]}]
227 [{"rows":[{"_uuid":["uuid","<1>"],"_version":["uuid","<2>"],"name":"one","number":1},{"_uuid":["uuid","<0>"],"_version":["uuid","<3>"],"name":"zero","number":2}]}]
230 OVSDB_CHECK_EXECUTION([insert rows, delete by named-uuid],
235 "row": {"number": 0, "name": "zero"},
236 "uuid-name": "first"},
239 "row": {"number": 1, "name": "one"},
240 "uuid-name": "second"},
243 "where": [["_uuid", "==", ["named-uuid", "first"]]]},
247 "columns": ["name","number"]}]]]],
248 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"count":1},{"rows":[{"name":"one","number":1}]}]
251 OVSDB_CHECK_EXECUTION([insert rows, delete rows by value],
256 "row": {"number": 0, "name": "zero"},
257 "uuid-name": "first"}]]],
261 "row": {"number": 1, "name": "one"},
262 "uuid-name": "first"}]]],
266 "where": [["name", "==", "zero"]]}]]],
271 [[[{"uuid":["uuid","<0>"]}]
272 [{"uuid":["uuid","<1>"]}]
274 [{"rows":[{"_uuid":["uuid","<1>"],"_version":["uuid","<2>"],"name":"one","number":1}]}]
277 OVSDB_CHECK_EXECUTION([insert rows, delete by (non-matching) value],
282 "row": {"number": 0, "name": "zero"},
283 "uuid-name": "first"}]]],
287 "row": {"number": 1, "name": "one"},
288 "uuid-name": "first"}]]],
292 "where": [["name", "==", "nought"]]}]]],
297 "sort": ["number"]}]]]],
298 [[[{"uuid":["uuid","<0>"]}]
299 [{"uuid":["uuid","<1>"]}]
301 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"zero","number":0},{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}]
304 OVSDB_CHECK_EXECUTION([insert rows, delete all],
309 "row": {"number": 0, "name": "zero"},
310 "uuid-name": "first"},
313 "row": {"number": 1, "name": "one"},
314 "uuid-name": "second"},
321 "columns": ["name","number"]}]]]],
322 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"count":2},{"rows":[]}]
325 OVSDB_CHECK_EXECUTION([insert row, query table, commit],
330 "row": {"number": 0, "name": "zero"}},
335 "durable": false}]]]],
336 [[[{"uuid":["uuid","<0>"]},{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"zero","number":0}]},{}]
339 OVSDB_CHECK_EXECUTION([insert row, query table, commit durably],
344 "row": {"number": 0, "name": "zero"}},
349 "durable": true}]]]],
350 [[[{"uuid":["uuid","<0>"]},{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"zero","number":0}]},{}]
353 OVSDB_CHECK_EXECUTION([equality wait with correct rows],
358 "row": {"number": 0, "name": "zero"}},
361 "row": {"number": 1, "name": "one"}},
366 "columns": ["name", "number"],
368 "rows": [{"name": "zero", "number": 0},
369 {"name": "one", "number": 1}]}]]]],
370 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{}]
373 OVSDB_CHECK_EXECUTION([equality wait with extra row],
378 "row": {"number": 0, "name": "zero"}},
381 "row": {"number": 1, "name": "one"}},
386 "columns": ["name", "number"],
388 "rows": [{"name": "zero", "number": 0},
389 {"name": "one", "number": 1},
390 {"name": "two", "number": 2}]}]]]],
391 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"details":"\"wait\" timed out","error":"timed out"}]
394 OVSDB_CHECK_EXECUTION([equality wait with missing row],
399 "row": {"number": 0, "name": "zero"}},
402 "row": {"number": 1, "name": "one"}},
407 "columns": ["name", "number"],
409 "rows": [{"name": "one", "number": 1}]}]]]],
410 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"details":"\"wait\" timed out","error":"timed out"}]
413 OVSDB_CHECK_EXECUTION([inequality wait with correct rows],
418 "row": {"number": 0, "name": "zero"}},
421 "row": {"number": 1, "name": "one"}},
426 "columns": ["name", "number"],
428 "rows": [{"name": "zero", "number": 0},
429 {"name": "one", "number": 1}]}]]]],
430 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"details":"\"wait\" timed out","error":"timed out"}]
433 OVSDB_CHECK_EXECUTION([inequality wait with extra row],
438 "row": {"number": 0, "name": "zero"}},
441 "row": {"number": 1, "name": "one"}},
446 "columns": ["name", "number"],
448 "rows": [{"name": "zero", "number": 0},
449 {"name": "one", "number": 1},
450 {"name": "two", "number": 2}]}]]]],
451 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{}]
454 OVSDB_CHECK_EXECUTION([inequality wait with missing row],
459 "row": {"number": 0, "name": "zero"}},
462 "row": {"number": 1, "name": "one"}},
467 "columns": ["name", "number"],
469 "rows": [{"name": "one", "number": 1}]}]]]],
470 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{}]
473 OVSDB_CHECK_EXECUTION([insert and update constraints],
477 "table": "constrained",
481 "table": "constrained",
482 "row": {"positive": -1}}]]],
485 "table": "constrained",
487 "row": {"positive": -2}}]]],
490 "table": "constrained",
491 "row": {"positive": 1}}]]],
494 "table": "constrained",
495 "row": {"positive": 2}}]]]],
496 [[[{"details":"0 is less than minimum allowed value 1","error":"constraint violation"}]
497 [{"details":"-1 is less than minimum allowed value 1","error":"constraint violation"}]
498 [{"details":"-2 is less than minimum allowed value 1","error":"constraint violation"}]
499 [{"uuid":["uuid","<0>"]}]
500 [{"uuid":["uuid","<1>"]},{"details":"transaction causes \"constrained\" table to contain 2 rows, greater than the schema-defined limit of 1 row(s)","error":"constraint violation"}]
503 OVSDB_CHECK_EXECUTION([referential integrity -- simple],
509 "uuid-name": "brow"},
513 "a2b": ["set", [["named-uuid", "brow"]]]}},
517 "a2b": ["set", [["named-uuid", "brow"]]]}},
521 "a2b": ["set", [["named-uuid", "brow"]]]}}]]],
529 "where": [["a", "==", 0]]}]]],
537 "where": [["a", "==", 1]]}]]],
545 "where": [["a", "==", 2]]}]]],
550 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]}]
551 [{"count":1},{"details":"cannot delete b row <0> because of 3 remaining reference(s)","error":"referential integrity violation"}]
553 [{"count":1},{"details":"cannot delete b row <0> because of 2 remaining reference(s)","error":"referential integrity violation"}]
555 [{"count":1},{"details":"cannot delete b row <0> because of 1 remaining reference(s)","error":"referential integrity violation"}]
560 OVSDB_CHECK_EXECUTION([referential integrity -- mutual references],
566 "a2b": ["set", [["named-uuid", "row2"]]],
567 "a2a": ["set", [["named-uuid", "row1"]]]},
568 "uuid-name": "row1"},
572 "b2b": ["set", [["named-uuid", "row2"]]],
573 "b2a": ["set", [["named-uuid", "row1"]]]},
574 "uuid-name": "row2"}]]],
578 "row": {"a2b": ["set", [["uuid", "b516b960-5b19-4fc2-bb82-fe1cbd6d0241"]]]}}]]],
582 "where": [["a", "==", 0]]}]]],
586 "where": [["b", "==", 1]]}]]],
587 dnl Try the deletions again to make sure that the refcounts got rolled back.
591 "where": [["a", "==", 0]]}]]],
595 "where": [["b", "==", 1]]}]]],
599 "where": [["a", "==", 0]]},
602 "where": [["b", "==", 1]]}]]]],
603 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}]
604 [{"uuid":["uuid","<2>"]},{"details":"Table a column a2b row <2> references nonexistent row <3> in table b.","error":"referential integrity violation"}]
605 [{"count":1},{"details":"cannot delete a row <0> because of 1 remaining reference(s)","error":"referential integrity violation"}]
606 [{"count":1},{"details":"cannot delete b row <1> because of 1 remaining reference(s)","error":"referential integrity violation"}]
607 [{"count":1},{"details":"cannot delete a row <0> because of 1 remaining reference(s)","error":"referential integrity violation"}]
608 [{"count":1},{"details":"cannot delete b row <1> because of 1 remaining reference(s)","error":"referential integrity violation"}]
609 [{"count":1},{"count":1}]
612 OVSDB_CHECK_EXECUTION([weak references],
618 "a2a": ["set", [["named-uuid", "row1"],
619 ["named-uuid", "row2"],
620 ["uuid", "0e767b36-6822-4044-8307-d58467e04669"]]],
621 "a2a1": ["named-uuid", "row1"],
622 "a2b": ["named-uuid", "row3"]},
623 "uuid-name": "row1"},
627 "a2a": ["set", [["named-uuid", "row1"],
628 ["named-uuid", "row2"]]],
629 "a2a1": ["named-uuid", "row2"],
630 "a2b": ["named-uuid", "row3"]},
631 "uuid-name": "row2"},
635 "a2a": ["set", [["named-uuid", "row1"],
636 ["named-uuid", "row2"]]],
637 "a2a1": ["named-uuid", "row2"],
638 "a2b": ["named-uuid", "row4"]}},
642 "b2a": ["named-uuid", "row1"]},
643 "uuid-name": "row3"},
647 "b2a": ["named-uuid", "row2"]},
648 "uuid-name": "row4"}]]],
649 dnl Check that the nonexistent row UUID we added to row a0 was deleted,
650 dnl and that other rows were inserted as requested.
655 "columns": ["_uuid", "a2a", "a2a1", "a2b"],
661 "columns": ["_uuid", "b", "b2a"],
663 dnl Try to insert invalid all-zeros weak reference (the default) into
664 dnl "a2b", which requires exactly one value.
668 "row": {"a2a1": ["named-uuid", "me"]},
669 "uuid-name": "me"}]]],
670 dnl Try to delete row from "b" that is referred to by weak references
671 dnl from "a" table "a2b" column that requires exactly one value.
675 "where": [["b", "==", 3]]}]]],
676 dnl Try to delete row from "a" that is referred to by weak references
677 dnl from "a" table "a2a1" column that requires exactly one value.
681 "where": [["a", "==", 1]]}]]],
682 dnl Delete the row that had the reference that caused the previous
683 dnl deletion to fail, then check that other rows are unchanged.
687 "where": [["a", "==", 2]]}]]],
692 "columns": ["_uuid", "a2a", "a2a1", "a2b"],
698 "columns": ["_uuid", "b", "b2a"],
700 dnl Delete row a0 then check that references to it were removed.
704 "where": [["a", "==", 0]]}]]],
709 "columns": ["_uuid", "a2a", "a2a1", "a2b"],
715 "columns": ["_uuid", "b", "b2a"],
717 dnl Delete row a1 then check that references to it were removed.
721 "where": [["a", "==", 1]]}]]],
726 "columns": ["_uuid", "a2a", "a2a1", "a2b"],
732 "columns": ["_uuid", "b", "b2a"],
734 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]},{"uuid":["uuid","<4>"]}]
735 [{"rows":[{"_uuid":["uuid","<0>"],"a2a":["set",[["uuid","<0>"],["uuid","<1>"]]],"a2a1":["uuid","<0>"],"a2b":["uuid","<3>"]},{"_uuid":["uuid","<1>"],"a2a":["set",[["uuid","<0>"],["uuid","<1>"]]],"a2a1":["uuid","<1>"],"a2b":["uuid","<3>"]},{"_uuid":["uuid","<2>"],"a2a":["set",[["uuid","<0>"],["uuid","<1>"]]],"a2a1":["uuid","<1>"],"a2b":["uuid","<4>"]}]}]
736 [{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["uuid","<0>"]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["uuid","<1>"]}]}]
737 [{"uuid":["uuid","<5>"]},{"details":"Weak reference column \"a2b\" in \"a\" row <5> (inserted within this transaction) contained all-zeros UUID (probably as the default value for this column) but deleting this value caused a constraint volation because this column is not allowed to be empty.","error":"constraint violation"}]
738 [{"count":1},{"details":"Deletion of 1 weak reference(s) to deleted (or never-existing) rows from column \"a2b\" in \"a\" row <2> caused this column to become empty, but constraints on this column disallow an empty column.","error":"constraint violation"}]
739 [{"count":1},{"details":"Deletion of 1 weak reference(s) to deleted (or never-existing) rows from column \"a2a1\" in \"a\" row <2> caused this column to become empty, but constraints on this column disallow an empty column.","error":"constraint violation"}]
741 [{"rows":[{"_uuid":["uuid","<0>"],"a2a":["set",[["uuid","<0>"],["uuid","<1>"]]],"a2a1":["uuid","<0>"],"a2b":["uuid","<3>"]},{"_uuid":["uuid","<1>"],"a2a":["set",[["uuid","<0>"],["uuid","<1>"]]],"a2a1":["uuid","<1>"],"a2b":["uuid","<3>"]}]}]
742 [{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["uuid","<0>"]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["uuid","<1>"]}]}]
744 [{"rows":[{"_uuid":["uuid","<1>"],"a2a":["uuid","<1>"],"a2a1":["uuid","<1>"],"a2b":["uuid","<3>"]}]}]
745 [{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["set",[]]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["uuid","<1>"]}]}]
748 [{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["set",[]]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["set",[]]}]}]