23c33bfde67c74f20625ec6b056e99b90f33b12c
[samba.git] / ctdb / tests / simple / 52_ctdb_fetch.sh
1 #!/bin/bash
2
3 test_info()
4 {
5     cat <<EOF
6 Run the ctdb_fetch test and sanity check the output.
7
8 This doesn't test for performance regressions or similarly anything
9 useful.  Only vague sanity checking of results is done.
10
11 Prerequisites:
12
13 * An active CTDB cluster with at least 2 active nodes.
14
15 Steps:
16
17 1. Verify that the status on all of the ctdb nodes is 'OK'.
18 2. Run ctdb_fetch on all nodes with default options.
19 3. Ensure that the number of +ve and -ive messages are within 1% of
20    each other.
21 4. Ensure that the number of messages per second is greater than 10.
22
23 Expected results:
24
25 * ctdb_fetch runs without error and prints reasonable results.
26 EOF
27 }
28
29 . "${TEST_SCRIPTS_DIR}/integration.bash"
30
31 ctdb_test_init "$@"
32
33 set -e
34
35 cluster_is_healthy
36
37 try_command_on_node 0 "$CTDB listnodes"
38 num_nodes=$(echo "$out" | wc -l)
39
40 echo "Running ctdb_fetch on all $num_nodes nodes."
41 try_command_on_node -v -p all $CTDB_TEST_WRAPPER $VALGRIND ctdb_fetch -n $num_nodes
42
43 pat='^(Fetch: [[:digit:]]+(\.[[:digit:]]+)? msgs/sec[[:space:]]?|msg_count=[[:digit:]]+ on node [[:digit:]]|Fetching final record|DATA:|Test data|Waiting for cluster[[:space:]]?|.*: Reqid wrap!|Sleeping for [[:digit:]]+ seconds|)+$'
44 sanity_check_output 1 "$pat" "$out"
45
46 # Filter out the performance figures:
47 out_fetch=$(echo "$out" | egrep '^(Fetch: .*)+$')
48
49 # Get the last line of output.
50 while read line ; do
51     prev=$line
52 done <<<"$out_fetch"
53
54 # $prev should look like this:
55 #    Fetch: 10670.93 msgs/sec
56 stuff="${prev##*Fetch: }"
57 mps="${stuff% msgs/sec*}"
58
59 if [ ${mps%.*} -ge 10 ] ; then
60     echo "OK: $mps msgs/sec >= 10 msgs/sec"
61 else
62     echo "BAD: $mps msgs/sec < 10 msgs/sec"
63     exit 1
64 fi