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",
31 "minInteger": 1}}}}}}}]])
33 m4_define([WEAK_SCHEMA],
38 "a": {"type": "integer"},
39 "a2a": {"type": {"key": {"type": "uuid",
42 "min": 0, "max": "unlimited"}},
43 "a2a1": {"type": {"key": {"type": "uuid",
46 "a2b": {"type": {"key": {"type": "uuid",
48 "refType": "weak"}}}}},
51 "b": {"type": "integer"},
52 "b2a": {"type": {"key": {"type": "uuid",
55 "min": 0, "max": "unlimited"}}}}}}]])
57 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
59 # Runs "test-ovsdb execute" with the given SCHEMA and each of the
60 # TRANSACTIONS (which should be a quoted list of quoted strings).
62 # Checks that the overall output is OUTPUT, but UUIDs in the output
63 # are replaced by markers of the form <N> where N is a number. The
64 # first unique UUID is replaced by <0>, the next by <1>, and so on.
65 # If a given UUID appears more than once it is always replaced by the
68 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
69 m4_define([OVSDB_CHECK_EXECUTION],
71 AT_KEYWORDS([ovsdb execute execution positive $5])
72 AT_CHECK([test-ovsdb execute '$2' m4_foreach([txn], [$3], [ 'txn'])],
74 AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0], [$4])
77 m4_define([EXECUTION_EXAMPLES], [
78 dnl At one point the "commit" code ignored new rows with all-default values,
79 dnl so this checks for that problem.
80 OVSDB_CHECK_EXECUTION([insert default row, query table],
90 [[[{"uuid":["uuid","<0>"]}]
91 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"","number":0}]}]
94 OVSDB_CHECK_EXECUTION([insert row, query table],
99 "row": {"number": 0, "name": "zero"}}]]],
104 [[[{"uuid":["uuid","<0>"]}]
105 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"zero","number":0}]}]
108 OVSDB_CHECK_EXECUTION([insert rows, query by value],
113 "row": {"number": 0, "name": "zero"}}]]],
117 "row": {"number": 1, "name": "one"}}]]],
121 "where": [["name", "==", "zero"]]}]]],
125 "where": [["name", "==", "one"]]}]]]],
126 [[[{"uuid":["uuid","<0>"]}]
127 [{"uuid":["uuid","<1>"]}]
128 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"zero","number":0}]}]
129 [{"rows":[{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}]
132 OVSDB_CHECK_EXECUTION([insert rows, query by named-uuid],
137 "row": {"number": 0, "name": "zero"},
138 "uuid-name": "first"},
141 "row": {"number": 1, "name": "one"},
142 "uuid-name": "second"},
145 "where": [["_uuid", "==", ["named-uuid", "first"]]]},
148 "where": [["_uuid", "==", ["named-uuid", "second"]]]}]]]],
149 [[[{"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}]}]
152 OVSDB_CHECK_EXECUTION([insert rows, update rows by value],
157 "row": {"number": 0, "name": "zero"},
158 "uuid-name": "first"}]]],
162 "row": {"number": 1, "name": "one"},
163 "uuid-name": "first"}]]],
167 "where": [["name", "==", "zero"]],
168 "row": {"name": "nought"}}]]],
173 "sort": ["number"]}]]]],
174 [[[{"uuid":["uuid","<0>"]}]
175 [{"uuid":["uuid","<1>"]}]
177 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"nought","number":0},{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}]
180 OVSDB_CHECK_EXECUTION([insert rows, mutate rows],
185 "row": {"number": 0, "name": "zero"},
186 "uuid-name": "first"}]]],
190 "row": {"number": 1, "name": "one"},
191 "uuid-name": "first"}]]],
195 "where": [["name", "==", "zero"]],
196 "mutations": [["number", "+=", 2]]}]]],
201 "sort": ["number"]}]]]],
202 [[[{"uuid":["uuid","<0>"]}]
203 [{"uuid":["uuid","<1>"]}]
205 [{"rows":[{"_uuid":["uuid","<1>"],"_version":["uuid","<2>"],"name":"one","number":1},{"_uuid":["uuid","<0>"],"_version":["uuid","<3>"],"name":"zero","number":2}]}]
208 OVSDB_CHECK_EXECUTION([insert rows, delete by named-uuid],
213 "row": {"number": 0, "name": "zero"},
214 "uuid-name": "first"},
217 "row": {"number": 1, "name": "one"},
218 "uuid-name": "second"},
221 "where": [["_uuid", "==", ["named-uuid", "first"]]]},
225 "columns": ["name","number"]}]]]],
226 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"count":1},{"rows":[{"name":"one","number":1}]}]
229 OVSDB_CHECK_EXECUTION([insert rows, delete rows by value],
234 "row": {"number": 0, "name": "zero"},
235 "uuid-name": "first"}]]],
239 "row": {"number": 1, "name": "one"},
240 "uuid-name": "first"}]]],
244 "where": [["name", "==", "zero"]]}]]],
249 [[[{"uuid":["uuid","<0>"]}]
250 [{"uuid":["uuid","<1>"]}]
252 [{"rows":[{"_uuid":["uuid","<1>"],"_version":["uuid","<2>"],"name":"one","number":1}]}]
255 OVSDB_CHECK_EXECUTION([insert rows, delete by (non-matching) value],
260 "row": {"number": 0, "name": "zero"},
261 "uuid-name": "first"}]]],
265 "row": {"number": 1, "name": "one"},
266 "uuid-name": "first"}]]],
270 "where": [["name", "==", "nought"]]}]]],
275 "sort": ["number"]}]]]],
276 [[[{"uuid":["uuid","<0>"]}]
277 [{"uuid":["uuid","<1>"]}]
279 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"zero","number":0},{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}]
282 OVSDB_CHECK_EXECUTION([insert rows, delete all],
287 "row": {"number": 0, "name": "zero"},
288 "uuid-name": "first"},
291 "row": {"number": 1, "name": "one"},
292 "uuid-name": "second"},
299 "columns": ["name","number"]}]]]],
300 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"count":2},{"rows":[]}]
303 OVSDB_CHECK_EXECUTION([insert row, query table, commit],
308 "row": {"number": 0, "name": "zero"}},
313 "durable": false}]]]],
314 [[[{"uuid":["uuid","<0>"]},{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"zero","number":0}]},{}]
317 OVSDB_CHECK_EXECUTION([insert row, query table, commit durably],
322 "row": {"number": 0, "name": "zero"}},
327 "durable": true}]]]],
328 [[[{"uuid":["uuid","<0>"]},{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"zero","number":0}]},{}]
331 OVSDB_CHECK_EXECUTION([equality wait with correct rows],
336 "row": {"number": 0, "name": "zero"}},
339 "row": {"number": 1, "name": "one"}},
344 "columns": ["name", "number"],
346 "rows": [{"name": "zero", "number": 0},
347 {"name": "one", "number": 1}]}]]]],
348 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{}]
351 OVSDB_CHECK_EXECUTION([equality wait with extra row],
356 "row": {"number": 0, "name": "zero"}},
359 "row": {"number": 1, "name": "one"}},
364 "columns": ["name", "number"],
366 "rows": [{"name": "zero", "number": 0},
367 {"name": "one", "number": 1},
368 {"name": "two", "number": 2}]}]]]],
369 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"details":"\"wait\" timed out","error":"timed out"}]
372 OVSDB_CHECK_EXECUTION([equality wait with missing row],
377 "row": {"number": 0, "name": "zero"}},
380 "row": {"number": 1, "name": "one"}},
385 "columns": ["name", "number"],
387 "rows": [{"name": "one", "number": 1}]}]]]],
388 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"details":"\"wait\" timed out","error":"timed out"}]
391 OVSDB_CHECK_EXECUTION([inequality wait with correct rows],
396 "row": {"number": 0, "name": "zero"}},
399 "row": {"number": 1, "name": "one"}},
404 "columns": ["name", "number"],
406 "rows": [{"name": "zero", "number": 0},
407 {"name": "one", "number": 1}]}]]]],
408 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"details":"\"wait\" timed out","error":"timed out"}]
411 OVSDB_CHECK_EXECUTION([inequality wait with extra row],
416 "row": {"number": 0, "name": "zero"}},
419 "row": {"number": 1, "name": "one"}},
424 "columns": ["name", "number"],
426 "rows": [{"name": "zero", "number": 0},
427 {"name": "one", "number": 1},
428 {"name": "two", "number": 2}]}]]]],
429 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{}]
432 OVSDB_CHECK_EXECUTION([inequality wait with missing row],
437 "row": {"number": 0, "name": "zero"}},
440 "row": {"number": 1, "name": "one"}},
445 "columns": ["name", "number"],
447 "rows": [{"name": "one", "number": 1}]}]]]],
448 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{}]
451 OVSDB_CHECK_EXECUTION([insert and update constraints],
455 "table": "constrained",
459 "table": "constrained",
460 "row": {"positive": -1}}]]],
463 "table": "constrained",
465 "row": {"positive": -2}}]]]],
466 [[[{"details":"0 is less than minimum allowed value 1","error":"constraint violation"}]
467 [{"details":"-1 is less than minimum allowed value 1","error":"constraint violation"}]
468 [{"details":"-2 is less than minimum allowed value 1","error":"constraint violation"}]
471 OVSDB_CHECK_EXECUTION([referential integrity -- simple],
477 "uuid-name": "brow"},
481 "a2b": ["set", [["named-uuid", "brow"]]]}},
485 "a2b": ["set", [["named-uuid", "brow"]]]}},
489 "a2b": ["set", [["named-uuid", "brow"]]]}}]]],
497 "where": [["a", "==", 0]]}]]],
505 "where": [["a", "==", 1]]}]]],
513 "where": [["a", "==", 2]]}]]],
518 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]}]
519 [{"count":1},{"details":"cannot delete b row <0> because of 3 remaining reference(s)","error":"referential integrity violation"}]
521 [{"count":1},{"details":"cannot delete b row <0> because of 2 remaining reference(s)","error":"referential integrity violation"}]
523 [{"count":1},{"details":"cannot delete b row <0> because of 1 remaining reference(s)","error":"referential integrity violation"}]
528 OVSDB_CHECK_EXECUTION([referential integrity -- mutual references],
534 "a2b": ["set", [["named-uuid", "row2"]]],
535 "a2a": ["set", [["named-uuid", "row1"]]]},
536 "uuid-name": "row1"},
540 "b2b": ["set", [["named-uuid", "row2"]]],
541 "b2a": ["set", [["named-uuid", "row1"]]]},
542 "uuid-name": "row2"}]]],
546 "row": {"a2b": ["set", [["uuid", "b516b960-5b19-4fc2-bb82-fe1cbd6d0241"]]]}}]]],
550 "where": [["a", "==", 0]]}]]],
554 "where": [["b", "==", 1]]}]]],
555 dnl Try the deletions again to make sure that the refcounts got rolled back.
559 "where": [["a", "==", 0]]}]]],
563 "where": [["b", "==", 1]]}]]],
567 "where": [["a", "==", 0]]},
570 "where": [["b", "==", 1]]}]]]],
571 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}]
572 [{"uuid":["uuid","<2>"]},{"details":"reference to nonexistent row <3>","error":"referential integrity violation"}]
573 [{"count":1},{"details":"cannot delete a row <0> because of 1 remaining reference(s)","error":"referential integrity violation"}]
574 [{"count":1},{"details":"cannot delete b row <1> because of 1 remaining reference(s)","error":"referential integrity violation"}]
575 [{"count":1},{"details":"cannot delete a row <0> because of 1 remaining reference(s)","error":"referential integrity violation"}]
576 [{"count":1},{"details":"cannot delete b row <1> because of 1 remaining reference(s)","error":"referential integrity violation"}]
577 [{"count":1},{"count":1}]
580 OVSDB_CHECK_EXECUTION([weak references],
586 "a2a": ["set", [["named-uuid", "row1"],
587 ["named-uuid", "row2"],
588 ["uuid", "0e767b36-6822-4044-8307-d58467e04669"]]],
589 "a2a1": ["named-uuid", "row1"],
590 "a2b": ["named-uuid", "row3"]},
591 "uuid-name": "row1"},
595 "a2a": ["set", [["named-uuid", "row1"],
596 ["named-uuid", "row2"]]],
597 "a2a1": ["named-uuid", "row2"],
598 "a2b": ["named-uuid", "row3"]},
599 "uuid-name": "row2"},
603 "a2a": ["set", [["named-uuid", "row1"],
604 ["named-uuid", "row2"]]],
605 "a2a1": ["named-uuid", "row2"],
606 "a2b": ["named-uuid", "row4"]}},
610 "b2a": ["named-uuid", "row1"]},
611 "uuid-name": "row3"},
615 "b2a": ["named-uuid", "row2"]},
616 "uuid-name": "row4"}]]],
617 dnl Check that the nonexistent row UUID we added to row a0 was deleted,
618 dnl and that other rows were inserted as requested.
623 "columns": ["_uuid", "a2a", "a2a1", "a2b"],
629 "columns": ["_uuid", "b", "b2a"],
631 dnl Try to insert invalid all-zeros weak reference (the default) into
632 dnl "a2b", which requires exactly one value.
637 dnl Try to delete row from "b" that is referred to by weak references
638 dnl from "a" table "a2b" column that requires exactly one value.
642 "where": [["b", "==", 3]]}]]],
643 dnl Try to delete row from "a" that is referred to by weak references
644 dnl from "a" table "a2a1" column that requires exactly one value.
648 "where": [["a", "==", 1]]}]]],
649 dnl Delete the row that had the reference that caused the previous
650 dnl deletion to fail, then check that other rows are unchanged.
654 "where": [["a", "==", 2]]}]]],
659 "columns": ["_uuid", "a2a", "a2a1", "a2b"],
665 "columns": ["_uuid", "b", "b2a"],
667 dnl Delete row a0 then check that references to it were removed.
671 "where": [["a", "==", 0]]}]]],
676 "columns": ["_uuid", "a2a", "a2a1", "a2b"],
682 "columns": ["_uuid", "b", "b2a"],
684 dnl Delete row a1 then check that references to it were removed.
688 "where": [["a", "==", 1]]}]]],
693 "columns": ["_uuid", "a2a", "a2a1", "a2b"],
699 "columns": ["_uuid", "b", "b2a"],
701 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]},{"uuid":["uuid","<4>"]}]
702 [{"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>"]}]}]
703 [{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["uuid","<0>"]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["uuid","<1>"]}]}]
704 [{"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"}]
705 [{"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"}]
706 [{"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"}]
708 [{"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>"]}]}]
709 [{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["uuid","<0>"]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["uuid","<1>"]}]}]
711 [{"rows":[{"_uuid":["uuid","<1>"],"a2a":["uuid","<1>"],"a2a1":["uuid","<1>"],"a2b":["uuid","<3>"]}]}]
712 [{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["set",[]]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["uuid","<1>"]}]}]
715 [{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["set",[]]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["set",[]]}]}]