From b31240acafb20100cf249c6346fb41f90a06158b Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Tue, 22 Apr 2014 12:19:08 +1000 Subject: [PATCH] ctdb-tests: Add test for re-attaching detached database Signed-off-by: Amitay Isaacs Reviewed-by: Michael Adam --- ctdb/tests/simple/27_ctdb_detach.sh | 33 +++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/ctdb/tests/simple/27_ctdb_detach.sh b/ctdb/tests/simple/27_ctdb_detach.sh index f86d10af60b..108a270bd44 100755 --- a/ctdb/tests/simple/27_ctdb_detach.sh +++ b/ctdb/tests/simple/27_ctdb_detach.sh @@ -124,3 +124,36 @@ try_command_on_node 0 $CTDB detach $testdb2 $testdb3 $testdb4 for db in "$testdb2" "$testdb3" "$testdb4" ; do check_no_db "$db" done + +###################################################################### + +echo +echo "Attach a single test database" +try_command_on_node all $CTDB setvar AllowClientDBAttach 1 +try_command_on_node 0 $CTDB attach $testdb1 +check_db "$testdb1" + +echo +echo "Write a key to database" +try_command_on_node 0 $CTDB writekey $testdb1 foo bar +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 1 ]; then + echo "GOOD: Key added to database" +else + echo "BAD: Key did not get added to database" + echo "$out" + exit 1 +fi + +echo +echo "Detach test database" +try_command_on_node all $CTDB setvar AllowClientDBAttach 0 +try_command_on_node 0 $CTDB detach $testdb1 +check_no_db "$testdb1" + +echo +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" -- 2.34.1