ovsdb: Add support for referential integrity in the database itself.
[cascardo/ovs.git] / tests / ovsdb-idl.at
index 0be2a11..552f627 100644 (file)
@@ -227,55 +227,58 @@ OVSDB_CHECK_IDL([self-linking idl, inconsistent ops],
   [['[{"op": "insert",
        "table": "link1",
        "row": {"i": 0, "k": ["uuid", "cf197cc5-c8c9-42f5-82d5-c71a9f2cb96b"]}}]' \
-     '[{"op": "update",
+    '+[{"op": "insert",
        "table": "link1",
-       "where": [],
-       "row": {"k": ["uuid", "#0#"]}}]' \
+       "uuid-name": "one",
+       "row": {"i": 1, "k": ["named-uuid", "one"]}},
+      {"op": "insert",
+       "table": "link1",
+       "row": {"i": 2, "k": ["named-uuid", "one"]}}]' \
      '[{"op": "update",
        "table": "link1",
        "where": [],
        "row": {"k": ["uuid", "c2fca39a-e69a-42a4-9c56-5eca85839ce9"]}}]' \
-     '[{"op": "insert",
+     '+[{"op": "delete",
        "table": "link1",
-       "row": {"i": 1, "k": ["uuid", "52d752a3-b062-4668-9446-d2e0d4a14703"]}}]' \
-     '[{"op": "update",
+       "where": [["_uuid", "==", ["uuid", "#1#"]]]}]' \
+     '+[{"op": "delete",
        "table": "link1",
-       "where": [],
-       "row": {"k": ["uuid", "#1#"]}}]' \
+       "where": [["_uuid", "==", ["uuid", "#2#"]]]}]' \
+     '[{"op": "delete",
+       "table": "link1",
+       "where": []}]' \
 ]],
   [[000: empty
-001: {"error":null,"result":[{"uuid":["uuid","<0>"]}]}
-002: i=0 k= ka=[] l2= uuid=<0>
-003: {"error":null,"result":[{"count":1}]}
-004: i=0 k=0 ka=[] l2= uuid=<0>
-005: {"error":null,"result":[{"count":1}]}
-006: i=0 k= ka=[] l2= uuid=<0>
-007: {"error":null,"result":[{"uuid":["uuid","<1>"]}]}
-008: i=0 k= ka=[] l2= uuid=<0>
-008: i=1 k= ka=[] l2= uuid=<1>
-009: {"error":null,"result":[{"count":2}]}
-010: i=0 k=1 ka=[] l2= uuid=<0>
-010: i=1 k=1 ka=[] l2= uuid=<1>
-011: done
+001: {"error":null,"result":[{"uuid":["uuid","<0>"]},{"details":"reference to nonexistent row <1>","error":"referential integrity violation"}]}
+002: {"error":null,"result":[{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]}]}
+003: i=1 k=1 ka=[] l2= uuid=<2>
+003: i=2 k=1 ka=[] l2= uuid=<3>
+004: {"error":null,"result":[{"count":2},{"details":"reference to nonexistent row <4>","error":"referential integrity violation"}]}
+005: {"error":null,"result":[{"count":1},{"details":"cannot delete link1 row <2> because of 1 remaining reference(s)","error":"referential integrity violation"}]}
+006: {"error":null,"result":[{"count":1}]}
+007: i=1 k=1 ka=[] l2= uuid=<2>
+008: {"error":null,"result":[{"count":1}]}
+009: empty
+010: done
 ]])
 
 OVSDB_CHECK_IDL([self-linking idl, sets],
   [],
   [['[{"op": "insert",
        "table": "link1",
-       "row": {"i": 0, "ka": ["set", [["named-uuid", "i0"]]]},
+       "row": {"i": 0, "k": ["named-uuid", "i0"], "ka": ["set", [["named-uuid", "i0"]]]},
        "uuid-name": "i0"},
       {"op": "insert",
        "table": "link1",
-       "row": {"i": 1, "ka": ["set", [["named-uuid", "i1"]]]},
+       "row": {"i": 1, "k": ["named-uuid", "i0"], "ka": ["set", [["named-uuid", "i1"]]]},
        "uuid-name": "i1"},
       {"op": "insert",
        "table": "link1",
-       "row": {"i": 2, "ka": ["set", [["named-uuid", "i2"]]]},
+       "row": {"i": 2, "k": ["named-uuid", "i0"], "ka": ["set", [["named-uuid", "i2"]]]},
        "uuid-name": "i2"},
       {"op": "insert",
        "table": "link1",
-       "row": {"i": 3, "ka": ["set", [["named-uuid", "i3"]]]},
+       "row": {"i": 3, "k": ["named-uuid", "i0"], "ka": ["set", [["named-uuid", "i3"]]]},
        "uuid-name": "i3"}]' \
     '[{"op": "update",
        "table": "link1",
@@ -284,24 +287,25 @@ OVSDB_CHECK_IDL([self-linking idl, sets],
     '[{"op": "update",
        "table": "link1",
        "where": [],
-       "row": {"ka": ["set", [["uuid", "#0#"], ["uuid", "88702e78-845b-4a6e-ad08-cf68922ae84a"], ["uuid", "#2#"], ["uuid", "1ac2b12e-b767-4805-a55d-43976e40c465"]]]}}]']],
+       "row": {"ka": ["set", [["uuid", "#0#"], ["uuid", "88702e78-845b-4a6e-ad08-cf68922ae84a"], ["uuid", "#2#"], ["uuid", "1ac2b12e-b767-4805-a55d-43976e40c465"]]]}}]' \
+    '+[{"op": "delete",
+       "table": "link1",
+       "where": []}]']],
   [[000: empty
 001: {"error":null,"result":[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]}]}
