6 Verify the operation of 'ctdb attach' 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. Shut down one of the nodes
16 3. Attach test databases
17 4. Start shutdown node
18 5. Verify that the databases are attached.
19 6. Restart one of the nodes
20 7. Verify that the databses are attached.
25 * Command 'ctdb attach' command successfully attaches databases.
29 .
"${TEST_SCRIPTS_DIR}/integration.bash"
38 ctdb_restart_when_done
40 ######################################################################
42 try_command_on_node
0 "$CTDB listnodes -X"
43 listnodes_output
="$out"
44 numnodes
=$
(wc -l <<<"$listnodes_output")
45 lastnode
=$
(( numnodes
- 1 ))
47 ######################################################################
49 # Confirm that the database is attached
55 try_command_on_node
$pnn "$CTDB getdbmap | grep $db"
56 if [ -z "$out" ] ; then
57 echo "BAD: database $db is not attached on node $node"
61 local flags
=$
(awk '{print $4}' <<<"$out") || true
62 if [ "$flags" = "$flag" ]; then
63 echo "GOOD: database $db is attached on node $node with flag $flag"
65 echo "BAD: database $db is attached on node $node with wrong flag"
72 ######################################################################
74 testdb1
="test_volatile.tdb"
75 testdb2
="test_persistent.tdb"
76 testdb3
="test_replicated.tdb"
80 echo "Shutting down node $test_node"
81 stop_ctdb_1
"$test_node"
83 wait_until_node_has_status
1 recovered
84 try_command_on_node
-v 1 $CTDB status
86 echo "Create test databases"
87 try_command_on_node
1 $CTDB attach
"$testdb1"
88 try_command_on_node
1 $CTDB attach
"$testdb2" persistent
89 try_command_on_node
1 $CTDB attach
"$testdb3" replicated
92 echo "Checking if database is attached with correct flags"
93 for node
in $
(seq 0 $lastnode) ; do
94 if [ $node -ne $test_node ] ; then
95 check_db
$node $testdb1 ""
96 check_db
$node $testdb2 PERSISTENT
97 check_db
$node $testdb3 REPLICATED
101 ######################################################################
104 echo "Start node $test_node"
105 start_ctdb_1
"$test_node"
110 echo "Checking if database is attached with correct flags"
111 check_db
$test_node $testdb1 ""
112 check_db
$test_node $testdb2 PERSISTENT
113 check_db
$test_node $testdb3 REPLICATED
115 ######################################################################
118 echo "Restarting node $test_node"
119 restart_ctdb_1
"$test_node"
124 echo "Checking if database is attached with correct flags"
125 check_db
$test_node $testdb1 ""
126 check_db
$test_node $testdb2 PERSISTENT
127 check_db
$test_node $testdb3 REPLICATED