ctdb-tests: Drop ctdb_restart_when_done()
[amitay/samba.git] / ctdb / tests / simple / 56_replicated_transaction_recovery.sh
1 #!/bin/bash
2
3 test_info()
4 {
5     cat <<EOF
6 Verify that the transaction_loop test succeeds with recoveries for replicated
7 databases.
8
9 Prerequisites:
10
11 * An active CTDB cluster with at least 2 active nodes.
12 EOF
13 }
14
15 recovery_loop()
16 {
17         local COUNT=1
18
19         while true ; do
20                 echo Recovery $COUNT
21                 try_command_on_node 0 $CTDB recover
22                 sleep 2
23                 COUNT=$((COUNT + 1))
24         done
25 }
26
27 recovery_loop_start()
28 {
29         recovery_loop >/dev/null &
30         RECLOOP_PID=$!
31         ctdb_test_exit_hook_add "kill $RECLOOP_PID >/dev/null 2>&1"
32 }
33
34 . "${TEST_SCRIPTS_DIR}/integration.bash"
35
36 ctdb_test_init "$@"
37
38 set -e
39
40 cluster_is_healthy
41
42 TESTDB="replicated_trans.tdb"
43
44 try_command_on_node 0 "$CTDB attach $TESTDB replicated"
45 try_command_on_node 0 "$CTDB wipedb $TESTDB"
46
47 try_command_on_node 0 "$CTDB listnodes"
48 num_nodes=$(echo "$out" | wc -l)
49
50 if [ -z "$CTDB_TEST_TIMELIMIT" ] ; then
51     CTDB_TEST_TIMELIMIT=30
52 fi
53
54 t="$CTDB_TEST_WRAPPER $VALGRIND transaction_loop \
55         -n ${num_nodes} -t ${CTDB_TEST_TIMELIMIT} \
56         -D ${TESTDB} -T replicated -k testkey"
57
58 echo "Starting recovery loop"
59 recovery_loop_start
60
61 echo "Running transaction_loop on all $num_nodes nodes."
62 try_command_on_node -v -p all "$t"