AT_BANNER([OVSDB -- execution]) m4_define([ORDINAL_SCHEMA], [[{"name": "ordinals", "tables": { "ordinals": { "columns": { "number": {"type": "integer"}, "name": {"type": "string"}}}}}]]) m4_define([CONSTRAINT_SCHEMA], [[{"name": "constraints", "tables": { "a": { "columns": { "a": {"type": "integer"}, "a2a": {"type": {"key": {"type": "uuid", "refTable": "a"}, "min": 0, "max": "unlimited"}}, "a2b": {"type": {"key": {"type": "uuid", "refTable": "b"}, "min": 0, "max": "unlimited"}}}}, "b": { "columns": { "b": {"type": "integer"}, "b2a": {"type": {"key": {"type": "uuid", "refTable": "a"}, "min": 0, "max": "unlimited"}}, "b2b": {"type": {"key": {"type": "uuid", "refTable": "b"}, "min": 0, "max": "unlimited"}}}}, "constrained": { "columns": { "positive": {"type": {"key": {"type": "integer", "minInteger": 1}}}}}}}]]) # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS]) # # Runs "test-ovsdb execute" with the given SCHEMA and each of the # TRANSACTIONS (which should be a quoted list of quoted strings). # # Checks that the overall output is OUTPUT, but UUIDs in the output # are replaced by markers of the form where N is a number. The # first unique UUID is replaced by <0>, the next by <1>, and so on. # If a given UUID appears more than once it is always replaced by the # same marker. # # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS. m4_define([OVSDB_CHECK_EXECUTION], [AT_SETUP([$1]) AT_KEYWORDS([ovsdb execute execution positive $5]) AT_CHECK([test-ovsdb execute '$2' m4_foreach([txn], [$3], [ 'txn'])], [0], [stdout], []) AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0], [$4]) AT_CLEANUP]) m4_define([EXECUTION_EXAMPLES], [ dnl At one point the "commit" code ignored new rows with all-default values, dnl so this checks for that problem. OVSDB_CHECK_EXECUTION([insert default row, query table], [ORDINAL_SCHEMA], [[[["ordinals", {"op": "insert", "table": "ordinals", "row": {}}]]], [[["ordinals", {"op": "select", "table": "ordinals", "where": []}]]]], [[[{"uuid":["uuid","<0>"]}] [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"","number":0}]}] ]]) OVSDB_CHECK_EXECUTION([insert row, query table], [ORDINAL_SCHEMA], [[[["ordinals", {"op": "insert", "table": "ordinals", "row": {"number": 0, "name": "zero"}}]]], [[["ordinals", {"op": "select", "table": "ordinals", "where": []}]]]], [[[{"uuid":["uuid","<0>"]}] [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"zero","number":0}]}] ]]) OVSDB_CHECK_EXECUTION([insert rows, query by value], [ORDINAL_SCHEMA], [[[["ordinals", {"op": "insert", "table": "ordinals", "row": {"number": 0, "name": "zero"}}]]], [[["ordinals", {"op": "insert", "table": "ordinals", "row": {"number": 1, "name": "one"}}]]], [[["ordinals", {"op": "select", "table": "ordinals", "where": [["name", "==", "zero"]]}]]], [[["ordinals", {"op": "select", "table": "ordinals", "where": [["name", "==", "one"]]}]]]], [[[{"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}]}] ]]) OVSDB_CHECK_EXECUTION([insert rows, query by named-uuid], [ORDINAL_SCHEMA], [[[["ordinals", {"op": "insert", "table": "ordinals", "row": {"number": 0, "name": "zero"}, "uuid-name": "first"}, {"op": "insert", "table": "ordinals", "row": {"number": 1, "name": "one"}, "uuid-name": "second"}, {"op": "select", "table": "ordinals", "where": [["_uuid", "==", ["named-uuid", "first"]]]}, {"op": "select", "table": "ordinals", "where": [["_uuid", "==", ["named-uuid", "second"]]]}]]]], [[[{"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}]}] ]]) OVSDB_CHECK_EXECUTION([insert rows, update rows by value], [ORDINAL_SCHEMA], [[[["ordinals", {"op": "insert", "table": "ordinals", "row": {"number": 0, "name": "zero"}, "uuid-name": "first"}]]], [[["ordinals", {"op": "insert", "table": "ordinals", "row": {"number": 1, "name": "one"}, "uuid-name": "first"}]]], [[["ordinals", {"op": "update", "table": "ordinals", "where": [["name", "==", "zero"]], "row": {"name": "nought"}}]]], [[["ordinals", {"op": "select", "table": "ordinals", "where": [], "sort": ["number"]}]]]], [[[{"uuid":["uuid","<0>"]}] [{"uuid":["uuid","<1>"]}] [{"count":1}] [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"nought","number":0},{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}] ]]) OVSDB_CHECK_EXECUTION([insert rows, mutate rows], [ORDINAL_SCHEMA], [[[["ordinals", {"op": "insert", "table": "ordinals", "row": {"number": 0, "name": "zero"}, "uuid-name": "first"}]]], [[["ordinals", {"op": "insert", "table": "ordinals", "row": {"number": 1, "name": "one"}, "uuid-name": "first"}]]], [[["ordinals", {"op": "mutate", "table": "ordinals", "where": [["name", "==", "zero"]], "mutations": [["number", "+=", 2]]}]]], [[["ordinals", {"op": "select", "table": "ordinals", "where": [], "sort": ["number"]}]]]], [[[{"uuid":["uuid","<0>"]}] [{"uuid":["uuid","<1>"]}] [{"count":1}] [{"rows":[{"_uuid":["uuid","<1>"],"_version":["uuid","<2>"],"name":"one","number":1},{"_uuid":["uuid","<0>"],"_version":["uuid","<3>"],"name":"zero","number":2}]}] ]]) OVSDB_CHECK_EXECUTION([insert rows, delete by named-uuid], [ORDINAL_SCHEMA], [[[["ordinals", {"op": "insert", "table": "ordinals", "row": {"number": 0, "name": "zero"}, "uuid-name": "first"}, {"op": "insert", "table": "ordinals", "row": {"number": 1, "name": "one"}, "uuid-name": "second"}, {"op": "delete", "table": "ordinals", "where": [["_uuid", "==", ["named-uuid", "first"]]]}, {"op": "select", "table": "ordinals", "where": [], "columns": ["name","number"]}]]]], [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"count":1},{"rows":[{"name":"one","number":1}]}] ]]) OVSDB_CHECK_EXECUTION([insert rows, delete rows by value], [ORDINAL_SCHEMA], [[[["ordinals", {"op": "insert", "table": "ordinals", "row": {"number": 0, "name": "zero"}, "uuid-name": "first"}]]], [[["ordinals", {"op": "insert", "table": "ordinals", "row": {"number": 1, "name": "one"}, "uuid-name": "first"}]]], [[["ordinals", {"op": "delete", "table": "ordinals", "where": [["name", "==", "zero"]]}]]], [[["ordinals", {"op": "select", "table": "ordinals", "where": []}]]]], [[[{"uuid":["uuid","<0>"]}] [{"uuid":["uuid","<1>"]}] [{"count":1}] [{"rows":[{"_uuid":["uuid","<1>"],"_version":["uuid","<2>"],"name":"one","number":1}]}] ]]) OVSDB_CHECK_EXECUTION([insert rows, delete by (non-matching) value], [ORDINAL_SCHEMA], [[[["ordinals", {"op": "insert", "table": "ordinals", "row": {"number": 0, "name": "zero"}, "uuid-name": "first"}]]], [[["ordinals", {"op": "insert", "table": "ordinals", "row": {"number": 1, "name": "one"}, "uuid-name": "first"}]]], [[["ordinals", {"op": "delete", "table": "ordinals", "where": [["name", "==", "nought"]]}]]], [[["ordinals", {"op": "select", "table": "ordinals", "where": [], "sort": ["number"]}]]]], [[[{"uuid":["uuid","<0>"]}] [{"uuid":["uuid","<1>"]}] [{"count":0}] [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"zero","number":0},{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}] ]]) OVSDB_CHECK_EXECUTION([insert rows, delete all], [ORDINAL_SCHEMA], [[[["ordinals", {"op": "insert", "table": "ordinals", "row": {"number": 0, "name": "zero"}, "uuid-name": "first"}, {"op": "insert", "table": "ordinals", "row": {"number": 1, "name": "one"}, "uuid-name": "second"}, {"op": "delete", "table": "ordinals", "where": []}, {"op": "select", "table": "ordinals", "where": [], "columns": ["name","number"]}]]]], [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"count":2},{"rows":[]}] ]]) OVSDB_CHECK_EXECUTION([insert row, query table, commit], [ORDINAL_SCHEMA], [[[["ordinals", {"op": "insert", "table": "ordinals", "row": {"number": 0, "name": "zero"}}, {"op": "select", "table": "ordinals", "where": []}, {"op": "commit", "durable": false}]]]], [[[{"uuid":["uuid","<0>"]},{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"zero","number":0}]},{}] ]]) OVSDB_CHECK_EXECUTION([insert row, query table, commit durably], [ORDINAL_SCHEMA], [[[["ordinals", {"op": "insert", "table": "ordinals", "row": {"number": 0, "name": "zero"}}, {"op": "select", "table": "ordinals", "where": []}, {"op": "commit", "durable": true}]]]], [[[{"uuid":["uuid","<0>"]},{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"zero","number":0}]},{}] ]]) OVSDB_CHECK_EXECUTION([equality wait with correct rows], [ORDINAL_SCHEMA], [[[["ordinals", {"op": "insert", "table": "ordinals", "row": {"number": 0, "name": "zero"}}, {"op": "insert", "table": "ordinals", "row": {"number": 1, "name": "one"}}, {"op": "wait", "timeout": 0, "table": "ordinals", "where": [], "columns": ["name", "number"], "until": "==", "rows": [{"name": "zero", "number": 0}, {"name": "one", "number": 1}]}]]]], [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{}] ]]) OVSDB_CHECK_EXECUTION([equality wait with extra row], [ORDINAL_SCHEMA], [[[["ordinals", {"op": "insert", "table": "ordinals", "row": {"number": 0, "name": "zero"}}, {"op": "insert", "table": "ordinals", "row": {"number": 1, "name": "one"}}, {"op": "wait", "timeout": 0, "table": "ordinals", "where": [], "columns": ["name", "number"], "until": "==", "rows": [{"name": "zero", "number": 0}, {"name": "one", "number": 1}, {"name": "two", "number": 2}]}]]]], [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"details":"\"wait\" timed out","error":"timed out"}] ]]) OVSDB_CHECK_EXECUTION([equality wait with missing row], [ORDINAL_SCHEMA], [[[["ordinals", {"op": "insert", "table": "ordinals", "row": {"number": 0, "name": "zero"}}, {"op": "insert", "table": "ordinals", "row": {"number": 1, "name": "one"}}, {"op": "wait", "timeout": 0, "table": "ordinals", "where": [], "columns": ["name", "number"], "until": "==", "rows": [{"name": "one", "number": 1}]}]]]], [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"details":"\"wait\" timed out","error":"timed out"}] ]]) OVSDB_CHECK_EXECUTION([inequality wait with correct rows], [ORDINAL_SCHEMA], [[[["ordinals", {"op": "insert", "table": "ordinals", "row": {"number": 0, "name": "zero"}}, {"op": "insert", "table": "ordinals", "row": {"number": 1, "name": "one"}}, {"op": "wait", "timeout": 0, "table": "ordinals", "where": [], "columns": ["name", "number"], "until": "!=", "rows": [{"name": "zero", "number": 0}, {"name": "one", "number": 1}]}]]]], [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"details":"\"wait\" timed out","error":"timed out"}] ]]) OVSDB_CHECK_EXECUTION([inequality wait with extra row], [ORDINAL_SCHEMA], [[[["ordinals", {"op": "insert", "table": "ordinals", "row": {"number": 0, "name": "zero"}}, {"op": "insert", "table": "ordinals", "row": {"number": 1, "name": "one"}}, {"op": "wait", "timeout": 0, "table": "ordinals", "where": [], "columns": ["name", "number"], "until": "!=", "rows": [{"name": "zero", "number": 0}, {"name": "one", "number": 1}, {"name": "two", "number": 2}]}]]]], [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{}] ]]) OVSDB_CHECK_EXECUTION([inequality wait with missing row], [ORDINAL_SCHEMA], [[[["ordinals", {"op": "insert", "table": "ordinals", "row": {"number": 0, "name": "zero"}}, {"op": "insert", "table": "ordinals", "row": {"number": 1, "name": "one"}}, {"op": "wait", "timeout": 0, "table": "ordinals", "where": [], "columns": ["name", "number"], "until": "!=", "rows": [{"name": "one", "number": 1}]}]]]], [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{}] ]]) OVSDB_CHECK_EXECUTION([insert and update constraints], [CONSTRAINT_SCHEMA], [[[["constraints", {"op": "insert", "table": "constrained", "row": {}}]]], [[["constraints", {"op": "insert", "table": "constrained", "row": {"positive": -1}}]]], [[["constraints", {"op": "update", "table": "constrained", "where": [], "row": {"positive": -2}}]]]], [[[{"details":"0 is less than minimum allowed value 1","error":"constraint violation"}] [{"details":"-1 is less than minimum allowed value 1","error":"constraint violation"}] [{"details":"-2 is less than minimum allowed value 1","error":"constraint violation"}] ]]) OVSDB_CHECK_EXECUTION([referential integrity -- simple], [CONSTRAINT_SCHEMA], [[[["constraints", {"op": "insert", "table": "b", "row": {"b": 1}, "uuid-name": "brow"}, {"op": "insert", "table": "a", "row": {"a": 0, "a2b": ["set", [["named-uuid", "brow"]]]}}, {"op": "insert", "table": "a", "row": {"a": 1, "a2b": ["set", [["named-uuid", "brow"]]]}}, {"op": "insert", "table": "a", "row": {"a": 2, "a2b": ["set", [["named-uuid", "brow"]]]}}]]], [[["constraints", {"op": "delete", "table": "b", "where": []}]]], [[["constraints", {"op": "delete", "table": "a", "where": [["a", "==", 0]]}]]], [[["constraints", {"op": "delete", "table": "b", "where": []}]]], [[["constraints", {"op": "delete", "table": "a", "where": [["a", "==", 1]]}]]], [[["constraints", {"op": "delete", "table": "b", "where": []}]]], [[["constraints", {"op": "delete", "table": "a", "where": [["a", "==", 2]]}]]], [[["constraints", {"op": "delete", "table": "b", "where": []}]]]], [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]}] [{"count":1},{"details":"cannot delete b row <0> because of 3 remaining reference(s)","error":"referential integrity violation"}] [{"count":1}] [{"count":1},{"details":"cannot delete b row <0> because of 2 remaining reference(s)","error":"referential integrity violation"}] [{"count":1}] [{"count":1},{"details":"cannot delete b row <0> because of 1 remaining reference(s)","error":"referential integrity violation"}] [{"count":1}] [{"count":1}] ]]) OVSDB_CHECK_EXECUTION([referential integrity -- mutual references], [CONSTRAINT_SCHEMA], [[[["constraints", {"op": "insert", "table": "a", "row": {"a": 0, "a2b": ["set", [["named-uuid", "row2"]]], "a2a": ["set", [["named-uuid", "row1"]]]}, "uuid-name": "row1"}, {"op": "insert", "table": "b", "row": {"b": 1, "b2b": ["set", [["named-uuid", "row2"]]], "b2a": ["set", [["named-uuid", "row1"]]]}, "uuid-name": "row2"}]]], [[["constraints", {"op": "insert", "table": "a", "row": {"a2b": ["set", [["uuid", "b516b960-5b19-4fc2-bb82-fe1cbd6d0241"]]]}}]]], [[["constraints", {"op": "delete", "table": "a", "where": [["a", "==", 0]]}]]], [[["constraints", {"op": "delete", "table": "b", "where": [["b", "==", 1]]}]]], dnl Try the deletions again to make sure that the refcounts got rolled back. [[["constraints", {"op": "delete", "table": "a", "where": [["a", "==", 0]]}]]], [[["constraints", {"op": "delete", "table": "b", "where": [["b", "==", 1]]}]]], [[["constraints", {"op": "delete", "table": "a", "where": [["a", "==", 0]]}, {"op": "delete", "table": "b", "where": [["b", "==", 1]]}]]]], [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}] [{"uuid":["uuid","<2>"]},{"details":"reference to nonexistent row <3>","error":"referential integrity violation"}] [{"count":1},{"details":"cannot delete a row <0> because of 1 remaining reference(s)","error":"referential integrity violation"}] [{"count":1},{"details":"cannot delete b row <1> because of 1 remaining reference(s)","error":"referential integrity violation"}] [{"count":1},{"details":"cannot delete a row <0> because of 1 remaining reference(s)","error":"referential integrity violation"}] [{"count":1},{"details":"cannot delete b row <1> because of 1 remaining reference(s)","error":"referential integrity violation"}] [{"count":1},{"count":1}] ]])]) EXECUTION_EXAMPLES