diff options
author | Alan Conway <aconway@apache.org> | 2010-09-27 19:41:33 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2010-09-27 19:41:33 +0000 |
commit | b738bb7b4eb9030f39095a09e7205df9ea3e521c (patch) | |
tree | d27fe3dbbac60ea6318c1171acb5af8ac126e795 /cpp | |
parent | 815420f4009fb975dd4d570f77c465dc80af7c08 (diff) | |
download | qpid-python-b738bb7b4eb9030f39095a09e7205df9ea3e521c.tar.gz |
Scripts using rsync and ssh to assist cluster testing:
- run a command on all hosts in a cluster.
- copy files to all hosts in a cluster.
- "make install" locally and copy install tree to cluster.
- copy source tree to cluster and "make install" on each host.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1001888 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp')
-rwxr-xr-x | cpp/src/tests/allhosts | 77 | ||||
-rw-r--r-- | cpp/src/tests/cluster.mk | 3 | ||||
-rwxr-xr-x | cpp/src/tests/qpid-build-rinstall | 28 | ||||
-rwxr-xr-x | cpp/src/tests/qpid-src-rinstall | 31 | ||||
-rwxr-xr-x | cpp/src/tests/rsynchosts | 49 |
5 files changed, 188 insertions, 0 deletions
diff --git a/cpp/src/tests/allhosts b/cpp/src/tests/allhosts new file mode 100755 index 0000000000..0d244e8b69 --- /dev/null +++ b/cpp/src/tests/allhosts @@ -0,0 +1,77 @@ +#!/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. +# + +usage() { + echo "Usage: $0 [options] command. +Run a command on each host in \$HOSTS. +Options: + -l USER passed to ssh - run as USER. + -t passed to ssh - create a terminal. + -b run in background, wait for commands to complete. + -d run in background, don't wait for commands to complete. + -s SECONDS sleep between starting commands. + -q don't print banner lines for each host. + -o SUFFIX log output of each command to <host>.SUFFIX +" + exit 1 +} + +while getopts "tl:bs:dqo:" opt; do + case $opt in + l) SSHOPTS="-l$OPTARG $SSHOPTS" ;; + t) TERMOPT="-t" ;; + b) BACKGROUND=1 ;; + d) BACKGROUND=1; DISOWN=1 ;; + s) SLEEP="sleep $OPTARG" ;; + q) NOBANNER=1 ;; + o) SUFFIX=$OPTARG ;; + *) usage;; + esac +done +shift `expr $OPTIND - 1` +test "$*" || usage; + +OK_FILE=`mktemp` # Will be deleted if anything goes wrong. +trap "rm -f $OK_FILE" EXIT + +do_ssh() { + h=$1; shift + if test $SUFFIX ; then ssh $SSHOPTS $h "$@" &> $h.$SUFFIX + else ssh $SSHOPTS $h "$@"; fi || { echo "allhosts: error on $h"; rm -rf $OK_FILE; } +} + +for h in $HOSTS ; do + test "$NOBANNER" || echo "== ssh $SSHOPTS $h $@ ==" + if [ "$BACKGROUND" = 1 ]; then + do_ssh $h "$@" & + CHILDREN="$! $CHILDREN" + else + do_ssh $h "$@" + fi + $SLEEP +done + +if [ "$DISOWN" = 1 ]; then + for c in $CHILDREN; do disown $c; done +else + wait +fi + +test -f $OK_FILE diff --git a/cpp/src/tests/cluster.mk b/cpp/src/tests/cluster.mk index e9e4c84b02..3ca4d3244a 100644 --- a/cpp/src/tests/cluster.mk +++ b/cpp/src/tests/cluster.mk @@ -81,4 +81,7 @@ cluster_test_LDADD=$(lib_client) $(lib_broker) ../cluster.la -lboost_unit_test_f qpidtest_SCRIPTS += run_cluster_tests cluster_tests.py run_long_cluster_tests long_cluster_tests.py testlib.py cluster_tests.fail +qpidtest_SCRIPTS += allhosts rsynchosts qpid-build-rinstall qpid-src-rinstall + + endif diff --git a/cpp/src/tests/qpid-build-rinstall b/cpp/src/tests/qpid-build-rinstall new file mode 100755 index 0000000000..1a92f8750a --- /dev/null +++ b/cpp/src/tests/qpid-build-rinstall @@ -0,0 +1,28 @@ +#!/bin/sh +# +# Licensed to the Apache Software Foundation (ASF) under onemake +# 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 "make install"" locally then copy the install tree to each of $HOSTS +# Must be run in a configured qpid build directory. +# +test -f config.status || { echo "Not in a configured build directory."; usage; } +. src/tests/install_env.sh +set -ex +make && make -j1 install +rsynchosts $QPID_INSTALL_PREFIX diff --git a/cpp/src/tests/qpid-src-rinstall b/cpp/src/tests/qpid-src-rinstall new file mode 100755 index 0000000000..5e69e0ade1 --- /dev/null +++ b/cpp/src/tests/qpid-src-rinstall @@ -0,0 +1,31 @@ +#!/bin/sh +# +# Licensed to the Apache Software Foundation (ASF) under onemake +# 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. +# + +# Copy the source tree and run "make install" on each of $HOSTS +# Must be run in a configured qpid build directory. + +absdir() { echo `cd $1 && pwd`; } + +test -f config.status || { echo "Not in a configured build directory."; } +CONFIGURE=`./config.status -V | grep '^configured by' | sed 's/^configured by \([^,]*\),.*$/\1/'` +CONFIG_OPTIONS=`./config.status -V | grep 'with options' | sed 's/^.*with options "\([^"]*\)".*$/\1/'` +set -ex +rsynchosts `absdir $(dirname $CONFIGURE)/..` # Copy cpp srcdir and siblings. +allhosts -bo rbuild.log "mkdir -p $PWD && cd $PWD && { test -f config.status || $CONFIGURE $CONFIG_OPTIONS; } && make && make -j1 install" diff --git a/cpp/src/tests/rsynchosts b/cpp/src/tests/rsynchosts new file mode 100755 index 0000000000..56ee57e898 --- /dev/null +++ b/cpp/src/tests/rsynchosts @@ -0,0 +1,49 @@ +#!/bin/sh +# +# Licensed to the Apache Software Foundation (ASF) under onemake +# 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. +# + +absdir() { echo `cd $1 && pwd`; } + +abspath() { + if test -d "$1"; then absdir "$1"; + else echo $(absdir $(dirname "$1"))/$(basename "$1") + fi +} + +usage() { + echo "Usage: $(basename $0) file [file...] +Synchronize the contents of each file or directory to the same absolute path on +each host in \$HOSTS. +" + exit 1 +} + +test "$*" || usage + +for f in $*; do FILES="$FILES $(abspath $f)" || exit 1; done + +OK_FILE=`mktemp` # Will be deleted if anything goes wrong. +trap "rm -f $OK_FILE" EXIT + +for h in $HOSTS; do + rsync -aRO --delete $FILES $h:/ || { echo "rsync to $h failed"; rm -f $OK_FILE; } & +done +wait +test -f $OK_FILE + |