-002: i=0 k= ka=[0] l2= uuid=<0>
-002: i=1 k= ka=[1] l2= uuid=<1>
-002: i=2 k= ka=[2] l2= uuid=<2>
-002: i=3 k= ka=[3] l2= uuid=<3>
+002: i=0 k=0 ka=[0] l2= uuid=<0>
+002: i=1 k=0 ka=[1] l2= uuid=<1>
+002: i=2 k=0 ka=[2] l2= uuid=<2>
+002: i=3 k=0 ka=[3] l2= uuid=<3>
 003: {"error":null,"result":[{"count":4}]}
-004: i=0 k= ka=[0 1 2 3] l2= uuid=<0>
-004: i=1 k= ka=[0 1 2 3] l2= uuid=<1>
-004: i=2 k= ka=[0 1 2 3] l2= uuid=<2>
-004: i=3 k= ka=[0 1 2 3] l2= uuid=<3>
-005: {"error":null,"result":[{"count":4}]}
-006: i=0 k= ka=[0 2] l2= uuid=<0>
-006: i=1 k= ka=[0 2] l2= uuid=<1>
-006: i=2 k= ka=[0 2] l2= uuid=<2>
-006: i=3 k= ka=[0 2] l2= uuid=<3>
-007: done
+004: i=0 k=0 ka=[0 1 2 3] l2= uuid=<0>
+004: i=1 k=0 ka=[0 1 2 3] l2= uuid=<1>
+004: i=2 k=0 ka=[0 1 2 3] l2= uuid=<2>
+004: i=3 k=0 ka=[0 1 2 3] l2= uuid=<3>
+005: {"error":null,"result":[{"count":4},{"details":"reference to nonexistent row <4>","error":"referential integrity violation"}]}
+006: {"error":null,"result":[{"count":4}]}
+007: empty
+008: done
 ]])
 
 OVSDB_CHECK_IDL([external-linking idl, consistent ops],
@@ -312,11 +316,11 @@ OVSDB_CHECK_IDL([external-linking idl, consistent ops],
        "uuid-name": "row0"},
       {"op": "insert",
        "table": "link1",
-       "row": {"i": 1, "l2": ["set", [["named-uuid", "row0"]]]},
+       "row": {"i": 1, "k": ["named-uuid", "row1"], "l2": ["set", [["named-uuid", "row0"]]]},
        "uuid-name": "row1"}]']],
   [[000: empty
 001: {"error":null,"result":[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}]}
 002: i=0 l1= uuid=<0>
-002: i=1 k= ka=[] l2=0 uuid=<1>
+002: i=1 k=1 ka=[] l2=0 uuid=<1>
 003: done
 ]])