ovsdb-data: Verify that named-uuid string is an <id>.
[sliver-openvswitch.git] / tests / ovsdb-execution.at
index dc4f3e8..47be193 100644 (file)
@@ -6,7 +6,9 @@ m4_define([ORDINAL_SCHEMA],
        "ordinals": {
          "columns": {
            "number": {"type": "integer"},
-           "name": {"type": "string"}}}}}]])
+           "name": {"type": "string"}}}},
+     "version": "5.1.3",
+     "cksum": "12345678 9"}]])
 
 m4_define([CONSTRAINT_SCHEMA],
   [[{"name": "constraints",
@@ -28,7 +30,8 @@ m4_define([CONSTRAINT_SCHEMA],
        "constrained": {
          "columns": {
            "positive": {"type": {"key": {"type": "integer",
-                                         "minInteger": 1}}}}}}}]])
+                                         "minInteger": 1}}}},
+         "maxRows": 1}}}]])
 
 m4_define([WEAK_SCHEMA],
   [[{"name": "weak",
@@ -74,6 +77,25 @@ m4_define([OVSDB_CHECK_EXECUTION],
    AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0], [$4])
    AT_CLEANUP])
 
+OVSDB_CHECK_EXECUTION([uuid-name must be <id>],
+  [CONSTRAINT_SCHEMA],
+  [[[["constraints",
+      {"op": "insert",
+       "table": "a",
+       "row": {},
+       "uuid-name": "0"}]]]],
+  [[[{"details":"Parsing ovsdb operation 1 of 1 failed: Type mismatch for member 'uuid-name'.","error":"syntax error","syntax":"{\"op\":\"insert\",\"row\":{},\"table\":\"a\",\"uuid-name\":\"0\"}"}]
+]])
+
+OVSDB_CHECK_EXECUTION([named-uuid must be <id>],
+  [CONSTRAINT_SCHEMA],
+  [[[["constraints",
+      {"op": "insert",
+       "table": "a",
+       "row": {"a2a": ["named-uuid", "0"]}}]]]],
+  [[[{"details":"named-uuid string is not a valid <id>","error":"syntax error","syntax":"[\"named-uuid\",\"0\"]"}]
+]])
+
 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.
@@ -462,10 +484,20 @@ OVSDB_CHECK_EXECUTION([insert and update constraints],
       {"op": "update",
        "table": "constrained",
        "where": [],
-       "row": {"positive": -2}}]]]],
+       "row": {"positive": -2}}]]],
+   [[["constraints",
+      {"op": "insert",
+       "table": "constrained",
+       "row": {"positive": 1}}]]],
+   [[["constraints",
+      {"op": "insert",
+       "table": "constrained",
+       "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"}]
+[{"uuid":["uuid","<0>"]}]
+[{"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"}]
 ]])
 
 OVSDB_CHECK_EXECUTION([referential integrity -- simple],
@@ -569,7 +601,7 @@ OVSDB_CHECK_EXECUTION([referential integrity -- mutual references],
        "table": "b",
        "where": [["b", "==", 1]]}]]]],
   [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}]
-[{"uuid":["uuid","<2>"]},{"details":"reference to nonexistent row <3>","error":"referential integrity violation"}]
+[{"uuid":["uuid","<2>"]},{"details":"Table a column a2b row <2> references nonexistent row <3> in table b.","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"}]
@@ -633,7 +665,8 @@ OVSDB_CHECK_EXECUTION([weak references],
    [[["weak",
       {"op": "insert",
        "table": "a",
-       "row": {}}]]],
+       "row": {"a2a1": ["named-uuid", "me"]},
+       "uuid-name": "me"}]]],
    dnl Try to delete row from "b" that is referred to by weak references
    dnl from "a" table "a2b" column that requires exactly one value.
    [[["weak",