From 574c49e4b1f1e9e6c6b639342c2d921ff3573b1e Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Tue, 10 Mar 2009 22:48:51 +0000 Subject: QPID-1724: Allow replication events to be shared across multiple federations bridges. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@752290 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ReplicationTest.cpp | 129 +++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 qpid/cpp/src/tests/ReplicationTest.cpp (limited to 'qpid/cpp/src/tests/ReplicationTest.cpp') diff --git a/qpid/cpp/src/tests/ReplicationTest.cpp b/qpid/cpp/src/tests/ReplicationTest.cpp new file mode 100644 index 0000000000..7bd585639d --- /dev/null +++ b/qpid/cpp/src/tests/ReplicationTest.cpp @@ -0,0 +1,129 @@ + /* + * + * 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. + * + */ +#include "unit_test.h" +#include "test_tools.h" +#include "BrokerFixture.h" + +#include "qpid/Plugin.h" +#include "qpid/broker/Broker.h" +#include "qpid/client/QueueOptions.h" +#include "qpid/framing/reply_exceptions.h" +#include "qpid/framing/SequenceNumber.h" +#include "qpid/replication/constants.h" +#include "qpid/sys/Shlib.h" + +#include +#include +#include + +#include +#include + +using namespace qpid::client; +using namespace qpid::framing; +using namespace qpid::replication::constants; +using boost::assign::list_of; + +QPID_AUTO_TEST_SUITE(ReplicationTestSuite) + +qpid::sys::Shlib plugin("../.libs/replicating_listener.so"); + +qpid::broker::Broker::Options getBrokerOpts(const std::vector& args) +{ + std::vector argv(args.size()); + transform(args.begin(), args.end(), argv.begin(), boost::bind(&string::c_str, _1)); + + qpid::broker::Broker::Options opts; + qpid::Plugin::addOptions(opts); + opts.parse(argv.size(), &argv[0], "", true); + return opts; +} + +QPID_AUTO_TEST_CASE(testReplicationExchange) +{ + qpid::broker::Broker::Options brokerOpts(getBrokerOpts(list_of("qpidd") + ("--replication-exchange-name=qpid.replication"))); + ProxySessionFixture f(brokerOpts); + + + std::string dataQ("queue-1"); + std::string eventQ("event-queue-1"); + std::string dataQ2("queue-2"); + std::string eventQ2("event-queue-2"); + FieldTable eventQopts; + eventQopts.setString("qpid.insert_sequence_numbers", REPLICATION_EVENT_SEQNO); + + f.session.queueDeclare(arg::queue=eventQ, arg::exclusive=true, arg::autoDelete=true, arg::arguments=eventQopts); + f.session.exchangeBind(arg::exchange="qpid.replication", arg::queue=eventQ, arg::bindingKey=dataQ); + + f.session.queueDeclare(arg::queue=eventQ2, arg::exclusive=true, arg::autoDelete=true, arg::arguments=eventQopts); + f.session.exchangeBind(arg::exchange="qpid.replication", arg::queue=eventQ2, arg::bindingKey=dataQ2); + + QueueOptions args; + args.enableQueueEvents(false); + f.session.queueDeclare(arg::queue=dataQ, arg::exclusive=true, arg::autoDelete=true, arg::arguments=args); + f.session.queueDeclare(arg::queue=dataQ2, arg::exclusive=true, arg::autoDelete=true, arg::arguments=args); + for (int i = 0; i < 10; i++) { + f.session.messageTransfer(arg::content=Message((boost::format("%1%_%2%") % "Message" % (i+1)).str(), dataQ)); + f.session.messageTransfer(arg::content=Message((boost::format("%1%_%2%") % "Message" % (i+1)).str(), dataQ2)); + } + Message msg; + LocalQueue incoming; + Subscription sub = f.subs.subscribe(incoming, dataQ); + for (int i = 0; i < 10; i++) { + BOOST_CHECK(incoming.get(msg, qpid::sys::TIME_SEC)); + BOOST_CHECK_EQUAL((boost::format("%1%_%2%") % "Message" % (i+1)).str(), msg.getData()); + } + BOOST_CHECK(!f.subs.get(msg, dataQ)); + + sub.cancel(); + sub = f.subs.subscribe(incoming, eventQ); + //check that we received enqueue events for first queue: + for (int i = 0; i < 10; i++) { + BOOST_CHECK(incoming.get(msg, qpid::sys::TIME_SEC)); + BOOST_CHECK_EQUAL(msg.getHeaders().getAsString(REPLICATION_TARGET_QUEUE), dataQ); + BOOST_CHECK_EQUAL(msg.getHeaders().getAsInt(REPLICATION_EVENT_TYPE), ENQUEUE); + BOOST_CHECK_EQUAL(msg.getHeaders().getAsInt64(REPLICATION_EVENT_SEQNO), (i+1)); + BOOST_CHECK_EQUAL((boost::format("%1%_%2%") % "Message" % (i+1)).str(), msg.getData()); + } + //check that we received dequeue events for first queue: + for (int i = 0; i < 10; i++) { + BOOST_CHECK(incoming.get(msg, qpid::sys::TIME_SEC)); + BOOST_CHECK_EQUAL(msg.getHeaders().getAsString(REPLICATION_TARGET_QUEUE), dataQ); + BOOST_CHECK_EQUAL(msg.getHeaders().getAsInt(REPLICATION_EVENT_TYPE), DEQUEUE); + BOOST_CHECK_EQUAL(msg.getHeaders().getAsInt(DEQUEUED_MESSAGE_POSITION), (i+1)); + BOOST_CHECK_EQUAL(msg.getHeaders().getAsInt64(REPLICATION_EVENT_SEQNO), (i+11)); + } + + sub.cancel(); + sub = f.subs.subscribe(incoming, eventQ2); + //check that we received enqueue events for second queue: + for (int i = 0; i < 10; i++) { + BOOST_CHECK(incoming.get(msg, qpid::sys::TIME_SEC)); + BOOST_CHECK_EQUAL(msg.getHeaders().getAsString(REPLICATION_TARGET_QUEUE), dataQ2); + BOOST_CHECK_EQUAL(msg.getHeaders().getAsInt(REPLICATION_EVENT_TYPE), ENQUEUE); + BOOST_CHECK_EQUAL(msg.getHeaders().getAsInt64(REPLICATION_EVENT_SEQNO), (i+1)); + BOOST_CHECK_EQUAL((boost::format("%1%_%2%") % "Message" % (i+1)).str(), msg.getData()); + } +} + + +QPID_AUTO_TEST_SUITE_END() -- cgit v1.2.1 From 14816555f98f5e70dd8f8102c553c500ae9219ce Mon Sep 17 00:00:00 2001 From: "Stephen D. Huston" Date: Wed, 29 Apr 2009 23:34:33 +0000 Subject: Pass platform's shared lib prefix, suffix to test progs that need it; use it to pick up proper file for libtool/cmake/Windows git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@770001 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ReplicationTest.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'qpid/cpp/src/tests/ReplicationTest.cpp') diff --git a/qpid/cpp/src/tests/ReplicationTest.cpp b/qpid/cpp/src/tests/ReplicationTest.cpp index 7bd585639d..08f662142f 100644 --- a/qpid/cpp/src/tests/ReplicationTest.cpp +++ b/qpid/cpp/src/tests/ReplicationTest.cpp @@ -44,7 +44,13 @@ using boost::assign::list_of; QPID_AUTO_TEST_SUITE(ReplicationTestSuite) +// The CMake-based build passes in the module suffix; if it's not there, this +// is a Linux/UNIX libtool-based build. +#if defined (QPID_MODULE_SUFFIX) +qpid::sys::Shlib plugin("../replicating_listener" QPID_MODULE_SUFFIX); +#else qpid::sys::Shlib plugin("../.libs/replicating_listener.so"); +#endif qpid::broker::Broker::Options getBrokerOpts(const std::vector& args) { -- cgit v1.2.1 From 8ee91d113f20dd874beca66c40394d721ff66f7b Mon Sep 17 00:00:00 2001 From: "Stephen D. Huston" Date: Fri, 26 Jun 2009 22:26:47 +0000 Subject: Take dirpath off of plugin name to load; fixes QPID-1959 git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@788890 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ReplicationTest.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'qpid/cpp/src/tests/ReplicationTest.cpp') diff --git a/qpid/cpp/src/tests/ReplicationTest.cpp b/qpid/cpp/src/tests/ReplicationTest.cpp index 08f662142f..38dc1a9e52 100644 --- a/qpid/cpp/src/tests/ReplicationTest.cpp +++ b/qpid/cpp/src/tests/ReplicationTest.cpp @@ -1,4 +1,4 @@ - /* +/* * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -47,7 +47,7 @@ QPID_AUTO_TEST_SUITE(ReplicationTestSuite) // The CMake-based build passes in the module suffix; if it's not there, this // is a Linux/UNIX libtool-based build. #if defined (QPID_MODULE_SUFFIX) -qpid::sys::Shlib plugin("../replicating_listener" QPID_MODULE_SUFFIX); +qpid::sys::Shlib plugin("replicating_listener" QPID_MODULE_SUFFIX); #else qpid::sys::Shlib plugin("../.libs/replicating_listener.so"); #endif -- cgit v1.2.1 From ffd20ee19a5fd027e0007c27a12dd402dbeca4f8 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Tue, 14 Jul 2009 14:32:39 +0000 Subject: Add directory to #include git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@793909 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ReplicationTest.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'qpid/cpp/src/tests/ReplicationTest.cpp') diff --git a/qpid/cpp/src/tests/ReplicationTest.cpp b/qpid/cpp/src/tests/ReplicationTest.cpp index 38dc1a9e52..38369640a9 100644 --- a/qpid/cpp/src/tests/ReplicationTest.cpp +++ b/qpid/cpp/src/tests/ReplicationTest.cpp @@ -18,9 +18,9 @@ * under the License. * */ -#include "unit_test.h" -#include "test_tools.h" -#include "BrokerFixture.h" +#include "tests/unit_test.h" +#include "tests/test_tools.h" +#include "tests/BrokerFixture.h" #include "qpid/Plugin.h" #include "qpid/broker/Broker.h" -- cgit v1.2.1 From 795b3bb9e5c033abf33635119694e21e7143fc0a Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Tue, 14 Jul 2009 14:41:22 +0000 Subject: Remove incorrect directory from #include git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@793912 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ReplicationTest.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'qpid/cpp/src/tests/ReplicationTest.cpp') diff --git a/qpid/cpp/src/tests/ReplicationTest.cpp b/qpid/cpp/src/tests/ReplicationTest.cpp index 38369640a9..38dc1a9e52 100644 --- a/qpid/cpp/src/tests/ReplicationTest.cpp +++ b/qpid/cpp/src/tests/ReplicationTest.cpp @@ -18,9 +18,9 @@ * under the License. * */ -#include "tests/unit_test.h" -#include "tests/test_tools.h" -#include "tests/BrokerFixture.h" +#include "unit_test.h" +#include "test_tools.h" +#include "BrokerFixture.h" #include "qpid/Plugin.h" #include "qpid/broker/Broker.h" -- cgit v1.2.1 From 9259c46ecb8c5f3e98441080a26914bdea59bffe Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Wed, 9 Sep 2009 19:46:56 +0000 Subject: Tidied up namespace usage Miscelleneous whitespace fixes git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@813094 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ReplicationTest.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'qpid/cpp/src/tests/ReplicationTest.cpp') diff --git a/qpid/cpp/src/tests/ReplicationTest.cpp b/qpid/cpp/src/tests/ReplicationTest.cpp index 38dc1a9e52..ed768f1306 100644 --- a/qpid/cpp/src/tests/ReplicationTest.cpp +++ b/qpid/cpp/src/tests/ReplicationTest.cpp @@ -7,9 +7,9 @@ * 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 @@ -42,6 +42,9 @@ using namespace qpid::framing; using namespace qpid::replication::constants; using boost::assign::list_of; +namespace qpid { +namespace tests { + QPID_AUTO_TEST_SUITE(ReplicationTestSuite) // The CMake-based build passes in the module suffix; if it's not there, this @@ -63,7 +66,7 @@ qpid::broker::Broker::Options getBrokerOpts(const std::vector& args return opts; } -QPID_AUTO_TEST_CASE(testReplicationExchange) +QPID_AUTO_TEST_CASE(testReplicationExchange) { qpid::broker::Broker::Options brokerOpts(getBrokerOpts(list_of("qpidd") ("--replication-exchange-name=qpid.replication"))); @@ -79,7 +82,7 @@ QPID_AUTO_TEST_CASE(testReplicationExchange) f.session.queueDeclare(arg::queue=eventQ, arg::exclusive=true, arg::autoDelete=true, arg::arguments=eventQopts); f.session.exchangeBind(arg::exchange="qpid.replication", arg::queue=eventQ, arg::bindingKey=dataQ); - + f.session.queueDeclare(arg::queue=eventQ2, arg::exclusive=true, arg::autoDelete=true, arg::arguments=eventQopts); f.session.exchangeBind(arg::exchange="qpid.replication", arg::queue=eventQ2, arg::bindingKey=dataQ2); @@ -133,3 +136,5 @@ QPID_AUTO_TEST_CASE(testReplicationExchange) QPID_AUTO_TEST_SUITE_END() + +}} // namespace qpid::tests -- cgit v1.2.1 From 6bb0134ca322b6e50e6ec76a242f89259cd12274 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Mon, 30 Nov 2009 19:34:36 +0000 Subject: Clean up test environment variables, prepare for running more tests in cmake. - consolidate test env vars in test_env.sh, also useful from command line. - generate test_env.sh with autoconf/cmake to cover library location differences. - Remove explicit mention of .libs, use $QPID_MODULE_DIR to load modules. - Fix run_test to run valgrind under cmake git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@885557 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ReplicationTest.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'qpid/cpp/src/tests/ReplicationTest.cpp') diff --git a/qpid/cpp/src/tests/ReplicationTest.cpp b/qpid/cpp/src/tests/ReplicationTest.cpp index ed768f1306..3b289d1b4e 100644 --- a/qpid/cpp/src/tests/ReplicationTest.cpp +++ b/qpid/cpp/src/tests/ReplicationTest.cpp @@ -47,12 +47,13 @@ namespace tests { QPID_AUTO_TEST_SUITE(ReplicationTestSuite) +// FIXME aconway 2009-11-26: clean this up. // The CMake-based build passes in the module suffix; if it's not there, this // is a Linux/UNIX libtool-based build. #if defined (QPID_MODULE_SUFFIX) qpid::sys::Shlib plugin("replicating_listener" QPID_MODULE_SUFFIX); #else -qpid::sys::Shlib plugin("../.libs/replicating_listener.so"); +qpid::sys::Shlib plugin(getLibPath("REPLICATING_LISTENER_LIB")); #endif qpid::broker::Broker::Options getBrokerOpts(const std::vector& args) -- cgit v1.2.1 From 06a7140bb80448d4e8884f2644663862cb03c92f Mon Sep 17 00:00:00 2001 From: "Stephen D. Huston" Date: Fri, 28 May 2010 14:07:25 +0000 Subject: Allow tests that load shareable libs to work on Windows with a debug build. Those libs have a 'd' appended to their name. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@949181 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ReplicationTest.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'qpid/cpp/src/tests/ReplicationTest.cpp') diff --git a/qpid/cpp/src/tests/ReplicationTest.cpp b/qpid/cpp/src/tests/ReplicationTest.cpp index 3b289d1b4e..7310a3fe20 100644 --- a/qpid/cpp/src/tests/ReplicationTest.cpp +++ b/qpid/cpp/src/tests/ReplicationTest.cpp @@ -20,6 +20,7 @@ */ #include "unit_test.h" #include "test_tools.h" +#include "config.h" #include "BrokerFixture.h" #include "qpid/Plugin.h" @@ -50,11 +51,13 @@ QPID_AUTO_TEST_SUITE(ReplicationTestSuite) // FIXME aconway 2009-11-26: clean this up. // The CMake-based build passes in the module suffix; if it's not there, this // is a Linux/UNIX libtool-based build. -#if defined (QPID_MODULE_SUFFIX) -qpid::sys::Shlib plugin("replicating_listener" QPID_MODULE_SUFFIX); +#if defined (QPID_MODULE_PREFIX) && defined (QPID_MODULE_SUFFIX) +static const char *default_shlib = + QPID_MODULE_PREFIX "replicating_listener" QPID_MODULE_POSTFIX QPID_MODULE_SUFFIX; #else -qpid::sys::Shlib plugin(getLibPath("REPLICATING_LISTENER_LIB")); +static const char *default_shlib = ".libs/replicating_listener.so"; #endif +qpid::sys::Shlib plugin(getLibPath("REPLICATING_LISTENER_LIB", default_shlib)); qpid::broker::Broker::Options getBrokerOpts(const std::vector& args) { -- cgit v1.2.1