From 4d0a31b642c989de6c079e8db8cc3398dde30436 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Fri, 15 Dec 2017 08:35:41 -0800 Subject: ovsdb-client: Add new "backup" command. Signed-off-by: Ben Pfaff Acked-by: Justin Pettit --- tests/ovsdb-client.at | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'tests/ovsdb-client.at') 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 -- cgit v1.2.1