summaryrefslogtreecommitdiff
path: root/qpid/cpp/src
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2008-09-05 16:30:03 +0000
committerAlan Conway <aconway@apache.org>2008-09-05 16:30:03 +0000
commitf26c2d31e51044712b7df93a0f4f587af8169213 (patch)
tree50f845b060e169bf587ea326eba1b14cb03ad464 /qpid/cpp/src
parent6c3647858be91b75c03498563071b91fd612b082 (diff)
downloadqpid-python-f26c2d31e51044712b7df93a0f4f587af8169213.tar.gz
src/qpid/client/SubscriptionManager.cpp: added start().
src/tests* improvements to multi-host test scripts. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@692478 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src')
-rw-r--r--qpid/cpp/src/qpid/client/SubscriptionManager.cpp6
-rw-r--r--qpid/cpp/src/qpid/client/SubscriptionManager.h13
-rwxr-xr-xqpid/cpp/src/tests/benchmark54
-rwxr-xr-xqpid/cpp/src/tests/perfdist9
-rwxr-xr-xqpid/cpp/src/tests/start_cluster_hosts37
5 files changed, 79 insertions, 40 deletions
diff --git a/qpid/cpp/src/qpid/client/SubscriptionManager.cpp b/qpid/cpp/src/qpid/client/SubscriptionManager.cpp
index b4c48f7365..e4d68e723f 100644
--- a/qpid/cpp/src/qpid/client/SubscriptionManager.cpp
+++ b/qpid/cpp/src/qpid/client/SubscriptionManager.cpp
@@ -124,6 +124,12 @@ void SubscriptionManager::run()
dispatcher.run();
}
+void SubscriptionManager::start()
+{
+ dispatcher.setAutoStop(autoStop);
+ dispatcher.start();
+}
+
void SubscriptionManager::stop()
{
dispatcher.stop();
diff --git a/qpid/cpp/src/qpid/client/SubscriptionManager.h b/qpid/cpp/src/qpid/client/SubscriptionManager.h
index 3dad15fd29..3a463d9038 100644
--- a/qpid/cpp/src/qpid/client/SubscriptionManager.h
+++ b/qpid/cpp/src/qpid/client/SubscriptionManager.h
@@ -134,16 +134,25 @@ class SubscriptionManager : public sys::Runnable
/** Cancel a subscription. */
void cancel(const std::string tag);
- /** Deliver messages until stop() is called. */
+ /** Deliver messages in the current thread until stop() is called.
+ * Only one thread may be running in a SubscriptionManager at a time.
+ * @see run
+ */
void run();
+ /** Start a new thread to deliver messages.
+ * Only one thread may be running in a SubscriptionManager at a time.
+ * @see start
+ */
+ void start();
+
/** If set true, run() will stop when all subscriptions
* are cancelled. If false, run will only stop when stop()
* is called. True by default.
*/
void setAutoStop(bool set=true);
- /** Cause run() to return */
+ /** Stop delivery. Causes run() to return, or the thread started with start() to exit. */
void stop();
static const uint32_t UNLIMITED=0xFFFFFFFF;
diff --git a/qpid/cpp/src/tests/benchmark b/qpid/cpp/src/tests/benchmark
index dbf72c9e5c..9e8023043b 100755
--- a/qpid/cpp/src/tests/benchmark
+++ b/qpid/cpp/src/tests/benchmark
@@ -17,20 +17,37 @@
# specific language governing permissions and limitations
# under the License.
#
-# A basic "benchmark" to generate performacne samples of throughput and latency.
+# A basic "benchmark" to generate performacne samples of throughput
+# and latency against a single cluster member while they are replicating.
+#
# Must be run in the qpid src/tests build directory.
-#
-SAMPLES=${SAMPLES:-10}
-CLIENTS=${CLIENTS:-mrg8} # Client hosts
-CLIENTS=($CLIENTS) # Array
-COUNT=${COUNT:-10000}
-ECHO=${ECHO:-100}
-BROKER=${BROKER:-mrg7}
+#
+
+# Defaults
+TESTDIR=${TESTDIR:-$PWD} # Absolute path to test exes on all hosts.
+SCRIPTDIR=${SCRIPTDIR:-$PWD/`dirname $0`} # Absolute path to test exes on all hosts.
+SAMPLES=10 # Runs of each test.
+COUNT=${COUNT:-10000} # Count for pub/sub tests.
+ECHO=${ECHO:-1000} # Count for echo test.
+BROKER_FLAGS=
-srcdir=`dirname $0`
-ADDPATH=$PWD:$PWD/../../../src/tests
-PATH=$ADDPATH:$PATH
+while getopts "t:b:p:s:c:n:e" opt ; do
+ case $opt in
+ t) TESTDIR=$OPTARG ;;
+ b) BROKER_FLAGS="$BROKER_FLAGS -b $OPTARG" ;;
+ p) BROKER_FLAGS="$BROKER_FLAGS -p $OPTARG" ;;
+ s) SAMPLES=$OPTARG ;;
+ c) CLIENTS="$CLIENTS $OPTARG" ;;
+ n) COUNT="$OPTARG" ;;
+ e) ECHO="$OPTARG" ;;
+ esac
+done
+test -z "$CLIENTS" && { echo "Must specify at least one client host."; exit 1; }
+test -z "$BROKER_FLAGS" && { echo "Must specify a broker host."; exit 1; }
+
+export TESTDIR # For perfdist
+CLIENTS=($CLIENTS) # Convert to array
trap "rm -f $FILES" EXIT
dosamples() {
@@ -40,22 +57,21 @@ dosamples() {
{
echo "\"$*\"$TABS"
echo "$HEADING"
- for (( i=0; i<$SAMPLES; ++i)) ; do echo "`$@`" ; done
+ for (( i=0; i<$SAMPLES; ++i)) ; do echo "`$*`" ; done
echo
} | tee $FILE
}
HEADING="pub sub total Mb"
-dosamples perfdist -b $BROKER --count $COUNT -s -- ${CLIENTS[*]}
+dosamples $SCRIPTDIR/perfdist $BROKER_FLAGS --count $COUNT --nsubs 2 --npubs 2 --qt 2 -s -- ${CLIENTS[*]}
HEADING="pub"
-dosamples ssh ${CLIENTS[0]} $PWD/publish --routing-key perftest0 -s -b $BROKER --count $COUNT
+dosamples ssh -A ${CLIENTS[0]} $TESTDIR/publish --routing-key perftest0 -s $BROKER_FLAGS --count $COUNT
HEADING="sub"
-dosamples ssh ${CLIENTS[0]} $PWD/consume --queue perftest0 -s -b $BROKER --count $COUNT
+dosamples ssh -A ${CLIENTS[0]} $TESTDIR/consume --queue perftest0 -s $BROKER_FLAGS --count $COUNT
HEADING="min max avg"
-dosamples echotest --count $ECHO -s
-HEADING="pub sub total Mb"
-dosamples perfdist -b $BROKER --count $COUNT --nsubs 2 --npubs 2 --qt 2 -s -- ${CLIENTS[*]}
+dosamples ssh -A ${CLIENTS[0]} $TESTDIR/echotest --count $ECHO -s
+
echo
-echo "Tab separated spreadsheet:"
+echo "Tab separated spreadsheet (also stored in benchmark.tab):"
echo
paste $FILES | tee benchmark.tab
diff --git a/qpid/cpp/src/tests/perfdist b/qpid/cpp/src/tests/perfdist
index b05787f37d..59b6396fe0 100755
--- a/qpid/cpp/src/tests/perfdist
+++ b/qpid/cpp/src/tests/perfdist
@@ -12,7 +12,7 @@ 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.
+include a --host <brokerhost> flag (and --port if necessary).
Do not pass preftest action flags: --setup, --control, --publish, --subscribe.
The script will pass them to the appropriate client processes.
@@ -24,6 +24,8 @@ EOF
exit 1
}
+TESTDIR=${TESTDIR:-$PWD} # Absolute path to test exes on all hosts.
+
collect() { eval $COLLECT=\""\$$COLLECT $*"\"; }
NPUBS=1
NSUBS=1
@@ -40,10 +42,7 @@ while test $# -gt 0; do
done
if [ -z "$HOSTS" ]; then usage "No hosts listed after --"; fi
-ADDPATH="$PWD"
-PATH=$ADDPATH:$PATH
-which perftest>/dev/null || exit 1
-PERFTEST="perftest $ARGS"
+PERFTEST="$TESTDIR/perftest $ARGS"
HOSTS=($HOSTS)
start() {
diff --git a/qpid/cpp/src/tests/start_cluster_hosts b/qpid/cpp/src/tests/start_cluster_hosts
index 1c32247050..37dda882ca 100755
--- a/qpid/cpp/src/tests/start_cluster_hosts
+++ b/qpid/cpp/src/tests/start_cluster_hosts
@@ -6,36 +6,45 @@
# Arguments: [-k] [-p port] HOST [HOST...]
# -p port to start broker on, can be 0. Actual ports recorded in cluster.addr.
# -k kill any qpidd processes owned by this user before starting.
-# Start a broker on each named host. Name a host twice to start multiple brokers.
#
-# You must be able to ssh to each host and have primary group ais.
-# qpidd must exist in the same directory `pwd`/.. as on this host.
+# Start a broker on each named host. Name a host twice to start multiple brokers.
#
+# You must be able to ssh to each host and be in group ais.
+# $QPIDD must be executable on each host.
+# Logs go to syslog on each host, with a unique prefix per broker.
+#
-ADDR_FILE=cluster.addr
+QPIDD=${QPIDD:-$PWD/../qpidd}
+LIBQPIDCLUSTER=${LIBQPIDCLUSTER:-$PWD/../.libs/libqpidcluster.so}
+CLUSTER=$USER # User name is default cluster name.
+RESTART=NO
-while getopts "kp:" ARG ; do
+while getopts "kp:c:q:r" ARG ; do
case $ARG in
- k) KILL=yes ; rm -f $ADDR_FILE ;;
+ k) KILL=yes ;;
p) PORT="$OPTARG" ;;
+ c) CLUSTER=$OPTARG ;;
+ q) QPIDD=$OPTARG ;;
+ l) LIBQPIDCLUSTER=$OPTARG ;;
+ r) RESTART=yes ;;
*) echo "Error parsing options: $ARG"; exit 1 ;;
esac
done
shift `expr $OPTIND - 1`
test -n "$PORT" && PORTOPT="-p $PORT"
-test -n $KILL && KILL="../qpidd -q $PORTOPT ;"
-
+test "$KILL" = yes && KILL="$QPIDD -q $PORTOPT ;"
test -z "$*" && { echo Must specify at least one host; exit 1; }
-test -f $ADDR_FILE && { echo "$ADDR_FILE file already exists" ; exit 1; }
-CLUSTER=$USER # User name is cluster name.
-OPTS="-d $PORTOPT --load-module ../.libs/libqpidcluster.so --cluster-name=$CLUSTER --no-data-dir --auth=no --log-output=syslog"
+
+
+OPTS="-d $PORTOPT --load-module $LIBQPIDCLUSTER --cluster-name=$CLUSTER --no-data-dir --auth=no --log-output=syslog"
num=0
for h in $*; do
num=`expr $num + 1` # Give a unique log prefix to each node.
- cmd="cd $PWD; $KILL ../qpidd $OPTS --log-prefix $num.$h"
- out=`ssh $h "$cmd"` || { echo $out ; exit 1; }
+ cmd="$KILL $QPIDD $OPTS --log-prefix $num.$h"
+ echo == $h
+ out=`echo "$cmd" | ssh $h newgrp ais` || { echo $out ; exit 1; }
if [ "$PORT" = 0 ] ; then p=$out; else p=$PORT; fi
- echo "$h $p" | tee -a $ADDR_FILE
+ echo "$h $p"
done