Catalli's threaded switch
[sliver-openvswitch.git] / tests / ovsdb-idl.at
index 0ce6535..b184e9d 100644 (file)
@@ -1,6 +1,7 @@
 AT_BANNER([OVSDB -- interface description language (IDL)])
 
-# OVSDB_CHECK_IDL(TITLE, [PRE-IDL-TXN], TRANSACTIONS, OUTPUT, [KEYWORDS])
+# OVSDB_CHECK_IDL(TITLE, [PRE-IDL-TXN], TRANSACTIONS, OUTPUT, [KEYWORDS],
+#                 [FILTER])
 #
 # Creates a database with a schema derived from idltest.ovsidl, runs
 # each PRE-IDL-TXN (if any), starts an ovsdb-server on that database,
@@ -11,31 +12,23 @@ AT_BANNER([OVSDB -- interface description language (IDL)])
 # by markers of the form <N> 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.
+# marker.  If FILTER is supplied then the output is also filtered
+# through the specified program.
 #
 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
 m4_define([OVSDB_CHECK_IDL], 
   [AT_SETUP([$1])
    AT_KEYWORDS([ovsdb server idl positive $5])
-   OVS_CHECK_LCOV(
-     [SCHEMA=$abs_builddir/idltest.ovsschema
-      if test ! -e $SCHEMA; then
-        SCHEMA=$abs_srcdir/idltest.ovsschema
-          if test ! -e $SCHEMA; then
-            echo 'Failed to find idltest.ovsschema'
-            exit 1
-          fi
-      fi
-      ovsdb-tool create db $SCHEMA],
-     [0], [stdout], [ignore])
-   AT_CHECK([ovsdb-server '-vPATTERN:console:ovsdb-server|%c|%m' --detach --pidfile=$PWD/server-pid --remote=punix:socket --unixctl=$PWD/unixctl db], [0], [ignore], [ignore])
+   AT_CHECK([ovsdb-tool create db $abs_srcdir/idltest.ovsschema],
+                  [0], [stdout], [ignore])
+   AT_CHECK([ovsdb-server '-vPATTERN:console:ovsdb-server|%c|%m' --detach --pidfile=$PWD/pid --remote=punix:socket --unixctl=$PWD/unixctl db], [0], [ignore], [ignore])
    m4_if([$2], [], [],
-     [OVS_CHECK_LCOV([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore], [kill `cat server-pid`])])
+     [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore], [kill `cat pid`])])
    AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 idl unix:socket $3], 
