qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acon...@apache.org
Subject svn commit: r1058287 - /qpid/trunk/qpid/cpp/src/tests/qpid-test-cluster
Date Wed, 12 Jan 2011 19:41:39 GMT
Author: aconway
Date: Wed Jan 12 19:41:39 2011
New Revision: 1058287

URL: http://svn.apache.org/viewvc?rev=1058287&view=rev
Log:
qpid-test-cluster script: added -d option to delete data-directory.

Also allow hosts to be specified on command line.

Modified:
    qpid/trunk/qpid/cpp/src/tests/qpid-test-cluster

Modified: qpid/trunk/qpid/cpp/src/tests/qpid-test-cluster
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/qpid-test-cluster?rev=1058287&r1=1058286&r2=1058287&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/qpid-test-cluster (original)
+++ qpid/trunk/qpid/cpp/src/tests/qpid-test-cluster Wed Jan 12 19:41:39 2011
@@ -19,8 +19,8 @@
 #
 
 usage() {
-    echo "Usage: `basename $0` [options] start|stop|restart|check [qpidd-args]
-Start/stop/restart a cluster on hosts in \$HOSTS via ssh.
+    echo "Usage: `basename $0` [options] start|stop|restart|check [hosts]
+Start/stop/restart a cluster on specified hosts or on \$HOSTS via ssh.
 
 Options:
  -l USER     Run qpidd and copy files as USER.
@@ -28,6 +28,7 @@ Options:
              Default is $DEFAULT_ENV.
  -c CONFIG   Use CONFIG as qpidd config file. Copies CONFIG to each host.
              Default is $DEFAULT_CONF
+ -d          Delete data-dir and log file before starting broker.	     
 "
     exit 1
 }
@@ -37,57 +38,72 @@ DEFAULT_ENV=~/qpid-test-env.sh
 
 test -f $DEFAULT_CONF && CONF_FILE=$DEFAULT_CONF
 test -f $DEFAULT_ENV && ENV_FILE=$DEFAULT_ENV
-while getopts "l:e:c:" opt; do
+
+while getopts "l:e:c:d" opt; do
     case $opt in
 	l) SSHOPTS="-l$OPTARG $SSHOPTS" ; RSYNC_USER="$OPTARG@" ;;
 	e) ENV_FILE=$OPTARG ;;
 	c) CONF_FILE=$OPTARG ;;
+	d) DO_DELETE=1 ;;
 	*) usage;;
     esac
 done
 shift `expr $OPTIND - 1`
 test "$*" || usage
 CMD=$1; shift
-QPIDD_ARGS="$QPIDD_ARGS $*"
+HOSTS=${*:-$HOSTS}
+
+conf_value() { test -f "$CONF_FILE" && awk -F= "/^$1=/ {print \$2}" $CONF_FILE; }
 
 if test -n "$CONF_FILE"; then
+    test -f "$CONF_FILE" || { echo Config file not found: $CONF_FILE; exit 1; }
     RSYNCFILES="$RSYNCFILES $CONF_FILE"
     QPIDD_ARGS="$QPIDD_ARGS --config $CONF_FILE"
-    QPID_PORT=${QPID_PORT:-`awk -F= '/^ *port=/ {print $2}' $CONF_FILE`}
+    CONF_PORT=`conf_value port`
+    CONF_DATA_DIR=`conf_value data-dir`
+    CONF_LOG_FILE=`conf_value log-to-file`
 fi
+
 if test -n "$ENV_FILE"; then
+    test -f "$ENV_FILE" || { echo Environment file not found: $ENV_FILE; exit 1; }
     RSYNCFILES="$RSYNCFILES $ENV_FILE"
-    SOURCE_ENV="source $ENV_FILE && "
+    SOURCE_ENV="source $ENV_FILE ; "
 fi
-test -n "$RSYNCFILES" && rsynchosts $RSYNCFILES
+
+test -n "$RSYNCFILES" && rsynchosts $RSYNCFILES	# Copy conf/env files to all hosts
 
 do_start() {
     for h in $HOSTS; do
 	COMMAND="qpidd -d $QPIDD_ARGS"
 	id -nG | grep '\<ais\>' >/dev/null && COMMAND="sg ais -c '$COMMAND'"
-	ssh $SSHOPTS $h "$SOURCE_ENV $COMMAND" || { echo "error on $h: $COMMAND"; exit 1; }
+	if test "$DO_DELETE"; then COMMAND="rm -rf $CONF_DATA_DIR $CONF_LOG_FILE; $COMMAND"; fi
+	ssh $h "$SOURCE_ENV $COMMAND" || { echo "Failed to start on $h"; exit 1; }
     done
 }
 
 do_stop() {
-    for h in $HOSTS; do ssh $SSHOPTS $h "$SOURCE_ENV qpidd -q $QPIDD_ARGS"; done
+    for h in $HOSTS; do
+	ssh $h "$SOURCE_ENV qpidd -q --no-module-dir --no-data-dir $QPIDD_ARGS"
+    done
 }
 
-do_check() {
+do_status() {
     for h in $HOSTS; do
-	test -n "$QPID_PORT" && PORTOPT="-p $QPID_PORT"
-	if qpid-ping -b $h $PORTOPT -q $* &> /dev/null; then
-	    echo $h ok
+	if ssh $h "$SOURCE_ENV qpidd -c --no-module-dir --no-data-dir $QPIDD_ARGS > /dev/null";
then
+	    echo "$h ok"
 	else
-	    echo $h failed
+	    echo "$h not running"
+	    STATUS=1
 	fi
     done
 }
+
 case $CMD in
     start) do_start ;;
     stop) do_stop ;;
     restart) do_stop ; do_start ;;
-    check) do_check ;;
+    status) do_status ;;
     *) usage;;
 esac
 
+exit $STATUS



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message