summaryrefslogtreecommitdiff
path: root/qpid/cpp/src/tests/cluster_test_scripts
diff options
context:
space:
mode:
Diffstat (limited to 'qpid/cpp/src/tests/cluster_test_scripts')
-rw-r--r--qpid/cpp/src/tests/cluster_test_scripts/README.txt20
-rwxr-xr-xqpid/cpp/src/tests/cluster_test_scripts/cluster_check37
-rwxr-xr-xqpid/cpp/src/tests/cluster_test_scripts/cluster_start56
-rwxr-xr-xqpid/cpp/src/tests/cluster_test_scripts/cluster_stop38
-rwxr-xr-xqpid/cpp/src/tests/cluster_test_scripts/config_example.sh44
-rwxr-xr-xqpid/cpp/src/tests/cluster_test_scripts/perftest54
6 files changed, 249 insertions, 0 deletions
diff --git a/qpid/cpp/src/tests/cluster_test_scripts/README.txt b/qpid/cpp/src/tests/cluster_test_scripts/README.txt
new file mode 100644
index 0000000000..e861a2f397
--- /dev/null
+++ b/qpid/cpp/src/tests/cluster_test_scripts/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/qpid/cpp/src/tests/cluster_test_scripts/cluster_check b/qpid/cpp/src/tests/cluster_test_scripts/cluster_check
new file mode 100755
index 0000000000..05fcc1bcd2
--- /dev/null
+++ b/qpid/cpp/src/tests/cluster_test_scripts/cluster_check
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+#
+# 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.
+#
+
+# 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/qpid/cpp/src/tests/cluster_test_scripts/cluster_start b/qpid/cpp/src/tests/cluster_test_scripts/cluster_start
new file mode 100755
index 0000000000..8911358f7e
--- /dev/null
+++ b/qpid/cpp/src/tests/cluster_test_scripts/cluster_start
@@ -0,0 +1,56 @@
+#!/bin/sh
+
+#
+# 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.
+#
+
+# 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/qpid/cpp/src/tests/cluster_test_scripts/cluster_stop b/qpid/cpp/src/tests/cluster_test_scripts/cluster_stop
new file mode 100755
index 0000000000..09aa8f3b21
--- /dev/null
+++ b/qpid/cpp/src/tests/cluster_test_scripts/cluster_stop
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+#
+# 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.
+#
+
+# 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/qpid/cpp/src/tests/cluster_test_scripts/config_example.sh b/qpid/cpp/src/tests/cluster_test_scripts/config_example.sh
new file mode 100755
index 0000000000..d47c9a9c77
--- /dev/null
+++ b/qpid/cpp/src/tests/cluster_test_scripts/config_example.sh
@@ -0,0 +1,44 @@
+# Cluster configuration.
+
+#
+# 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.
+#
+
+# 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/qpid/cpp/src/tests/cluster_test_scripts/perftest b/qpid/cpp/src/tests/cluster_test_scripts/perftest
new file mode 100755
index 0000000000..984761eb5f
--- /dev/null
+++ b/qpid/cpp/src/tests/cluster_test_scripts/perftest
@@ -0,0 +1,54 @@
+#!/bin/sh
+
+#
+# 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.
+#
+
+# 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
+
+