summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2009-10-01 16:55:58 +0000
committerAlan Conway <aconway@apache.org>2009-10-01 16:55:58 +0000
commit054546a9f7dda8e6877550c46eb258c623e67de6 (patch)
tree9cb54e090ad84f588d0d811f7df689dbbff8bc61
parenta27debd4d1711ecdb9980419325f0707bb13c3f7 (diff)
downloadqpid-python-054546a9f7dda8e6877550c46eb258c623e67de6.tar.gz
Fix QPID-2086 - problem with read-credit.
Also cleaned up the cluster test scripts. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@820717 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--cpp/src/qpid/sys/AsynchIOHandler.cpp7
-rwxr-xr-xcpp/src/tests/ais_check6
-rw-r--r--cpp/src/tests/cluster.mk5
-rwxr-xr-xcpp/src/tests/cluster_read_credit27
-rwxr-xr-xcpp/src/tests/clustered_replication_test20
-rwxr-xr-xcpp/src/tests/federated_cluster_test20
-rwxr-xr-xcpp/src/tests/run_cluster_test26
-rwxr-xr-xcpp/src/tests/run_failover_soak24
-rwxr-xr-xcpp/src/tests/start_cluster9
9 files changed, 70 insertions, 74 deletions
diff --git a/cpp/src/qpid/sys/AsynchIOHandler.cpp b/cpp/src/qpid/sys/AsynchIOHandler.cpp
index ae41eacfc3..eb0f213547 100644
--- a/cpp/src/qpid/sys/AsynchIOHandler.cpp
+++ b/cpp/src/qpid/sys/AsynchIOHandler.cpp
@@ -110,6 +110,13 @@ void AsynchIOHandler::readbuff(AsynchIO& , AsynchIO::BufferBase* buff) {
// Check here for read credit
if (readCredit.get() != InfiniteCredit) {
+ if (readCredit.get() == 0) {
+ // FIXME aconway 2009-10-01: Workaround to avoid "false wakeups".
+ // readbuff is sometimes called with no credit.
+ // This should be fixed somewhere else to avoid such calls.
+ aio->unread(buff);
+ return;
+ }
// TODO In theory should be able to use an atomic operation before taking the lock
// but in practice there seems to be an unexplained race in that case
ScopedLock<Mutex> l(creditLock);
diff --git a/cpp/src/tests/ais_check b/cpp/src/tests/ais_check
index 79862d7439..d76c518808 100755
--- a/cpp/src/tests/ais_check
+++ b/cpp/src/tests/ais_check
@@ -47,9 +47,3 @@ with_ais_group() {
id -nG | grep '\<ais\>' >/dev/null || { echo "You are not a member of the ais group."; exit 1; }
echo $* | newgrp ais
}
-
-# Run the tests
-srcdir=`dirname $0`
-with_ais_group $srcdir/run_test ./cluster_test || ERROR=1
-exit $ERROR
-
diff --git a/cpp/src/tests/cluster.mk b/cpp/src/tests/cluster.mk
index 05e18ab9eb..bdec10ebb0 100644
--- a/cpp/src/tests/cluster.mk
+++ b/cpp/src/tests/cluster.mk
@@ -30,7 +30,8 @@ if HAVE_LIBCPG
# ais_check checks pre-requisites for cluster tests and runs them if ok.
TESTS += \
- ais_check \
+ run_cluster_test \
+ cluster_read_credit \
test_watchdog \
run_cluster_tests \
federated_cluster_test \
@@ -38,6 +39,8 @@ TESTS += \
EXTRA_DIST += \
ais_check \
+ run_cluster_test \
+ cluster_read_credit \
test_watchdog \
start_cluster \
stop_cluster \
diff --git a/cpp/src/tests/cluster_read_credit b/cpp/src/tests/cluster_read_credit
new file mode 100755
index 0000000000..370d4098c5
--- /dev/null
+++ b/cpp/src/tests/cluster_read_credit
@@ -0,0 +1,27 @@
+#!/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.
+#
+
+# Regression test for http://issues.apache.org/jira/browse/QPID-2086
+
+srcdir=`dirname $0`
+. $srcdir/ais_check
+$srcdir/start_cluster 1 --cluster-read-max=2 || exit 1
+trap $srcdir/stop_cluster EXIT
+seq 1 10000 | ./sender --port `cat cluster.ports` --routing-key no-such-queue
diff --git a/cpp/src/tests/clustered_replication_test b/cpp/src/tests/clustered_replication_test
index 4713f4b3f9..4dcd113c47 100755
--- a/cpp/src/tests/clustered_replication_test
+++ b/cpp/src/tests/clustered_replication_test
@@ -55,25 +55,7 @@ stop_brokers() {
}
if test -d $PYTHON_DIR; then
- id -nG | grep '\<ais\>' >/dev/null || \
- NOGROUP="You are not a member of the ais group."
- ps -u root | grep 'aisexec\|corosync' >/dev/null || \
- NOAISEXEC="The aisexec or corosync daemon is not running as root"
-
- if test -n "$NOGROUP" -o -n "$NOAISEXEC"; then
- cat <<EOF
-
- =========== WARNING: NOT RUNNING AIS TESTS ==============
-
- Not running cluster replication test because:
- $NOGROUP
- $NOAISEXEC
-
- ==========================================================
-
-EOF
- exit 0;
- fi
+ . $srcdir/ais_check
#todo: these cluster names need to be unique to prevent clashes
PRIMARY_CLUSTER=PRIMARY_$(hostname)_$(pwd)
diff --git a/cpp/src/tests/federated_cluster_test b/cpp/src/tests/federated_cluster_test
index 7f2442451e..8b3ce3cb95 100755
--- a/cpp/src/tests/federated_cluster_test
+++ b/cpp/src/tests/federated_cluster_test
@@ -126,25 +126,7 @@ run_test_pull_from_cluster() {
if test -d ${PYTHON_DIR}; then
- id -nG | grep '\<ais\>' >/dev/null || \
- NOGROUP="You are not a member of the ais group."
- ps -u root | grep 'aisexec\|corosync' >/dev/null || \
- NOAISEXEC="The aisexec or corosync daemon is not running as root"
-
- if test -n "$NOGROUP" -o -n "$NOAISEXEC"; then
- cat <<EOF
-
- =========== WARNING: NOT RUNNING AIS TESTS ==============
-
- Not running federation to cluster test because:
- $NOGROUP
- $NOAISEXEC
-
- ==========================================================
-
-EOF
- exit 0;
- fi
+ . $srcdir/ais_check
rm -f fed*.tmp #cleanup any files left from previous run
start_brokers
diff --git a/cpp/src/tests/run_cluster_test b/cpp/src/tests/run_cluster_test
new file mode 100755
index 0000000000..c022eea1fe
--- /dev/null
+++ b/cpp/src/tests/run_cluster_test
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+#
+# 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 the tests
+srcdir=`dirname $0`
+. $srcdir/ais_check
+with_ais_group $srcdir/run_test ./cluster_test
diff --git a/cpp/src/tests/run_failover_soak b/cpp/src/tests/run_failover_soak
index 3c9a5589c4..8d5b37f008 100755
--- a/cpp/src/tests/run_failover_soak
+++ b/cpp/src/tests/run_failover_soak
@@ -19,29 +19,7 @@
# under the License.
#
-# Check AIS requirements and run tests if found.
-id -ng | grep '\<ais\>' >/dev/null || \
- NOGROUP="The ais group is not your primary group."
-ps -u root | grep 'aisexec\|corosync' >/dev/null || \
- NOAISEXEC="The aisexec/corosync daemon is not running as root"
-
-if test -n "$NOGROUP" -o -n "$NOAISEXEC"; then
- cat <<EOF
-
- =========== WARNING: NOT RUNNING AIS TESTS ==============
-
- Tests that depend on the openais library (used for clustering)
- will not be run because:
-
- $NOGROUP
- $NOAISEXEC
-
- ==========================================================
-
-EOF
- exit 0; # A warning, not a failure.
-fi
-
+. `dirname $0`/ais_check
host=127.0.0.1
diff --git a/cpp/src/tests/start_cluster b/cpp/src/tests/start_cluster
index 585ba082d5..fb3d27373a 100755
--- a/cpp/src/tests/start_cluster
+++ b/cpp/src/tests/start_cluster
@@ -23,20 +23,17 @@
#
# Execute command with the ais group set.
-with_ais_group() {
- id -nG | grep '\<ais\>' >/dev/null || { echo "You are not a member of the ais group." 1>&2; exit 1; }
- echo $* | newgrp ais
-}
+. `dirname $0`/ais_check
rm -f cluster*.log cluster.ports qpidd.port
SIZE=${1:-3}; shift
CLUSTER=`pwd` # Cluster name=pwd, avoid clashes.
-OPTS="-d --no-module-dir --load-module ../.libs/cluster.so --cluster-name=$CLUSTER --auth=no $@"
+OPTS="-d --no-module-dir --load-module ../.libs/cluster.so --cluster-name=$CLUSTER --auth=no --log-enable notice+ --log-enable debug+:cluster $@"
for (( i=0; i<SIZE; ++i )); do
DDIR=`mktemp -d /tmp/start_cluster.XXXXXXXXXX`
- PORT=`with_ais_group ../qpidd -p0 --log-to-file=cluster$i.log $OPTS --data-dir=$DDIR` || exit 1
+ PORT=`with_ais_group ../qpidd -p0 --log-to-file=cluster$i.log $OPTS --data-dir=$DDIR` || exit 1
echo $PORT >> cluster.ports
done