-            [0], [stdout], [ignore], [kill `cat server-pid`])
-   AT_CHECK([sort stdout | perl $srcdir/uuidfilt.pl], [0], [$4], [],
-            [kill `cat server-pid`])
-   kill `cat server-pid`
+            [0], [stdout], [ignore], [kill `cat pid`])
+   AT_CHECK([sort stdout | perl $srcdir/uuidfilt.pl]m4_if([$6],,, [[| $6]]),
+            [0], [$4], [], [kill `cat pid`])
+   OVSDB_SERVER_SHUTDOWN
    AT_CLEANUP])
 
 OVSDB_CHECK_IDL([simple idl, initially empty, no ops],
@@ -47,7 +40,8 @@ OVSDB_CHECK_IDL([simple idl, initially empty, no ops],
 
 OVSDB_CHECK_IDL([simple idl, initially empty, various ops],
   [],
-  [['[{"op": "insert",
+  [['["idltest",
+      {"op": "insert",
        "table": "simple",
        "row": {"i": 1,
                "r": 2.0,
@@ -63,15 +57,18 @@ OVSDB_CHECK_IDL([simple idl, initially empty, various ops],
       {"op": "insert",
        "table": "simple",
        "row": {}}]' \
-    '[{"op": "update",
+    '["idltest",
+      {"op": "update",
        "table": "simple",
        "where": [],
        "row": {"b": true}}]' \
-    '[{"op": "update",
+    '["idltest",
+      {"op": "update",
        "table": "simple",
        "where": [],
        "row": {"r": 123.5}}]' \
-    '[{"op": "insert",
+    '["idltest",
+      {"op": "insert",
        "table": "simple",
        "row": {"i": -1,
                "r": 125,
@@ -82,11 +79,13 @@ OVSDB_CHECK_IDL([simple idl, initially empty, various ops],
                "ba": ["set", [false]],
                "sa": ["set", []], 
                "ua": ["set", []]}}]' \
-    '[{"op": "update",
+    '["idltest",
+      {"op": "update",
        "table": "simple",
        "where": [["i", "<", 1]],
        "row": {"s": "newstring"}}]' \
-    '[{"op": "delete",
+    '["idltest",
+      {"op": "delete",
        "table": "simple",
        "where": [["i", "==", 0]]}]' \
     'reconnect']],
@@ -118,7 +117,8 @@ OVSDB_CHECK_IDL([simple idl, initially empty, various ops],
 ]])
 
 OVSDB_CHECK_IDL([simple idl, initially populated],
-  [['[{"op": "insert",
+  [['["idltest",
+      {"op": "insert",
        "table": "simple",
        "row": {"i": 1,
                "r": 2.0,
@@ -134,7 +134,8 @@ OVSDB_CHECK_IDL([simple idl, initially populated],
       {"op": "insert",
        "table": "simple",
        "row": {}}]']],
-  [['[{"op": "update",
+  [['["idltest",
+      {"op": "update",
        "table": "simple",
        "where": [],
        "row": {"b": true}}]']],
@@ -147,7 +148,8 @@ OVSDB_CHECK_IDL([simple idl, initially populated],
 ]])
 
 OVSDB_CHECK_IDL([simple idl, writing via IDL],
-  [['[{"op": "insert",
+  [['["idltest",
+      {"op": "insert",
        "table": "simple",
        "row": {"i": 1,
                "r": 2.0,
@@ -177,7 +179,8 @@ OVSDB_CHECK_IDL([simple idl, writing via IDL],
 ]])
 
 OVSDB_CHECK_IDL([simple idl, increment operation],
-  [['[{"op": "insert",
+  [['["idltest",
+      {"op": "insert",
        "table": "simple",
        "row": {}}]']],
   [['set 0 r 2.0, increment simple i']],
@@ -189,14 +192,12 @@ OVSDB_CHECK_IDL([simple idl, increment operation],
 
 OVSDB_CHECK_IDL([self-linking idl, consistent ops],
   [],
-  [['[{"op": "insert",
+  [['["idltest",
+      {"op": "insert",
        "table": "link1",
        "row": {"i": 0, "k": ["named-uuid", "self"]},
        "uuid-name": "self"}]' \
-    '[{"op": "declare",
-       "uuid-name": "row1"},
-      {"op": "declare",
-       "uuid-name": "row2"},
+    '["idltest",
       {"op": "insert",
        "table": "link1",
        "row": {"i": 1, "k": ["named-uuid", "row2"]},
@@ -205,18 +206,20 @@ OVSDB_CHECK_IDL([self-linking idl, consistent ops],
        "table": "link1",
        "row": {"i": 2, "k": ["named-uuid", "row1"]},
        "uuid-name": "row2"}]' \
-    '[{"op": "update",
+    '["idltest",
+      {"op": "update",
        "table": "link1",
        "where": [["i", "==", 1]],
        "row": {"k": ["uuid", "#1#"]}}]' \
-    '[{"op": "update",
+    '["idltest",
+      {"op": "update",
        "table": "link1",
        "where": [],
        "row": {"k": ["uuid", "#0#"]}}]']],
   [[000: empty
 001: {"error":null,"result":[{"uuid":["uuid","<0>"]}]}
 002: i=0 k=0 ka=[] l2= uuid=<0>
-003: {"error":null,"result":[{"uuid":"<1>"},{"uuid":"<2>"},{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]}]}
+003: {"error":null,"result":[{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]}]}
 004: i=0 k=0 ka=[] l2= uuid=<0>
 004: i=1 k=2 ka=[] l2= uuid=<1>
 004: i=2 k=1 ka=[] l2= uuid=<2>
@@ -233,99 +236,116 @@ OVSDB_CHECK_IDL([self-linking idl, consistent ops],
 
 OVSDB_CHECK_IDL([self-linking idl, inconsistent ops],
   [],
-  [['[{"op": "insert",
+  [['["idltest",
+      {"op": "insert",
        "table": "link1",
        "row": {"i": 0, "k": ["uuid", "cf197cc5-c8c9-42f5-82d5-c71a9f2cb96b"]}}]' \
-     '[{"op": "update",
+    '+["idltest",
+      {"op": "insert",
        "table": "link1",
-       "where": [],
-       "row": {"k": ["uuid", "#0#"]}}]' \
-     '[{"op": "update",
+       "uuid-name": "one",
+       "row": {"i": 1, "k": ["named-uuid", "one"]}},
+      {"op": "insert",
+       "table": "link1",
+       "row": {"i": 2, "k": ["named-uuid", "one"]}}]' \
+     '["idltest",
+      {"op": "update",
        "table": "link1",
        "where": [],
        "row": {"k": ["uuid", "c2fca39a-e69a-42a4-9c56-5eca85839ce9"]}}]' \
-     '[{"op": "insert",
+     '+["idltest",
+      {"op": "delete",
        "table": "link1",
-       "row": {"i": 1, "k": ["uuid", "52d752a3-b062-4668-9446-d2e0d4a14703"]}}]' \
-     '[{"op": "update",
+       "where": [["_uuid", "==", ["uuid", "#1#"]]]}]' \
+     '+["idltest",
+      {"op": "delete",
        "table": "link1",
-       "where": [],
-       "row": {"k": ["uuid", "#1#"]}}]' \
+       "where": [["_uuid", "==", ["uuid", "#2#"]]]}]' \
+     '["idltest",
+      {"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":"Table link1 column k row <0> references nonexistent row <1> in table link1.","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":"Table link1 column k row <x> references nonexistent row <4> in table link1.","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
+]],
+  [],
+  [[sed -e '/004:/s/row <[23]> references/row <x> references/']])
 
 OVSDB_CHECK_IDL([self-linking idl, sets],
   [],
-  [['[{"op": "insert",
+  [['["idltest",
+      {"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",
+    '["idltest",
+      {"op": "update",
        "table": "link1",
        "where": [],
        "row": {"ka": ["set", [["uuid", "#0#"], ["uuid", "#1#"], ["uuid", "#2#"], ["uuid", "#3#"]]]}}]' \
-    '[{"op": "update",
+    '["idltest",
+      {"op": "update",
        "table": "link1",
-       "where": [],
-       "row": {"ka": ["set", [["uuid", "#0#"], ["uuid", "88702e78-845b-4a6e-ad08-cf68922ae84a"], ["uuid", "#2#"], ["uuid", "1ac2b12e-b767-4805-a55d-43976e40c465"]]]}}]']],
+       "where": [["i", "==", 2]],
+       "row": {"ka": ["set", [["uuid", "#0#"], ["uuid", "88702e78-845b-4a6e-ad08-cf68922ae84a"], ["uuid", "#2#"]]]}}]' \
+    '+["idltest",
+      {"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":1},{"details":"Table link1 column ka row <2> references nonexistent row <4> in table link1.","error":"referential integrity violation"}]}
+006: {"error":null,"result":[{"count":4}]}
+007: empty
+008: done
 ]])
 
 OVSDB_CHECK_IDL([external-linking idl, consistent ops],
   [],
-  [['[{"op": "insert",
+  [['["idltest",
+      {"op": "insert",
        "table": "link2",
        "row": {"i": 0},
        "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
 ]])