summaryrefslogtreecommitdiff
path: root/tests/ovsdb-tool.at
diff options
context:
space:
mode:
authorBen Pfaff <blp@ovn.org>2017-12-31 21:15:58 -0800
committerBen Pfaff <blp@ovn.org>2018-03-24 12:04:53 -0700
commit1b1d2e6daa563cc91f974ffdc082fb3a8b424801 (patch)
tree9cc5df01b7af35962d5f40d0ffd8882fb277e047 /tests/ovsdb-tool.at
parent53178986d7fc86bcfc2f297b547a97ee71a21bb7 (diff)
downloadopenvswitch-1b1d2e6daa563cc91f974ffdc082fb3a8b424801.tar.gz
ovsdb: Introduce experimental support for clustered databases.
This commit adds support for OVSDB clustering via Raft. Please read ovsdb(7) for information on how to set up a clustered database. It is simple and boils down to running "ovsdb-tool create-cluster" on one server and "ovsdb-tool join-cluster" on each of the others and then starting ovsdb-server in the usual way on all of them. One you have a clustered database, you configure ovn-controller and ovn-northd to use it by pointing them to all of the servers, e.g. where previously you might have said "tcp:1.2.3.4" was the database server, now you say that it is "tcp:1.2.3.4,tcp:5.6.7.8,tcp:9.10.11.12". This also adds support for database clustering to ovs-sandbox. Acked-by: Justin Pettit <jpettit@ovn.org> Tested-by: aginwala <aginwala@asu.edu> Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'tests/ovsdb-tool.at')
-rw-r--r--tests/ovsdb-tool.at118
1 files changed, 116 insertions, 2 deletions
diff --git a/tests/ovsdb-tool.at b/tests/ovsdb-tool.at
index 1409a80c4..ab766be24 100644
--- a/tests/ovsdb-tool.at
+++ b/tests/ovsdb-tool.at
@@ -302,6 +302,22 @@ _uuid name number
OVS_APP_EXIT_AND_WAIT([ovsdb-server])
AT_CLEANUP
+AT_SETUP([ovsdb-tool unsupported cluster operations])
+AT_KEYWORDS([ovsdb file negative compact query transact convert])
+ordinal_schema > schema
+AT_CHECK([ovsdb-tool create-cluster db schema unix:s1.raft])
+AT_CHECK([ovsdb-tool compact db], [1], [], [ovsdb-tool: ovsdb error: db: cannot apply this operation to clustered database file
+])
+AT_CHECK([ovsdb-tool convert db schema], [1], [], [ovsdb-tool: ovsdb error: db: cannot apply this operation to clustered database file
+])
+AT_CHECK([ovsdb-tool needs-conversion db schema], [1], [], [ovsdb-tool: ovsdb error: db: cannot apply this operation to clustered database file
+])
+AT_CHECK([ovsdb-tool query db '[[]]'], [1], [], [ovsdb-tool: ovsdb error: db: cannot apply this operation to clustered database file
+])
+AT_CHECK([ovsdb-tool transact db '[[]]'], [1], [], [ovsdb-tool: ovsdb error: db: cannot apply this operation to clustered database file
+])
+AT_CLEANUP
+
AT_SETUP([ovsdb-tool schema-version, schema-cksum, schema-name])
AT_KEYWORDS([ovsdb file positive schema-version schema-cksum])
ordinal_schema > schema
@@ -313,8 +329,8 @@ AT_CHECK([ovsdb-tool schema-name schema], [0], [ordinals
])
AT_CLEANUP
-AT_SETUP([ovsdb-tool db-version, db-cksum, db-name])
-AT_KEYWORDS([ovsdb file positive db-version db-cksum])
+AT_SETUP([ovsdb-tool database inspection commands - standalone])
+AT_KEYWORDS([ovsdb file positive db-version db-cksum db-name db-cid db-sid db-local-address])
ordinal_schema > schema
touch .db.~lock~
AT_CHECK([ovsdb-tool create db schema], [0], [], [ignore])
@@ -324,6 +340,61 @@ AT_CHECK([ovsdb-tool db-cksum db], [0], [12345678 9
])
AT_CHECK([ovsdb-tool db-name db], [0], [ordinals
])
+AT_CHECK([ovsdb-tool db-cid db], [1], [], [ovsdb-tool: db: not a clustered database
+])
+AT_CHECK([ovsdb-tool db-sid db], [1], [], [ovsdb-tool: db: not a clustered database
+])
+AT_CHECK([ovsdb-tool db-local-address db], [1], [], [ovsdb-tool: db: not a clustered database
+])
+AT_CLEANUP
+
+AT_SETUP([ovsdb-tool database inspection commands - clustered])
+AT_KEYWORDS([ovsdb file negative db-version db-cksum db-name db-cid db-sid db-local-address cluster])
+ordinal_schema > schema
+touch .db.~lock~
+AT_CHECK([ovsdb-tool create-cluster db schema tcp:1.2.3.4:1234])
+AT_CHECK([ovsdb-tool db-version db], [1], [], [ovsdb-tool: ovsdb error: db: cannot apply this operation to clustered database file
+])
+AT_CHECK([ovsdb-tool db-cksum db], [1], [], [ovsdb-tool: ovsdb error: db: cannot apply this operation to clustered database file
+])
+AT_CHECK([ovsdb-tool db-name db], [0], [ordinals
+])
+AT_CHECK([(ovsdb-tool db-cid db; ovsdb-tool db-sid db) | uuidfilt], [0], [<0>
+<1>
+])
+AT_CHECK([ovsdb-tool db-local-address db], [0], [tcp:1.2.3.4:1234
+])
+AT_CLEANUP
+
+AT_SETUP([ovsdb-tool database inspection commands - joining a cluster])
+AT_KEYWORDS([ovsdb file positive db-version db-cksum db-name db-cid db-sid db-local-address cluster join joining])
+ordinal_schema > schema
+touch .db.~lock~
+for cid in '' 520cf525-3772-43cc-8268-23bf5b548cf4; do
+ if test -z "$cid"; then
+ cid_option=
+ else
+ cid_option=--cid=$cid
+ fi
+ AT_CHECK([rm -f db && ovsdb-tool $cid_option join-cluster db ordinals tcp:1.2.3.4:1234 tcp:2.3.4.5:1234], [0], [], [ignore])
+ AT_CHECK([ovsdb-tool db-version db], [1], [], [ovsdb-tool: ovsdb error: db: cannot apply this operation to clustered database file
+])
+ AT_CHECK([ovsdb-tool db-cksum db], [1], [], [ovsdb-tool: ovsdb error: db: cannot apply this operation to clustered database file
+])
+ AT_CHECK([ovsdb-tool db-name db], [0], [ordinals
+])
+ if test -z "$cid"; then
+ AT_CHECK([ovsdb-tool db-cid db], [2], [], [db: cluster ID not yet known
+])
+ else
+ AT_CHECK_UNQUOTED([ovsdb-tool db-cid db], [0], [$cid
+])
+ fi
+ AT_CHECK([ovsdb-tool db-sid db | uuidfilt], [0], [<0>
+])
+ AT_CHECK([ovsdb-tool db-local-address db], [0], [tcp:1.2.3.4:1234
+])
+done
AT_CLEANUP
AT_SETUP([ovsdb-tool needs-conversion (no conversion needed)])
@@ -345,3 +416,46 @@ AT_CHECK([diff schema schema2], [1], [ignore])
AT_CHECK([ovsdb-tool needs-conversion db schema2], [0], [yes
])
AT_CLEANUP
+
+AT_SETUP([ovsdb-tool create-cluster with initial data])
+AT_KEYWORDS([ovsdb file positive])
+
+# Create a standalone database and put some data in it.
+ordinal_schema > schema
+ovsdb-tool create db1 schema
+AT_CHECK(
+ [[for pair in 'zero 0' 'one 1' 'two 2' 'three 3' 'four 4' 'five 5'; do
+ set -- $pair
+ ovsdb-tool transact db1 '
+ ["ordinals",
+ {"op": "insert",
+ "table": "ordinals",
+ "row": {"name": "'$1'", "number": '$2'}},
+ {"op": "comment",
+ "comment": "add row for '"$pair"'"}]'
+ done | uuidfilt]], [0],
+[[[{"uuid":["uuid","<0>"]},{}]
+[{"uuid":["uuid","<1>"]},{}]
+[{"uuid":["uuid","<2>"]},{}]
+[{"uuid":["uuid","<3>"]},{}]
+[{"uuid":["uuid","<4>"]},{}]
+[{"uuid":["uuid","<5>"]},{}]
+]], [ignore])
+
+# Dump the data.
+AT_CHECK([ovsdb-server -vfile -vvlog:off --monitor --detach --no-chdir --pidfile --log-file --remote=punix:db.sock db1])
+AT_CHECK([ovsdb-client dump > expout])
+OVS_APP_EXIT_AND_WAIT([ovsdb-server])
+
+# Create a clustered database from the standalone one.
+ovsdb-tool create-cluster db2 db1 unix:s1.raft
+
+# Dump the data.
+AT_CHECK([ovsdb-server -vconsole:off -vfile -vvlog:off --monitor --detach --no-chdir --pidfile --log-file --remote=punix:db.sock db2])
+AT_CHECK([ovsdb-client wait ordinals connected])
+AT_CHECK([ovsdb-client dump > dump2])
+OVS_APP_EXIT_AND_WAIT([ovsdb-server])
+
+# Make sure that the clustered data matched the standalone data.
+AT_CHECK([cat dump2], [0], [expout])
+AT_CLEANUP