6 Verify the operation of 'ctdb detach' command.
10 * An active CTDB cluster with at least 2 active nodes.
14 1. Verify that the status on all of the ctdb nodes is 'OK'.
15 2. Attach test databases
16 3. Detach test databases
17 4. Verify that the databases are not attached.
21 * Command 'ctdb detach' command successfully removes attached databases.
25 .
"${TEST_SCRIPTS_DIR}/integration.bash"
34 ctdb_restart_when_done
36 ######################################################################
38 try_command_on_node
0 "$CTDB listnodes -Y"
39 listnodes_output
="$out"
40 numnodes
=$
(wc -l <<<"$listnodes_output")
42 ######################################################################
44 # Confirm that the database is attached
48 try_command_on_node all
$CTDB getdbmap
49 local num_db
=$
(grep -cF "$db" <<<"$out") || true
50 if [ $num_db -eq $numnodes ]; then
51 echo "GOOD: database $db is attached on all nodes"
53 echo "BAD: database $db is not attached on all nodes"
59 # Confirm that no nodes have databases attached
63 try_command_on_node all
$CTDB getdbmap
64 local num_db
=$
(grep -cF "$db" <<<"$out") || true
65 if [ $num_db -eq 0 ]; then
66 echo "GOOD: database $db is not attached any more"
68 echo "BAD: database $db is still attached"
74 ######################################################################
76 testdb1
="detach_test1.tdb"
77 testdb2
="detach_test2.tdb"
78 testdb3
="detach_test3.tdb"
79 testdb4
="detach_test4.tdb"
81 echo "Create test databases"
82 for db
in "$testdb1" "$testdb2" "$testdb3" "$testdb4" ; do
84 try_command_on_node
0 $CTDB attach
"$db"
87 for db
in "$testdb1" "$testdb2" "$testdb3" "$testdb4" ; do
91 ######################################################################
94 echo "Ensuring AllowClientDBAttach=1 on all nodes"
95 try_command_on_node all
$CTDB setvar AllowClientDBAttach
1
97 echo "Check failure detaching single test database $testdb1"
98 try_command_on_node
1 "! $CTDB detach $testdb1"
102 echo "Setting AllowClientDBAttach=0 on node 0"
103 try_command_on_node
0 $CTDB setvar AllowClientDBAttach
0
105 echo "Check failure detaching single test database $testdb1"
106 try_command_on_node
1 "! $CTDB detach $testdb1"
110 echo "Setting AllowClientDBAttach=0 on all nodes"
111 try_command_on_node all
$CTDB setvar AllowClientDBAttach
0
113 echo "Check detaching single test database $testdb1"
114 try_command_on_node
1 "$CTDB detach $testdb1"
115 check_no_db
"$testdb1"
117 ######################################################################
120 echo "Detach multiple test databases"
121 echo " $testdb2, $testdb3, $testdb4"
122 try_command_on_node
0 $CTDB detach
$testdb2 $testdb3 $testdb4
124 for db
in "$testdb2" "$testdb3" "$testdb4" ; do