diff options
author | Martin Schwenke <martin@meltin.net> | 2016-08-02 14:47:39 +1000 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2016-08-10 11:24:35 +0200 |
commit | 88178499a528bba35f96866ab91d54005993f3b9 (patch) | |
tree | 97649f182dc5bc2de4dde54f1fae2db149be9ddf | |
parent | 0686be63a54a161094f841ca220ce238aba1398e (diff) | |
download | samba-88178499a528bba35f96866ab91d54005993f3b9.tar.gz |
ctdb-tests: Clean up and rename simple message_ring test
* Rename to clarify purpose of test
* Simplify test info to avoid unnecessary bit-rot
* Have message_ring print PNN for clearer output and update patterns
in test script to suit.
* Drop quantitative percentage check since this is hard to predict
when under extreme load. To compensate, tighten up expectations for
the total number of messages in each direction: at least 10 messages
are required over 10 seconds.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12109
Pair-programmed-with: Amitay Isaacs <amitay@gmail.com>
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit e7a220377ec14090435f448c9a900f8f8e852a77)
-rwxr-xr-x | ctdb/tests/simple/51_ctdb_bench.sh | 92 | ||||
-rwxr-xr-x | ctdb/tests/simple/51_message_ring.sh | 66 | ||||
-rw-r--r-- | ctdb/tests/src/message_ring.c | 5 |
3 files changed, 69 insertions, 94 deletions
diff --git a/ctdb/tests/simple/51_ctdb_bench.sh b/ctdb/tests/simple/51_ctdb_bench.sh deleted file mode 100755 index b8d6e5a2a3a..00000000000 --- a/ctdb/tests/simple/51_ctdb_bench.sh +++ /dev/null @@ -1,92 +0,0 @@ -#!/bin/bash - -test_info() -{ - cat <<EOF -Run the ctdb_bench test and sanity check the output. - -This doesn't test for performance regressions or similarly anything -useful. Only vague sanity checking of results is done. - -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. Run ctdb_bench on all nodes with default options. -3. Ensure that the number of +ve and -ive messages are within 1% of - each other. -4. Ensure that the number of messages per second is greater than 10. - -Expected results: - -* ctdb_bench runs without error and prints reasonable results. -EOF -} - -. "${TEST_SCRIPTS_DIR}/integration.bash" - -ctdb_test_init "$@" - -set -e - -cluster_is_healthy - -try_command_on_node 0 "$CTDB listnodes" -num_nodes=$(echo "$out" | wc -l) - -echo "Running ctdb_bench on all $num_nodes nodes." -try_command_on_node -v -p all $CTDB_TEST_WRAPPER $VALGRIND message_ring -n $num_nodes - -# Get the last line of output. -while read line ; do - prev=$line -done <<<"$out" - -pat='^(Ring: [[:digit:]]+(\.[[:digit:]]+)? msgs/sec \(\+ve=[[:digit:]]+ -ve=[[:digit:]]+\)[[:space:]]?|Waiting for cluster[[:space:]]?)+$' -sanity_check_output 1 "$pat" "$out" - -# $prev should look like this: -# Ring: 10670.93 msgs/sec (+ve=53391 -ve=53373) -stuff="${prev##*Ring: }" -mps="${stuff% msgs/sec*}" - -if [ ${mps%.*} -ge 10 ] ; then - echo "OK: $mps msgs/sec >= 10 msgs/sec" -else - echo "BAD: $mps msgs/sec < 10 msgs/sec" - exit 1 -fi - -stuff="${stuff#*msgs/sec (+ve=}" -positive="${stuff%% *}" - -if [ $positive -gt 0 ] ; then - echo "OK: +ive ($positive) > 0" -else - echo "BAD: +ive ($positive) = 0" - exit 1 -fi - -stuff="${stuff#*-ve=}" -negative="${stuff%)}" - -if [ $negative -gt 0 ] ; then - echo "OK: -ive ($negative) > 0" -else - echo "BAD: -ive ($negative) = 0" - exit 1 -fi - -perc_diff=$(( ($positive - $negative) * 100 / $positive )) -perc_diff=${perc_diff#-} - -check_percent=5 -if [ $perc_diff -le $check_percent ] ; then - echo "OK: percentage difference between +ive and -ive ($perc_diff%) <= $check_percent%" -else - echo "BAD: percentage difference between +ive and -ive ($perc_diff%) > $check_percent%" - exit 1 -fi diff --git a/ctdb/tests/simple/51_message_ring.sh b/ctdb/tests/simple/51_message_ring.sh new file mode 100755 index 00000000000..e1bdab383c7 --- /dev/null +++ b/ctdb/tests/simple/51_message_ring.sh @@ -0,0 +1,66 @@ +#!/bin/bash + +test_info() +{ + cat <<EOF +Run the message_ring test and sanity check the output. + +Prerequisites: + +* An active CTDB cluster with at least 2 active nodes. +EOF +} + +. "${TEST_SCRIPTS_DIR}/integration.bash" + +ctdb_test_init "$@" + +set -e + +cluster_is_healthy + +try_command_on_node 0 "$CTDB listnodes" +num_nodes=$(echo "$out" | wc -l) + +echo "Running message_ring on all $num_nodes nodes." +try_command_on_node -v -p all $CTDB_TEST_WRAPPER $VALGRIND message_ring -n $num_nodes + +# Get the last line of output. +while read line ; do + prev=$line +done <<<"$out" + +pat='^(Waiting for cluster|Ring\[[[:digit:]]+\]: [[:digit:]]+(\.[[:digit:]]+)? msgs/sec \(\+ve=[[:digit:]]+ -ve=[[:digit:]]+\))$' +sanity_check_output 1 "$pat" "$out" + +# $prev should look like this: +# Ring[1]: 10670.93 msgs/sec (+ve=53391 -ve=53373) +stuff="${prev##Ring\[*\]: }" +mps="${stuff% msgs/sec*}" + +if [ ${mps%.*} -ge 10 ] ; then + echo "OK: $mps msgs/sec >= 10 msgs/sec" +else + echo "BAD: $mps msgs/sec < 10 msgs/sec" + exit 1 +fi + +stuff="${stuff#*msgs/sec (+ve=}" +positive="${stuff%% *}" + +if [ $positive -ge 10 ] ; then + echo "OK: +ive ($positive) >= 10" +else + echo "BAD: +ive ($positive) < 10" + exit 1 +fi + +stuff="${stuff#*-ve=}" +negative="${stuff%)}" + +if [ $negative -ge 10 ] ; then + echo "OK: -ive ($negative) >= 10" +else + echo "BAD: -ive ($negative) < 10" + exit 1 +fi diff --git a/ctdb/tests/src/message_ring.c b/ctdb/tests/src/message_ring.c index 2c8aa5017f9..dabae65ff86 100644 --- a/ctdb/tests/src/message_ring.c +++ b/ctdb/tests/src/message_ring.c @@ -290,8 +290,9 @@ static void message_ring_finish(struct tevent_req *subreq) t = timeval_elapsed(&state->start_time); - printf("Ring: %.2f msgs/sec (+ve=%d -ve=%d)\n", - state->msg_count / t, state->msg_plus, state->msg_minus); + printf("Ring[%u]: %.2f msgs/sec (+ve=%d -ve=%d)\n", + ctdb_client_pnn(state->client), state->msg_count / t, + state->msg_plus, state->msg_minus); tevent_req_done(req); } |