summaryrefslogtreecommitdiff
path: root/qpid/cpp/src/tests/perfdist
blob: 816d2d99f6b1630f0e0421779a1881137810e2c7 (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
#!/bin/bash
#
# Distributed perftest.
# Runs perftest clients on multiple hosts using ssh.
# 

set -e
usage() {
cat <<EOF
usage: $0 <perftest-args> -- <client-hosts ...> 

Run perftest with clients running on the listed hosts.  Clients are
assigned to hosts publishers first, then subscribers the host list is
used round-robin if there are more clients than hosts. perftest-args should
include a --host <brokerhost>  flag.

Do not pass preftest action flags: --setup, --control, --publish, --subscribe.
The script will pass them to the appropriate client processes.

Note all perftest args must come before  --.

Error: $*
EOF
exit 1
}

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 ;;
	--) COLLECT=HOSTS; shift ;; 
	*) collect $1; shift ;;
    esac
done
if [ -z "$HOSTS" ]; then usage "No hosts listed after --"; fi
PATH="`dirname $0`:$PATH"	
PERFTEST="`which perftest` $ARGS" || usage "Can't find perftest executable"

HOSTS=($HOSTS)
start() { ssh ${HOSTS[i % ${#HOSTS[*]}]} $PERFTEST $*& }

$PERFTEST --setup
for (( i=0 ; i < $NPUBS ; ++i)); do start --publish; done
for (( ; i < $NPUBS+$NSUBS ; ++i)); do start --subscribe; done
$PERFTEST --control