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"
33 ######################################################################
35 try_command_on_node
0 "$CTDB listnodes -X | wc -l"
38 ######################################################################
40 # Confirm that the database is attached
47 try_command_on_node all
"$CTDB getdbmap"
48 num_db
=$
(grep -cF "name:${db}" "$outfile") || true
49 if [ "$num_db" -eq "$numnodes" ]; then
60 echo "Waiting until database ${db} is attached on all nodes"
61 wait_until
10 check_db_once
"$db"
64 # Confirm that no nodes have databases attached
71 try_command_on_node all
"$CTDB getdbmap"
72 num_db
=$
(grep -cF "name:${db}" "$outfile") || true
73 if [ "$num_db" -eq 0 ]; then
84 echo "Waiting until database ${db} is detached on all nodes"
85 wait_until
10 check_no_db_once
"$db"
88 ######################################################################
90 testdb1
="detach_test1.tdb"
91 testdb2
="detach_test2.tdb"
92 testdb3
="detach_test3.tdb"
93 testdb4
="detach_test4.tdb"
95 echo "Create test databases"
96 for db
in "$testdb1" "$testdb2" "$testdb3" "$testdb4" ; do
98 try_command_on_node
0 $CTDB attach
"$db"
101 for db
in "$testdb1" "$testdb2" "$testdb3" "$testdb4" ; do
105 ######################################################################
108 echo "Ensuring AllowClientDBAttach=1 on all nodes"
109 try_command_on_node all
$CTDB setvar AllowClientDBAttach
1
111 echo "Check failure detaching single test database $testdb1"
112 try_command_on_node
1 "! $CTDB detach $testdb1"
116 echo "Setting AllowClientDBAttach=0 on node 0"
117 try_command_on_node
0 $CTDB setvar AllowClientDBAttach
0
119 echo "Check failure detaching single test database $testdb1"
120 try_command_on_node
1 "! $CTDB detach $testdb1"
124 echo "Setting AllowClientDBAttach=0 on all nodes"
125 try_command_on_node all
$CTDB setvar AllowClientDBAttach
0
127 echo "Check detaching single test database $testdb1"
128 try_command_on_node
1 "$CTDB detach $testdb1"
129 check_no_db
"$testdb1"
131 ######################################################################
134 echo "Detach multiple test databases"
135 echo " $testdb2, $testdb3, $testdb4"
136 try_command_on_node
0 $CTDB detach
$testdb2 $testdb3 $testdb4
138 for db
in "$testdb2" "$testdb3" "$testdb4" ; do
142 ######################################################################
145 echo "Attach a single test database"
146 try_command_on_node all
$CTDB setvar AllowClientDBAttach
1
147 try_command_on_node
0 $CTDB attach
$testdb1
151 echo "Write a key to database"
152 try_command_on_node
0 $CTDB writekey
$testdb1 foo bar
153 try_command_on_node
0 $CTDB catdb
$testdb1
154 num_keys
=$
(sed -n -e 's/Dumped \([0-9]*\) records/\1/p' "$outfile") || true
155 if [ -n "$num_keys" -a $num_keys -eq 1 ]; then
156 echo "GOOD: Key added to database"
158 echo "BAD: Key did not get added to database"
164 echo "Detach test database"
165 try_command_on_node all
$CTDB setvar AllowClientDBAttach
0
166 try_command_on_node
0 $CTDB detach
$testdb1
167 check_no_db
"$testdb1"
170 echo "Re-attach test database"
171 try_command_on_node all
$CTDB setvar AllowClientDBAttach
1
172 try_command_on_node
0 $CTDB attach
$testdb1
176 echo "Check if the database is empty"
177 try_command_on_node
0 $CTDB catdb
$testdb1
178 num_keys
=$
(sed -n -e 's/Dumped \([0-9]*\) records/\1/p' "$outfile") || true
179 if [ -n "$num_keys" -a $num_keys -eq 0 ]; then
180 echo "GOOD: Database $testdb1 is empty"
182 echo "BAD: Database $testdb1 is not empty"