diff options
author | Alan Conway <aconway@apache.org> | 2009-06-22 21:44:15 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2009-06-22 21:44:15 +0000 |
commit | f5a9d635e388ec9fdfb064c541c9ae1f24250b7b (patch) | |
tree | 259a96cb81628a12a9d47d651bf112a095f2efb4 /cpp | |
parent | 3e52cd743be669757707b1f7c556211f11458ea7 (diff) | |
download | qpid-python-f5a9d635e388ec9fdfb064c541c9ae1f24250b7b.tar.gz |
Test script to run distributed perftest against a cluster.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@787415 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/src/tests/cluster_test/README.txt | 20 | ||||
-rwxr-xr-x | cpp/src/tests/cluster_test/cluster_check | 17 | ||||
-rwxr-xr-x | cpp/src/tests/cluster_test/cluster_start | 36 | ||||
-rwxr-xr-x | cpp/src/tests/cluster_test/cluster_stop | 18 | ||||
-rwxr-xr-x | cpp/src/tests/cluster_test/config_example.sh | 25 | ||||
-rwxr-xr-x | cpp/src/tests/cluster_test/perftest | 34 |
6 files changed, 150 insertions, 0 deletions
diff --git a/cpp/src/tests/cluster_test/README.txt b/cpp/src/tests/cluster_test/README.txt new file mode 100644 index 0000000000..e861a2f397 --- /dev/null +++ b/cpp/src/tests/cluster_test/README.txt @@ -0,0 +1,20 @@ +Cluster test scripts. + +A set of scripts to start and stop cluster and test clients on +multiple hosts using ssh. + +Pre-requisites: You must be + - set up for password-free ssh access to the test hosts. + - a member of the ais group on all the test hosts. + +Configuration: + +Copy defaults.sh to config.sh and edit the values as necessary. + +Test scripts: + +Test scripts use the functions in functions.sh to start & monitor +cluster and clients. +A test script can collect other scripts. + + diff --git a/cpp/src/tests/cluster_test/cluster_check b/cpp/src/tests/cluster_test/cluster_check new file mode 100755 index 0000000000..5cc872a921 --- /dev/null +++ b/cpp/src/tests/cluster_test/cluster_check @@ -0,0 +1,17 @@ +#!/bin/sh +# Check that all members of a cluster are running + +source config.sh + +HOSTS=(`cat $CLUSTER_HOME/hosts`) +PORTS=(`cat $CLUSTER_HOME/ports`) + +for ((i=0; i<${#HOSTS[*]}; ++i)); do + host=${HOSTS[$i]} + port=${PORTS[$i]} + ssh $host "$QPIDD -cp $port" > /dev/null || { + ret=1 + echo "ERROR: broker not running $host:$port" + } +done +exit $ret diff --git a/cpp/src/tests/cluster_test/cluster_start b/cpp/src/tests/cluster_test/cluster_start new file mode 100755 index 0000000000..bde582ef2b --- /dev/null +++ b/cpp/src/tests/cluster_test/cluster_start @@ -0,0 +1,36 @@ +#!/bin/sh +# Start a cluster +# +# Arguments: NAME HOST [host...] +# Start a cluster called NAME with N nodes running on the given HOSTs +# repeat the host name to run multiple brokers on one host. Use dynamic +# ports. +# +# Log files, data directories and hosts/ports files are all stored under +# $HOME/cluster_test/$NAME +# + +source config.sh + +CLUSTER_NAME=`date +"${USER}_%F_%T"` +HOSTS=($BROKER_HOSTS) +for ((i = 0; i < ${#HOSTS[*]}; ++i)) ; do + host=${HOSTS[$i]} + datadir=$CLUSTER_HOME/broker$i + log=$datadir/qpidd.log + ssh $host "rm -rf $datadir; mkdir -p $datadir" || { + echo "ERROR: can't make data dir $datadir"; exit 1 + } + port=`ssh $host "echo $QPIDD -dp0 --cluster-name=$CLUSTER_NAME \ + --data-dir=$datadir \ + --log-to-file=$log --log-prefix=broker$i \ + $QPIDD_OPTS | newgrp ais"` || { + error "ERROR: can't start broker $i on $host"; exit 1; + } + PORTS="$PORTS $port" +done + +echo "$BROKER_HOSTS" > $CLUSTER_HOME/hosts +echo "$PORTS" > $CLUSTER_HOME/ports + +`dirname $0`/cluster_check $NAME diff --git a/cpp/src/tests/cluster_test/cluster_stop b/cpp/src/tests/cluster_test/cluster_stop new file mode 100755 index 0000000000..d4543d2d4a --- /dev/null +++ b/cpp/src/tests/cluster_test/cluster_stop @@ -0,0 +1,18 @@ +#!/bin/sh +# Stop the cluster. + +source config.sh + +HOSTS=(`cat $CLUSTER_HOME/hosts`) +PORTS=(`cat $CLUSTER_HOME/ports`) + +for ((i=0; i<${#HOSTS[*]}; ++i)); do + host=${HOSTS[$i]} + port=${PORTS[$i]} + ssh $host "$QPIDD -qp $port" > /dev/null || { + ret=1 + echo "ERROR: stopping broker at $host:$port" + } +done + +exit $ret diff --git a/cpp/src/tests/cluster_test/config_example.sh b/cpp/src/tests/cluster_test/config_example.sh new file mode 100755 index 0000000000..fd5b800df7 --- /dev/null +++ b/cpp/src/tests/cluster_test/config_example.sh @@ -0,0 +1,25 @@ +# Cluster configuration. + +# All output stored under $HOME/$CLUSTER_HOME. +CLUSTER_HOME=$HOME/cluster_test + +# Hosts where brokers will be run. Repeat hostname to run multiple brokers on 1 host. +BROKER_HOSTS="mrg22 mrg23 mrg24 mrg25 mrg26" + +# Hosts where clients will be run. +CLIENT_HOSTS="$BROKER_HOSTS" + +# Paths to executables +QPIDD=qpidd +PERFTEST=perftest + +# Directory containing tests +TESTDIR=/usr/bin + +# Options for qpidd, must be sufficient to load the cluster plugin. +# Scripts will add --cluster-name, --daemon, --port and --log-to-file options here. +QPIDD_OPTS=" \ +--auth=no \ +--log-enable=notice+ \ +--log-enable=debug+:cluster \ +" diff --git a/cpp/src/tests/cluster_test/perftest b/cpp/src/tests/cluster_test/perftest new file mode 100755 index 0000000000..72c8268835 --- /dev/null +++ b/cpp/src/tests/cluster_test/perftest @@ -0,0 +1,34 @@ +#!/bin/sh +# Run a distributed perftest against a cluster. +# Args: npubs nsubs [perftest-options] + +source config.sh + +NPUBS=${1:-4} ; shift +NSUBS=${1:-4} ; shift +OPTS="--npubs $NPUBS --nsubs $NSUBS $*" + +CLIENTS=($CLIENT_HOSTS) +BROKERS=(`cat $CLUSTER_HOME/hosts`) +PORTS=(`cat $CLUSTER_HOME/ports`) + +start() { + client=${CLIENTS[i % ${#CLIENTS[*]}]} + broker=${BROKERS[i % ${#BROKERS[*]}]} + port=${PORTS[i % ${#PORTS[*]}]} + ssh -n $client $PERFTEST $OPTS $* -b $broker -p $port & + PIDS="$PIDS $!" +} + +ssh ${CLIENTS[0]} $PERFTEST $OPTS --setup -b ${BROKERS[0]} -p${PORTS[0]} +for (( i=0 ; i < $NPUBS ; ++i)); do start --publish; done +for (( ; i < $NPUBS+$NSUBS ; ++i)); do start --subscribe; done +ssh ${CLIENTS[0]} $PERFTEST $OPTS --control -b ${BROKERS[0]} -p${PORTS[0]} + +for pid in $PIDS; do + wait $pid || echo "ERROR: client process $pid failed" +done + +`dirname $0`/cluster_check + + |