summaryrefslogtreecommitdiff
path: root/M4-RCs/qpid/cpp/src/tests/perfdist
blob: 59548b23f74571aee773efd28fd5f7fecc2f668c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash

#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
# 
#   http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.
#


#
# Distributed perftest.
# Runs perftest clients on multiple hosts using ssh.
# 

set -e
usage() {
cat <<EOF
usage: $0 <perftest-args> -- <client-hosts ...> [ --- <broker hosts...> ]
Client & broker hosts can also be set in env vars CLIENTS and BROKERS.

Run perftest clients on the client hosts against brokers on the broker
hosts Clients are assigned to client hosts round robin: publishers
first, then subscribers. If there are multiple brokers (for cluster
tests) clients connect to them round robin.

Broker hosts can be listed with -b in perftest-args or after ---
at the end of the arguments.

Error: $*
EOF
exit 1
}

TESTDIR=${TESTDIR:-$PWD}	# Absolute path to test exes on all hosts.

collect() { eval $COLLECT=\""\$$COLLECT $*"\"; }
NPUBS=1
NSUBS=1
COLLECT=ARGS
while test $# -gt 0; do
    case $1 in
	--publish|--subscribe|--setup|--control) usage "Don't pass perftest action flags: $1" ;;
	--npubs) collect $1 $2; NPUBS=$2; shift 2 ;;
	--nsubs) collect $1 $2; NSUBS=$2; shift 2 ;;
	-s|--summary) collect $1; QUIET=yes; shift 1 ;;
	-b|--broker) BROKERS="$BROKERS $2"; shift 2;;
	--) COLLECT=CLIENTARG; shift ;;
	---) COLLECT=BROKERARG; shift;;
	*) collect $1; shift ;;
    esac
done

CLIENTS=${CLIENTARG:-$CLIENTS}
if [ -z "$CLIENTS" ]; then usage "No client hosts listed after --"; fi
BROKERS=${BROKERARG:-$BROKERS}
if [ -z "$BROKERS" ]; then usage "No brokers specified"; fi

PERFTEST="$TESTDIR/perftest $ARGS"

CLIENTS=($CLIENTS)
BROKERS=($BROKERS)
start() {
    CLIENT=${CLIENTS[i % ${#CLIENTS[*]}]}
    BROKER=${BROKERS[i % ${#BROKERS[*]}]}
    ARGS="$* --broker $BROKER"
    cmd="ssh -n $CLIENT $PERFTEST $ARGS"
    test -z "$QUIET" && echo "Client $i: $cmd"
    $cmd &
}

$PERFTEST --setup -b ${BROKERS[0]}
for (( i=0 ; i < $NPUBS ; ++i)); do start --publish; done
for (( ; i < $NPUBS+$NSUBS ; ++i)); do start --subscribe; done
$PERFTEST --control  -b ${BROKERS[0]}