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 m4_define([EXECUTION_EXAMPLES], [
81 dnl At one point the "commit" code ignored new rows with all-default values,
82 dnl so this checks for that problem.
83 OVSDB_CHECK_EXECUTION([insert default row, query table],
93 [[[{"uuid":["uuid","<0>"]}]
94 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"","number":0}]}]
97 OVSDB_CHECK_EXECUTION([insert row, query table],
102 "row": {"number": 0, "name": "zero"}}]]],
107 [[[{"uuid":["uuid","<0>"]}]
108 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"zero","number":0}]}]
111 OVSDB_CHECK_EXECUTION([insert rows, query by value],
116 "row": {"number": 0, "name": "zero"}}]]],
120 "row": {"number": 1, "name": "one"}}]]],
124 "where": [["name", "==", "zero"]]}]]],
128 "where": [["name", "==", "one"]]}]]]],
129 [[[{"uuid":["uuid","<0>"]}]
130 [{"uuid":["uuid","<1>"]}]
131 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"zero","number":0}]}]
132 [{"rows":[{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}]
135 OVSDB_CHECK_EXECUTION([insert rows, query by named-uuid],
140 "row": {"number": 0, "name": "zero"},
141 "uuid-name": "first"},
144 "row": {"number": 1, "name": "one"},
145 "uuid-name": "second"},
148 "where": [["_uuid", "==", ["named-uuid", "first"]]]},
151 "where": [["_uuid", "==", ["named-uuid", "second"]]]}]]]],
152 [[[{"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}]}]
155 OVSDB_CHECK_EXECUTION([insert rows, update rows by value],
160 "row": {"number": 0, "name": "zero"},
161 "uuid-name": "first"}]]],
165 "row": {"number": 1, "name": "one"},
166 "uuid-name": "first"}]]],
170 "where": [["name", "==", "zero"]],
171 "row": {"name": "nought"}}]]],
176 "sort": ["number"]}]]]],
177 [[[{"uuid":["uuid","<0>"]}]
178 [{"uuid":["uuid","<1>"]}]
180 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"nought","number":0},{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}]
183 OVSDB_CHECK_EXECUTION([insert rows, mutate rows],
188 "row": {"number": 0, "name": "zero"},
189 "uuid-name": "first"}]]],
193 "row": {"number": 1, "name": "one"},
194 "uuid-name": "first"}]]],
198 "where": [["name", "==", "zero"]],
199 "mutations": [["number", "+=", 2]]}]]],
204 "sort": ["number"]}]]]],
205 [[[{"uuid":["uuid","<0>"]}]
206 [{"uuid":["uuid","<1>"]}]
208 [{"rows":[{"_uuid":["uuid","<1>"],"_version":["uuid","<2>"],"name":"one","number":1},{"_uuid":["uuid","<0>"],"_version":["uuid","<3>"],"name":"zero","number":2}]}]
211 OVSDB_CHECK_EXECUTION([insert rows, delete by named-uuid],
216 "row": {"number": 0, "name": "zero"},
217 "uuid-name": "first"},
220 "row": {"number": 1, "name": "one"},
221 "uuid-name": "second"},
224 "where": [["_uuid", "==", ["named-uuid", "first"]]]},
228 "columns": ["name","number"]}]]]],
229 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"count":1},{"rows":[{"name":"one","number":1}]}]
232 OVSDB_CHECK_EXECUTION([insert rows, delete rows by value],
237 "row": {"number": 0, "name": "zero"},
238 "uuid-name": "first"}]]],
242 "row": {"number": 1, "name": "one"},
243 "uuid-name": "first"}]]],
247 "where": [["name", "==", "zero"]]}]]],
252 [[[{"uuid":["uuid","<0>"]}]
253 [{"uuid":["uuid","<1>"]}]
255 [{"rows":[{"_uuid":["uuid","<1>"],"_version":["uuid","<2>"],"name":"one","number":1}]}]
258 OVSDB_CHECK_EXECUTION([insert rows, delete by (non-matching) value],
263 "row": {"number": 0, "name": "zero"},
264 "uuid-name": "first"}]]],
268 "row": {"number": 1, "name": "one"},
269 "uuid-name": "first"}]]],
273 "where": [["name", "==", "nought"]]}]]],
278 "sort": ["number"]}]]]],
279 [[[{"uuid":["uuid","<0>"]}]
280 [{"uuid":["uuid","<1>"]}]
282 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"zero","number":0},{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}]
285 OVSDB_CHECK_EXECUTION([insert rows, delete all],
290 "row": {"number": 0, "name": "zero"},
291 "uuid-name": "first"},
294 "row": {"number": 1, "name": "one"},
295 "uuid-name": "second"},
302 "columns": ["name","number"]}]]]],
303 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"count":2},{"rows":[]}]
306 OVSDB_CHECK_EXECUTION([insert row, query table, commit],
311 "row": {"number": 0, "name": "zero"}},
316 "durable": false}]]]],
317 [[[{"uuid":["uuid","<0>"]},{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"zero","number":0}]},{}]
320 OVSDB_CHECK_EXECUTION([insert row, query table, commit durably],
325 "row": {"number": 0, "name": "zero"}},
330 "durable": true}]]]],
331 [[[{"uuid":["uuid","<0>"]},{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"zero","number":0}]},{}]
334 OVSDB_CHECK_EXECUTION([equality wait with correct rows],
339 "row": {"number": 0, "name": "zero"}},
342 "row": {"number": 1, "name": "one"}},
347 "columns": ["name", "number"],
349 "rows": [{"name": "zero", "number": 0},
350 {"name": "one", "number": 1}]}]]]],
351 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{}]
354 OVSDB_CHECK_EXECUTION([equality wait with extra row],
359 "row": {"number": 0, "name": "zero"}},
362 "row": {"number": 1, "name": "one"}},
367 "columns": ["name", "number"],
369 "rows": [{"name": "zero", "number": 0},
370 {"name": "one", "number": 1},
371 {"name": "two", "number": 2}]}]]]],
372 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"details":"\"wait\" timed out","error":"timed out"}]
375 OVSDB_CHECK_EXECUTION([equality wait with missing row],
380 "row": {"number": 0, "name": "zero"}},
383 "row": {"number": 1, "name": "one"}},
388 "columns": ["name", "number"],
390 "rows": [{"name": "one", "number": 1}]}]]]],
391 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"details":"\"wait\" timed out","error":"timed out"}]
394 OVSDB_CHECK_EXECUTION([inequality wait with correct rows],
399 "row": {"number": 0, "name": "zero"}},
402 "row": {"number": 1, "name": "one"}},
407 "columns": ["name", "number"],
409 "rows": [{"name": "zero", "number": 0},
410 {"name": "one", "number": 1}]}]]]],
411 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"details":"\"wait\" timed out","error":"timed out"}]
414 OVSDB_CHECK_EXECUTION([inequality wait with extra row],
419 "row": {"number": 0, "name": "zero"}},
422 "row": {"number": 1, "name": "one"}},
427 "columns": ["name", "number"],
429 "rows": [{"name": "zero", "number": 0},
430 {"name": "one", "number": 1},
431 {"name": "two", "number": 2}]}]]]],
432 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{}]
435 OVSDB_CHECK_EXECUTION([inequality wait with missing row],
440 "row": {"number": 0, "name": "zero"}},
443 "row": {"number": 1, "name": "one"}},
448 "columns": ["name", "number"],
450 "rows": [{"name": "one", "number": 1}]}]]]],
451 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{}]
454 OVSDB_CHECK_EXECUTION([insert and update constraints],
458 "table": "constrained",
462 "table": "constrained",
463 "row": {"positive": -1}}]]],
466 "table": "constrained",
468 "row": {"positive": -2}}]]],
471 "table": "constrained",
472 "row": {"positive": 1}}]]],
475 "table": "constrained",
476 "row": {"positive": 2}}]]]],
477 [[[{"details":"0 is less than minimum allowed value 1","error":"constraint violation"}]
478 [{"details":"-1 is less than minimum allowed value 1","error":"constraint violation"}]
479 [{"details":"-2 is less than minimum allowed value 1","error":"constraint violation"}]
480 [{"uuid":["uuid","<0>"]}]
481 [{"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"}]
484 OVSDB_CHECK_EXECUTION([referential integrity -- simple],
490 "uuid-name": "brow"},
494 "a2b": ["set", [["named-uuid", "brow"]]]}},
498 "a2b": ["set", [["named-uuid", "brow"]]]}},
502 "a2b": ["set", [["named-uuid", "brow"]]]}}]]],
510 "where": [["a", "==", 0]]}]]],
518 "where": [["a", "==", 1]]}]]],
526 "where": [["a", "==", 2]]}]]],
531 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]}]
532 [{"count":1},{"details":"cannot delete b row <0> because of 3 remaining reference(s)","error":"referential integrity violation"}]
534 [{"count":1},{"details":"cannot delete b row <0> because of 2 remaining reference(s)","error":"referential integrity violation"}]
536 [{"count":1},{"details":"cannot delete b row <0> because of 1 remaining reference(s)","error":"referential integrity violation"}]
541 OVSDB_CHECK_EXECUTION([referential integrity -- mutual references],
547 "a2b": ["set", [["named-uuid", "row2"]]],
548 "a2a": ["set", [["named-uuid", "row1"]]]},
549 "uuid-name": "row1"},
553 "b2b": ["set", [["named-uuid", "row2"]]],
554 "b2a": ["set", [["named-uuid", "row1"]]]},
555 "uuid-name": "row2"}]]],
559 "row": {"a2b": ["set", [["uuid", "b516b960-5b19-4fc2-bb82-fe1cbd6d0241"]]]}}]]],
563 "where": [["a", "==", 0]]}]]],
567 "where": [["b", "==", 1]]}]]],
568 dnl Try the deletions again to make sure that the refcounts got rolled back.
572 "where": [["a", "==", 0]]}]]],
576 "where": [["b", "==", 1]]}]]],
580 "where": [["a", "==", 0]]},
583 "where": [["b", "==", 1]]}]]]],
584 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}]
585 [{"uuid":["uuid","<2>"]},{"details":"Table a column a2b row <2> references nonexistent row <3> in table b.","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},{"details":"cannot delete a row <0> because of 1 remaining reference(s)","error":"referential integrity violation"}]
589 [{"count":1},{"details":"cannot delete b row <1> because of 1 remaining reference(s)","error":"referential integrity violation"}]
590 [{"count":1},{"count":1}]
593 OVSDB_CHECK_EXECUTION([weak references],
599 "a2a": ["set", [["named-uuid", "row1"],
600 ["named-uuid", "row2"],
601 ["uuid", "0e767b36-6822-4044-8307-d58467e04669"]]],
602 "a2a1": ["named-uuid", "row1"],
603 "a2b": ["named-uuid", "row3"]},
604 "uuid-name": "row1"},
608 "a2a": ["set", [["named-uuid", "row1"],
609 ["named-uuid", "row2"]]],
610 "a2a1": ["named-uuid", "row2"],
611 "a2b": ["named-uuid", "row3"]},
612 "uuid-name": "row2"},
616 "a2a": ["set", [["named-uuid", "row1"],
617 ["named-uuid", "row2"]]],
618 "a2a1": ["named-uuid", "row2"],
619 "a2b": ["named-uuid", "row4"]}},
623 "b2a": ["named-uuid", "row1"]},
624 "uuid-name": "row3"},
628 "b2a": ["named-uuid", "row2"]},
629 "uuid-name": "row4"}]]],
630 dnl Check that the nonexistent row UUID we added to row a0 was deleted,
631 dnl and that other rows were inserted as requested.
636 "columns": ["_uuid", "a2a", "a2a1", "a2b"],
642 "columns": ["_uuid", "b", "b2a"],
644 dnl Try to insert invalid all-zeros weak reference (the default) into
645 dnl "a2b", which requires exactly one value.
649 "row": {"a2a1": ["named-uuid", "me"]},
650 "uuid-name": "me"}]]],
651 dnl Try to delete row from "b" that is referred to by weak references
652 dnl from "a" table "a2b" column that requires exactly one value.
656 "where": [["b", "==", 3]]}]]],
657 dnl Try to delete row from "a" that is referred to by weak references
658 dnl from "a" table "a2a1" column that requires exactly one value.
662 "where": [["a", "==", 1]]}]]],
663 dnl Delete the row that had the reference that caused the previous
664 dnl deletion to fail, then check that other rows are unchanged.
668 "where": [["a", "==", 2]]}]]],
673 "columns": ["_uuid", "a2a", "a2a1", "a2b"],
679 "columns": ["_uuid", "b", "b2a"],
681 dnl Delete row a0 then check that references to it were removed.
685 "where": [["a", "==", 0]]}]]],
690 "columns": ["_uuid", "a2a", "a2a1", "a2b"],
696 "columns": ["_uuid", "b", "b2a"],
698 dnl Delete row a1 then check that references to it were removed.
702 "where": [["a", "==", 1]]}]]],
707 "columns": ["_uuid", "a2a", "a2a1", "a2b"],
713 "columns": ["_uuid", "b", "b2a"],
715 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]},{"uuid":["uuid","<4>"]}]
716 [{"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>"]}]}]
717 [{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["uuid","<0>"]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["uuid","<1>"]}]}]
718 [{"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"}]
719 [{"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"}]
720 [{"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"}]
722 [{"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>"]}]}]
723 [{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["uuid","<0>"]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["uuid","<1>"]}]}]
725 [{"rows":[{"_uuid":["uuid","<1>"],"a2a":["uuid","<1>"],"a2a1":["uuid","<1>"],"a2b":["uuid","<3>"]}]}]
726 [{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["set",[]]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["uuid","<1>"]}]}]
729 [{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["set",[]]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["set",[]]}]}]