ctdb-tests: Improve ctdb detach test
authorAmitay Isaacs <amitay@gmail.com>
Fri, 6 Nov 2015 03:48:44 +0000 (14:48 +1100)
committerAmitay Isaacs <amitay@samba.org>
Fri, 12 Feb 2016 04:32:16 +0000 (05:32 +0100)
Confirm that after re-attaching detached database, it is empty.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
ctdb/tests/simple/27_ctdb_detach.sh

index 4b7b3b5f22fdc43402bbd3776243235c6b00cc07..42ec635fb65c0fe622d27150345b6fcbec76a28c 100755 (executable)
@@ -157,3 +157,15 @@ echo "Re-attach test database"
 try_command_on_node all $CTDB setvar AllowClientDBAttach 1
 try_command_on_node 0 $CTDB attach $testdb1
 check_db "$testdb1"
+
+echo
+echo "Check if the database is empty"
+try_command_on_node 0 $CTDB catdb $testdb1
+num_keys=$(echo "$out" | sed -n -e 's/Dumped \([0-9]*\) records/\1/p') || true
+if [ -n "$num_keys" -a $num_keys -eq 0 ]; then
+    echo "GOOD: Database $testdb1 is empty"
+else
+    echo "BAD: Database $testdb1 is not empty"
+    echo "$out"
+    exit 1
+fi