X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=tests%2Fovsdb-execution.at;h=334e20848dc542a193ae92446af917e13db6d827;hb=0d0f05b909b6428d44eb147bd4edd73782d2a137;hp=3a360416afd0acc460613d002ee282b34a62bda3;hpb=e9f8f9367e9e654b9582279608af86ea3744a2a0;p=openvswitch diff --git a/tests/ovsdb-execution.at b/tests/ovsdb-execution.at index 3a360416..334e2084 100644 --- a/tests/ovsdb-execution.at +++ b/tests/ovsdb-execution.at @@ -8,6 +8,28 @@ m4_define([ORDINAL_SCHEMA], "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 @@ -23,7 +45,7 @@ m4_define([ORDINAL_SCHEMA], m4_define([OVSDB_CHECK_EXECUTION], [AT_SETUP([$1]) AT_KEYWORDS([ovsdb execute execution positive $5]) - OVS_CHECK_LCOV([test-ovsdb execute '$2' m4_foreach([txn], [$3], [ 'txn'])], + AT_CHECK([test-ovsdb execute '$2' m4_foreach([txn], [$3], [ 'txn'])], [0], [stdout], []) AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0], [$4]) AT_CLEANUP]) @@ -352,6 +374,120 @@ OVSDB_CHECK_EXECUTION([inequality wait with missing row], "rows": [{"name": "one", "number": 1}]}]]]], [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{}] ]]) -]) + +OVSDB_CHECK_EXECUTION([insert and update constraints], + [CONSTRAINT_SCHEMA], + [[[[{"op": "insert", + "table": "constrained", + "row": {}}]]], + [[[{"op": "insert", + "table": "constrained", + "row": {"positive": -1}}]]], + [[[{"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], + [[[[{"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"]]]}}]]], + [[[{"op": "delete", + "table": "b", + "where": []}]]], + [[[{"op": "delete", + "table": "a", + "where": [["a", "==", 0]]}]]], + [[[{"op": "delete", + "table": "b", + "where": []}]]], + [[[{"op": "delete", + "table": "a", + "where": [["a", "==", 1]]}]]], + [[[{"op": "delete", + "table": "b", + "where": []}]]], + [[[{"op": "delete", + "table": "a", + "where": [["a", "==", 2]]}]]], + [[[{"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], + [[[[{"op": "declare", + "uuid-name": "row1"}, + {"op": "declare", + "uuid-name": "row2"}, + {"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"}]]], + [[[{"op": "insert", + "table": "a", + "row": {"a2b": ["set", [["uuid", "b516b960-5b19-4fc2-bb82-fe1cbd6d0241"]]]}}]]], + [[[{"op": "delete", + "table": "a", + "where": [["a", "==", 0]]}]]], + [[[{"op": "delete", + "table": "b", + "where": [["b", "==", 1]]}]]], + dnl Try the deletions again to make sure that the refcounts got rolled back. + [[[{"op": "delete", + "table": "a", + "where": [["a", "==", 0]]}]]], + [[[{"op": "delete", + "table": "b", + "where": [["b", "==", 1]]}]]], + [[[{"op": "delete", + "table": "a", + "where": [["a", "==", 0]]}, + {"op": "delete", + "table": "b", + "where": [["b", "==", 1]]}]]]], + [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<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