summaryrefslogtreecommitdiff
path: root/tests/ovsdb-client.at
diff options
context:
space:
mode:
authorBen Pfaff <blp@ovn.org>2017-12-15 08:35:41 -0800
committerBen Pfaff <blp@ovn.org>2017-12-15 08:35:44 -0800
commit4d0a31b642c989de6c079e8db8cc3398dde30436 (patch)
tree972a4fe828d4f24e55fa7253880cb9c745b9cc9d /tests/ovsdb-client.at
parentbfaf6352f39ce40ab12e29b673c9f5d69c4ee496 (diff)
downloadopenvswitch-4d0a31b642c989de6c079e8db8cc3398dde30436.tar.gz
ovsdb-client: Add new "backup" command.
Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Justin Pettit <jpettit@ovn.org>
Diffstat (limited to 'tests/ovsdb-client.at')
-rw-r--r--tests/ovsdb-client.at51
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/ovsdb-client.at b/tests/ovsdb-client.at
index 903929550..b35e9f75e 100644
--- a/tests/ovsdb-client.at
+++ b/tests/ovsdb-client.at
@@ -11,3 +11,54 @@ AT_CHECK([ovsdb-client get-schema-cksum unix:socket ordinals], [0], [12345678 9
])
OVSDB_SERVER_SHUTDOWN
AT_CLEANUP
+
+AT_SETUP([ovsdb-client backup])
+AT_KEYWORDS([ovsdb client positive])
+
+on_exit 'kill `cat *.pid`'
+
+dnl Create a database.
+ordinal_schema > schema
+touch .db.~lock~
+AT_CHECK([ovsdb-tool create db schema])
+
+dnl Put some data in the database.
+AT_CHECK(
+ [[for pair in 'zero 0' 'one 1' 'two 2' 'three 3' 'four 4' 'five 5'; do
+ set -- $pair
+ ovsdb-tool transact db '
+ ["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])
+
+dnl Start the database server.
+AT_CHECK([ovsdb-server -vfile -vvlog:off --detach --no-chdir --pidfile --log-file --remote=punix:db.sock db], [0])
+AT_CAPTURE_FILE([ovsdb-server.log])
+
+dnl Dump a copy of the data and a backup of it.
+AT_CHECK([ovsdb-client dump > dump1])
+AT_CHECK([ovsdb-client backup > backup])
+
+dnl Stop the database server, then re-start it based on the backup.
+OVS_APP_EXIT_AND_WAIT([ovsdb-server])
+AT_CHECK([ovsdb-server -vfile -vvlog:off --detach --no-chdir --pidfile --log-file --remote=punix:db.sock backup], [0])
+
+dnl Dump a new copy of the data.
+AT_CHECK([ovsdb-client dump > dump2])
+sort dump2 > expout
+
+dnl Verify that the two dumps are the same.
+AT_CHECK([sort dump1], [0], [expout])
+
+AT_CLEANUP