summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMario Cabrera <mario.cabrera@hpe.com>2016-06-24 17:13:06 -0700
committerBen Pfaff <blp@ovn.org>2016-06-24 17:15:38 -0700
commitae671c5feb88db395304e452ab47c83b4ac84ee0 (patch)
tree209bc454a4b82ef2c0c316aad784349b6cdc15b1 /tests
parent55460ac526f2ec35708771151541ceb85a2b1557 (diff)
downloadopenvswitch-ae671c5feb88db395304e452ab47c83b4ac84ee0.tar.gz
ovsdb: Introduce OVSDB replication feature
Replication is enabled by using the following option when starting the database server: --sync-from=server Where 'server' can take any form described in the ovsdb-client(1) manpage as an active connection. If this option is specified, the replication process is immediately started. Signed-off-by: Mario Cabrera <mario.cabrera@hpe.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/ovsdb-server.at51
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/ovsdb-server.at b/tests/ovsdb-server.at
index 9da511d18..30140462b 100644
--- a/tests/ovsdb-server.at
+++ b/tests/ovsdb-server.at
@@ -3,6 +3,11 @@ AT_BANNER([OVSDB -- ovsdb-server transactions (Unix sockets)])
m4_define([OVSDB_SERVER_SHUTDOWN],
[OVS_APP_EXIT_AND_WAIT_BY_TARGET([`pwd`/unixctl], [`pwd`/pid])])
+m4_define([OVSDB_SERVER_SHUTDOWN2],
+ [cp pid2 savepid2
+ AT_CHECK([ovs-appctl -t "`pwd`"/unixctl2 -e exit], [0], [ignore], [ignore])
+ OVS_WAIT_WHILE([kill -0 `cat savepid2`], [kill `cat savepid2`])])
+
# OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
#
# Creates a database with the given SCHEMA, starts an ovsdb-server on
@@ -972,3 +977,49 @@ m4_define([OVSDB_CHECK_EXECUTION],
AT_CLEANUP])
EXECUTION_EXAMPLES
+
+AT_BANNER([OVSDB -- ovsdb-server replication (TCP IPv4 sockets)])
+
+# OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
+#
+# Creates two databases with the given SCHEMA, and starts an ovsdb-server on
+# each database.
+# Runs each of the TRANSACTIONS (which should be a quoted list of
+# quoted strings) against one of the servers with ovsdb-client one at a
+# time. The server replicates its database to the other ovsdb-server.
+#
+# Checks that the dump of both databases are the same.
+#
+# TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
+m4_define([OVSDB_CHECK_EXECUTION],
+ [AT_SETUP([$1])
+ AT_KEYWORDS([ovsdb server tcp replication $5])
+ $2 > 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])
+
+ m4_foreach([txn], [$3],
+ [AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT1 'txn'; sleep 2], [0], [stdout], [ignore],
+ [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
+ ])
+
+ 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])
+
+EXECUTION_EXAMPLES