ovsdb: Add unixctl commands for OVSDB replication
[cascardo/ovs.git] / tests / ovsdb-server.at
index 299e537..2f2ef99 100644 (file)
@@ -1079,3 +1079,192 @@ m4_define([OVSDB_CHECK_REPLICATION],
    AT_CLEANUP])
 
 REPLICATION_EXAMPLES
+
+AT_BANNER([OVSDB -- ovsdb-server replication runtime management commands])
+
+#ovsdb-server/get-remote-ovsdb-server command
+AT_SETUP([ovsdb-server/get-remote-ovsdb-server])
+AT_KEYWORDS([ovsdb server replication get-remote])
+ordinal_schema > schema
+AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
+on_exit 'kill `cat *.pid`'
+AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --sync-from=tcp:127.0.0.1:9999 db])
+
+AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/get-remote-ovsdb-server],
+  [0], [tcp:127.0.0.1:9999
+])
+AT_CLEANUP
+
+#*ovsdb-server/set-remote-ovsdb-server command
+AT_SETUP([ovsdb-server/set-remote-ovsdb-server])
+AT_KEYWORDS([ovsdb server replication set-remote])
+ordinal_schema > schema
+AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
+on_exit 'kill `cat *.pid`'
+AT_CHECK([ovsdb-server --detach --no-chdir --pidfile db])
+
+AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/set-remote-ovsdb-server tcp:127.0.0.1:9999])
+AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/get-remote-ovsdb-server],
+  [0], [tcp:127.0.0.1:9999
+])
+AT_CLEANUP
+
+#ovsdb-server/get-sync-excluded-tables command
+AT_SETUP([ovsdb-server/get-sync-excluded-tables])
+AT_KEYWORDS([ovsdb server replication get-excluded-tables])
+ordinal_schema > schema
+AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
+on_exit 'kill `cat *.pid`'
+AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --sync-exclude-tables=mydb:db1,mydb:db2 db])
+
+AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/get-sync-excluded-tables],
+  [0], [mydb:db2
+mydb:db1
+])
+AT_CLEANUP
+
+#ovsdb-server/set-sync-excluded-tables command
+AT_SETUP([ovsdb-server/set-sync-excluded-tables])
+AT_KEYWORDS([ovsdb server replication set-excluded-tables])
+replication_schema > schema
+AT_CHECK([ovsdb-tool create db1 schema], [0], [stdout], [ignore])
+AT_CHECK([ovsdb-tool create db2 schema], [0], [stdout], [ignore])
+
+AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server1.log --pidfile="`pwd`"/pid --remote=ptcp:0:127.0.0.1 --unixctl="`pwd`"/unixctl db1], [0], [ignore], [ignore])
+PARSE_LISTENING_PORT([ovsdb-server1.log], [TCP_PORT1])
+
+AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server2.log --pidfile="`pwd`"/pid2 --remote=ptcp:0:127.0.0.1 --unixctl="`pwd`"/unixctl2 --sync-from=tcp:127.0.0.1:$TCP_PORT1        db2], [0], [ignore], [ignore])
+PARSE_LISTENING_PORT([ovsdb-server2.log], [TCP_PORT2])
+
+AT_CHECK([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/set-sync-excluded-tables mydb:b], [0], [ignore], [ignore], [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
+
+AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT1 \
+ '[["mydb",
+    {"op": "insert",
+      "table": "a",
+      "row": {"number": 0, "name": "zero"}},
+    {"op": "insert",
+      "table": "b",
+      "row": {"number": 1, "name": "one"}}]]'], [0], [stdout], [ignore],
+ [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
+sleep 2
+
+AT_CHECK([ovsdb-client dump tcp:127.0.0.1:$TCP_PORT1], [0], [stdout], [ignore],
+ [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
+cat stdout >> dump1
+AT_CHECK([ovsdb-client dump tcp:127.0.0.1:$TCP_PORT2], [0], [stdout], [ignore],
+ [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
+cat stdout >> dump2
+
+AT_CHECK([diff dump1 dump2], [1], [stdout], [ignore],
+        [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
+cat stdout >> output
+
+AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [7,9c7,8
+< _uuid                                name number
+< ------------------------------------ ---- ------
+< <0> one  1     @&t@
+---
+> _uuid name number
+> ----- ---- ------
+], [ignore], [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
+
+OVSDB_SERVER_SHUTDOWN
+OVSDB_SERVER_SHUTDOWN2
+AT_CLEANUP
+
+#ovsdb-server/connect-remote-ovsdb-server
+AT_SETUP([ovsdb-server/connect-remote-server])
+AT_KEYWORDS([ovsdb server replication connect-remote-server])
+replication_schema > schema
+AT_CHECK([ovsdb-tool create db1 schema], [0], [stdout], [ignore])
+AT_CHECK([ovsdb-tool create db2 schema], [0], [stdout], [ignore])
+
+AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server1.log --pidfile="`pwd`"/pid --remote=ptcp:0:127.0.0.1 --unixctl="`pwd`"/unixctl db1], [0], [ignore], [ignore])
+PARSE_LISTENING_PORT([ovsdb-server1.log], [TCP_PORT1])
+
+AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server2.log --pidfile="`pwd`"/pid2 --remote=ptcp:0:127.0.0.1 --unixctl="`pwd`"/unixctl2 db2], [0], [ignore], [ignore])
+PARSE_LISTENING_PORT([ovsdb-server2.log], [TCP_PORT2])
+
+AT_CHECK([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/set-remote-ovsdb-server tcp:127.0.0.1:$TCP_PORT1], [0], [ignore], [ignore], [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
+
+AT_CHECK([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/connect-remote-ovsdb-server], [0], [ignore], [ignore],
+        [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
+
+AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT1 \
+ '[["mydb",
+  {"op": "insert",
+   "table": "a",
+   "row": {},
+   "uuid-name": "0"}]]'], [0], [stdout], [ignore],
+ [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
+sleep 2
+
+AT_CHECK([ovsdb-client dump tcp:127.0.0.1:$TCP_PORT1], [0], [stdout], [ignore],
+ [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
+cat stdout >> dump1
+AT_CHECK([ovsdb-client dump tcp:127.0.0.1:$TCP_PORT2], [0], [stdout], [ignore],
+ [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
+cat stdout >> dump2
+
+AT_CHECK([diff dump1 dump2], [0], [], [ignore], [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
+OVSDB_SERVER_SHUTDOWN
+OVSDB_SERVER_SHUTDOWN2
+AT_CLEANUP
+
+#ovsdb-server/disconnect-remote-server command
+AT_SETUP([ovsbd-server/disconnect-remote-server])
+AT_KEYWORDS([ovsdb server replication disconnect-remote-server])
+replication_schema > schema
+AT_CHECK([ovsdb-tool create db1 schema], [0], [stdout], [ignore])
+AT_CHECK([ovsdb-tool create db2 schema], [0], [stdout], [ignore])
+
+AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server1.log --pidfile="`pwd`"/pid --remote=ptcp:0:127.0.0.1 --unixctl="`pwd`"/unixctl db1], [0], [ignore], [ignore])
+PARSE_LISTENING_PORT([ovsdb-server1.log], [TCP_PORT1])
+
+AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server2.log --pidfile="`pwd`"/pid2 --remote=ptcp:0:127.0.0.1 --unixctl="`pwd`"/unixctl2 --sync-from=tcp:127.0.0.1:$TCP_PORT1        db2], [0], [ignore], [ignore])
+PARSE_LISTENING_PORT([ovsdb-server2.log], [TCP_PORT2])
+
+AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT1 \
+'[["mydb",
+  {"op": "insert",
+   "table": "a",
+   "row": {"number": 0, "name": "zero"}}]]'], [0], [stdout], [ignore],
+[test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
+sleep 2
+
+AT_CHECK([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/disconnect-remote-ovsdb-server], [0], [ignore], [ignore],
+        [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
+
+AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT1 \
+'[["mydb",
+  {"op": "insert",
+   "table": "b",
+   "row": {"number": 1, "name": "one"}}]]'], [0], [stdout], [ignore],
+[test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
+sleep 2
+
+AT_CHECK([ovsdb-client dump tcp:127.0.0.1:$TCP_PORT1], [0], [stdout], [ignore],
+ [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
+cat stdout >> dump1
+
+AT_CHECK([ovsdb-client dump tcp:127.0.0.1:$TCP_PORT2], [0], [stdout], [ignore],
+ [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
+cat stdout >> dump2
+
+AT_CHECK([diff dump1 dump2], [1], [stdout], [ignore],
+        [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
+cat stdout >> output
+
+AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [7,9c7,8
+< _uuid                                name number
+< ------------------------------------ ---- ------
+< <0> one  1     @&t@
+---
+> _uuid name number
+> ----- ---- ------
+], [ignore], [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
+
+OVSDB_SERVER_SHUTDOWN
+OVSDB_SERVER_SHUTDOWN2
+AT_CLEANUP