summaryrefslogtreecommitdiffstats
path: root/ctdb/tests
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2014-04-22 12:19:08 +1000
committerMichael Adam <obnox@samba.org>2014-04-23 14:49:07 +0200
commitb31240acafb20100cf249c6346fb41f90a06158b (patch)
tree4d4b176be8d61125d0006b7952653217a63a13cd /ctdb/tests
parent581ee2e4c32a1ddb77f4fccb6a5ade610998d47e (diff)
downloadsamba-b31240acafb20100cf249c6346fb41f90a06158b.tar.gz
samba-b31240acafb20100cf249c6346fb41f90a06158b.tar.xz
samba-b31240acafb20100cf249c6346fb41f90a06158b.zip
ctdb-tests: Add test for re-attaching detached database
Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'ctdb/tests')
-rwxr-xr-xctdb/tests/simple/27_ctdb_detach.sh33
1 files changed, 33 insertions, 0 deletions
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"