ctdb-tests: Clean up and rename simple message_ring test
[jlayton/samba.git] / ctdb / tests / simple / 51_message_ring.sh
1 #!/bin/bash
2
3 test_info()
4 {
5     cat <<EOF
6 Run the message_ring test and sanity check the output.
7
8 Prerequisites:
9
10 * An active CTDB cluster with at least 2 active nodes.
11 EOF
12 }
13
14 . "${TEST_SCRIPTS_DIR}/integration.bash"
15
16 ctdb_test_init "$@"
17
18 set -e
19
20 cluster_is_healthy
21
22 try_command_on_node 0 "$CTDB listnodes"
23 num_nodes=$(echo "$out" | wc -l)
24
25 echo "Running message_ring on all $num_nodes nodes."
26 try_command_on_node -v -p all $CTDB_TEST_WRAPPER $VALGRIND message_ring -n $num_nodes
27
28 # Get the last line of output.
29 while read line ; do
30     prev=$line
31 done <<<"$out"
32
33 pat='^(Waiting for cluster|Ring\[[[:digit:]]+\]: [[:digit:]]+(\.[[:digit:]]+)? msgs/sec \(\+ve=[[:digit:]]+ -ve=[[:digit:]]+\))$'
34 sanity_check_output 1 "$pat" "$out"
35
36 # $prev should look like this:
37 #    Ring[1]: 10670.93 msgs/sec (+ve=53391 -ve=53373)
38 stuff="${prev##Ring\[*\]: }"
39 mps="${stuff% msgs/sec*}"
40
41 if [ ${mps%.*} -ge 10 ] ; then
42     echo "OK: $mps msgs/sec >= 10 msgs/sec"
43 else
44     echo "BAD: $mps msgs/sec < 10 msgs/sec"
45     exit 1
46 fi
47
48 stuff="${stuff#*msgs/sec (+ve=}"
49 positive="${stuff%% *}"
50
51 if [ $positive -ge 10 ] ; then
52     echo "OK: +ive ($positive) >= 10"
53 else
54     echo "BAD: +ive ($positive) < 10"
55     exit 1
56 fi
57
58 stuff="${stuff#*-ve=}"
59 negative="${stuff%)}"
60
61 if [ $negative -ge 10 ] ; then
62     echo "OK: -ive ($negative) >= 10"
63 else
64     echo "BAD: -ive ($negative) < 10"
65     exit 1
66 fi