1 AT_BANNER([OVSDB -- execution])
3 m4_define([ORDINAL_SCHEMA],
8 "number": {"type": "integer"},
9 "name": {"type": "string"}}}},
10 "version": "5.1.3"}]])
12 m4_define([CONSTRAINT_SCHEMA],
13 [[{"name": "constraints",
17 "a": {"type": "integer"},
18 "a2a": {"type": {"key": {"type": "uuid", "refTable": "a"},
19 "min": 0, "max": "unlimited"}},
20 "a2b": {"type": {"key": {"type": "uuid", "refTable": "b"},
21 "min": 0, "max": "unlimited"}}}},
24 "b": {"type": "integer"},
25 "b2a": {"type": {"key": {"type": "uuid", "refTable": "a"},
26 "min": 0, "max": "unlimited"}},
27 "b2b": {"type": {"key": {"type": "uuid", "refTable": "b"},
28 "min": 0, "max": "unlimited"}}}},
31 "positive": {"type": {"key": {"type": "integer",
35 m4_define([WEAK_SCHEMA],
40 "a": {"type": "integer"},
41 "a2a": {"type": {"key": {"type": "uuid",
44 "min": 0, "max": "unlimited"}},
45 "a2a1": {"type": {"key": {"type": "uuid",
48 "a2b": {"type": {"key": {"type": "uuid",
50 "refType": "weak"}}}}},
53 "b": {"type": "integer"},
54 "b2a": {"type": {"key": {"type": "uuid",
57 "min": 0, "max": "unlimited"}}}}}}]])
59 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
61 # Runs "test-ovsdb execute" with the given SCHEMA and each of the
62 # TRANSACTIONS (which should be a quoted list of quoted strings).
64 # Checks that the overall output is OUTPUT, but UUIDs in the output
65 # are replaced by markers of the form <N> where N is a number. The
66 # first unique UUID is replaced by <0>, the next by <1>, and so on.
67 # If a given UUID appears more than once it is always replaced by the
70 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
71 m4_define([OVSDB_CHECK_EXECUTION],
73 AT_KEYWORDS([ovsdb execute execution positive $5])
74 AT_CHECK([test-ovsdb execute '$2' m4_foreach([txn], [$3], [ 'txn'])],
76 AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0], [$4])
79 m4_define([EXECUTION_EXAMPLES], [
80 dnl At one point the "commit" code ignored new rows with all-default values,
81 dnl so this checks for that problem.
82 OVSDB_CHECK_EXECUTION([insert default row, query table],
92 [[[{"uuid":["uuid","<0>"]}]
93 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"","number":0}]}]
96 OVSDB_CHECK_EXECUTION([insert row, query table],
101 "row": {"number": 0, "name": "zero"}}]]],
106 [[[{"uuid":["uuid","<0>"]}]
107 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"zero","number":0}]}]
110 OVSDB_CHECK_EXECUTION([insert rows, query by value],
115 "row": {"number": 0, "name": "zero"}}]]],
119 "row": {"number": 1, "name": "one"}}]]],
123 "where": [["name", "==", "zero"]]}]]],
127 "where": [["name", "==", "one"]]}]]]],
128 [[[{"uuid":["uuid","<0>"]}]
129 [{"uuid":["uuid","<1>"]}]
130 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"zero","number":0}]}]
131 [{"rows":[{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}]
134 OVSDB_CHECK_EXECUTION([insert rows, query by named-uuid],
139 "row": {"number": 0, "name": "zero"},
140 "uuid-name": "first"},
143 "row": {"number": 1, "name": "one"},
144 "uuid-name": "second"},
147 "where": [["_uuid", "==", ["named-uuid", "first"]]]},
150 "where": [["_uuid", "==", ["named-uuid", "second"]]]}]]]],
151 [[[{"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}]}]
154 OVSDB_CHECK_EXECUTION([insert rows, update rows by value],
159 "row": {"number": 0, "name": "zero"},
160 "uuid-name": "first"}]]],
164 "row": {"number": 1, "name": "one"},
165 "uuid-name": "first"}]]],
169 "where": [["name", "==", "zero"]],
170 "row": {"name": "nought"}}]]],
175 "sort": ["number"]}]]]],
176 [[[{"uuid":["uuid","<0>"]}]
177 [{"uuid":["uuid","<1>"]}]
179 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"nought","number":0},{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}]
182 OVSDB_CHECK_EXECUTION([insert rows, mutate rows],
187 "row": {"number": 0, "name": "zero"},
188 "uuid-name": "first"}]]],
192 "row": {"number": 1, "name": "one"},
193 "uuid-name": "first"}]]],
197 "where": [["name", "==", "zero"]],
198 "mutations": [["number", "+=", 2]]}]]],
203 "sort": ["number"]}]]]],
204 [[[{"uuid":["uuid","<0>"]}]
205 [{"uuid":["uuid","<1>"]}]
207 [{"rows":[{"_uuid":["uuid","<1>"],"_version":["uuid","<2>"],"name":"one","number":1},{"_uuid":["uuid","<0>"],"_version":["uuid","<3>"],"name":"zero","number":2}]}]
210 OVSDB_CHECK_EXECUTION([insert rows, delete by named-uuid],
215 "row": {"number": 0, "name": "zero"},
216 "uuid-name": "first"},
219 "row": {"number": 1, "name": "one"},
220 "uuid-name": "second"},
223 "where": [["_uuid", "==", ["named-uuid", "first"]]]},
227 "columns": ["name","number"]}]]]],
228 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"count":1},{"rows":[{"name":"one","number":1}]}]
231 OVSDB_CHECK_EXECUTION([insert rows, delete rows by value],
236 "row": {"number": 0, "name": "zero"},
237 "uuid-name": "first"}]]],
241 "row": {"number": 1, "name": "one"},
242 "uuid-name": "first"}]]],
246 "where": [["name", "==", "zero"]]}]]],
251 [[[{"uuid":["uuid","<0>"]}]
252 [{"uuid":["uuid","<1>"]}]
254 [{"rows":[{"_uuid":["uuid","<1>"],"_version":["uuid","<2>"],"name":"one","number":1}]}]
257 OVSDB_CHECK_EXECUTION([insert rows, delete by (non-matching) value],
262 "row": {"number": 0, "name": "zero"},
263 "uuid-name": "first"}]]],
267 "row": {"number": 1, "name": "one"},
268 "uuid-name": "first"}]]],
272 "where": [["name", "==", "nought"]]}]]],
277 "sort": ["number"]}]]]],
278 [[[{"uuid":["uuid","<0>"]}]
279 [{"uuid":["uuid","<1>"]}]
281 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"zero","number":0},{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}]
284 OVSDB_CHECK_EXECUTION([insert rows, delete all],
289 "row": {"number": 0, "name": "zero"},
290 "uuid-name": "first"},
293 "row": {"number": 1, "name": "one"},
294 "uuid-name": "second"},
301 "columns": ["name","number"]}]]]],
302 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"count":2},{"rows":[]}]
305 OVSDB_CHECK_EXECUTION([insert row, query table, commit],
310 "row": {"number": 0, "name": "zero"}},
315 "durable": false}]]]],
316 [[[{"uuid":["uuid","<0>"]},{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"zero","number":0}]},{}]
319 OVSDB_CHECK_EXECUTION([insert row, query table, commit durably],
324 "row": {"number": 0, "name": "zero"}},
329 "durable": true}]]]],
330 [[[{"uuid":["uuid","<0>"]},{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"zero","number":0}]},{}]
333 OVSDB_CHECK_EXECUTION([equality wait with correct rows],
338 "row": {"number": 0, "name": "zero"}},
341 "row": {"number": 1, "name": "one"}},
346 "columns": ["name", "number"],
348 "rows": [{"name": "zero", "number": 0},
349 {"name": "one", "number": 1}]}]]]],
350 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{}]
353 OVSDB_CHECK_EXECUTION([equality wait with extra row],
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 {"name": "two", "number": 2}]}]]]],
371 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"details":"\"wait\" timed out","error":"timed out"}]
374 OVSDB_CHECK_EXECUTION([equality wait with missing row],
379 "row": {"number": 0, "name": "zero"}},
382 "row": {"number": 1, "name": "one"}},
387 "columns": ["name", "number"],
389 "rows": [{"name": "one", "number": 1}]}]]]],
390 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"details":"\"wait\" timed out","error":"timed out"}]
393 OVSDB_CHECK_EXECUTION([inequality wait with correct rows],
398 "row": {"number": 0, "name": "zero"}},
401 "row": {"number": 1, "name": "one"}},
406 "columns": ["name", "number"],
408 "rows": [{"name": "zero", "number": 0},
409 {"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 extra row],
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 {"name": "two", "number": 2}]}]]]],
431 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{}]
434 OVSDB_CHECK_EXECUTION([inequality wait with missing row],
439 "row": {"number": 0, "name": "zero"}},
442 "row": {"number": 1, "name": "one"}},
447 "columns": ["name", "number"],
449 "rows": [{"name": "one", "number": 1}]}]]]],
450 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{}]
453 OVSDB_CHECK_EXECUTION([insert and update constraints],
457 "table": "constrained",
461 "table": "constrained",
462 "row": {"positive": -1}}]]],
465 "table": "constrained",
467 "row": {"positive": -2}}]]],
470 "table": "constrained",
471 "row": {"positive": 1}}]]],
474 "table": "constrained",
475 "row": {"positive": 2}}]]]],
476 [[[{"details":"0 is less than minimum allowed value 1","error":"constraint violation"}]
477 [{"details":"-1 is less than minimum allowed value 1","error":"constraint violation"}]
478 [{"details":"-2 is less than minimum allowed value 1","error":"constraint violation"}]
479 [{"uuid":["uuid","<0>"]}]
480 [{"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"}]
483 OVSDB_CHECK_EXECUTION([referential integrity -- simple],
489 "uuid-name": "brow"},
493 "a2b": ["set", [["named-uuid", "brow"]]]}},
497 "a2b": ["set", [["named-uuid", "brow"]]]}},
501 "a2b": ["set", [["named-uuid", "brow"]]]}}]]],
509 "where": [["a", "==", 0]]}]]],
517 "where": [["a", "==", 1]]}]]],
525 "where": [["a", "==", 2]]}]]],
530 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]}]
531 [{"count":1},{"details":"cannot delete b row <0> because of 3 remaining reference(s)","error":"referential integrity violation"}]
533 [{"count":1},{"details":"cannot delete b row <0> because of 2 remaining reference(s)","error":"referential integrity violation"}]
535 [{"count":1},{"details":"cannot delete b row <0> because of 1 remaining reference(s)","error":"referential integrity violation"}]
540 OVSDB_CHECK_EXECUTION([referential integrity -- mutual references],
546 "a2b": ["set", [["named-uuid", "row2"]]],
547 "a2a": ["set", [["named-uuid", "row1"]]]},
548 "uuid-name": "row1"},
552 "b2b": ["set", [["named-uuid", "row2"]]],
553 "b2a": ["set", [["named-uuid", "row1"]]]},
554 "uuid-name": "row2"}]]],
558 "row": {"a2b": ["set", [["uuid", "b516b960-5b19-4fc2-bb82-fe1cbd6d0241"]]]}}]]],
562 "where": [["a", "==", 0]]}]]],
566 "where": [["b", "==", 1]]}]]],
567 dnl Try the deletions again to make sure that the refcounts got rolled back.
571 "where": [["a", "==", 0]]}]]],
575 "where": [["b", "==", 1]]}]]],
579 "where": [["a", "==", 0]]},
582 "where": [["b", "==", 1]]}]]]],
583 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}]
584 [{"uuid":["uuid","<2>"]},{"details":"Table a column a2b row <2> references nonexistent row <3> in table b.","error":"referential integrity violation"}]
585 [{"count":1},{"details":"cannot delete a row <0> because of 1 remaining reference(s)","error":"referential integrity violation"}]
586 [{"count":1},{"details":"cannot delete b row <1> because of 1 remaining reference(s)","error":"referential integrity violation"}]
587 [{"count":1},{"details":"cannot delete a row <0> because of 1 remaining reference(s)","error":"referential integrity violation"}]
588 [{"count":1},{"details":"cannot delete b row <1> because of 1 remaining reference(s)","error":"referential integrity violation"}]
589 [{"count":1},{"count":1}]
592 OVSDB_CHECK_EXECUTION([weak references],
598 "a2a": ["set", [["named-uuid", "row1"],
599 ["named-uuid", "row2"],
600 ["uuid", "0e767b36-6822-4044-8307-d58467e04669"]]],
601 "a2a1": ["named-uuid", "row1"],
602 "a2b": ["named-uuid", "row3"]},
603 "uuid-name": "row1"},
607 "a2a": ["set", [["named-uuid", "row1"],
608 ["named-uuid", "row2"]]],
609 "a2a1": ["named-uuid", "row2"],
610 "a2b": ["named-uuid", "row3"]},
611 "uuid-name": "row2"},
615 "a2a": ["set", [["named-uuid", "row1"],
616 ["named-uuid", "row2"]]],
617 "a2a1": ["named-uuid", "row2"],
618 "a2b": ["named-uuid", "row4"]}},
622 "b2a": ["named-uuid", "row1"]},
623 "uuid-name": "row3"},
627 "b2a": ["named-uuid", "row2"]},
628 "uuid-name": "row4"}]]],
629 dnl Check that the nonexistent row UUID we added to row a0 was deleted,
630 dnl and that other rows were inserted as requested.
635 "columns": ["_uuid", "a2a", "a2a1", "a2b"],
641 "columns": ["_uuid", "b", "b2a"],
643 dnl Try to insert invalid all-zeros weak reference (the default) into
644 dnl "a2b", which requires exactly one value.
648 "row": {"a2a1": ["named-uuid", "me"]},
649 "uuid-name": "me"}]]],
650 dnl Try to delete row from "b" that is referred to by weak references
651 dnl from "a" table "a2b" column that requires exactly one value.
655 "where": [["b", "==", 3]]}]]],
656 dnl Try to delete row from "a" that is referred to by weak references
657 dnl from "a" table "a2a1" column that requires exactly one value.
661 "where": [["a", "==", 1]]}]]],
662 dnl Delete the row that had the reference that caused the previous
663 dnl deletion to fail, then check that other rows are unchanged.
667 "where": [["a", "==", 2]]}]]],
672 "columns": ["_uuid", "a2a", "a2a1", "a2b"],
678 "columns": ["_uuid", "b", "b2a"],
680 dnl Delete row a0 then check that references to it were removed.
684 "where": [["a", "==", 0]]}]]],
689 "columns": ["_uuid", "a2a", "a2a1", "a2b"],
695 "columns": ["_uuid", "b", "b2a"],
697 dnl Delete row a1 then check that references to it were removed.
701 "where": [["a", "==", 1]]}]]],
706 "columns": ["_uuid", "a2a", "a2a1", "a2b"],
712 "columns": ["_uuid", "b", "b2a"],
714 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]},{"uuid":["uuid","<4>"]}]
715 [{"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>"]}]}]
716 [{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["uuid","<0>"]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["uuid","<1>"]}]}]
717 [{"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"}]
718 [{"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"}]
719 [{"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"}]
721 [{"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>"]}]}]
722 [{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["uuid","<0>"]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["uuid","<1>"]}]}]
724 [{"rows":[{"_uuid":["uuid","<1>"],"a2a":["uuid","<1>"],"a2a1":["uuid","<1>"],"a2b":["uuid","<3>"]}]}]
725 [{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["set",[]]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["uuid","<1>"]}]}]
728 [{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["set",[]]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["set",[]]}]}]