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 OVSDB_CHECK_EXECUTION([duplicate uuid-name not allowed],
109 "uuid-name": "x"}]]]],
110 [[[{"uuid":["uuid","<0>"]},{"details":"This \"uuid-name\" appeared on an earlier \"insert\" operation.","error":"duplicate uuid-name","syntax":"\"x\""}]
113 m4_define([EXECUTION_EXAMPLES], [
114 dnl At one point the "commit" code ignored new rows with all-default values,
115 dnl so this checks for that problem.
116 OVSDB_CHECK_EXECUTION([insert default row, query table],
126 [[[{"uuid":["uuid","<0>"]}]
127 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"","number":0}]}]
130 OVSDB_CHECK_EXECUTION([insert row, query table],
135 "row": {"number": 0, "name": "zero"}}]]],
140 [[[{"uuid":["uuid","<0>"]}]
141 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"zero","number":0}]}]
144 OVSDB_CHECK_EXECUTION([insert rows, query by value],
149 "row": {"number": 0, "name": "zero"}}]]],
153 "row": {"number": 1, "name": "one"}}]]],
157 "where": [["name", "==", "zero"]]}]]],
161 "where": [["name", "==", "one"]]}]]]],
162 [[[{"uuid":["uuid","<0>"]}]
163 [{"uuid":["uuid","<1>"]}]
164 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"zero","number":0}]}]
165 [{"rows":[{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}]
168 OVSDB_CHECK_EXECUTION([insert rows, query by named-uuid],
173 "row": {"number": 0, "name": "zero"},
174 "uuid-name": "first"},
177 "row": {"number": 1, "name": "one"},
178 "uuid-name": "second"},
181 "where": [["_uuid", "==", ["named-uuid", "first"]]]},
184 "where": [["_uuid", "==", ["named-uuid", "second"]]]}]]]],
185 [[[{"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}]}]
188 OVSDB_CHECK_EXECUTION([insert rows, update rows by value],
193 "row": {"number": 0, "name": "zero"},
194 "uuid-name": "first"}]]],
198 "row": {"number": 1, "name": "one"},
199 "uuid-name": "first"}]]],
203 "where": [["name", "==", "zero"]],
204 "row": {"name": "nought"}}]]],
209 "sort": ["number"]}]]]],
210 [[[{"uuid":["uuid","<0>"]}]
211 [{"uuid":["uuid","<1>"]}]
213 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"nought","number":0},{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}]
216 OVSDB_CHECK_EXECUTION([insert rows, mutate rows],
221 "row": {"number": 0, "name": "zero"},
222 "uuid-name": "first"}]]],
226 "row": {"number": 1, "name": "one"},
227 "uuid-name": "first"}]]],
231 "where": [["name", "==", "zero"]],
232 "mutations": [["number", "+=", 2]]}]]],
237 "sort": ["number"]}]]]],
238 [[[{"uuid":["uuid","<0>"]}]
239 [{"uuid":["uuid","<1>"]}]
241 [{"rows":[{"_uuid":["uuid","<1>"],"_version":["uuid","<2>"],"name":"one","number":1},{"_uuid":["uuid","<0>"],"_version":["uuid","<3>"],"name":"zero","number":2}]}]
244 OVSDB_CHECK_EXECUTION([insert rows, delete by named-uuid],
249 "row": {"number": 0, "name": "zero"},
250 "uuid-name": "first"},
253 "row": {"number": 1, "name": "one"},
254 "uuid-name": "second"},
257 "where": [["_uuid", "==", ["named-uuid", "first"]]]},
261 "columns": ["name","number"]}]]]],
262 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"count":1},{"rows":[{"name":"one","number":1}]}]
265 OVSDB_CHECK_EXECUTION([insert rows, delete rows by value],
270 "row": {"number": 0, "name": "zero"},
271 "uuid-name": "first"}]]],
275 "row": {"number": 1, "name": "one"},
276 "uuid-name": "first"}]]],
280 "where": [["name", "==", "zero"]]}]]],
285 [[[{"uuid":["uuid","<0>"]}]
286 [{"uuid":["uuid","<1>"]}]
288 [{"rows":[{"_uuid":["uuid","<1>"],"_version":["uuid","<2>"],"name":"one","number":1}]}]
291 OVSDB_CHECK_EXECUTION([insert rows, delete by (non-matching) value],
296 "row": {"number": 0, "name": "zero"},
297 "uuid-name": "first"}]]],
301 "row": {"number": 1, "name": "one"},
302 "uuid-name": "first"}]]],
306 "where": [["name", "==", "nought"]]}]]],
311 "sort": ["number"]}]]]],
312 [[[{"uuid":["uuid","<0>"]}]
313 [{"uuid":["uuid","<1>"]}]
315 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"zero","number":0},{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}]
318 OVSDB_CHECK_EXECUTION([insert rows, delete all],
323 "row": {"number": 0, "name": "zero"},
324 "uuid-name": "first"},
327 "row": {"number": 1, "name": "one"},
328 "uuid-name": "second"},
335 "columns": ["name","number"]}]]]],
336 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"count":2},{"rows":[]}]
339 OVSDB_CHECK_EXECUTION([insert row, query table, commit],
344 "row": {"number": 0, "name": "zero"}},
349 "durable": false}]]]],
350 [[[{"uuid":["uuid","<0>"]},{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"zero","number":0}]},{}]
353 OVSDB_CHECK_EXECUTION([insert row, query table, commit durably],
358 "row": {"number": 0, "name": "zero"}},
363 "durable": true}]]]],
364 [[[{"uuid":["uuid","<0>"]},{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"zero","number":0}]},{}]
367 OVSDB_CHECK_EXECUTION([equality wait with correct rows],
372 "row": {"number": 0, "name": "zero"}},
375 "row": {"number": 1, "name": "one"}},
380 "columns": ["name", "number"],
382 "rows": [{"name": "zero", "number": 0},
383 {"name": "one", "number": 1}]}]]]],
384 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{}]
387 OVSDB_CHECK_EXECUTION([equality wait with extra row],
392 "row": {"number": 0, "name": "zero"}},
395 "row": {"number": 1, "name": "one"}},
400 "columns": ["name", "number"],
402 "rows": [{"name": "zero", "number": 0},
403 {"name": "one", "number": 1},
404 {"name": "two", "number": 2}]}]]]],
405 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"details":"\"wait\" timed out","error":"timed out"}]
408 OVSDB_CHECK_EXECUTION([equality wait with missing row],
413 "row": {"number": 0, "name": "zero"}},
416 "row": {"number": 1, "name": "one"}},
421 "columns": ["name", "number"],
423 "rows": [{"name": "one", "number": 1}]}]]]],
424 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"details":"\"wait\" timed out","error":"timed out"}]
427 OVSDB_CHECK_EXECUTION([inequality wait with correct rows],
432 "row": {"number": 0, "name": "zero"}},
435 "row": {"number": 1, "name": "one"}},
440 "columns": ["name", "number"],
442 "rows": [{"name": "zero", "number": 0},
443 {"name": "one", "number": 1}]}]]]],
444 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"details":"\"wait\" timed out","error":"timed out"}]
447 OVSDB_CHECK_EXECUTION([inequality wait with extra row],
452 "row": {"number": 0, "name": "zero"}},
455 "row": {"number": 1, "name": "one"}},
460 "columns": ["name", "number"],
462 "rows": [{"name": "zero", "number": 0},
463 {"name": "one", "number": 1},
464 {"name": "two", "number": 2}]}]]]],
465 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{}]
468 OVSDB_CHECK_EXECUTION([inequality wait with missing row],
473 "row": {"number": 0, "name": "zero"}},
476 "row": {"number": 1, "name": "one"}},
481 "columns": ["name", "number"],
483 "rows": [{"name": "one", "number": 1}]}]]]],
484 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{}]
487 OVSDB_CHECK_EXECUTION([insert and update constraints],
491 "table": "constrained",
495 "table": "constrained",
496 "row": {"positive": -1}}]]],
499 "table": "constrained",
501 "row": {"positive": -2}}]]],
504 "table": "constrained",
505 "row": {"positive": 1}}]]],
508 "table": "constrained",
509 "row": {"positive": 2}}]]]],
510 [[[{"details":"0 is less than minimum allowed value 1","error":"constraint violation"}]
511 [{"details":"-1 is less than minimum allowed value 1","error":"constraint violation"}]
512 [{"details":"-2 is less than minimum allowed value 1","error":"constraint violation"}]
513 [{"uuid":["uuid","<0>"]}]
514 [{"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"}]
517 OVSDB_CHECK_EXECUTION([referential integrity -- simple],
523 "uuid-name": "brow"},
527 "a2b": ["set", [["named-uuid", "brow"]]]}},
531 "a2b": ["set", [["named-uuid", "brow"]]]}},
535 "a2b": ["set", [["named-uuid", "brow"]]]}}]]],
543 "where": [["a", "==", 0]]}]]],
551 "where": [["a", "==", 1]]}]]],
559 "where": [["a", "==", 2]]}]]],
564 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]}]
565 [{"count":1},{"details":"cannot delete b row <0> because of 3 remaining reference(s)","error":"referential integrity violation"}]
567 [{"count":1},{"details":"cannot delete b row <0> because of 2 remaining reference(s)","error":"referential integrity violation"}]
569 [{"count":1},{"details":"cannot delete b row <0> because of 1 remaining reference(s)","error":"referential integrity violation"}]
574 OVSDB_CHECK_EXECUTION([referential integrity -- mutual references],
580 "a2b": ["set", [["named-uuid", "row2"]]],
581 "a2a": ["set", [["named-uuid", "row1"]]]},
582 "uuid-name": "row1"},
586 "b2b": ["set", [["named-uuid", "row2"]]],
587 "b2a": ["set", [["named-uuid", "row1"]]]},
588 "uuid-name": "row2"}]]],
592 "row": {"a2b": ["set", [["uuid", "b516b960-5b19-4fc2-bb82-fe1cbd6d0241"]]]}}]]],
596 "where": [["a", "==", 0]]}]]],
600 "where": [["b", "==", 1]]}]]],
601 dnl Try the deletions again to make sure that the refcounts got rolled back.
605 "where": [["a", "==", 0]]}]]],
609 "where": [["b", "==", 1]]}]]],
613 "where": [["a", "==", 0]]},
616 "where": [["b", "==", 1]]}]]]],
617 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}]
618 [{"uuid":["uuid","<2>"]},{"details":"Table a column a2b row <2> references nonexistent row <3> in table b.","error":"referential integrity violation"}]
619 [{"count":1},{"details":"cannot delete a row <0> because of 1 remaining reference(s)","error":"referential integrity violation"}]
620 [{"count":1},{"details":"cannot delete b row <1> because of 1 remaining reference(s)","error":"referential integrity violation"}]
621 [{"count":1},{"details":"cannot delete a row <0> because of 1 remaining reference(s)","error":"referential integrity violation"}]
622 [{"count":1},{"details":"cannot delete b row <1> because of 1 remaining reference(s)","error":"referential integrity violation"}]
623 [{"count":1},{"count":1}]
626 OVSDB_CHECK_EXECUTION([weak references],
632 "a2a": ["set", [["named-uuid", "row1"],
633 ["named-uuid", "row2"],
634 ["uuid", "0e767b36-6822-4044-8307-d58467e04669"]]],
635 "a2a1": ["named-uuid", "row1"],
636 "a2b": ["named-uuid", "row3"]},
637 "uuid-name": "row1"},
641 "a2a": ["set", [["named-uuid", "row1"],
642 ["named-uuid", "row2"]]],
643 "a2a1": ["named-uuid", "row2"],
644 "a2b": ["named-uuid", "row3"]},
645 "uuid-name": "row2"},
649 "a2a": ["set", [["named-uuid", "row1"],
650 ["named-uuid", "row2"]]],
651 "a2a1": ["named-uuid", "row2"],
652 "a2b": ["named-uuid", "row4"]}},
656 "b2a": ["named-uuid", "row1"]},
657 "uuid-name": "row3"},
661 "b2a": ["named-uuid", "row2"]},
662 "uuid-name": "row4"}]]],
663 dnl Check that the nonexistent row UUID we added to row a0 was deleted,
664 dnl and that other rows were inserted as requested.
669 "columns": ["_uuid", "a2a", "a2a1", "a2b"],
675 "columns": ["_uuid", "b", "b2a"],
677 dnl Try to insert invalid all-zeros weak reference (the default) into
678 dnl "a2b", which requires exactly one value.
682 "row": {"a2a1": ["named-uuid", "me"]},
683 "uuid-name": "me"}]]],
684 dnl Try to delete row from "b" that is referred to by weak references
685 dnl from "a" table "a2b" column that requires exactly one value.
689 "where": [["b", "==", 3]]}]]],
690 dnl Try to delete row from "a" that is referred to by weak references
691 dnl from "a" table "a2a1" column that requires exactly one value.
695 "where": [["a", "==", 1]]}]]],
696 dnl Delete the row that had the reference that caused the previous
697 dnl deletion to fail, then check that other rows are unchanged.
701 "where": [["a", "==", 2]]}]]],
706 "columns": ["_uuid", "a2a", "a2a1", "a2b"],
712 "columns": ["_uuid", "b", "b2a"],
714 dnl Delete row a0 then check that references to it were removed.
718 "where": [["a", "==", 0]]}]]],
723 "columns": ["_uuid", "a2a", "a2a1", "a2b"],
729 "columns": ["_uuid", "b", "b2a"],
731 dnl Delete row a1 then check that references to it were removed.
735 "where": [["a", "==", 1]]}]]],
740 "columns": ["_uuid", "a2a", "a2a1", "a2b"],
746 "columns": ["_uuid", "b", "b2a"],
748 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]},{"uuid":["uuid","<4>"]}]
749 [{"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>"]}]}]
750 [{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["uuid","<0>"]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["uuid","<1>"]}]}]
751 [{"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"}]
752 [{"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"}]
753 [{"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"}]
755 [{"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>"]}]}]
756 [{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["uuid","<0>"]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["uuid","<1>"]}]}]
758 [{"rows":[{"_uuid":["uuid","<1>"],"a2a":["uuid","<1>"],"a2a1":["uuid","<1>"],"a2b":["uuid","<3>"]}]}]
759 [{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["set",[]]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["uuid","<1>"]}]}]
762 [{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["set",[]]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["set",[]]}]}]