summaryrefslogtreecommitdiff
path: root/qpid/cpp/src/tests/perfdist
blob: 820fc535cb1f51458e1ad754dde1396b3a36b55b (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
#!/bin/bash
#
set -e
usage() {
cat <<EOF
usage: $0 <perftest-args> --pubhosts <publish-hosts> --subhosts <subscribe-hosts>

All perftest args must come before --pubhosts or --subhosts. If
--npubs or --nsubs is larger than corresponding hosts list, the list
is used round-robin.

Do not pass action flags --setup, --control, --publish, --subscribe they
will be passed to the appropriate processes.
EOF
exit 1
}

collect() { eval $COLLECT=\""\$$COLLECT $*"\"; }

COLLECT=ARGS
while test $# -gt 0; do
    case $1 in
	--publish|--subscribe|--setup|--control) usage ;;
	--npubs) collect $1 $2; NPUBS=$2; shift 2 ;;
	--nsubs) collect $1 $2; NSUBS=$2; shift 2 ;;
	--pubhosts) COLLECT=PUBHOSTS; shift ;; 
	--subhosts) COLLECT=SUBHOSTS; shift ;;
	*) collect $1; shift ;;
    esac
done
if [ -z "$PUBHOSTS" ]; then echo "Missing --pubhosts"; usage; fi
if [ -z "$SUBHOSTS" ]; then echo "Missing --subhosts"; usage; fi

PERFTEST="`PATH=$PWD:$PATH which perftest` $ARGS"

start() {
    ssh $2 $PERFTEST --$1
}

$PERFTEST --setup
PUBS=($PUBHOSTS)
for (( i=0 ; i < $NPUBS ; ++i)); do start publish ${PUBS[i % ${#PUBS[*]}]} & done
SUBS=($SUBHOSTS)
for (( i=0 ; i < $NSUBS ; ++i)); do start subscribe ${SUBS[i % ${#SUBS[*]}]} & done
$PERFTEST --control