baeea22ab101e270fb7beb246160adef39018736
[amitay/samba.git] / ctdb / tests / simple / 54_ctdb_transaction_recovery.sh
1 #!/bin/bash
2
3 test_info()
4 {
5     cat <<EOF
6 Verify that the ctdb_transaction test succeeds.
7
8 Prerequisites:
9
10 * An active CTDB cluster with at least 2 active nodes.
11
12 Steps:
13
14 1. Verify that the status on all of the ctdb nodes is 'OK'.
15 2. Run two copies of ctdb_transaction on each node with a 30 second
16    timeout.
17 3. Ensure that all ctdb_transaction processes complete successfully.
18
19 Expected results:
20
21 * ctdb_transaction runs without error.
22 EOF
23 }
24
25 recovery_loop()
26 {
27         local COUNT=1
28
29         while true ; do
30                 echo Recovery $COUNT
31                 ctdb recover
32                 sleep 2
33                 COUNT=$((COUNT + 1))
34         done
35 }
36
37 recovery_loop_start()
38 {
39         recovery_loop > /tmp/recloop.out &
40         RECLOOP_PID=$!
41         ctdb_test_exit_hook_add "kill $RECLOOP_PID >/dev/null 2>&1"
42 }
43
44 . "${TEST_SCRIPTS_DIR}/integration.bash"
45
46 ctdb_test_init "$@"
47
48 set -e
49
50 cluster_is_healthy
51
52 try_command_on_node 0 "$CTDB listnodes"
53 num_nodes=$(echo "$out" | wc -l)
54
55 if test "x${CTDB_TEST_TIMELIMIT}" == "x" ; then
56         CTDB_TEST_TIMELIMIT=30
57 fi
58
59 t="$CTDB_TEST_WRAPPER $VALGRIND ctdb_transaction --timelimit=${CTDB_TEST_TIMELIMIT}"
60
61 echo "Starting recovery loop"
62 recovery_loop_start
63
64 echo "Running ctdb_transaction on all $num_nodes nodes."
65 try_command_on_node -v -pq all "$t & $t"
66