mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
3cb53a7a05
Sometimes the detach test fails: Check detaching single test database detach_test1.tdb BAD: database detach_test1.tdb is still attached Number of databases:4 dbid:0x5ae995ee name:detach_test4.tdb path:tests/var/simple/node.0/db/volatile/detach_test4.tdb.0 dbid:0xd84cc13c name:detach_test3.tdb path:tests/var/simple/node.0/db/volatile/detach_test3.tdb.0 dbid:0x8e8e8cef name:detach_test2.tdb path:tests/var/simple/node.0/db/volatile/detach_test2.tdb.0 dbid:0xc62491f4 name:detach_test1.tdb path:tests/var/simple/node.0/db/volatile/detach_test1.tdb.0 Number of databases:3 dbid:0x5ae995ee name:detach_test4.tdb path:tests/var/simple/node.1/db/volatile/detach_test4.tdb.1 dbid:0xd84cc13c name:detach_test3.tdb path:tests/var/simple/node.1/db/volatile/detach_test3.tdb.1 dbid:0x8e8e8cef name:detach_test2.tdb path:tests/var/simple/node.1/db/volatile/detach_test2.tdb.1 Number of databases:4 dbid:0x5ae995ee name:detach_test4.tdb path:tests/var/simple/node.2/db/volatile/detach_test4.tdb.2 dbid:0xd84cc13c name:detach_test3.tdb path:tests/var/simple/node.2/db/volatile/detach_test3.tdb.2 dbid:0x8e8e8cef name:detach_test2.tdb path:tests/var/simple/node.2/db/volatile/detach_test2.tdb.2 dbid:0xc62491f4 name:detach_test1.tdb path:tests/var/simple/node.2/db/volatile/detach_test1.tdb.2 *** TEST COMPLETED (RC=1) AT 2019-04-27 03:35:40, CLEANING UP... When issued from a client, the detach control re-broadcasts itself asynchronously to all nodes and then returns success. The controls to some nodes to do the actual detach may still be in flight when success is returned to the client. Therefore, the test should wait for a few seconds to allow the asynchronous controls to complete. The same is true for the attach control, so workaround the problem in the attach test too. An alternative is to make the attach and detach controls synchronous by avoiding the broadcast and waiting for the results of the individual controls sent to the nodes. However, a simple implementation would involve adding new nested event loops. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13924 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
136 lines
2.9 KiB
Bash
Executable File
136 lines
2.9 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
test_info()
|
|
{
|
|
cat <<EOF
|
|
Verify the operation of 'ctdb attach' command.
|
|
|
|
Prerequisites:
|
|
|
|
* An active CTDB cluster with at least 2 active nodes.
|
|
|
|
Steps:
|
|
|
|
1. Verify that the status on all of the ctdb nodes is 'OK'.
|
|
2. Shut down one of the nodes
|
|
3. Attach test databases
|
|
4. Start shutdown node
|
|
5. Verify that the databases are attached.
|
|
6. Restart one of the nodes
|
|
7. Verify that the databses are attached.
|
|
|
|
|
|
Expected results:
|
|
|
|
* Command 'ctdb attach' command successfully attaches databases.
|
|
EOF
|
|
}
|
|
|
|
. "${TEST_SCRIPTS_DIR}/integration.bash"
|
|
|
|
ctdb_test_init
|
|
|
|
set -e
|
|
|
|
cluster_is_healthy
|
|
|
|
######################################################################
|
|
|
|
try_command_on_node 0 "$CTDB listnodes -X | wc -l"
|
|
numnodes="$out"
|
|
lastnode=$(( numnodes - 1 ))
|
|
|
|
######################################################################
|
|
|
|
# Confirm that the database is attached with appropriate flags
|
|
check_db_once ()
|
|
{
|
|
local pnn="$1"
|
|
local db="$2"
|
|
|
|
try_command_on_node "$pnn" $CTDB getdbmap
|
|
if grep -qF "name:${db}" "$outfile" >/dev/null ; then
|
|
return 0
|
|
else
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
check_db ()
|
|
{
|
|
local pnn="$1"
|
|
local db="$2"
|
|
local flag="$3"
|
|
|
|
local flags
|
|
|
|
echo "Waiting until database ${db} is attached on node ${pnn}"
|
|
wait_until 10 check_db_once "$pnn" "$db"
|
|
|
|
flags=$(awk -v db="$db" '$2 == "name:" db {print $4}' "$outfile")
|
|
if [ "$flags" = "$flag" ]; then
|
|
echo "GOOD: db ${db} attached on node ${pnn} with flag $flag"
|
|
else
|
|
echo "BAD: db ${db} attached on node ${pnn} with wrong flag"
|
|
cat "$outfile"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
######################################################################
|
|
|
|
testdb1="test_volatile.tdb"
|
|
testdb2="test_persistent.tdb"
|
|
testdb3="test_replicated.tdb"
|
|
|
|
test_node="0"
|
|
|
|
echo "Shutting down node $test_node"
|
|
stop_ctdb_1 "$test_node"
|
|
sleep 1
|
|
wait_until_node_has_status 1 recovered
|
|
try_command_on_node -v 1 $CTDB status
|
|
|
|
echo "Create test databases"
|
|
try_command_on_node 1 $CTDB attach "$testdb1"
|
|
try_command_on_node 1 $CTDB attach "$testdb2" persistent
|
|
try_command_on_node 1 $CTDB attach "$testdb3" replicated
|
|
|
|
echo
|
|
echo "Checking if database is attached with correct flags"
|
|
for node in $(seq 0 $lastnode) ; do
|
|
if [ $node -ne $test_node ] ; then
|
|
check_db $node $testdb1 ""
|
|
check_db $node $testdb2 PERSISTENT
|
|
check_db $node $testdb3 REPLICATED
|
|
fi
|
|
done
|
|
|
|
######################################################################
|
|
|
|
echo
|
|
echo "Start node $test_node"
|
|
start_ctdb_1 "$test_node"
|
|
sleep 1
|
|
wait_until_ready
|
|
|
|
echo
|
|
echo "Checking if database is attached with correct flags"
|
|
check_db $test_node $testdb1 ""
|
|
check_db $test_node $testdb2 PERSISTENT
|
|
check_db $test_node $testdb3 REPLICATED
|
|
|
|
######################################################################
|
|
|
|
echo
|
|
echo "Restarting node $test_node"
|
|
restart_ctdb_1 "$test_node"
|
|
sleep 1
|
|
wait_until_ready
|
|
|
|
echo
|
|
echo "Checking if database is attached with correct flags"
|
|
check_db $test_node $testdb1 ""
|
|
check_db $test_node $testdb2 PERSISTENT
|
|
check_db $test_node $testdb3 REPLICATED
|