summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2009-02-18 12:07:48 +0000
committerGordon Sim <gsim@apache.org>2009-02-18 12:07:48 +0000
commit4e2fb7df5affa7b989e80aabbecbd5369807c736 (patch)
tree5b3b5ae6b89bddbddd73d47fd623f616ff9efde3
parent99d4449d13756dc8cbf403dd61b2b08cda655cb7 (diff)
downloadqpid-python-4e2fb7df5affa7b989e80aabbecbd5369807c736.tar.gz
Added tests for federated links to and from a cluster
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@745486 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/cpp/src/tests/Makefile.am2
-rw-r--r--qpid/cpp/src/tests/cluster.mk4
-rwxr-xr-xqpid/cpp/src/tests/federated_cluster_test131
3 files changed, 134 insertions, 3 deletions
diff --git a/qpid/cpp/src/tests/Makefile.am b/qpid/cpp/src/tests/Makefile.am
index 108f8e26c3..9da85eaad4 100644
--- a/qpid/cpp/src/tests/Makefile.am
+++ b/qpid/cpp/src/tests/Makefile.am
@@ -255,7 +255,7 @@ CLEANFILES+=valgrind.out *.log *.vglog* dummy_test $(unit_wrappers)
# Longer running stability tests, not run by default check: target.
# Not run under valgrind, too slow
-LONG_TESTS+=start_broker fanout_perftest shared_perftest multiq_perftest topic_perftest run_failover_soak reliable_replication_test stop_broker
+LONG_TESTS+=start_broker fanout_perftest shared_perftest multiq_perftest topic_perftest run_failover_soak stop_broker reliable_replication_test
EXTRA_DIST+=fanout_perftest shared_perftest multiq_perftest topic_perftest run_failover_soak reliable_replication_test
diff --git a/qpid/cpp/src/tests/cluster.mk b/qpid/cpp/src/tests/cluster.mk
index 0427a1783b..c3100ac968 100644
--- a/qpid/cpp/src/tests/cluster.mk
+++ b/qpid/cpp/src/tests/cluster.mk
@@ -29,8 +29,8 @@ if HAVE_LIBCPG
# ais_check checks pre-requisites for cluster tests and runs them if ok.
-TESTS+=ais_check
-EXTRA_DIST+=ais_check start_cluster stop_cluster restart_cluster cluster_python_tests cluster_python_tests_failing.txt
+TESTS+=ais_check federated_cluster_test
+EXTRA_DIST+=ais_check start_cluster stop_cluster restart_cluster cluster_python_tests cluster_python_tests_failing.txt federated_cluster_test
check_PROGRAMS+=cluster_test
cluster_test_SOURCES=unit_test.cpp cluster_test.cpp ClusterFixture.cpp ClusterFixture.h ForkedBroker.h ForkedBroker.cpp
diff --git a/qpid/cpp/src/tests/federated_cluster_test b/qpid/cpp/src/tests/federated_cluster_test
new file mode 100755
index 0000000000..d4549738b2
--- /dev/null
+++ b/qpid/cpp/src/tests/federated_cluster_test
@@ -0,0 +1,131 @@
+#!/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.
+#
+
+# Test reliability of the replication feature in the face of link
+# failures:
+MY_DIR=`dirname \`which $0\``
+PYTHON_DIR=${MY_DIR}/../../../python
+
+trap stop_brokers EXIT
+
+fail() {
+ echo $1
+ exit 1
+}
+
+stop_brokers() {
+ if [[ $BROKER_A ]] ; then
+ ../qpidd -q --port $BROKER_A
+ unset BROKER_A
+ fi
+ if [[ $NODE_1 ]] ; then
+ ./stop_cluster
+ unset NODE_1
+ fi
+}
+
+start_brokers() {
+ #start single node...
+ ../qpidd --daemon --port 0 --no-data-dir --no-module-dir --auth no --log-enable info+ > fed.port.tmp
+ BROKER_A=`cat fed.port.tmp`
+
+ #...and start cluster
+ ./start_cluster 2 || fail "Could not start cluster"
+ NODE_1=$(head -1 cluster.ports)
+ NODE_2=$(tail -1 cluster.ports)
+}
+
+setup() {
+ #create exchange on both cluster and single broker
+ $PYTHON_DIR/commands/qpid-config -a "localhost:$BROKER_A" add exchange direct test-exchange
+ $PYTHON_DIR/commands/qpid-config -a "localhost:$NODE_1" add exchange direct test-exchange
+
+ #create dynamic routes for test exchange
+ $PYTHON_DIR/commands/qpid-route dynamic add "localhost:$NODE_1" "localhost:$BROKER_A" test-exchange
+ $PYTHON_DIR/commands/qpid-route dynamic add "localhost:$BROKER_A" "localhost:$NODE_1" test-exchange
+
+ #create test queue on cluster and bind it to the test exchange
+ $PYTHON_DIR/commands/qpid-config -a "localhost:$NODE_1" add queue test-queue
+ $PYTHON_DIR/commands/qpid-config -a "localhost:$NODE_1" bind test-exchange test-queue to-cluster
+
+ #create test queue on single broker and bind it to the test exchange
+ $PYTHON_DIR/commands/qpid-config -a "localhost:$BROKER_A" add queue test-queue
+ $PYTHON_DIR/commands/qpid-config -a "localhost:$BROKER_A" bind test-exchange test-queue from-cluster
+}
+
+run_test_pull_to_cluster() {
+ #start consumers on each of the two nodes of the cluster
+ ./receiver --port $NODE_1 --queue test-queue --credit-window 1 > fed1.out.tmp &
+ ./receiver --port $NODE_2 --queue test-queue --credit-window 1 > fed2.out.tmp &
+
+ #send stream of messages to test exchange on single broker
+ for i in `seq 1 1000`; do echo Message $i >> fed.in.tmp; done
+ ./sender --port $BROKER_A --exchange test-exchange --routing-key to-cluster --send-eos 2 < fed.in.tmp
+
+ #combine output of the two consumers, sort it and compare with the expected stream
+ wait
+ sort -g -k 2 fed1.out.tmp fed2.out.tmp > fed.out.tmp
+ diff fed.in.tmp fed.out.tmp || fail "federated link to cluster failed: expectations not met!"
+
+ rm -f fed*.tmp #cleanup
+}
+
+run_test_pull_from_cluster() {
+ #start consumer on single broker
+ ./receiver --port $BROKER_A --queue test-queue --credit-window 1 > fed.out.tmp &
+
+ #send stream of messages to test exchange on cluster
+ for i in `seq 1 1000`; do echo Message $i >> fed.in.tmp; done
+ ./sender --port $NODE_2 --exchange test-exchange --routing-key from-cluster --send-eos 1 < fed.in.tmp
+
+ #verify all messages are received
+ wait
+ diff fed.in.tmp fed.out.tmp || fail "federated link from cluster failed: expectations not met!"
+
+ rm -f fed*.tmp #cleanup
+}
+
+
+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
+Not running federation to cluster test because:
+ $NOGROUP
+ $NOAISEXEC
+EOF
+ exit 0;
+ fi
+
+ rm -f fed*.tmp #cleanup any files left from previous run
+ start_brokers
+ echo "brokers started"
+ setup
+ echo "setup completed"
+ run_test_pull_to_cluster
+ echo "federated link to cluster verified"
+ run_test_pull_from_cluster
+ echo "federated link from cluster verified"
+fi