Merge "next" branch into "master".
[openvswitch] / tests / ovsdb-server.at
index 0d8752423b8ecd009985e500ac2ea5ef7eb9851e..c32bc3a0defa32c09766d2b0fbec94ffce490b36 100644 (file)
@@ -1,5 +1,10 @@
 AT_BANNER([OVSDB -- ovsdb-server transactions (Unix sockets)])
 
+m4_define([OVSDB_SERVER_SHUTDOWN], 
+  [cp pid savepid
+   AT_CHECK([ovs-appctl -t $PWD/unixctl -e exit], [0], [ignore], [ignore])
+   OVS_WAIT_WHILE([kill -0 `cat savepid`], [kill `cat savepid`])])
+
 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
 #
 # Creates a database with the given SCHEMA, starts an ovsdb-server on
@@ -16,7 +21,7 @@ AT_BANNER([OVSDB -- ovsdb-server transactions (Unix sockets)])
 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
 m4_define([OVSDB_CHECK_EXECUTION], 
   [AT_SETUP([$1])
-   AT_KEYWORDS([ovsdb server positive $5])
+   AT_KEYWORDS([ovsdb server positive unix $5])
    AT_DATA([schema], [$2
 ])
    AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
@@ -28,11 +33,28 @@ cat stdout >> output
 ])
    AT_CHECK([perl $srcdir/uuidfilt.pl output], [0], [$4], [ignore],
             [test ! -e pid || kill `cat pid`])
-   test ! -e pid || kill `cat pid`
+   OVSDB_SERVER_SHUTDOWN
    AT_CLEANUP])
 
 EXECUTION_EXAMPLES
 \f
+AT_SETUP([database multiplexing implementation])
+AT_KEYWORDS([ovsdb server positive])
+AT_DATA([schema], [ORDINAL_SCHEMA
+])
+AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
+AT_CHECK([ovsdb-server --detach --pidfile=$PWD/pid --unixctl=$PWD/unixctl --remote=punix:socket db], [0], [ignore], [ignore])
+AT_CHECK(
+  [[ovsdb-client list-dbs unix:socket]], 
+  [0], [ordinals
+], [ignore], [test ! -e pid || kill `cat pid`])
+AT_CHECK(
+  [[ovsdb-client get-schema unix:socket nonexistent]], 
+  [1], [], [[ovsdb-client: syntax "{"syntax":"[\"nonexistent\"]","details":"get_schema request specifies unknown database nonexistent","error":"unknown database"}": syntax error: Parsing database schema failed: Required 'name' member is missing.
+]], [test ! -e pid || kill `cat pid`])
+OVSDB_SERVER_SHUTDOWN
+AT_CLEANUP
+
 AT_SETUP([--remote=db: implementation])
 AT_KEYWORDS([ovsdb server positive])
 AT_DATA([schema],
@@ -45,13 +67,15 @@ AT_DATA([schema],
 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
 AT_CHECK(
   [[ovsdb-tool transact db \
-     '[{"op": "insert",
+     '["mydb",
+       {"op": "insert",
         "table": "Manager",
         "row": {"manager": "punix:socket"}}]']], [0], [ignore], [ignore])
 AT_CHECK([ovsdb-server --detach --pidfile=$PWD/pid --remote=db:Manager,manager --unixctl=$PWD/unixctl db], [0], [ignore], [ignore])
 AT_CHECK(
   [[ovsdb-client transact unix:socket \
-     '[{"op": "select",
+     '["mydb",
+       {"op": "select",
         "table": "Manager",
         "where": [],
         "columns": ["manager"]}]']], 
@@ -63,7 +87,7 @@ AT_CHECK(
 ]], 
   [ignore], 
   [test ! -e pid || kill `cat pid`])
-test ! -e pid || kill `cat pid`
+OVSDB_SERVER_SHUTDOWN
 AT_CLEANUP
 \f
 AT_BANNER([OVSDB -- ovsdb-server transactions (SSL sockets)])
@@ -100,7 +124,43 @@ cat stdout >> output
 ])
    AT_CHECK([perl $srcdir/uuidfilt.pl output], [0], [$4], [ignore],
             [test ! -e pid || kill `cat pid`])
-   test ! -e pid || kill `cat pid`
+   OVSDB_SERVER_SHUTDOWN
+   AT_CLEANUP])
+
+EXECUTION_EXAMPLES
+\f
+AT_BANNER([OVSDB -- transactions on transient ovsdb-server])
+
+# OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
+#
+# Creates a database with the given SCHEMA and runs each of the
+# TRANSACTIONS (which should be a quoted list of quoted strings)
+# against it with ovsdb-client one at a time.  Each ovsdb-client
+# is run against a separately started ovsdb-server that executes
+# only that single transaction.  (The idea is that this should
+# help to ferret out any differences between what ovsdb-server has
+# in memory and what actually gets committed to disk.)
+#
+# Checks that the overall output is OUTPUT, but UUIDs in the output
+# are replaced 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.
+#
+# TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
+m4_define([OVSDB_CHECK_EXECUTION], 
+  [AT_SETUP([$1])
+   AT_KEYWORDS([ovsdb server positive transient $5])
+   AT_DATA([schema], [$2
+])
+   AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
+   m4_foreach([txn], [$3], 
+     [AT_DATA([txnfile], [ovsdb-client transact unix:socket 'txn'
+])
+      AT_CHECK([ovsdb-server --remote=punix:socket --unixctl=$PWD/unixctl db --run="sh txnfile"], [0], [stdout], [ignore])
+      cat stdout >> output
+])
+   AT_CHECK([perl $srcdir/uuidfilt.pl output], [0], [$4], [ignore])
    AT_CLEANUP])
 
 EXECUTION_EXAMPLES