diff options
author | Mario Cabrera <mario.cabrera@hpe.com> | 2016-03-29 11:01:00 -0600 |
---|---|---|
committer | Ben Pfaff <blp@ovn.org> | 2016-06-24 17:15:38 -0700 |
commit | 7a9d65d294c903ef77191cd143a467a5a1e8d3ac (patch) | |
tree | 3f62a2d8d21ae655a15c22e78804d101b4ea3320 /tests | |
parent | ae671c5feb88db395304e452ab47c83b4ac84ee0 (diff) | |
download | openvswitch-7a9d65d294c903ef77191cd143a467a5a1e8d3ac.tar.gz |
ovsdb: Add table exclusion functionality to OVSDB replication
A blacklist of tables that will be excluded from replication can be
specified by the following option:
--sync-exclude-tables=db:table[,db:table]…
Where 'table' corresponds to a table name, and 'db' corresponds to the
database name where the table resides.
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/automake.mk | 1 | ||||
-rw-r--r-- | tests/ovsdb-replication.at | 174 | ||||
-rw-r--r-- | tests/ovsdb-server.at | 56 | ||||
-rw-r--r-- | tests/ovsdb.at | 1 |
4 files changed, 232 insertions, 0 deletions
diff --git a/tests/automake.mk b/tests/automake.mk index 777f6db74..8b24221ae 100644 --- a/tests/automake.mk +++ b/tests/automake.mk @@ -75,6 +75,7 @@ TESTSUITE_AT = \ tests/ovsdb-execution.at \ tests/ovsdb-trigger.at \ tests/ovsdb-tool.at \ + tests/ovsdb-replication.at \ tests/ovsdb-server.at \ tests/ovsdb-monitor.at \ tests/ovsdb-idl.at \ diff --git a/tests/ovsdb-replication.at b/tests/ovsdb-replication.at new file mode 100644 index 000000000..bd96ae78d --- /dev/null +++ b/tests/ovsdb-replication.at @@ -0,0 +1,174 @@ +AT_BANNER([OVSDB -- replication]) + +m4_divert_push([PREPARE_TESTS]) +[ +replication_schema () { + cat <<'EOF' + {"name": "mydb", + "tables": { + "a": { + "columns": { + "number": {"type": "integer"}, + "name": {"type": "string"}}, + "indexes": [["number"]]}, + "b": { + "columns": { + "number": {"type": "integer"}, + "name": {"type": "string"}}, + "indexes": [["number"]]}} + } +EOF +} +] +m4_divert_pop([PREPARE_TESTS]) + +m4_define([REPLICATION_EXAMPLES], [ + +OVSDB_CHECK_REPLICATION([insert monitored table, insert excluded table], + [replication_schema], + [[[["mydb", + {"op": "insert", + "table": "a", + "row": {"number": 0, "name": "zero"}}]]], + [[["mydb", + {"op": "insert", + "table": "b", + "row": {"number": 1, "name": "one"}}]]]], + [[7,9c7,8 +< _uuid name number +< ------------------------------------ ---- ------ +< <0> one 1 @&t@ +--- +> _uuid name number +> ----- ---- ------]] +) + +OVSDB_CHECK_REPLICATION([insert monitored table, update excluded table], + [replication_schema], + [[[["mydb", + {"op": "insert", + "table": "a", + "row": {"number": 0, "name": "zero"}}]]], + [[["mydb", + {"op": "insert", + "table": "b", + "row": {"number": 1, "name": "one"}}]]], + [[["mydb", + {"op": "update", + "table": "b", + "where":[["name","==","one"]], + "row": {"number": 2, "name": "two"}}]]]], + [[7,9c7,8 +< _uuid name number +< ------------------------------------ ---- ------ +< <0> two 2 @&t@ +--- +> _uuid name number +> ----- ---- ------]] +) + +OVSDB_CHECK_REPLICATION([update monitored table, insert excluded table], + [replication_schema], + [[[["mydb", + {"op": "insert", + "table": "a", + "row": {"number": 0, "name": "zero"}}]]], + [[["mydb", + {"op": "update", + "table": "a", + "where":[["name","==","zero"]], + "row": {"number": 1, "name": "one"}}]]], + [[["mydb", + {"op": "insert", + "table": "b", + "row": {"number": 2, "name": "two"}}]]]], + [[7,9c7,8 +< _uuid name number +< ------------------------------------ ---- ------ +< <0> two 2 @&t@ +--- +> _uuid name number +> ----- ---- ------]] +) + +OVSDB_CHECK_REPLICATION([update monitored table, update excluded table], + [replication_schema], + [[[["mydb", + {"op": "insert", + "table": "a", + "row": {"number": 0, "name": "zero"}}]]], + [[["mydb", + {"op": "update", + "table": "a", + "where":[["name","==","zero"]], + "row": {"number": 1, "name": "one"}}]]], + [[["mydb", + {"op": "insert", + "table": "b", + "row": {"number": 2, "name": "two"}}]]], + [[["mydb", + {"op": "update", + "table": "b", + "where":[["name","==","two"]], + "row": {"number": 3, "name": "three"}}]]]], + [[7,9c7,8 +< _uuid name number +< ------------------------------------ ----- ------ +< <0> three 3 @&t@ +--- +> _uuid name number +> ----- ---- ------]] +) + +OVSDB_CHECK_REPLICATION([delete monitored table, insert excluded table], + [replication_schema], + [[[["mydb", + {"op": "insert", + "table": "a", + "row": {"number": 0, "name": "zero"}}]]], + [[["mydb", + {"op": "delete", + "table": "a", + "where":[["name","==","zero"]]}]]], + [[["mydb", + {"op": "insert", + "table": "b", + "row": {"number": 1, "name": "one"}}]]]], + [[6,8c6,7 +< _uuid name number +< ------------------------------------ ---- ------ +< <0> one 1 @&t@ +--- +> _uuid name number +> ----- ---- ------]] +) + +OVSDB_CHECK_REPLICATION([delete monitored table, update excluded table], + [replication_schema], + [[[["mydb", + {"op": "insert", + "table": "a", + "row": {"number": 0, "name": "zero"}}]]], + [[["mydb", + {"op": "delete", + "table": "a", + "where":[["name","==","zero"]]}]]], + [[["mydb", + {"op": "insert", + "table": "b", + "row": {"number": 1, "name": "one"}}]]], + [[["mydb", + {"op": "update", + "table": "b", + "where":[["name","==","one"]], + "row": {"number": 2, "name": "two"}}]]]], + [[6,8c6,7 +< _uuid name number +< ------------------------------------ ---- ------ +< <0> two 2 @&t@ +--- +> _uuid name number +> ----- ---- ------]] +) + +]) diff --git a/tests/ovsdb-server.at b/tests/ovsdb-server.at index 30140462b..299e53774 100644 --- a/tests/ovsdb-server.at +++ b/tests/ovsdb-server.at @@ -1023,3 +1023,59 @@ m4_define([OVSDB_CHECK_EXECUTION], AT_CLEANUP]) EXECUTION_EXAMPLES + +AT_BANNER([OVSDB -- ovsdb-server replication table-exclusion (TCP IPv4 sockets)]) + +# OVSDB_CHECK_REPLICATION(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 difference between the dump of the databases 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_REPLICATION], + [AT_SETUP([$1]) + AT_KEYWORDS([ovsdb server tcp replication table-exclusion]) + $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 --sync-exclude-tables=mydb:b 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], [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], [$4], [ignore], + [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`]) + + OVSDB_SERVER_SHUTDOWN + OVSDB_SERVER_SHUTDOWN2 + AT_CLEANUP]) + +REPLICATION_EXAMPLES diff --git a/tests/ovsdb.at b/tests/ovsdb.at index 500071334..b20ab9e4b 100644 --- a/tests/ovsdb.at +++ b/tests/ovsdb.at @@ -143,6 +143,7 @@ m4_include([tests/ovsdb-transaction.at]) m4_include([tests/ovsdb-execution.at]) m4_include([tests/ovsdb-trigger.at]) m4_include([tests/ovsdb-tool.at]) +m4_include([tests/ovsdb-replication.at]) m4_include([tests/ovsdb-server.at]) m4_include([tests/ovsdb-monitor.at]) m4_include([tests/ovsdb-idl.at]) |