1 AT_BANNER([OVSDB -- execution])
3 m4_define([ORDINAL_SCHEMA],
8 "number": {"type": "integer"},
9 "name": {"type": "string"}}}}}]])
11 m4_define([CONSTRAINT_SCHEMA],
12 [[{"name": "constraints",
16 "a": {"type": "integer"},
17 "a2a": {"type": {"key": {"type": "uuid", "refTable": "a"},
18 "min": 0, "max": "unlimited"}},
19 "a2b": {"type": {"key": {"type": "uuid", "refTable": "b"},
20 "min": 0, "max": "unlimited"}}}},
23 "b": {"type": "integer"},
24 "b2a": {"type": {"key": {"type": "uuid", "refTable": "a"},
25 "min": 0, "max": "unlimited"}},
26 "b2b": {"type": {"key": {"type": "uuid", "refTable": "b"},
27 "min": 0, "max": "unlimited"}}}},
30 "positive": {"type": {"key": {"type": "integer",
34 m4_define([WEAK_SCHEMA],
39 "a": {"type": "integer"},
40 "a2a": {"type": {"key": {"type": "uuid",
43 "min": 0, "max": "unlimited"}},
44 "a2a1": {"type": {"key": {"type": "uuid",
47 "a2b": {"type": {"key": {"type": "uuid",
49 "refType": "weak"}}}}},
52 "b": {"type": "integer"},
53 "b2a": {"type": {"key": {"type": "uuid",
56 "min": 0, "max": "unlimited"}}}}}}]])
58 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
60 # Runs "test-ovsdb execute" with the given SCHEMA and each of the
61 # TRANSACTIONS (which should be a quoted list of quoted strings).
63 # Checks that the overall output is OUTPUT, but UUIDs in the output
64 # are replaced by markers of the form <N> where N is a number. The
65 # first unique UUID is replaced by <0>, the next by <1>, and so on.
66 # If a given UUID appears more than once it is always replaced by the
69 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
70 m4_define([OVSDB_CHECK_EXECUTION],
72 AT_KEYWORDS([ovsdb execute execution positive $5])
73 AT_CHECK([test-ovsdb execute '$2' m4_foreach([txn], [$3], [ 'txn'])],
75 AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0], [$4])
78 m4_define([EXECUTION_EXAMPLES], [
79 dnl At one point the "commit" code ignored new rows with all-default values,
80 dnl so this checks for that problem.
81 OVSDB_CHECK_EXECUTION([insert default row, query table],
91 [[[{"uuid":["uuid","<0>"]}]
92 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"","number":0}]}]
95 OVSDB_CHECK_EXECUTION([insert row, query table],
100 "row": {"number": 0, "name": "zero"}}]]],
105 [[[{"uuid":["uuid","<0>"]}]
106 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"zero","number":0}]}]
109 OVSDB_CHECK_EXECUTION([insert rows, query by value],
114 "row": {"number": 0, "name": "zero"}}]]],
118 "row": {"number": 1, "name": "one"}}]]],
122 "where": [["name", "==", "zero"]]}]]],
126 "where": [["name", "==", "one"]]}]]]],
127 [[[{"uuid":["uuid","<0>"]}]
128 [{"uuid":["uuid","<1>"]}]
129 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"zero","number":0}]}]
130 [{"rows":[{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}]
133 OVSDB_CHECK_EXECUTION([insert rows, query by named-uuid],
138 "row": {"number": 0, "name": "zero"},
139 "uuid-name": "first"},
142 "row": {"number": 1, "name": "one"},
143 "uuid-name": "second"},
146 "where": [["_uuid", "==", ["named-uuid", "first"]]]},
149 "where": [["_uuid", "==", ["named-uuid", "second"]]]}]]]],
150 [[[{"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}]}]
153 OVSDB_CHECK_EXECUTION([insert rows, update rows by value],
158 "row": {"number": 0, "name": "zero"},
159 "uuid-name": "first"}]]],
163 "row": {"number": 1, "name": "one"},
164 "uuid-name": "first"}]]],
168 "where": [["name", "==", "zero"]],
169 "row": {"name": "nought"}}]]],
174 "sort": ["number"]}]]]],
175 [[[{"uuid":["uuid","<0>"]}]
176 [{"uuid":["uuid","<1>"]}]
178 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"nought","number":0},{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}]
181 OVSDB_CHECK_EXECUTION([insert rows, mutate rows],
186 "row": {"number": 0, "name": "zero"},
187 "uuid-name": "first"}]]],
191 "row": {"number": 1, "name": "one"},
192 "uuid-name": "first"}]]],
196 "where": [["name", "==", "zero"]],
197 "mutations": [["number", "+=", 2]]}]]],
202 "sort": ["number"]}]]]],
203 [[[{"uuid":["uuid","<0>"]}]
204 [{"uuid":["uuid","<1>"]}]
206 [{"rows":[{"_uuid":["uuid","<1>"],"_version":["uuid","<2>"],"name":"one","number":1},{"_uuid":["uuid","<0>"],"_version":["uuid","<3>"],"name":"zero","number":2}]}]
209 OVSDB_CHECK_EXECUTION([insert rows, delete by named-uuid],
214 "row": {"number": 0, "name": "zero"},
215 "uuid-name": "first"},
218 "row": {"number": 1, "name": "one"},
219 "uuid-name": "second"},
222 "where": [["_uuid", "==", ["named-uuid", "first"]]]},
226 "columns": ["name","number"]}]]]],
227 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"count":1},{"rows":[{"name":"one","number":1}]}]
230 OVSDB_CHECK_EXECUTION([insert rows, delete rows by value],
235 "row": {"number": 0, "name": "zero"},
236 "uuid-name": "first"}]]],
240 "row": {"number": 1, "name": "one"},
241 "uuid-name": "first"}]]],
245 "where": [["name", "==", "zero"]]}]]],
250 [[[{"uuid":["uuid","<0>"]}]
251 [{"uuid":["uuid","<1>"]}]
253 [{"rows":[{"_uuid":["uuid","<1>"],"_version":["uuid","<2>"],"name":"one","number":1}]}]
256 OVSDB_CHECK_EXECUTION([insert rows, delete by (non-matching) value],
261 "row": {"number": 0, "name": "zero"},
262 "uuid-name": "first"}]]],
266 "row": {"number": 1, "name": "one"},
267 "uuid-name": "first"}]]],
271 "where": [["name", "==", "nought"]]}]]],
276 "sort": ["number"]}]]]],
277 [[[{"uuid":["uuid","<0>"]}]
278 [{"uuid":["uuid","<1>"]}]
280 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"zero","number":0},{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}]
283 OVSDB_CHECK_EXECUTION([insert rows, delete all],
288 "row": {"number": 0, "name": "zero"},
289 "uuid-name": "first"},
292 "row": {"number": 1, "name": "one"},
293 "uuid-name": "second"},
300 "columns": ["name","number"]}]]]],
301 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"count":2},{"rows":[]}]
304 OVSDB_CHECK_EXECUTION([insert row, query table, commit],
309 "row": {"number": 0, "name": "zero"}},
314 "durable": false}]]]],
315 [[[{"uuid":["uuid","<0>"]},{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"zero","number":0}]},{}]
318 OVSDB_CHECK_EXECUTION([insert row, query table, commit durably],
323 "row": {"number": 0, "name": "zero"}},
328 "durable": true}]]]],
329 [[[{"uuid":["uuid","<0>"]},{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"zero","number":0}]},{}]
332 OVSDB_CHECK_EXECUTION([equality wait with correct rows],
337 "row": {"number": 0, "name": "zero"}},
340 "row": {"number": 1, "name": "one"}},
345 "columns": ["name", "number"],
347 "rows": [{"name": "zero", "number": 0},
348 {"name": "one", "number": 1}]}]]]],
349 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{}]
352 OVSDB_CHECK_EXECUTION([equality wait with extra row],
357 "row": {"number": 0, "name": "zero"}},
360 "row": {"number": 1, "name": "one"}},
365 "columns": ["name", "number"],
367 "rows": [{"name": "zero", "number": 0},
368 {"name": "one", "number": 1},
369 {"name": "two", "number": 2}]}]]]],
370 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"details":"\"wait\" timed out","error":"timed out"}]
373 OVSDB_CHECK_EXECUTION([equality wait with missing row],
378 "row": {"number": 0, "name": "zero"}},
381 "row": {"number": 1, "name": "one"}},
386 "columns": ["name", "number"],
388 "rows": [{"name": "one", "number": 1}]}]]]],
389 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"details":"\"wait\" timed out","error":"timed out"}]
392 OVSDB_CHECK_EXECUTION([inequality wait with correct rows],
397 "row": {"number": 0, "name": "zero"}},
400 "row": {"number": 1, "name": "one"}},
405 "columns": ["name", "number"],
407 "rows": [{"name": "zero", "number": 0},
408 {"name": "one", "number": 1}]}]]]],
409 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"details":"\"wait\" timed out","error":"timed out"}]
412 OVSDB_CHECK_EXECUTION([inequality wait with extra row],
417 "row": {"number": 0, "name": "zero"}},
420 "row": {"number": 1, "name": "one"}},
425 "columns": ["name", "number"],
427 "rows": [{"name": "zero", "number": 0},
428 {"name": "one", "number": 1},
429 {"name": "two", "number": 2}]}]]]],
430 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{}]
433 OVSDB_CHECK_EXECUTION([inequality wait with missing row],
438 "row": {"number": 0, "name": "zero"}},
441 "row": {"number": 1, "name": "one"}},
446 "columns": ["name", "number"],
448 "rows": [{"name": "one", "number": 1}]}]]]],
449 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{}]
452 OVSDB_CHECK_EXECUTION([insert and update constraints],
456 "table": "constrained",
460 "table": "constrained",
461 "row": {"positive": -1}}]]],
464 "table": "constrained",
466 "row": {"positive": -2}}]]],
469 "table": "constrained",
470 "row": {"positive": 1}}]]],
473 "table": "constrained",
474 "row": {"positive": 2}}]]]],
475 [[[{"details":"0 is less than minimum allowed value 1","error":"constraint violation"}]
476 [{"details":"-1 is less than minimum allowed value 1","error":"constraint violation"}]
477 [{"details":"-2 is less than minimum allowed value 1","error":"constraint violation"}]
478 [{"uuid":["uuid","<0>"]}]
479 [{"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"}]
482 OVSDB_CHECK_EXECUTION([referential integrity -- simple],
488 "uuid-name": "brow"},
492 "a2b": ["set", [["named-uuid", "brow"]]]}},
496 "a2b": ["set", [["named-uuid", "brow"]]]}},
500 "a2b": ["set", [["named-uuid", "brow"]]]}}]]],
508 "where": [["a", "==", 0]]}]]],
516 "where": [["a", "==", 1]]}]]],
524 "where": [["a", "==", 2]]}]]],
529 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]}]
530 [{"count":1},{"details":"cannot delete b row <0> because of 3 remaining reference(s)","error":"referential integrity violation"}]
532 [{"count":1},{"details":"cannot delete b row <0> because of 2 remaining reference(s)","error":"referential integrity violation"}]
534 [{"count":1},{"details":"cannot delete b row <0> because of 1 remaining reference(s)","error":"referential integrity violation"}]
539 OVSDB_CHECK_EXECUTION([referential integrity -- mutual references],
545 "a2b": ["set", [["named-uuid", "row2"]]],
546 "a2a": ["set", [["named-uuid", "row1"]]]},
547 "uuid-name": "row1"},
551 "b2b": ["set", [["named-uuid", "row2"]]],
552 "b2a": ["set", [["named-uuid", "row1"]]]},
553 "uuid-name": "row2"}]]],
557 "row": {"a2b": ["set", [["uuid", "b516b960-5b19-4fc2-bb82-fe1cbd6d0241"]]]}}]]],
561 "where": [["a", "==", 0]]}]]],
565 "where": [["b", "==", 1]]}]]],
566 dnl Try the deletions again to make sure that the refcounts got rolled back.
570 "where": [["a", "==", 0]]}]]],
574 "where": [["b", "==", 1]]}]]],
578 "where": [["a", "==", 0]]},
581 "where": [["b", "==", 1]]}]]]],
582 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}]
583 [{"uuid":["uuid","<2>"]},{"details":"reference to nonexistent row <3>","error":"referential integrity violation"}]
584 [{"count":1},{"details":"cannot delete a row <0> because of 1 remaining reference(s)","error":"referential integrity violation"}]
585 [{"count":1},{"details":"cannot delete b row <1> because of 1 remaining reference(s)","error":"referential integrity violation"}]
586 [{"count":1},{"details":"cannot delete a row <0> because of 1 remaining reference(s)","error":"referential integrity violation"}]
587 [{"count":1},{"details":"cannot delete b row <1> because of 1 remaining reference(s)","error":"referential integrity violation"}]
588 [{"count":1},{"count":1}]
591 OVSDB_CHECK_EXECUTION([weak references],
597 "a2a": ["set", [["named-uuid", "row1"],
598 ["named-uuid", "row2"],
599 ["uuid", "0e767b36-6822-4044-8307-d58467e04669"]]],
600 "a2a1": ["named-uuid", "row1"],
601 "a2b": ["named-uuid", "row3"]},
602 "uuid-name": "row1"},
606 "a2a": ["set", [["named-uuid", "row1"],
607 ["named-uuid", "row2"]]],
608 "a2a1": ["named-uuid", "row2"],
609 "a2b": ["named-uuid", "row3"]},
610 "uuid-name": "row2"},
614 "a2a": ["set", [["named-uuid", "row1"],
615 ["named-uuid", "row2"]]],
616 "a2a1": ["named-uuid", "row2"],
617 "a2b": ["named-uuid", "row4"]}},
621 "b2a": ["named-uuid", "row1"]},
622 "uuid-name": "row3"},
626 "b2a": ["named-uuid", "row2"]},
627 "uuid-name": "row4"}]]],
628 dnl Check that the nonexistent row UUID we added to row a0 was deleted,
629 dnl and that other rows were inserted as requested.
634 "columns": ["_uuid", "a2a", "a2a1", "a2b"],
640 "columns": ["_uuid", "b", "b2a"],
642 dnl Try to insert invalid all-zeros weak reference (the default) into
643 dnl "a2b", which requires exactly one value.
648 dnl Try to delete row from "b" that is referred to by weak references
649 dnl from "a" table "a2b" column that requires exactly one value.
653 "where": [["b", "==", 3]]}]]],
654 dnl Try to delete row from "a" that is referred to by weak references
655 dnl from "a" table "a2a1" column that requires exactly one value.
659 "where": [["a", "==", 1]]}]]],
660 dnl Delete the row that had the reference that caused the previous
661 dnl deletion to fail, then check that other rows are unchanged.
665 "where": [["a", "==", 2]]}]]],
670 "columns": ["_uuid", "a2a", "a2a1", "a2b"],
676 "columns": ["_uuid", "b", "b2a"],
678 dnl Delete row a0 then check that references to it were removed.
682 "where": [["a", "==", 0]]}]]],
687 "columns": ["_uuid", "a2a", "a2a1", "a2b"],
693 "columns": ["_uuid", "b", "b2a"],
695 dnl Delete row a1 then check that references to it were removed.
699 "where": [["a", "==", 1]]}]]],
704 "columns": ["_uuid", "a2a", "a2a1", "a2b"],
710 "columns": ["_uuid", "b", "b2a"],
712 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]},{"uuid":["uuid","<4>"]}]
713 [{"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>"]}]}]
714 [{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["uuid","<0>"]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["uuid","<1>"]}]}]
715 [{"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"}]
716 [{"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"}]
717 [{"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"}]
719 [{"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>"]}]}]
720 [{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["uuid","<0>"]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["uuid","<1>"]}]}]
722 [{"rows":[{"_uuid":["uuid","<1>"],"a2a":["uuid","<1>"],"a2a1":["uuid","<1>"],"a2b":["uuid","<3>"]}]}]
723 [{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["set",[]]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["uuid","<1>"]}]}]
726 [{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["set",[]]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["set",[]]}]}]