summaryrefslogtreecommitdiff
path: root/cpp/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/tests')
-rw-r--r--cpp/src/tests/Array.cpp4
-rw-r--r--cpp/src/tests/CMakeLists.txt25
-rw-r--r--cpp/src/tests/ExchangeTest.cpp46
-rw-r--r--cpp/src/tests/FieldTable.cpp4
-rw-r--r--cpp/src/tests/Frame.cpp1
-rw-r--r--cpp/src/tests/FramingTest.cpp1
-rw-r--r--cpp/src/tests/Makefile.am23
-rw-r--r--cpp/src/tests/MessagingSessionTests.cpp7
-rw-r--r--cpp/src/tests/QueueFlowLimitTest.cpp1
-rw-r--r--cpp/src/tests/QueueTest.cpp52
-rw-r--r--cpp/src/tests/RefCounted.cpp6
-rw-r--r--cpp/src/tests/SessionState.cpp1
-rw-r--r--cpp/src/tests/StringUtils.cpp6
-rw-r--r--cpp/src/tests/Uuid.cpp2
-rwxr-xr-xcpp/src/tests/acl.py957
-rw-r--r--cpp/src/tests/amqp_0_10/Map.cpp98
-rw-r--r--cpp/src/tests/amqp_0_10/ProxyTemplate.cpp49
-rw-r--r--cpp/src/tests/amqp_0_10/apply.cpp99
-rw-r--r--cpp/src/tests/amqp_0_10/handlers.cpp125
-rw-r--r--cpp/src/tests/amqp_0_10/serialize.cpp429
-rw-r--r--cpp/src/tests/brokertest.py56
-rwxr-xr-xcpp/src/tests/cli_tests.py139
-rw-r--r--cpp/src/tests/cluster.cmake2
-rw-r--r--cpp/src/tests/cluster.mk11
-rwxr-xr-xcpp/src/tests/cluster_failover19
-rwxr-xr-xcpp/src/tests/cluster_python_tests3
-rwxr-xr-xcpp/src/tests/cluster_read_credit4
-rwxr-xr-xcpp/src/tests/cluster_test_logs.py6
-rwxr-xr-xcpp/src/tests/cluster_tests.py122
-rwxr-xr-xcpp/src/tests/clustered_replication_test27
-rwxr-xr-xcpp/src/tests/cpg_check.sh.in (renamed from cpp/src/tests/ais_check)18
-rwxr-xr-xcpp/src/tests/federated_cluster_test35
-rwxr-xr-xcpp/src/tests/ha_tests.py523
-rw-r--r--cpp/src/tests/install_env.sh.in2
-rwxr-xr-xcpp/src/tests/ipv6_test9
-rw-r--r--cpp/src/tests/logging.cpp9
-rw-r--r--cpp/src/tests/python_tests.ps15
-rwxr-xr-xcpp/src/tests/qpid-cluster-benchmark29
-rwxr-xr-xcpp/src/tests/qpid-cpp-benchmark69
-rw-r--r--cpp/src/tests/qpid-perftest.cpp12
-rw-r--r--cpp/src/tests/qpid-ping.cpp27
-rw-r--r--cpp/src/tests/qpid-send.cpp67
-rw-r--r--cpp/src/tests/qpid-txtest.cpp5
-rw-r--r--cpp/src/tests/qpidd-empty.conf3
-rw-r--r--cpp/src/tests/queue_flow_limit_tests.py2
-rwxr-xr-xcpp/src/tests/reliable_replication_test6
-rwxr-xr-xcpp/src/tests/replication_test34
-rwxr-xr-xcpp/src/tests/ring_queue_test2
-rwxr-xr-xcpp/src/tests/run_acl_tests24
-rw-r--r--cpp/src/tests/run_acl_tests.ps15
-rwxr-xr-xcpp/src/tests/run_cli_tests4
-rwxr-xr-xcpp/src/tests/run_cluster_authentication_soak3
-rwxr-xr-xcpp/src/tests/run_cluster_authentication_test3
-rwxr-xr-xcpp/src/tests/run_cluster_test3
-rwxr-xr-xcpp/src/tests/run_cluster_tests4
-rwxr-xr-xcpp/src/tests/run_failover_soak3
-rwxr-xr-xcpp/src/tests/run_federation_sys_tests8
-rwxr-xr-xcpp/src/tests/run_federation_tests15
-rw-r--r--cpp/src/tests/run_federation_tests.ps13
-rw-r--r--cpp/src/tests/run_header_test.ps13
-rwxr-xr-xcpp/src/tests/run_msg_group_tests8
-rwxr-xr-xcpp/src/tests/run_msg_group_tests_soak4
-rw-r--r--cpp/src/tests/run_store_tests.ps19
-rw-r--r--cpp/src/tests/run_test.ps15
-rw-r--r--cpp/src/tests/sasl.mk21
-rwxr-xr-xcpp/src/tests/sasl_fed16
-rwxr-xr-xcpp/src/tests/sasl_fed_ex12
-rwxr-xr-xcpp/src/tests/sasl_fed_ex_dynamic_cluster4
-rwxr-xr-xcpp/src/tests/sasl_fed_ex_link_cluster3
-rwxr-xr-xcpp/src/tests/sasl_fed_ex_queue_cluster3
-rwxr-xr-xcpp/src/tests/sasl_fed_ex_route_cluster3
-rwxr-xr-xcpp/src/tests/ssl_test13
-rwxr-xr-xcpp/src/tests/start_cluster3
-rw-r--r--cpp/src/tests/test_env.ps1.in78
-rw-r--r--cpp/src/tests/test_env.sh.in2
-rw-r--r--cpp/src/tests/testagent.cpp11
-rw-r--r--cpp/src/tests/testlib.py4
-rw-r--r--cpp/src/tests/windows/DisableWin32ErrorWindows.cpp6
78 files changed, 1865 insertions, 1600 deletions
diff --git a/cpp/src/tests/Array.cpp b/cpp/src/tests/Array.cpp
index 7622b89d15..8ce7615162 100644
--- a/cpp/src/tests/Array.cpp
+++ b/cpp/src/tests/Array.cpp
@@ -58,7 +58,7 @@ QPID_AUTO_TEST_CASE(testEncodeDecode)
BOOST_CHECK_EQUAL(a, b);
std::vector<std::string> data2;
- b.collect(data2);
+ std::transform(b.begin(), b.end(), std::back_inserter(data2), Array::get<std::string, Array::ValuePtr>);
//BOOST_CHECK_EQUAL(data, data2);
BOOST_CHECK(data == data2);
}
@@ -74,7 +74,7 @@ QPID_AUTO_TEST_CASE(testArrayAssignment)
BOOST_CHECK_EQUAL(a, b);
}
std::vector<std::string> data2;
- b.collect(data2);
+ std::transform(b.begin(), b.end(), std::back_inserter(data2), Array::get<std::string, Array::ValuePtr>);
//BOOST_CHECK_EQUAL(data, data2);
BOOST_CHECK(data == data2);
}
diff --git a/cpp/src/tests/CMakeLists.txt b/cpp/src/tests/CMakeLists.txt
index 75ecffe866..5979ce42ae 100644
--- a/cpp/src/tests/CMakeLists.txt
+++ b/cpp/src/tests/CMakeLists.txt
@@ -23,7 +23,11 @@ include (CTest)
# Make sure that everything get built before the tests
# Need to create a var with all the necessary top level targets
-add_definitions(-DBOOST_TEST_DYN_LINK)
+# If we're linking Boost for DLLs, turn that on for the unit test too.
+if (QPID_LINK_BOOST_DYNAMIC)
+ add_definitions(-DBOOST_TEST_DYN_LINK)
+endif (QPID_LINK_BOOST_DYNAMIC)
+
include_directories( ${CMAKE_CURRENT_SOURCE_DIR} )
include (FindPythonInterp)
@@ -34,8 +38,14 @@ set (abs_builddir ${CMAKE_CURRENT_BINARY_DIR})
set (abs_top_srcdir ${CMAKE_SOURCE_DIR})
set (abs_top_builddir ${CMAKE_BINARY_DIR})
set (builddir_lib_suffix "")
-configure_file (${CMAKE_CURRENT_SOURCE_DIR}/test_env.sh.in
- ${CMAKE_CURRENT_BINARY_DIR}/test_env.sh)
+
+if (CMAKE_SYSTEM_NAME STREQUAL Windows)
+ configure_file (${CMAKE_CURRENT_SOURCE_DIR}/test_env.ps1.in
+ ${CMAKE_CURRENT_BINARY_DIR}/test_env.ps1)
+else (CMAKE_SYSTEM_NAME STREQUAL Windows)
+ configure_file (${CMAKE_CURRENT_SOURCE_DIR}/test_env.sh.in
+ ${CMAKE_CURRENT_BINARY_DIR}/test_env.sh)
+endif (CMAKE_SYSTEM_NAME STREQUAL Windows)
# If valgrind is selected in the configuration step, set up the path to it
@@ -145,13 +155,6 @@ set(unit_tests_to_build
mark_as_advanced(unit_tests_to_build)
-# Disabled till we move to amqp_0_10 codec.
-# amqp_0_10/serialize.cpp allSegmentTypes.h \
-# amqp_0_10/ProxyTemplate.cpp \
-# amqp_0_10/apply.cpp \
-# amqp_0_10/Map.cpp \
-# amqp_0_10/handlers.cpp
-
add_executable (unit_test unit_test
${unit_tests_to_build} ${platform_test_additions})
target_link_libraries (unit_test
@@ -320,7 +323,7 @@ if (BUILD_MSSQL)
add_test (store_tests ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/run_store_tests${test_script_suffix} MSSQL)
endif (BUILD_MSSQL)
if (BUILD_MSCLFS)
- add_test (store_tests ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/run_store_tests${test_script_suffix} MSSQL-CLFS)
+ add_test (store_tests_clfs ${shell} ${CMAKE_CURRENT_SOURCE_DIR}/run_store_tests${test_script_suffix} MSSQL-CLFS)
endif (BUILD_MSCLFS)
endif (PYTHON_EXECUTABLE)
diff --git a/cpp/src/tests/ExchangeTest.cpp b/cpp/src/tests/ExchangeTest.cpp
index fe72f42a46..2fb284741a 100644
--- a/cpp/src/tests/ExchangeTest.cpp
+++ b/cpp/src/tests/ExchangeTest.cpp
@@ -60,10 +60,10 @@ QPID_AUTO_TEST_CASE(testMe)
queue.reset();
queue2.reset();
- intrusive_ptr<Message> msgPtr(MessageUtils::createMessage("exchange", "key", false, "id"));
+ intrusive_ptr<Message> msgPtr(MessageUtils::createMessage("exchange", "abc", false, "id"));
DeliverableMessage msg(msgPtr);
- topic.route(msg, "abc", 0);
- direct.route(msg, "abc", 0);
+ topic.route(msg);
+ direct.route(msg);
}
@@ -187,17 +187,17 @@ QPID_AUTO_TEST_CASE(testSequenceOptions)
{
DirectExchange direct("direct1", false, args);
- intrusive_ptr<Message> msg1 = cmessage("e", "A");
- intrusive_ptr<Message> msg2 = cmessage("e", "B");
- intrusive_ptr<Message> msg3 = cmessage("e", "C");
+ intrusive_ptr<Message> msg1 = cmessage("e", "abc");
+ intrusive_ptr<Message> msg2 = cmessage("e", "abc");
+ intrusive_ptr<Message> msg3 = cmessage("e", "abc");
DeliverableMessage dmsg1(msg1);
DeliverableMessage dmsg2(msg2);
DeliverableMessage dmsg3(msg3);
- direct.route(dmsg1, "abc", 0);
- direct.route(dmsg2, "abc", 0);
- direct.route(dmsg3, "abc", 0);
+ direct.route(dmsg1);
+ direct.route(dmsg2);
+ direct.route(dmsg3);
BOOST_CHECK_EQUAL(1, msg1->getApplicationHeaders()->getAsInt64("qpid.msg_sequence"));
BOOST_CHECK_EQUAL(2, msg2->getApplicationHeaders()->getAsInt64("qpid.msg_sequence"));
@@ -208,22 +208,24 @@ QPID_AUTO_TEST_CASE(testSequenceOptions)
TopicExchange topic ("topic1", false, args);
// check other exchanges, that they preroute
- intrusive_ptr<Message> msg4 = cmessage("e", "A");
- intrusive_ptr<Message> msg5 = cmessage("e", "B");
- intrusive_ptr<Message> msg6 = cmessage("e", "C");
+ intrusive_ptr<Message> msg4 = cmessage("e", "abc");
+ intrusive_ptr<Message> msg5 = cmessage("e", "abc");
+
+ // Need at least empty header for the HeadersExchange to route at all
+ msg5->insertCustomProperty("", "");
+ intrusive_ptr<Message> msg6 = cmessage("e", "abc");
DeliverableMessage dmsg4(msg4);
DeliverableMessage dmsg5(msg5);
DeliverableMessage dmsg6(msg6);
- fanout.route(dmsg4, "abc", 0);
+ fanout.route(dmsg4);
BOOST_CHECK_EQUAL(1, msg4->getApplicationHeaders()->getAsInt64("qpid.msg_sequence"));
- FieldTable headers;
- header.route(dmsg5, "abc", &headers);
+ header.route(dmsg5);
BOOST_CHECK_EQUAL(1, msg5->getApplicationHeaders()->getAsInt64("qpid.msg_sequence"));
- topic.route(dmsg6, "abc", 0);
+ topic.route(dmsg6);
BOOST_CHECK_EQUAL(1, msg6->getApplicationHeaders()->getAsInt64("qpid.msg_sequence"));
direct.encode(buffer);
}
@@ -233,9 +235,9 @@ QPID_AUTO_TEST_CASE(testSequenceOptions)
buffer.reset();
DirectExchange::shared_ptr exch_dec = Exchange::decode(exchanges, buffer);
- intrusive_ptr<Message> msg1 = cmessage("e", "A");
+ intrusive_ptr<Message> msg1 = cmessage("e", "abc");
DeliverableMessage dmsg1(msg1);
- exch_dec->route(dmsg1, "abc", 0);
+ exch_dec->route(dmsg1);
BOOST_CHECK_EQUAL(4, msg1->getApplicationHeaders()->getAsInt64("qpid.msg_sequence"));
@@ -260,10 +262,10 @@ QPID_AUTO_TEST_CASE(testIVEOption)
args2.setString("x-match", "any");
args2.setString("a", "abc");
- direct.route(dmsg1, "abc", 0);
- fanout.route(dmsg1, "abc", 0);
- header.route(dmsg1, "abc", &args2);
- topic.route(dmsg1, "abc", 0);
+ direct.route(dmsg1);
+ fanout.route(dmsg1);
+ header.route(dmsg1);
+ topic.route(dmsg1);
Queue::shared_ptr queue(new Queue("queue", true));
Queue::shared_ptr queue1(new Queue("queue1", true));
Queue::shared_ptr queue2(new Queue("queue2", true));
diff --git a/cpp/src/tests/FieldTable.cpp b/cpp/src/tests/FieldTable.cpp
index fe2a14ec03..c79d110ae4 100644
--- a/cpp/src/tests/FieldTable.cpp
+++ b/cpp/src/tests/FieldTable.cpp
@@ -19,11 +19,11 @@
*
*/
#include <iostream>
+#include <algorithm>
#include "qpid/framing/Array.h"
#include "qpid/framing/FieldTable.h"
#include "qpid/framing/FieldValue.h"
#include "qpid/framing/List.h"
-#include "qpid/sys/alloca.h"
#include "unit_test.h"
@@ -127,7 +127,7 @@ QPID_AUTO_TEST_CASE(testNestedValues)
BOOST_CHECK(string("B") == b.getAsString("id"));
a.getArray("C", c);
std::vector<std::string> items;
- c.collect(items);
+ std::transform(c.begin(), c.end(), std::back_inserter(items), Array::get<std::string, Array::ValuePtr>);
BOOST_CHECK((uint) 2 == items.size());
BOOST_CHECK(string("one") == items[0]);
BOOST_CHECK(string("two") == items[1]);
diff --git a/cpp/src/tests/Frame.cpp b/cpp/src/tests/Frame.cpp
index 1270eabba3..cfcfde04a7 100644
--- a/cpp/src/tests/Frame.cpp
+++ b/cpp/src/tests/Frame.cpp
@@ -30,7 +30,6 @@ QPID_AUTO_TEST_SUITE(FrameTestSuite)
using namespace std;
using namespace qpid::framing;
-using namespace boost;
QPID_AUTO_TEST_CASE(testContentBody) {
Frame f(42, AMQContentBody("foobar"));
diff --git a/cpp/src/tests/FramingTest.cpp b/cpp/src/tests/FramingTest.cpp
index f8795316cc..2392b6fec4 100644
--- a/cpp/src/tests/FramingTest.cpp
+++ b/cpp/src/tests/FramingTest.cpp
@@ -25,6 +25,7 @@
#include "qpid/framing/all_method_bodies.h"
#include "qpid/framing/amqp_framing.h"
#include "qpid/framing/reply_exceptions.h"
+#include "qpid/framing/FieldValue.h"
#include "unit_test.h"
#include <boost/bind.hpp>
diff --git a/cpp/src/tests/Makefile.am b/cpp/src/tests/Makefile.am
index 325019fb22..66d2cdd5d5 100644
--- a/cpp/src/tests/Makefile.am
+++ b/cpp/src/tests/Makefile.am
@@ -149,7 +149,7 @@ endif
# Test programs that are installed and therefore built as part of make, not make check
-qpidexectest_SCRIPTS += qpid-cpp-benchmark install_env.sh
+qpidexectest_SCRIPTS += qpid-cpp-benchmark qpid-cluster-benchmark install_env.sh
EXTRA_DIST += qpid-cpp-benchmark install_env.sh
qpidexectest_PROGRAMS += receiver
@@ -320,7 +320,7 @@ EXTRA_DIST += \
header_test.py \
ssl_test \
config.null \
- ais_check \
+ cpg_check.sh.in \
run_federation_tests \
run_federation_sys_tests \
run_long_federation_sys_tests \
@@ -351,7 +351,9 @@ EXTRA_DIST += \
topictest.ps1 \
run_queue_flow_limit_tests \
run_msg_group_tests \
- ipv6_test
+ ipv6_test \
+ ha_tests.py \
+ test_env.ps1.in
check_LTLIBRARIES += libdlclose_noop.la
libdlclose_noop_la_LDFLAGS = -module -rpath $(abs_builddir)
@@ -366,9 +368,15 @@ LONG_TESTS+=start_broker \
fanout_perftest shared_perftest multiq_perftest topic_perftest run_ring_queue_test \
run_msg_group_tests_soak \
stop_broker \
- run_long_federation_sys_tests \
- run_failover_soak reliable_replication_test \
- federated_cluster_test_with_node_failure
+ run_long_federation_sys_tests
+
+if HAVE_LIBCPG
+
+LONG_TESTS+= federated_cluster_test_with_node_failure \
+ run_failover_soak \
+ reliable_replication_test
+
+endif HAVE_LIBCPG
EXTRA_DIST+= \
fanout_perftest \
@@ -379,7 +387,8 @@ EXTRA_DIST+= \
reliable_replication_test \
federated_cluster_test_with_node_failure \
sasl_test_setup.sh \
- run_msg_group_tests_soak
+ run_msg_group_tests_soak \
+ qpidd-empty.conf
check-long:
$(MAKE) check TESTS="$(LONG_TESTS)" VALGRIND=
diff --git a/cpp/src/tests/MessagingSessionTests.cpp b/cpp/src/tests/MessagingSessionTests.cpp
index 313e8b3132..968d55fd45 100644
--- a/cpp/src/tests/MessagingSessionTests.cpp
+++ b/cpp/src/tests/MessagingSessionTests.cpp
@@ -1139,6 +1139,13 @@ QPID_AUTO_TEST_CASE(testHeadersExchange)
}
}
+QPID_AUTO_TEST_CASE(testLargeRoutingKey)
+{
+ MessagingFixture fix;
+ std::string address = "amq.direct/" + std::string(300, 'x');//routing/binding key can be at most 225 chars in 0-10
+ BOOST_CHECK_THROW(fix.session.createReceiver(address), qpid::messaging::MessagingException);
+}
+
QPID_AUTO_TEST_SUITE_END()
}} // namespace qpid::tests
diff --git a/cpp/src/tests/QueueFlowLimitTest.cpp b/cpp/src/tests/QueueFlowLimitTest.cpp
index 8a6923fb09..bd868398f8 100644
--- a/cpp/src/tests/QueueFlowLimitTest.cpp
+++ b/cpp/src/tests/QueueFlowLimitTest.cpp
@@ -27,6 +27,7 @@
#include "qpid/broker/QueueFlowLimit.h"
#include "qpid/sys/Time.h"
#include "qpid/framing/reply_exceptions.h"
+#include "qpid/framing/FieldValue.h"
#include "MessageUtils.h"
#include "BrokerFixture.h"
diff --git a/cpp/src/tests/QueueTest.cpp b/cpp/src/tests/QueueTest.cpp
index bb4f7b9f4b..0058aa5133 100644
--- a/cpp/src/tests/QueueTest.cpp
+++ b/cpp/src/tests/QueueTest.cpp
@@ -254,8 +254,8 @@ QPID_AUTO_TEST_CASE(testBound){
//ensure the remaining exchanges don't still have the queue bound to them:
FailOnDeliver deliverable;
- exchange1->route(deliverable, key, &args);
- exchange3->route(deliverable, key, &args);
+ exchange1->route(deliverable);
+ exchange3->route(deliverable);
}
QPID_AUTO_TEST_CASE(testPersistLastNodeStanding){
@@ -1151,7 +1151,7 @@ QPID_AUTO_TEST_CASE(testFlowToDiskBlocking){
intrusive_ptr<Message> msg01 = mkMsg(testStore, std::string(5, 'X')); // transient w/ content
DeliverableMessage dmsg01(msg01);
- sbtFanout1.route(dmsg01, "", 0); // Brings queue 1 to capacity limit
+ sbtFanout1.route(dmsg01); // Brings queue 1 to capacity limit
msg01->tryReleaseContent();
BOOST_CHECK_EQUAL(msg01->isContentReleased(), false);
BOOST_CHECK_EQUAL(1u, tq1->getMessageCount());
@@ -1160,7 +1160,7 @@ QPID_AUTO_TEST_CASE(testFlowToDiskBlocking){
DeliverableMessage dmsg02(msg02);
{
ScopedSuppressLogging sl; // suppress expected error messages.
- BOOST_CHECK_THROW(sbtFanout1.route(dmsg02, "", 0), ResourceLimitExceededException);
+ BOOST_CHECK_THROW(sbtFanout1.route(dmsg02), ResourceLimitExceededException);
}
msg02->tryReleaseContent();
BOOST_CHECK_EQUAL(msg02->isContentReleased(), false);
@@ -1170,7 +1170,7 @@ QPID_AUTO_TEST_CASE(testFlowToDiskBlocking){
DeliverableMessage dmsg03(msg03);
{
ScopedSuppressLogging sl; // suppress expected error messages.
- BOOST_CHECK_THROW(sbtFanout1.route(dmsg03, "", 0), ResourceLimitExceededException);
+ BOOST_CHECK_THROW(sbtFanout1.route(dmsg03), ResourceLimitExceededException);
}
msg03->tryReleaseContent();
BOOST_CHECK_EQUAL(msg03->isContentReleased(), false);
@@ -1180,7 +1180,7 @@ QPID_AUTO_TEST_CASE(testFlowToDiskBlocking){
DeliverableMessage dmsg04(msg04);
{
ScopedSuppressLogging sl; // suppress expected error messages.
- BOOST_CHECK_THROW(sbtFanout1.route(dmsg04, "", 0), ResourceLimitExceededException);
+ BOOST_CHECK_THROW(sbtFanout1.route(dmsg04), ResourceLimitExceededException);
}
msg04->tryReleaseContent();
BOOST_CHECK_EQUAL(msg04->isContentReleased(), false);
@@ -1190,7 +1190,7 @@ QPID_AUTO_TEST_CASE(testFlowToDiskBlocking){
DeliverableMessage dmsg05(msg05);
{
ScopedSuppressLogging sl; // suppress expected error messages.
- BOOST_CHECK_THROW(sbtFanout1.route(dmsg05, "", 0), ResourceLimitExceededException);
+ BOOST_CHECK_THROW(sbtFanout1.route(dmsg05), ResourceLimitExceededException);
}
msg05->tryReleaseContent();
BOOST_CHECK_EQUAL(msg05->isContentReleased(), false);
@@ -1205,35 +1205,35 @@ QPID_AUTO_TEST_CASE(testFlowToDiskBlocking){
intrusive_ptr<Message> msg06 = mkMsg(testStore, std::string(5, 'X')); // transient w/ content
DeliverableMessage dmsg06(msg06);
- sbdFanout2.route(dmsg06, "", 0); // Brings queue 2 to capacity limit
+ sbdFanout2.route(dmsg06); // Brings queue 2 to capacity limit
msg06->tryReleaseContent();
BOOST_CHECK_EQUAL(msg06->isContentReleased(), false);
BOOST_CHECK_EQUAL(1u, dq2->getMessageCount());
intrusive_ptr<Message> msg07 = mkMsg(testStore, std::string(5, 'X')); // transient w/ content
DeliverableMessage dmsg07(msg07);
- sbdFanout2.route(dmsg07, "", 0);
+ sbdFanout2.route(dmsg07);
msg07->tryReleaseContent();
BOOST_CHECK_EQUAL(msg07->isContentReleased(), true);
BOOST_CHECK_EQUAL(2u, dq2->getMessageCount());
intrusive_ptr<Message> msg08 = mkMsg(testStore, std::string(5, 'X'), true); // durable w/ content
DeliverableMessage dmsg08(msg08);
- sbdFanout2.route(dmsg08, "", 0);
+ sbdFanout2.route(dmsg08);
msg08->tryReleaseContent();
BOOST_CHECK_EQUAL(msg08->isContentReleased(), true);
BOOST_CHECK_EQUAL(3u, dq2->getMessageCount());
intrusive_ptr<Message> msg09 = mkMsg(testStore); // transient no content
DeliverableMessage dmsg09(msg09);
- sbdFanout2.route(dmsg09, "", 0);
+ sbdFanout2.route(dmsg09);
msg09->tryReleaseContent();
BOOST_CHECK_EQUAL(msg09->isContentReleased(), true);
BOOST_CHECK_EQUAL(4u, dq2->getMessageCount());
intrusive_ptr<Message> msg10 = mkMsg(testStore, "", true); // durable no content
DeliverableMessage dmsg10(msg10);
- sbdFanout2.route(dmsg10, "", 0);
+ sbdFanout2.route(dmsg10);
msg10->tryReleaseContent();
BOOST_CHECK_EQUAL(msg10->isContentReleased(), true);
BOOST_CHECK_EQUAL(5u, dq2->getMessageCount());
@@ -1253,7 +1253,7 @@ QPID_AUTO_TEST_CASE(testFlowToDiskBlocking){
intrusive_ptr<Message> msg11 = mkMsg(testStore, std::string(5, 'X')); // transient w/ content
DeliverableMessage dmsg11(msg11);
- mbdFanout3.route(dmsg11, "", 0); // Brings queues 3 and 4 to capacity limit
+ mbdFanout3.route(dmsg11); // Brings queues 3 and 4 to capacity limit
msg11->tryReleaseContent();
BOOST_CHECK_EQUAL(msg11->isContentReleased(), false);
BOOST_CHECK_EQUAL(1u, dq3->getMessageCount());
@@ -1262,7 +1262,7 @@ QPID_AUTO_TEST_CASE(testFlowToDiskBlocking){
intrusive_ptr<Message> msg12 = mkMsg(testStore, std::string(5, 'X')); // transient w/ content
DeliverableMessage dmsg12(msg12);
- mbdFanout3.route(dmsg12, "", 0);
+ mbdFanout3.route(dmsg12);
msg12->tryReleaseContent();
BOOST_CHECK_EQUAL(msg12->isContentReleased(), false); // XXXX - consequence of transient msg multi-queue ftd policy-handling limitations, fix in broker at some point!
BOOST_CHECK_EQUAL(2u, dq3->getMessageCount());
@@ -1271,7 +1271,7 @@ QPID_AUTO_TEST_CASE(testFlowToDiskBlocking){
intrusive_ptr<Message> msg13 = mkMsg(testStore, std::string(5, 'X'), true); // durable w/ content
DeliverableMessage dmsg13(msg13);
- mbdFanout3.route(dmsg13, "", 0);
+ mbdFanout3.route(dmsg13);
msg13->tryReleaseContent();
BOOST_CHECK_EQUAL(msg13->isContentReleased(), true);
BOOST_CHECK_EQUAL(3u, dq3->getMessageCount());
@@ -1280,7 +1280,7 @@ QPID_AUTO_TEST_CASE(testFlowToDiskBlocking){
intrusive_ptr<Message> msg14 = mkMsg(testStore); // transient no content
DeliverableMessage dmsg14(msg14);
- mbdFanout3.route(dmsg14, "", 0);
+ mbdFanout3.route(dmsg14);
msg14->tryReleaseContent();
BOOST_CHECK_EQUAL(msg14->isContentReleased(), false); // XXXX - consequence of transient msg multi-queue ftd policy-handling limitations, fix in broker at some point!
BOOST_CHECK_EQUAL(4u, dq3->getMessageCount());
@@ -1289,7 +1289,7 @@ QPID_AUTO_TEST_CASE(testFlowToDiskBlocking){
intrusive_ptr<Message> msg15 = mkMsg(testStore, "", true); // durable no content
DeliverableMessage dmsg15(msg15);
- mbdFanout3.route(dmsg15, "", 0);
+ mbdFanout3.route(dmsg15);
msg15->tryReleaseContent();
BOOST_CHECK_EQUAL(msg15->isContentReleased(), true);
BOOST_CHECK_EQUAL(5u, dq3->getMessageCount());
@@ -1307,7 +1307,7 @@ QPID_AUTO_TEST_CASE(testFlowToDiskBlocking){
intrusive_ptr<Message> msg16 = mkMsg(testStore, std::string(5, 'X')); // transient w/ content
DeliverableMessage dmsg16(msg16);
- mbdFanout3.route(dmsg16, "", 0);
+ mbdFanout3.route(dmsg16);
msg16->tryReleaseContent();
BOOST_CHECK_EQUAL(msg16->isContentReleased(), false);
BOOST_CHECK_EQUAL(6u, dq3->getMessageCount());
@@ -1316,7 +1316,7 @@ QPID_AUTO_TEST_CASE(testFlowToDiskBlocking){
intrusive_ptr<Message> msg17 = mkMsg(testStore, std::string(5, 'X'), true); // durable w/ content
DeliverableMessage dmsg17(msg17);
- mbdFanout3.route(dmsg17, "", 0);
+ mbdFanout3.route(dmsg17);
msg17->tryReleaseContent();
BOOST_CHECK_EQUAL(msg17->isContentReleased(), false);
BOOST_CHECK_EQUAL(7u, dq3->getMessageCount());
@@ -1325,7 +1325,7 @@ QPID_AUTO_TEST_CASE(testFlowToDiskBlocking){
intrusive_ptr<Message> msg18 = mkMsg(testStore); // transient no content
DeliverableMessage dmsg18(msg18);
- mbdFanout3.route(dmsg18, "", 0);
+ mbdFanout3.route(dmsg18);
msg18->tryReleaseContent();
BOOST_CHECK_EQUAL(msg18->isContentReleased(), false);
BOOST_CHECK_EQUAL(8u, dq3->getMessageCount());
@@ -1334,7 +1334,7 @@ QPID_AUTO_TEST_CASE(testFlowToDiskBlocking){
intrusive_ptr<Message> msg19 = mkMsg(testStore, "", true); // durable no content
DeliverableMessage dmsg19(msg19);
- mbdFanout3.route(dmsg19, "", 0);
+ mbdFanout3.route(dmsg19);
msg19->tryReleaseContent();
BOOST_CHECK_EQUAL(msg19->isContentReleased(), false);
BOOST_CHECK_EQUAL(9u, dq3->getMessageCount());
@@ -1357,7 +1357,7 @@ QPID_AUTO_TEST_CASE(testFlowToDiskBlocking){
intrusive_ptr<Message> msg20 = mkMsg(testStore, std::string(5, 'X')); // transient w/ content
DeliverableMessage dmsg20(msg20);
- mbmFanout4.route(dmsg20, "", 0); // Brings queue 7 to capacity limit
+ mbmFanout4.route(dmsg20); // Brings queue 7 to capacity limit
msg20->tryReleaseContent();
BOOST_CHECK_EQUAL(msg20->isContentReleased(), false);
BOOST_CHECK_EQUAL(1u, dq7->getMessageCount());
@@ -1366,7 +1366,7 @@ QPID_AUTO_TEST_CASE(testFlowToDiskBlocking){
intrusive_ptr<Message> msg21 = mkMsg(testStore, std::string(5, 'X')); // transient w/ content
DeliverableMessage dmsg21(msg21);
- mbmFanout4.route(dmsg21, "", 0);
+ mbmFanout4.route(dmsg21);
msg21->tryReleaseContent();
BOOST_CHECK_EQUAL(msg21->isContentReleased(), false);
BOOST_CHECK_EQUAL(2u, dq7->getMessageCount()); // over limit
@@ -1375,7 +1375,7 @@ QPID_AUTO_TEST_CASE(testFlowToDiskBlocking){
intrusive_ptr<Message> msg22 = mkMsg(testStore, std::string(5, 'X'), true); // durable w/ content
DeliverableMessage dmsg22(msg22);
- mbmFanout4.route(dmsg22, "", 0);
+ mbmFanout4.route(dmsg22);
msg22->tryReleaseContent();
BOOST_CHECK_EQUAL(msg22->isContentReleased(), false);
BOOST_CHECK_EQUAL(3u, dq7->getMessageCount()); // over limit
@@ -1384,7 +1384,7 @@ QPID_AUTO_TEST_CASE(testFlowToDiskBlocking){
intrusive_ptr<Message> msg23 = mkMsg(testStore); // transient no content
DeliverableMessage dmsg23(msg23);
- mbmFanout4.route(dmsg23, "", 0);
+ mbmFanout4.route(dmsg23);
msg23->tryReleaseContent();
BOOST_CHECK_EQUAL(msg23->isContentReleased(), false);
BOOST_CHECK_EQUAL(4u, dq7->getMessageCount()); // over limit
@@ -1393,7 +1393,7 @@ QPID_AUTO_TEST_CASE(testFlowToDiskBlocking){
intrusive_ptr<Message> msg24 = mkMsg(testStore, "", true); // durable no content
DeliverableMessage dmsg24(msg24);
- mbmFanout4.route(dmsg24, "", 0);
+ mbmFanout4.route(dmsg24);
msg24->tryReleaseContent();
BOOST_CHECK_EQUAL(msg24->isContentReleased(), false);
BOOST_CHECK_EQUAL(5u, dq7->getMessageCount()); // over limit
diff --git a/cpp/src/tests/RefCounted.cpp b/cpp/src/tests/RefCounted.cpp
index e4c1da5696..3ac3895322 100644
--- a/cpp/src/tests/RefCounted.cpp
+++ b/cpp/src/tests/RefCounted.cpp
@@ -21,15 +21,15 @@
#include "unit_test.h"
+namespace qpid {
+namespace tests {
+
QPID_AUTO_TEST_SUITE(RefCountedTestSuiteTestSuite)
using boost::intrusive_ptr;
using namespace std;
using namespace qpid;
-namespace qpid {
-namespace tests {
-
struct CountMe : public RefCounted {
static int instances;
CountMe() { ++instances; }
diff --git a/cpp/src/tests/SessionState.cpp b/cpp/src/tests/SessionState.cpp
index 3be9bb0cbc..1cf3415484 100644
--- a/cpp/src/tests/SessionState.cpp
+++ b/cpp/src/tests/SessionState.cpp
@@ -34,7 +34,6 @@ namespace tests {
QPID_AUTO_TEST_SUITE(SessionStateTestSuite)
using namespace std;
-using namespace boost;
using namespace qpid::framing;
// ================================================================
diff --git a/cpp/src/tests/StringUtils.cpp b/cpp/src/tests/StringUtils.cpp
index 6a19119288..c50287a4f4 100644
--- a/cpp/src/tests/StringUtils.cpp
+++ b/cpp/src/tests/StringUtils.cpp
@@ -23,9 +23,11 @@
#include "unit_test.h"
+namespace qpid {
+namespace tests {
+
QPID_AUTO_TEST_SUITE(StringUtilsTestSuite)
-using namespace qpid;
using std::string;
QPID_AUTO_TEST_CASE(testSplit_general)
@@ -75,3 +77,5 @@ QPID_AUTO_TEST_CASE(testSplit_empty)
}
QPID_AUTO_TEST_SUITE_END()
+
+}}
diff --git a/cpp/src/tests/Uuid.cpp b/cpp/src/tests/Uuid.cpp
index 0195455ca3..f85a297adc 100644
--- a/cpp/src/tests/Uuid.cpp
+++ b/cpp/src/tests/Uuid.cpp
@@ -48,7 +48,7 @@ QPID_AUTO_TEST_CASE(testUuidCtor) {
for_each(uuids.begin(), uuids.end(), unique);
}
-boost::array<uint8_t, 16> sample = {{'\x1b', '\x4e', '\x28', '\xba', '\x2f', '\xa1', '\x11', '\xd2', '\x88', '\x3f', '\xb9', '\xa7', '\x61', '\xbd', '\xe3', '\xfb'}};
+boost::array<uint8_t, 16> sample = {{0x1b, 0x4e, 0x28, 0xba, 0x2f, 0xa1, 0x11, 0xd2, 0x88, 0x3f, 0xb9, 0xa7, 0x61, 0xbd, 0xe3, 0xfb}};
const string sampleStr("1b4e28ba-2fa1-11d2-883f-b9a761bde3fb");
const string zeroStr("00000000-0000-0000-0000-000000000000");
diff --git a/cpp/src/tests/acl.py b/cpp/src/tests/acl.py
index 65d5242e51..720b3b4216 100755
--- a/cpp/src/tests/acl.py
+++ b/cpp/src/tests/acl.py
@@ -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
@@ -31,13 +31,13 @@ import qpid.messaging
class ACLFile:
def __init__(self, policy='data_dir/policy.acl'):
self.f = open(policy,'w')
-
+
def write(self,line):
self.f.write(line)
-
+
def close(self):
self.f.close()
-
+
class ACLTests(TestBase010):
def get_session(self, user, passwd):
@@ -47,9 +47,44 @@ class ACLTests(TestBase010):
connection.start()
return connection.session(str(uuid4()))
+ def port_i(self):
+ return int(self.defines["port-i"])
+
+ def port_u(self):
+ return int(self.defines["port-u"])
+
+ def get_session_by_port(self, user, passwd, byPort):
+ socket = connect(self.broker.host, byPort)
+ connection = Connection (sock=socket, username=user, password=passwd,
+ mechanism="PLAIN")
+ connection.start()
+ return connection.session(str(uuid4()))
+
def reload_acl(self):
- acl = self.qmf.getObjects(_class="acl")[0]
- return acl.reloadACLFile()
+ result = None
+ try:
+ self.broker_access.reloadAclFile()
+ except Exception, e:
+ result = str(e)
+ return result
+
+ def acl_lookup(self, userName, action, aclObj, aclObjName, propMap):
+ result = {}
+ try:
+ result = self.broker_access.acl_lookup(userName, action, aclObj, aclObjName, propMap)
+ except Exception, e:
+ result['text'] = str(e)
+ result['result'] = str(e)
+ return result
+
+ def acl_lookupPublish(self, userName, exchange, key):
+ result = {}
+ try:
+ result = self.broker_access.acl_lookupPublish(userName, exchange, key)
+ except Exception, e:
+ result['text'] = str(e)
+ result['result'] = str(e)
+ return result
def get_acl_file(self):
return ACLFile(self.config.defines.get("policy-file", "data_dir/policy.acl"))
@@ -59,7 +94,7 @@ class ACLTests(TestBase010):
aclf.write('acl allow all all\n')
aclf.close()
TestBase010.setUp(self)
- self.startQmf()
+ self.startBrokerAccess()
self.reload_acl()
def tearDown(self):
@@ -69,10 +104,41 @@ class ACLTests(TestBase010):
self.reload_acl()
TestBase010.tearDown(self)
+
+ def Lookup(self, userName, action, aclObj, aclObjName, propMap, expectedResult):
+ result = self.acl_lookup(userName, action, aclObj, aclObjName, propMap)
+ if (result['result'] != expectedResult):
+ suffix = ', [ERROR: Expected= ' + expectedResult
+ if (result['result'] is None):
+ suffix = suffix + ', Exception= ' + result['text'] + ']'
+ else:
+ suffix = suffix + ', Actual= ' + result['result'] + ']'
+ self.fail('Lookup: name=' + userName + ', action=' + action + ', aclObj=' + aclObj + ', aclObjName=' + aclObjName + ', propertyMap=' + str(propMap) + suffix)
+
+
+ def LookupPublish(self, userName, exchName, keyName, expectedResult):
+ result = self.acl_lookupPublish(userName, exchName, keyName)
+ if (result['result'] != expectedResult):
+ if (result['result'] is None):
+ suffix = suffix + ', Exception= ' + result['text'] + ']'
+ else:
+ suffix = suffix + ', Actual= ' + result['result'] + ']'
+ self.fail('LookupPublish: name=' + userName + ', exchange=' + exchName + ', key=' + keyName + suffix)
+
+ def AllBut(self, allList, removeList):
+ tmpList = allList[:]
+ for item in removeList:
+ try:
+ tmpList.remove(item)
+ except Exception, e:
+ self.fail("ERROR in AllBut() \nallList = %s \nremoveList = %s \nerror = %s " \
+ % (allList, removeList, e))
+ return tmpList
+
#=====================================
# ACL general tests
- #=====================================
-
+ #=====================================
+
def test_deny_mode(self):
"""
Test the deny all mode
@@ -81,12 +147,12 @@ class ACLTests(TestBase010):
aclf.write('acl allow anonymous all all\n')
aclf.write('acl allow bob@QPID create queue\n')
aclf.write('acl deny all all')
- aclf.close()
-
+ aclf.close()
+
result = self.reload_acl()
- if (result.text.find("format error",0,len(result.text)) != -1):
- self.fail(result)
-
+ if (result):
+ self.fail(result)
+
session = self.get_session('bob','bob')
try:
session.queue_declare(queue="deny_queue")
@@ -94,13 +160,13 @@ class ACLTests(TestBase010):
if (403 == e.args[0].error_code):
self.fail("ACL should allow queue create request");
self.fail("Error during queue create request");
-
+
try:
session.exchange_bind(exchange="amq.direct", queue="deny_queue", binding_key="routing_key")
self.fail("ACL should deny queue bind request");
except qpid.session.SessionException, e:
- self.assertEqual(403,e.args[0].error_code)
-
+ self.assertEqual(403,e.args[0].error_code)
+
def test_allow_mode(self):
"""
Test the allow all mode
@@ -108,12 +174,12 @@ class ACLTests(TestBase010):
aclf = self.get_acl_file()
aclf.write('acl deny bob@QPID bind exchange\n')
aclf.write('acl allow all all')
- aclf.close()
-
+ aclf.close()
+
result = self.reload_acl()
- if (result.text.find("format error",0,len(result.text)) != -1):
- self.fail(result)
-
+ if (result):
+ self.fail(result)
+
session = self.get_session('bob','bob')
try:
session.queue_declare(queue="allow_queue")
@@ -121,18 +187,42 @@ class ACLTests(TestBase010):
if (403 == e.args[0].error_code):
self.fail("ACL should allow queue create request");
self.fail("Error during queue create request");
-
+
try:
session.exchange_bind(exchange="amq.direct", queue="allow_queue", binding_key="routing_key")
self.fail("ACL should deny queue bind request");
except qpid.session.SessionException, e:
- self.assertEqual(403,e.args[0].error_code)
-
-
+ self.assertEqual(403,e.args[0].error_code)
+
+
+ def test_allow_mode_with_specfic_allow_override(self):
+ """
+ Specific allow overrides a general deny
+ """
+ aclf = self.get_acl_file()
+ aclf.write('group admins bob@QPID joe@QPID \n')
+ aclf.write('acl allow bob@QPID create queue \n')
+ aclf.write('acl deny admins create queue \n')
+ aclf.write('acl allow all all')
+ aclf.close()
+
+ result = self.reload_acl()
+ if (result):
+ self.fail(result)
+
+ session = self.get_session('bob','bob')
+
+ try:
+ session.queue_declare(queue='zed')
+ except qpid.session.SessionException, e:
+ if (403 == e.args[0].error_code):
+ self.fail("ACL should allow create queue request");
+
+
#=====================================
# ACL file format tests
- #=====================================
-
+ #=====================================
+
def test_empty_groups(self):
"""
Test empty groups
@@ -141,11 +231,11 @@ class ACLTests(TestBase010):
aclf.write('acl group\n')
aclf.write('acl group admins bob@QPID joe@QPID\n')
aclf.write('acl allow all all')
- aclf.close()
-
- result = self.reload_acl()
- if (result.text.find("Insufficient tokens for acl definition",0,len(result.text)) == -1):
- self.fail("ACL Reader should reject the acl file due to empty group name")
+ aclf.close()
+
+ result = self.reload_acl()
+ if (result.find("Insufficient tokens for acl definition",0,len(result)) == -1):
+ self.fail("ACL Reader should reject the acl file due to empty group name")
def test_illegal_acl_formats(self):
"""
@@ -155,31 +245,31 @@ class ACLTests(TestBase010):
aclf.write('acl group admins bob@QPID joe@QPID\n')
aclf.write('acl allow all all')
aclf.close()
-
- result = self.reload_acl()
- if (result.text.find("Unknown ACL permission",0,len(result.text)) == -1):
- self.fail(result)
-
+
+ result = self.reload_acl()
+ if (result.find("Unknown ACL permission",0,len(result)) == -1):
+ self.fail(result)
+
def test_illegal_extension_lines(self):
"""
Test illegal extension lines
"""
-
+
aclf = self.get_acl_file()
aclf.write('group admins bob@QPID \n')
aclf.write(' \ \n')
aclf.write('joe@QPID \n')
aclf.write('acl allow all all')
- aclf.close()
-
- result = self.reload_acl()
- if (result.text.find("contains an illegal extension",0,len(result.text)) == -1):
+ aclf.close()
+
+ result = self.reload_acl()
+ if (result.find("contains an illegal extension",0,len(result)) == -1):
self.fail(result)
- if (result.text.find("Non-continuation line must start with \"group\" or \"acl\"",0,len(result.text)) == -1):
+ if (result.find("Non-continuation line must start with \"group\" or \"acl\"",0,len(result)) == -1):
self.fail(result)
- def test_llegal_extension_lines(self):
+ def test_illegal_extension_lines(self):
"""
Test proper extention lines
"""
@@ -190,9 +280,9 @@ class ACLTests(TestBase010):
aclf.write('host/123.example.com@TEST.COM\n') # should be allowed
aclf.write('acl allow all all')
aclf.close()
-
+
result = self.reload_acl()
- if (result.text.find("ACL format error",0,len(result.text)) != -1):
+ if (result):
self.fail(result)
def test_user_realm(self):
@@ -205,9 +295,9 @@ class ACLTests(TestBase010):
aclf.write('acl deny admin bind exchange\n')
aclf.write('acl allow all all')
aclf.close()
-
+
result = self.reload_acl()
- if (result.text.find("Username 'bob' must contain a realm",0,len(result.text)) == -1):
+ if (result.find("Username 'bob' must contain a realm",0,len(result)) == -1):
self.fail(result)
def test_allowed_chars_for_username(self):
@@ -221,18 +311,18 @@ class ACLTests(TestBase010):
aclf.write('group test4 host/somemachine.example.com@EXAMPLE.COM\n') # should be allowed
aclf.write('acl allow all all')
aclf.close()
-
+
result = self.reload_acl()
- if (result.text.find("ACL format error",0,len(result.text)) != -1):
+ if (result):
self.fail(result)
aclf = self.get_acl_file()
aclf.write('group test1 joe$H@EXAMPLE.com\n') # shouldn't be allowed
aclf.write('acl allow all all')
- aclf.close()
+ aclf.close()
result = self.reload_acl()
- if (result.text.find("Username \"joe$H@EXAMPLE.com\" contains illegal characters",0,len(result.text)) == -1):
+ if (result.find("Username \"joe$H@EXAMPLE.com\" contains illegal characters",0,len(result)) == -1):
self.fail(result)
#=====================================
@@ -243,118 +333,238 @@ class ACLTests(TestBase010):
"""
Test illegal queue policy
"""
-
+
aclf = self.get_acl_file()
aclf.write('acl deny bob@QPID create queue name=q2 exclusive=true policytype=ding\n')
aclf.write('acl allow all all')
- aclf.close()
-
- result = self.reload_acl()
+ aclf.close()
+
+ result = self.reload_acl()
expected = "ding is not a valid value for 'policytype', possible values are one of" \
- " { 'ring' 'ring_strict' 'flow_to_disk' 'reject' }";
- if (result.text != expected):
- self.fail(result)
+ " { 'ring' 'ring_strict' 'flow_to_disk' 'reject' }";
+ if (result.find(expected) == -1):
+ self.fail(result)
- def test_illegal_queue_size(self):
+ def test_illegal_queuemaxsize_upper_limit_spec(self):
"""
Test illegal queue policy
"""
-
+ #
+ # Use maxqueuesize
+ #
aclf = self.get_acl_file()
aclf.write('acl deny bob@QPID create queue name=q2 maxqueuesize=-1\n')
aclf.write('acl allow all all')
- aclf.close()
-
- result = self.reload_acl()
- expected = "-1 is not a valid value for 'maxqueuesize', " \
- "values should be between 0 and 9223372036854775807";
- if (result.text != expected):
- self.fail(result)
+ aclf.close()
+
+ result = self.reload_acl()
+ expected = "-1 is not a valid value for 'queuemaxsizeupperlimit', " \
+ "values should be between 0 and 9223372036854775807";
+ if (result.find(expected) == -1):
+ self.fail(result)
aclf = self.get_acl_file()
aclf.write('acl deny bob@QPID create queue name=q2 maxqueuesize=9223372036854775808\n')
- aclf.write('acl allow all all')
- aclf.close()
-
- result = self.reload_acl()
- expected = "9223372036854775808 is not a valid value for 'maxqueuesize', " \
+ aclf.write('acl allow all all')
+ aclf.close()
+
+ result = self.reload_acl()
+ expected = "9223372036854775808 is not a valid value for 'queuemaxsizeupperlimit', " \
"values should be between 0 and 9223372036854775807";
- if (result.text != expected):
- self.fail(result)
+ if (result.find(expected) == -1):
+ self.fail(result)
+
+ #
+ # Use queuemaxsizeupperlimit
+ #
+ aclf = self.get_acl_file()
+ aclf.write('acl deny bob@QPID create queue name=q2 queuemaxsizeupperlimit=-1\n')
+ aclf.write('acl allow all all')
+ aclf.close()
+ result = self.reload_acl()
+ expected = "-1 is not a valid value for 'queuemaxsizeupperlimit', " \
+ "values should be between 0 and 9223372036854775807";
+ if (result.find(expected) == -1):
+ self.fail(result)
- def test_illegal_queue_count(self):
+ aclf = self.get_acl_file()
+ aclf.write('acl deny bob@QPID create queue name=q2 queuemaxsizeupperlimit=9223372036854775808\n')
+ aclf.write('acl allow all all')
+ aclf.close()
+
+ result = self.reload_acl()
+ expected = "9223372036854775808 is not a valid value for 'queuemaxsizeupperlimit', " \
+ "values should be between 0 and 9223372036854775807";
+ if (result.find(expected) == -1):
+ self.fail(result)
+
+
+
+ def test_illegal_queuemaxcount_upper_limit_spec(self):
"""
Test illegal queue policy
"""
-
+ #
+ # Use maxqueuecount
+ #
+
aclf = self.get_acl_file()
aclf.write('acl deny bob@QPID create queue name=q2 maxqueuecount=-1\n')
aclf.write('acl allow all all')
- aclf.close()
-
- result = self.reload_acl()
- expected = "-1 is not a valid value for 'maxqueuecount', " \
- "values should be between 0 and 9223372036854775807";
- if (result.text != expected):
- self.fail(result)
+ aclf.close()
+
+ result = self.reload_acl()
+ expected = "-1 is not a valid value for 'queuemaxcountupperlimit', " \
+ "values should be between 0 and 9223372036854775807";
+ if (result.find(expected) == -1):
+ self.fail(result)
aclf = self.get_acl_file()
aclf.write('acl deny bob@QPID create queue name=q2 maxqueuecount=9223372036854775808\n')
- aclf.write('acl allow all all')
- aclf.close()
-
- result = self.reload_acl()
- expected = "9223372036854775808 is not a valid value for 'maxqueuecount', " \
+ aclf.write('acl allow all all')
+ aclf.close()
+
+ result = self.reload_acl()
+ expected = "9223372036854775808 is not a valid value for 'queuemaxcountupperlimit', " \
"values should be between 0 and 9223372036854775807";
- if (result.text != expected):
- self.fail(result)
+ if (result.find(expected) == -1):
+ self.fail(result)
+
+ #
+ # use maxqueuecountupperlimit
+ #
+ aclf = self.get_acl_file()
+ aclf.write('acl deny bob@QPID create queue name=q2 queuemaxcountupperlimit=-1\n')
+ aclf.write('acl allow all all')
+ aclf.close()
+
+ result = self.reload_acl()
+ expected = "-1 is not a valid value for 'queuemaxcountupperlimit', " \
+ "values should be between 0 and 9223372036854775807";
+ if (result.find(expected) == -1):
+ self.fail(result)
+
+ aclf = self.get_acl_file()
+ aclf.write('acl deny bob@QPID create queue name=q2 queuemaxcountupperlimit=9223372036854775808\n')
+ aclf.write('acl allow all all')
+ aclf.close()
+
+ result = self.reload_acl()
+ expected = "9223372036854775808 is not a valid value for 'queuemaxcountupperlimit', " \
+ "values should be between 0 and 9223372036854775807";
+ if (result.find(expected) == -1):
+ self.fail(result)
+
+
+ def test_illegal_queuemaxsize_lower_limit_spec(self):
+ """
+ Test illegal queue policy
+ """
+ aclf = self.get_acl_file()
+ aclf.write('acl deny bob@QPID create queue name=q2 queuemaxsizelowerlimit=-1\n')
+ aclf.write('acl allow all all')
+ aclf.close()
+
+ result = self.reload_acl()
+ expected = "-1 is not a valid value for 'queuemaxsizelowerlimit', " \
+ "values should be between 0 and 9223372036854775807";
+ if (result.find(expected) == -1):
+ self.fail(result)
+
+ aclf = self.get_acl_file()
+ aclf.write('acl deny bob@QPID create queue name=q2 queuemaxsizelowerlimit=9223372036854775808\n')
+ aclf.write('acl allow all all')
+ aclf.close()
+
+ result = self.reload_acl()
+ expected = "9223372036854775808 is not a valid value for 'queuemaxsizelowerlimit', " \
+ "values should be between 0 and 9223372036854775807";
+ if (result.find(expected) == -1):
+ self.fail(result)
+
+
+
+ def test_illegal_queuemaxcount_lower_limit_spec(self):
+ """
+ Test illegal queue policy
+ """
+
+ aclf = self.get_acl_file()
+ aclf.write('acl deny bob@QPID create queue name=q2 queuemaxcountlowerlimit=-1\n')
+ aclf.write('acl allow all all')
+ aclf.close()
+
+ result = self.reload_acl()
+ expected = "-1 is not a valid value for 'queuemaxcountlowerlimit', " \
+ "values should be between 0 and 9223372036854775807";
+ if (result.find(expected) == -1):
+ self.fail(result)
+
+ aclf = self.get_acl_file()
+ aclf.write('acl deny bob@QPID create queue name=q2 queuemaxcountlowerlimit=9223372036854775808\n')
+ aclf.write('acl allow all all')
+ aclf.close()
+
+ result = self.reload_acl()
+ expected = "9223372036854775808 is not a valid value for 'queuemaxcountlowerlimit', " \
+ "values should be between 0 and 9223372036854775807";
+ if (result.find(expected) == -1):
+ self.fail(result)
#=====================================
# ACL queue tests
#=====================================
-
+
def test_queue_allow_mode(self):
"""
Test cases for queue acl in allow mode
"""
aclf = self.get_acl_file()
- aclf.write('acl deny bob@QPID create queue name=q1 durable=true passive=true\n')
+ aclf.write('acl deny bob@QPID access queue name=q1\n')
+ aclf.write('acl deny bob@QPID create queue name=q1 durable=true\n')
aclf.write('acl deny bob@QPID create queue name=q2 exclusive=true policytype=ring\n')
aclf.write('acl deny bob@QPID access queue name=q3\n')
aclf.write('acl deny bob@QPID purge queue name=q3\n')
- aclf.write('acl deny bob@QPID delete queue name=q4\n')
- aclf.write('acl deny bob@QPID create queue name=q5 maxqueuesize=1000 maxqueuecount=100\n')
+ aclf.write('acl deny bob@QPID delete queue name=q4\n')
+ aclf.write('acl deny bob@QPID create queue name=q5 maxqueuesize=1000 maxqueuecount=100\n')
aclf.write('acl allow all all')
- aclf.close()
-
+ aclf.close()
+
result = self.reload_acl()
- if (result.text.find("format error",0,len(result.text)) != -1):
- self.fail(result)
-
+ if (result):
+ self.fail(result)
+
session = self.get_session('bob','bob')
-
+
+ try:
+ session.queue_declare(queue="q1", durable=True)
+ self.fail("ACL should deny queue create request with name=q1 durable=true");
+ except qpid.session.SessionException, e:
+ self.assertEqual(403,e.args[0].error_code)
+ session = self.get_session('bob','bob')
+
try:
session.queue_declare(queue="q1", durable=True, passive=True)
- self.fail("ACL should deny queue create request with name=q1 durable=true passive=true");
+ self.fail("ACL should deny queue passive declare request with name=q1 durable=true");
except qpid.session.SessionException, e:
self.assertEqual(403,e.args[0].error_code)
session = self.get_session('bob','bob')
-
+
try:
queue_options = {}
- queue_options["qpid.policy_type"] = "ring"
+ queue_options["qpid.policy_type"] = "ring"
session.queue_declare(queue="q2", exclusive=True, arguments=queue_options)
self.fail("ACL should deny queue create request with name=q2 exclusive=true qpid.policy_type=ring");
except qpid.session.SessionException, e:
- self.assertEqual(403,e.args[0].error_code)
+ self.assertEqual(403,e.args[0].error_code)
session = self.get_session('bob','bob')
-
+
try:
queue_options = {}
- queue_options["qpid.policy_type"] = "ring_strict"
- session.queue_declare(queue="q2", exclusive=True, arguments=queue_options)
+ queue_options["qpid.policy_type"] = "ring_strict"
+ session.queue_declare(queue="q2", exclusive=True, arguments=queue_options)
except qpid.session.SessionException, e:
if (403 == e.args[0].error_code):
self.fail("ACL should allow queue create request with name=q2 exclusive=true qpid.policy_type=ring_strict");
@@ -362,17 +572,17 @@ class ACLTests(TestBase010):
try:
queue_options = {}
queue_options["qpid.max_count"] = 200
- queue_options["qpid.max_size"] = 500
+ queue_options["qpid.max_size"] = 500
session.queue_declare(queue="q5", exclusive=True, arguments=queue_options)
self.fail("ACL should deny queue create request with name=q2, qpid.max_size=500 and qpid.max_count=200");
except qpid.session.SessionException, e:
- self.assertEqual(403,e.args[0].error_code)
+ self.assertEqual(403,e.args[0].error_code)
session = self.get_session('bob','bob')
try:
queue_options = {}
queue_options["qpid.max_count"] = 200
- queue_options["qpid.max_size"] = 100
+ queue_options["qpid.max_size"] = 100
session.queue_declare(queue="q2", exclusive=True, arguments=queue_options)
except qpid.session.SessionException, e:
if (403 == e.args[0].error_code):
@@ -390,63 +600,71 @@ class ACLTests(TestBase010):
except qpid.session.SessionException, e:
self.assertEqual(403,e.args[0].error_code)
session = self.get_session('bob','bob')
-
+
try:
session.queue_purge(queue="q3")
self.fail("ACL should deny queue purge request for q3");
except qpid.session.SessionException, e:
self.assertEqual(403,e.args[0].error_code)
session = self.get_session('bob','bob')
-
+
try:
session.queue_purge(queue="q4")
except qpid.session.SessionException, e:
if (403 == e.args[0].error_code):
self.fail("ACL should allow queue purge request for q4");
-
+
try:
session.queue_delete(queue="q4")
self.fail("ACL should deny queue delete request for q4");
except qpid.session.SessionException, e:
self.assertEqual(403,e.args[0].error_code)
session = self.get_session('bob','bob')
-
+
try:
session.queue_delete(queue="q3")
except qpid.session.SessionException, e:
if (403 == e.args[0].error_code):
self.fail("ACL should allow queue delete request for q3");
-
+
def test_queue_deny_mode(self):
"""
Test cases for queue acl in deny mode
"""
aclf = self.get_acl_file()
- aclf.write('acl allow bob@QPID create queue name=q1 durable=true passive=true\n')
+ aclf.write('acl allow bob@QPID access queue name=q1\n')
+ aclf.write('acl allow bob@QPID create queue name=q1 durable=true\n')
aclf.write('acl allow bob@QPID create queue name=q2 exclusive=true policytype=ring\n')
aclf.write('acl allow bob@QPID access queue name=q3\n')
aclf.write('acl allow bob@QPID purge queue name=q3\n')
- aclf.write('acl allow bob@QPID create queue name=q3\n')
- aclf.write('acl allow bob@QPID create queue name=q4\n')
- aclf.write('acl allow bob@QPID delete queue name=q4\n')
- aclf.write('acl allow bob@QPID create queue name=q5 maxqueuesize=1000 maxqueuecount=100\n')
+ aclf.write('acl allow bob@QPID create queue name=q3\n')
+ aclf.write('acl allow bob@QPID create queue name=q4\n')
+ aclf.write('acl allow bob@QPID delete queue name=q4\n')
+ aclf.write('acl allow bob@QPID create queue name=q5 maxqueuesize=1000 maxqueuecount=100\n')
+ aclf.write('acl allow bob@QPID create queue name=q6 queuemaxsizelowerlimit=50 queuemaxsizeupperlimit=100 queuemaxcountlowerlimit=50 queuemaxcountupperlimit=100\n')
aclf.write('acl allow anonymous all all\n')
aclf.write('acl deny all all')
- aclf.close()
-
+ aclf.close()
+
result = self.reload_acl()
- if (result.text.find("format error",0,len(result.text)) != -1):
- self.fail(result)
-
+ if (result):
+ self.fail(result)
+
session = self.get_session('bob','bob')
-
+
+ try:
+ session.queue_declare(queue="q1", durable=True)
+ except qpid.session.SessionException, e:
+ if (403 == e.args[0].error_code):
+ self.fail("ACL should allow queue create request with name=q1 durable=true");
+
try:
session.queue_declare(queue="q1", durable=True, passive=True)
except qpid.session.SessionException, e:
if (403 == e.args[0].error_code):
- self.fail("ACL should allow queue create request with name=q1 durable=true passive=true");
-
+ self.fail("ACL should allow queue passive declare request with name=q1 durable=true passive=true");
+
try:
session.queue_declare(queue="q1", durable=False, passive=False)
self.fail("ACL should deny queue create request with name=q1 durable=true passive=false");
@@ -458,32 +676,81 @@ class ACLTests(TestBase010):
session.queue_declare(queue="q2", exclusive=False)
self.fail("ACL should deny queue create request with name=q2 exclusive=false");
except qpid.session.SessionException, e:
- self.assertEqual(403,e.args[0].error_code)
+ self.assertEqual(403,e.args[0].error_code)
session = self.get_session('bob','bob')
-
+
try:
queue_options = {}
queue_options["qpid.max_count"] = 200
- queue_options["qpid.max_size"] = 500
+ queue_options["qpid.max_size"] = 500
session.queue_declare(queue="q5", arguments=queue_options)
- self.fail("ACL should deny queue create request with name=q2 maxqueuesize=500 maxqueuecount=200");
+ self.fail("ACL should deny queue create request with name=q5 maxqueuesize=500 maxqueuecount=200");
except qpid.session.SessionException, e:
- self.assertEqual(403,e.args[0].error_code)
+ self.assertEqual(403,e.args[0].error_code)
session = self.get_session('bob','bob')
try:
queue_options = {}
queue_options["qpid.max_count"] = 100
- queue_options["qpid.max_size"] = 500
- session.queue_declare(queue="q5", arguments=queue_options)
+ queue_options["qpid.max_size"] = 500
+ session.queue_declare(queue="q5", arguments=queue_options)
except qpid.session.SessionException, e:
if (403 == e.args[0].error_code):
- self.fail("ACL should allow queue create request with name=q2 maxqueuesize=500 maxqueuecount=200");
+ self.fail("ACL should allow queue create request with name=q5 maxqueuesize=500 maxqueuecount=200");
+
+ try:
+ queue_options = {}
+ queue_options["qpid.max_count"] = 49
+ queue_options["qpid.max_size"] = 100
+ session.queue_declare(queue="q6", arguments=queue_options)
+ self.fail("ACL should deny queue create request with name=q6 maxqueuesize=100 maxqueuecount=49");
+ except qpid.session.SessionException, e:
+ self.assertEqual(403,e.args[0].error_code)
+ session = self.get_session('bob','bob')
+
+ try:
+ queue_options = {}
+ queue_options["qpid.max_count"] = 101
+ queue_options["qpid.max_size"] = 100
+ session.queue_declare(queue="q6", arguments=queue_options)
+ self.fail("ACL should allow queue create request with name=q6 maxqueuesize=100 maxqueuecount=101");
+ except qpid.session.SessionException, e:
+ self.assertEqual(403,e.args[0].error_code)
+ session = self.get_session('bob','bob')
+
+ try:
+ queue_options = {}
+ queue_options["qpid.max_count"] = 100
+ queue_options["qpid.max_size"] = 49
+ session.queue_declare(queue="q6", arguments=queue_options)
+ self.fail("ACL should deny queue create request with name=q6 maxqueuesize=49 maxqueuecount=100");
+ except qpid.session.SessionException, e:
+ self.assertEqual(403,e.args[0].error_code)
+ session = self.get_session('bob','bob')
+
+ try:
+ queue_options = {}
+ queue_options["qpid.max_count"] = 100
+ queue_options["qpid.max_size"] =101
+ session.queue_declare(queue="q6", arguments=queue_options)
+ self.fail("ACL should deny queue create request with name=q6 maxqueuesize=101 maxqueuecount=100");
+ except qpid.session.SessionException, e:
+ self.assertEqual(403,e.args[0].error_code)
+ session = self.get_session('bob','bob')
+
+ try:
+ queue_options = {}
+ queue_options["qpid.max_count"] = 50
+ queue_options["qpid.max_size"] = 50
+ session.queue_declare(queue="q6", arguments=queue_options)
+ except qpid.session.SessionException, e:
+ if (403 == e.args[0].error_code):
+ self.fail("ACL should allow queue create request with name=q6 maxqueuesize=50 maxqueuecount=50");
try:
queue_options = {}
queue_options["qpid.policy_type"] = "ring"
- session.queue_declare(queue="q2", exclusive=True, arguments=queue_options)
+ session.queue_declare(queue="q2", exclusive=True, arguments=queue_options)
except qpid.session.SessionException, e:
if (403 == e.args[0].error_code):
self.fail("ACL should allow queue create request for q2 with exclusive=true policytype=ring");
@@ -501,14 +768,14 @@ class ACLTests(TestBase010):
except qpid.session.SessionException, e:
self.assertEqual(403,e.args[0].error_code)
session = self.get_session('bob','bob')
-
+
try:
session.queue_purge(queue="q4")
self.fail("ACL should deny queue purge request for q4");
except qpid.session.SessionException, e:
self.assertEqual(403,e.args[0].error_code)
session = self.get_session('bob','bob')
-
+
try:
session.queue_purge(queue="q3")
except qpid.session.SessionException, e:
@@ -520,14 +787,14 @@ class ACLTests(TestBase010):
except qpid.session.SessionException, e:
if (403 == e.args[0].error_code):
self.fail("ACL should allow queue query request for q3");
-
+
try:
session.queue_delete(queue="q3")
self.fail("ACL should deny queue delete request for q3");
except qpid.session.SessionException, e:
self.assertEqual(403,e.args[0].error_code)
session = self.get_session('bob','bob')
-
+
try:
session.queue_delete(queue="q4")
except qpid.session.SessionException, e:
@@ -537,54 +804,62 @@ class ACLTests(TestBase010):
#=====================================
# ACL exchange tests
#=====================================
-
+
def test_exchange_acl_allow_mode(self):
- session = self.get_session('bob','bob')
+ session = self.get_session('bob','bob')
session.queue_declare(queue="baz")
"""
Test cases for exchange acl in allow mode
"""
aclf = self.get_acl_file()
- aclf.write('acl deny bob@QPID create exchange name=testEx durable=true passive=true\n')
+ aclf.write('acl deny bob@QPID access exchange name=testEx\n')
+ aclf.write('acl deny bob@QPID create exchange name=testEx durable=true\n')
aclf.write('acl deny bob@QPID create exchange name=ex1 type=direct\n')
aclf.write('acl deny bob@QPID access exchange name=myEx queuename=q1 routingkey=rk1.*\n')
aclf.write('acl deny bob@QPID bind exchange name=myEx queuename=q1 routingkey=rk1\n')
aclf.write('acl deny bob@QPID unbind exchange name=myEx queuename=q1 routingkey=rk1\n')
aclf.write('acl deny bob@QPID delete exchange name=myEx\n')
aclf.write('acl allow all all')
- aclf.close()
-
+ aclf.close()
+
result = self.reload_acl()
- if (result.text.find("format error",0,len(result.text)) != -1):
- self.fail(result)
-
+ if (result):
+ self.fail(result)
+
session = self.get_session('bob','bob')
session.queue_declare(queue='q1')
session.queue_declare(queue='q2')
session.exchange_declare(exchange='myEx', type='direct')
try:
+ session.exchange_declare(exchange='testEx', durable=True)
+ self.fail("ACL should deny exchange create request with name=testEx durable=true");
+ except qpid.session.SessionException, e:
+ self.assertEqual(403,e.args[0].error_code)
+ session = self.get_session('bob','bob')
+
+ try:
session.exchange_declare(exchange='testEx', durable=True, passive=True)
- self.fail("ACL should deny exchange create request with name=testEx durable=true passive=true");
+ self.fail("ACL should deny passive exchange declare request with name=testEx durable=true passive=true");
except qpid.session.SessionException, e:
self.assertEqual(403,e.args[0].error_code)
session = self.get_session('bob','bob')
-
+
try:
- session.exchange_declare(exchange='testEx', type='direct', durable=True, passive=False)
+ session.exchange_declare(exchange='testEx', type='direct', durable=False)
except qpid.session.SessionException, e:
print e
if (403 == e.args[0].error_code):
- self.fail("ACL should allow exchange create request for testEx with any parameter other than durable=true and passive=true");
-
+ self.fail("ACL should allow exchange create request for testEx with any parameter other than durable=true");
+
try:
session.exchange_declare(exchange='ex1', type='direct')
self.fail("ACL should deny exchange create request with name=ex1 type=direct");
- except qpid.session.SessionException, e:
- self.assertEqual(403,e.args[0].error_code)
+ except qpid.session.SessionException, e:
+ self.assertEqual(403,e.args[0].error_code)
session = self.get_session('bob','bob')
-
+
try:
session.exchange_declare(exchange='myXml', type='direct')
except qpid.session.SessionException, e:
@@ -606,13 +881,13 @@ class ACLTests(TestBase010):
session = self.get_session('bob','bob')
try:
- session.exchange_query(name='amq.topic')
+ session.exchange_query(name='amq.topic')
except qpid.session.SessionException, e:
if (403 == e.args[0].error_code):
self.fail("ACL should allow exchange query request for exchange='amq.topic'");
-
+
try:
- session.exchange_bound(exchange='myEx', queue='q1', binding_key='rk2.*')
+ session.exchange_bound(exchange='myEx', queue='q1', binding_key='rk2.*')
except qpid.session.SessionException, e:
if (403 == e.args[0].error_code):
self.fail("ACL should allow exchange bound request for myEx with queuename=q1 and binding_key='rk2.*'");
@@ -621,12 +896,12 @@ class ACLTests(TestBase010):
session.exchange_bind(exchange='myEx', queue='q1', binding_key='rk1')
self.fail("ACL should deny exchange bind request with exchange='myEx' queuename='q1' bindingkey='rk1'");
except qpid.session.SessionException, e:
- self.assertEqual(403,e.args[0].error_code)
+ self.assertEqual(403,e.args[0].error_code)
session = self.get_session('bob','bob')
try:
session.exchange_bind(exchange='myEx', queue='q1', binding_key='x')
- except qpid.session.SessionException, e:
+ except qpid.session.SessionException, e:
if (403 == e.args[0].error_code):
self.fail("ACL should allow exchange bind request for exchange='myEx', queue='q1', binding_key='x'");
@@ -640,7 +915,7 @@ class ACLTests(TestBase010):
session.exchange_unbind(exchange='myEx', queue='q1', binding_key='rk1')
self.fail("ACL should deny exchange unbind request with exchange='myEx' queuename='q1' bindingkey='rk1'");
except qpid.session.SessionException, e:
- self.assertEqual(403,e.args[0].error_code)
+ self.assertEqual(403,e.args[0].error_code)
session = self.get_session('bob','bob')
try:
@@ -654,20 +929,20 @@ class ACLTests(TestBase010):
except qpid.session.SessionException, e:
if (403 == e.args[0].error_code):
self.fail("ACL should allow exchange unbind request for exchange='myEx', queue='q2', binding_key='rk1'");
-
+
try:
session.exchange_delete(exchange='myEx')
self.fail("ACL should deny exchange delete request for myEx");
except qpid.session.SessionException, e:
self.assertEqual(403,e.args[0].error_code)
session = self.get_session('bob','bob')
-
+
try:
session.exchange_delete(exchange='myXml')
except qpid.session.SessionException, e:
if (403 == e.args[0].error_code):
self.fail("ACL should allow exchange delete request for myXml");
-
+
def test_exchange_acl_deny_mode(self):
session = self.get_session('bob','bob')
@@ -677,19 +952,19 @@ class ACLTests(TestBase010):
Test cases for exchange acl in deny mode
"""
aclf = self.get_acl_file()
- aclf.write('acl allow bob@QPID create exchange name=myEx durable=true passive=false\n')
- aclf.write('acl allow bob@QPID bind exchange name=amq.topic queuename=bar routingkey=foo.*\n')
+ aclf.write('acl allow bob@QPID create exchange name=myEx durable=true\n')
+ aclf.write('acl allow bob@QPID bind exchange name=amq.topic queuename=bar routingkey=foo.*\n')
aclf.write('acl allow bob@QPID unbind exchange name=amq.topic queuename=bar routingkey=foo.*\n')
aclf.write('acl allow bob@QPID access exchange name=myEx queuename=q1 routingkey=rk1.*\n')
aclf.write('acl allow bob@QPID delete exchange name=myEx\n')
- aclf.write('acl allow anonymous all all\n')
+ aclf.write('acl allow anonymous all all\n')
aclf.write('acl deny all all')
- aclf.close()
-
+ aclf.close()
+
result = self.reload_acl()
- if (result.text.find("format error",0,len(result.text)) != -1):
- self.fail(result)
-
+ if (result):
+ self.fail(result)
+
session = self.get_session('bob','bob')
try:
@@ -697,14 +972,14 @@ class ACLTests(TestBase010):
except qpid.session.SessionException, e:
if (403 == e.args[0].error_code):
self.fail("ACL should allow exchange create request for myEx with durable=true and passive=false");
-
+
try:
session.exchange_declare(exchange='myEx', type='direct', durable=False)
self.fail("ACL should deny exchange create request with name=myEx durable=false");
except qpid.session.SessionException, e:
self.assertEqual(403,e.args[0].error_code)
session = self.get_session('bob','bob')
-
+
try:
session.exchange_bind(exchange='amq.topic', queue='bar', binding_key='foo.bar')
except qpid.session.SessionException, e:
@@ -759,13 +1034,13 @@ class ACLTests(TestBase010):
session = self.get_session('bob','bob')
try:
- session.exchange_query(name='myEx')
+ session.exchange_query(name='myEx')
except qpid.session.SessionException, e:
if (403 == e.args[0].error_code):
self.fail("ACL should allow exchange query request for exchange='myEx'");
-
+
try:
- session.exchange_bound(exchange='myEx', queue='q1', binding_key='rk1.*')
+ session.exchange_bound(exchange='myEx', queue='q1', binding_key='rk1.*')
except qpid.session.SessionException, e:
if (403 == e.args[0].error_code):
self.fail("ACL should allow exchange bound request for myEx with queuename=q1 and binding_key='rk1.*'");
@@ -776,7 +1051,7 @@ class ACLTests(TestBase010):
except qpid.session.SessionException, e:
self.assertEqual(403,e.args[0].error_code)
session = self.get_session('bob','bob')
-
+
try:
session.exchange_delete(exchange='myEx')
except qpid.session.SessionException, e:
@@ -805,7 +1080,7 @@ class ACLTests(TestBase010):
aclf.close()
result = self.reload_acl()
- if (result.text.find("format error",0,len(result.text)) != -1):
+ if (result):
self.fail(result)
bob = BrokerAdmin(self.config.broker, "bob", "bob")
@@ -832,24 +1107,24 @@ class ACLTests(TestBase010):
#=====================================
# ACL consume tests
#=====================================
-
+
def test_consume_allow_mode(self):
"""
Test cases for consume in allow mode
"""
aclf = self.get_acl_file()
aclf.write('acl deny bob@QPID consume queue name=q1\n')
- aclf.write('acl deny bob@QPID consume queue name=q2\n')
+ aclf.write('acl deny bob@QPID consume queue name=q2\n')
aclf.write('acl allow all all')
- aclf.close()
-
+ aclf.close()
+
result = self.reload_acl()
- if (result.text.find("format error",0,len(result.text)) != -1):
- self.fail(result)
-
+ if (result):
+ self.fail(result)
+
session = self.get_session('bob','bob')
-
-
+
+
try:
session.queue_declare(queue='q1')
session.queue_declare(queue='q2')
@@ -857,27 +1132,27 @@ class ACLTests(TestBase010):
except qpid.session.SessionException, e:
if (403 == e.args[0].error_code):
self.fail("ACL should allow create queue request");
-
+
try:
session.message_subscribe(queue='q1', destination='myq1')
self.fail("ACL should deny subscription for queue='q1'");
except qpid.session.SessionException, e:
self.assertEqual(403,e.args[0].error_code)
session = self.get_session('bob','bob')
-
+
try:
session.message_subscribe(queue='q2', destination='myq1')
self.fail("ACL should deny subscription for queue='q2'");
except qpid.session.SessionException, e:
self.assertEqual(403,e.args[0].error_code)
session = self.get_session('bob','bob')
-
+
try:
session.message_subscribe(queue='q3', destination='myq1')
except qpid.session.SessionException, e:
if (403 == e.args[0].error_code):
- self.fail("ACL should allow subscription for q3");
-
+ self.fail("ACL should allow subscription for q3");
+
def test_consume_deny_mode(self):
"""
@@ -886,18 +1161,18 @@ class ACLTests(TestBase010):
aclf = self.get_acl_file()
aclf.write('acl allow bob@QPID consume queue name=q1\n')
aclf.write('acl allow bob@QPID consume queue name=q2\n')
- aclf.write('acl allow bob@QPID create queue\n')
- aclf.write('acl allow anonymous all\n')
+ aclf.write('acl allow bob@QPID create queue\n')
+ aclf.write('acl allow anonymous all\n')
aclf.write('acl deny all all')
- aclf.close()
-
+ aclf.close()
+
result = self.reload_acl()
- if (result.text.find("format error",0,len(result.text)) != -1):
- self.fail(result)
-
+ if (result):
+ self.fail(result)
+
session = self.get_session('bob','bob')
-
-
+
+
try:
session.queue_declare(queue='q1')
session.queue_declare(queue='q2')
@@ -911,20 +1186,20 @@ class ACLTests(TestBase010):
session.message_subscribe(queue='q2', destination='myq2')
except qpid.session.SessionException, e:
if (403 == e.args[0].error_code):
- self.fail("ACL should allow subscription for q1 and q2");
-
+ self.fail("ACL should allow subscription for q1 and q2");
+
try:
session.message_subscribe(queue='q3', destination='myq3')
self.fail("ACL should deny subscription for queue='q3'");
except qpid.session.SessionException, e:
self.assertEqual(403,e.args[0].error_code)
session = self.get_session('bob','bob')
-
+
#=====================================
# ACL publish tests
#=====================================
-
+
def test_publish_acl_allow_mode(self):
"""
Test various publish acl
@@ -932,40 +1207,40 @@ class ACLTests(TestBase010):
aclf = self.get_acl_file()
aclf.write('acl deny bob@QPID publish exchange name=amq.direct routingkey=rk1\n')
aclf.write('acl deny bob@QPID publish exchange name=amq.topic\n')
- aclf.write('acl deny bob@QPID publish exchange name=myEx routingkey=rk2\n')
+ aclf.write('acl deny bob@QPID publish exchange name=myEx routingkey=rk2\n')
aclf.write('acl allow all all')
- aclf.close()
-
+ aclf.close()
+
result = self.reload_acl()
- if (result.text.find("format error",0,len(result.text)) != -1):
- self.fail(result)
-
+ if (result):
+ self.fail(result)
+
session = self.get_session('bob','bob')
-
+
props = session.delivery_properties(routing_key="rk1")
-
- try:
+
+ try:
session.message_transfer(destination="amq.direct", message=Message(props,"Test"))
self.fail("ACL should deny message transfer to name=amq.direct routingkey=rk1");
except qpid.session.SessionException, e:
self.assertEqual(403,e.args[0].error_code)
- session = self.get_session('bob','bob')
-
+ session = self.get_session('bob','bob')
+
try:
session.message_transfer(destination="amq.topic", message=Message(props,"Test"))
self.fail("ACL should deny message transfer to name=amq.topic");
except qpid.session.SessionException, e:
self.assertEqual(403,e.args[0].error_code)
session = self.get_session('bob','bob')
-
+
try:
session.exchange_declare(exchange='myEx', type='direct', durable=False)
session.message_transfer(destination="myEx", message=Message(props,"Test"))
except qpid.session.SessionException, e:
if (403 == e.args[0].error_code):
- self.fail("ACL should allow message transfer to exchange myEx with routing key rk1");
-
-
+ self.fail("ACL should allow message transfer to exchange myEx with routing key rk1");
+
+
props = session.delivery_properties(routing_key="rk2")
try:
session.message_transfer(destination="amq.direct", message=Message(props,"Test"))
@@ -982,39 +1257,39 @@ class ACLTests(TestBase010):
aclf.write('acl allow bob@QPID publish exchange name=amq.direct routingkey=rk1\n')
aclf.write('acl allow bob@QPID publish exchange name=amq.topic\n')
aclf.write('acl allow bob@QPID publish exchange name=myEx routingkey=rk2\n')
- aclf.write('acl allow bob@QPID create exchange\n')
- aclf.write('acl allow anonymous all all \n')
+ aclf.write('acl allow bob@QPID create exchange\n')
+ aclf.write('acl allow anonymous all all \n')
aclf.write('acl deny all all')
- aclf.close()
-
+ aclf.close()
+
result = self.reload_acl()
- if (result.text.find("format error",0,len(result.text)) != -1):
- self.fail(result)
-
+ if (result):
+ self.fail(result)
+
session = self.get_session('bob','bob')
-
+
props = session.delivery_properties(routing_key="rk2")
-
- try:
+
+ try:
session.message_transfer(destination="amq.direct", message=Message(props,"Test"))
self.fail("ACL should deny message transfer to name=amq.direct routingkey=rk2");
except qpid.session.SessionException, e:
self.assertEqual(403,e.args[0].error_code)
- session = self.get_session('bob','bob')
-
+ session = self.get_session('bob','bob')
+
try:
session.message_transfer(destination="amq.topic", message=Message(props,"Test"))
except qpid.session.SessionException, e:
if (403 == e.args[0].error_code):
- self.fail("ACL should allow message transfer to exchange amq.topic with any routing key");
-
+ self.fail("ACL should allow message transfer to exchange amq.topic with any routing key");
+
try:
session.exchange_declare(exchange='myEx', type='direct', durable=False)
session.message_transfer(destination="myEx", message=Message(props,"Test"))
except qpid.session.SessionException, e:
if (403 == e.args[0].error_code):
- self.fail("ACL should allow message transfer to exchange myEx with routing key=rk2");
-
+ self.fail("ACL should allow message transfer to exchange myEx with routing key=rk2");
+
props = session.delivery_properties(routing_key="rk1")
try:
@@ -1022,7 +1297,7 @@ class ACLTests(TestBase010):
self.fail("ACL should deny message transfer to name=myEx routingkey=rk1");
except qpid.session.SessionException, e:
self.assertEqual(403,e.args[0].error_code)
- session = self.get_session('bob','bob')
+ session = self.get_session('bob','bob')
try:
session.message_transfer(destination="amq.direct", message=Message(props,"Test"))
@@ -1056,7 +1331,7 @@ class ACLTests(TestBase010):
aclf.close()
result = self.reload_acl()
- if (result.text.find("format error",0,len(result.text)) != -1):
+ if (result):
self.fail(result)
ts = None
@@ -1088,6 +1363,200 @@ class ACLTests(TestBase010):
admin.set_timestamp_cfg(ts) #should pass
+
+ #=====================================
+ # QMF Functional tests
+ #=====================================
+
+ def test_qmf_functional_tests(self):
+ """
+ Test using QMF method hooks into ACL logic
+ """
+ aclf = self.get_acl_file()
+ aclf.write('group admins moe@COMPANY.COM \\\n')
+ aclf.write(' larry@COMPANY.COM \\\n')
+ aclf.write(' curly@COMPANY.COM \\\n')
+ aclf.write(' shemp@COMPANY.COM\n')
+ aclf.write('group auditors aaudit@COMPANY.COM baudit@COMPANY.COM caudit@COMPANY.COM \\\n')
+ aclf.write(' daudit@COMPANY.COM eaduit@COMPANY.COM eaudit@COMPANY.COM\n')
+ aclf.write('group tatunghosts tatung01@COMPANY.COM \\\n')
+ aclf.write(' tatung02/x86.build.company.com@COMPANY.COM \\\n')
+ aclf.write(' tatung03/x86.build.company.com@COMPANY.COM \\\n')
+ aclf.write(' tatung04/x86.build.company.com@COMPANY.COM \n')
+ aclf.write('group publishusers publish@COMPANY.COM x-pubs@COMPANY.COM\n')
+ aclf.write('acl allow-log admins all all\n')
+ aclf.write('# begin hack alert: allow anonymous to access the lookup debug functions\n')
+ aclf.write('acl allow-log anonymous create queue\n')
+ aclf.write('acl allow-log anonymous all exchange name=qmf.*\n')
+ aclf.write('acl allow-log anonymous all exchange name=amq.direct\n')
+ aclf.write('acl allow-log anonymous all exchange name=qpid.management\n')
+ aclf.write('acl allow-log anonymous access method name=*\n')
+ aclf.write('# end hack alert\n')
+ aclf.write('acl allow-log auditors all exchange name=company.topic routingkey=private.audit.*\n')
+ aclf.write('acl allow-log tatunghosts publish exchange name=company.topic routingkey=tatung.*\n')
+ aclf.write('acl allow-log tatunghosts publish exchange name=company.direct routingkey=tatung-service-queue\n')
+ aclf.write('acl allow-log publishusers create queue\n')
+ aclf.write('acl allow-log publishusers publish exchange name=qpid.management routingkey=broker\n')
+ aclf.write('acl allow-log publishusers publish exchange name=qmf.default.topic routingkey=*\n')
+ aclf.write('acl allow-log publishusers publish exchange name=qmf.default.direct routingkey=*\n')
+ aclf.write('acl allow-log all bind exchange name=company.topic routingkey=tatung.*\n')
+ aclf.write('acl allow-log all bind exchange name=company.direct routingkey=tatung-service-queue\n')
+ aclf.write('acl allow-log all consume queue\n')
+ aclf.write('acl allow-log all access exchange\n')
+ aclf.write('acl allow-log all access queue\n')
+ aclf.write('acl allow-log all create queue name=tmp.* durable=false autodelete=true exclusive=true policytype=ring\n')
+ aclf.write('acl allow mrQ create queue queuemaxsizelowerlimit=100 queuemaxsizeupperlimit=200 queuemaxcountlowerlimit=300 queuemaxcountupperlimit=400\n')
+ aclf.write('acl deny-log all all\n')
+ aclf.close()
+
+ result = self.reload_acl()
+ if (result):
+ self.fail(result)
+
+ #
+ # define some group lists
+ #
+ g_admins = ['moe@COMPANY.COM', \
+ 'larry@COMPANY.COM', \
+ 'curly@COMPANY.COM', \
+ 'shemp@COMPANY.COM']
+
+ g_auditors = [ 'aaudit@COMPANY.COM','baudit@COMPANY.COM','caudit@COMPANY.COM', \
+ 'daudit@COMPANY.COM','eaduit@COMPANY.COM','eaudit@COMPANY.COM']
+
+ g_tatunghosts = ['tatung01@COMPANY.COM', \
+ 'tatung02/x86.build.company.com@COMPANY.COM', \
+ 'tatung03/x86.build.company.com@COMPANY.COM', \
+ 'tatung04/x86.build.company.com@COMPANY.COM']
+
+ g_publishusers = ['publish@COMPANY.COM', 'x-pubs@COMPANY.COM']
+
+ g_public = ['jpublic@COMPANY.COM', 'me@yahoo.com']
+
+ g_all = g_admins + g_auditors + g_tatunghosts + g_publishusers + g_public
+
+ action_all = ['consume','publish','create','access','bind','unbind','delete','purge','update']
+
+ #
+ # Run some tests verifying against users who are in and who are out of given groups.
+ #
+
+ for u in g_admins:
+ self.Lookup(u, "create", "queue", "anything", {"durable":"true"}, "allow-log")
+
+ uInTest = g_auditors + g_admins
+ uOutTest = self.AllBut(g_all, uInTest)
+
+ for u in uInTest:
+ self.LookupPublish(u, "company.topic", "private.audit.This", "allow-log")
+
+ for u in uInTest:
+ for a in action_all:
+ self.Lookup(u, a, "exchange", "company.topic", {"routingkey":"private.audit.This"}, "allow-log")
+
+ for u in uOutTest:
+ self.LookupPublish(u, "company.topic", "private.audit.This", "deny-log")
+ self.Lookup(u, "bind", "exchange", "company.topic", {"routingkey":"private.audit.This"}, "deny-log")
+
+ uInTest = g_admins + g_tatunghosts
+ uOutTest = self.AllBut(g_all, uInTest)
+
+ for u in uInTest:
+ self.LookupPublish(u, "company.topic", "tatung.this2", "allow-log")
+ self.LookupPublish(u, "company.direct", "tatung-service-queue", "allow-log")
+
+ for u in uOutTest:
+ self.LookupPublish(u, "company.topic", "tatung.this2", "deny-log")
+ self.LookupPublish(u, "company.direct", "tatung-service-queue", "deny-log")
+
+ for u in uOutTest:
+ for a in ["bind", "access"]:
+ self.Lookup(u, a, "exchange", "company.topic", {"routingkey":"tatung.this2"}, "allow-log")
+ self.Lookup(u, a, "exchange", "company.direct", {"routingkey":"tatung-service-queue"}, "allow-log")
+
+ uInTest = g_admins + g_publishusers
+ uOutTest = self.AllBut(g_all, uInTest)
+
+ for u in uInTest:
+ self.LookupPublish(u, "qpid.management", "broker", "allow-log")
+ self.LookupPublish(u, "qmf.default.topic", "this3", "allow-log")
+ self.LookupPublish(u, "qmf.default.direct", "this4", "allow-log")
+
+ for u in uOutTest:
+ self.LookupPublish(u, "qpid.management", "broker", "deny-log")
+ self.LookupPublish(u, "qmf.default.topic", "this3", "deny-log")
+ self.LookupPublish(u, "qmf.default.direct", "this4", "deny-log")
+
+ for u in uOutTest:
+ for a in ["bind"]:
+ self.Lookup(u, a, "exchange", "qpid.management", {"routingkey":"broker"}, "deny-log")
+ self.Lookup(u, a, "exchange", "qmf.default.topic", {"routingkey":"this3"}, "deny-log")
+ self.Lookup(u, a, "exchange", "qmf.default.direct", {"routingkey":"this4"}, "deny-log")
+ for a in ["access"]:
+ self.Lookup(u, a, "exchange", "qpid.management", {"routingkey":"broker"}, "allow-log")
+ self.Lookup(u, a, "exchange", "qmf.default.topic", {"routingkey":"this3"}, "allow-log")
+ self.Lookup(u, a, "exchange", "qmf.default.direct", {"routingkey":"this4"}, "allow-log")
+
+ # Test against queue size limits
+
+ self.Lookup('mrQ', 'create', 'queue', 'abc', {"maxqueuesize":"150", "maxqueuecount":"350"}, "allow")
+ self.Lookup('mrQ', 'create', 'queue', 'def', {"maxqueuesize":"99", "maxqueuecount":"350"}, "deny")
+ self.Lookup('mrQ', 'create', 'queue', 'uvw', {"maxqueuesize":"201", "maxqueuecount":"350"}, "deny")
+ self.Lookup('mrQ', 'create', 'queue', 'xyz', {"maxqueuesize":"150", "maxqueuecount":"299"}, "deny")
+ self.Lookup('mrQ', 'create', 'queue', '', {"maxqueuesize":"150", "maxqueuecount":"401"}, "deny")
+ self.Lookup('mrQ', 'create', 'queue', '', {"maxqueuesize":"0", "maxqueuecount":"401"}, "deny")
+ self.Lookup('mrQ', 'create', 'queue', '', {"maxqueuesize":"150", "maxqueuecount":"0" }, "deny")
+
+
+ #=====================================
+ # Connection limits
+ #=====================================
+
+ def test_connection_limits(self):
+ """
+ Test ACL control connection limits
+ """
+ # By username should be able to connect twice per user
+ try:
+ sessiona1 = self.get_session_by_port('alice','alice', self.port_u())
+ sessiona2 = self.get_session_by_port('alice','alice', self.port_u())
+ except Exception, e:
+ self.fail("Could not create two connections for user alice: " + str(e))
+
+ # Third session should fail
+ try:
+ sessiona3 = self.get_session_by_port('alice','alice', self.port_u())
+ self.fail("Should not be able to create third connection for user alice")
+ except Exception, e:
+ result = None
+
+ try:
+ sessionb1 = self.get_session_by_port('bob','bob', self.port_u())
+ sessionb2 = self.get_session_by_port('bob','bob', self.port_u())
+ except Exception, e:
+ self.fail("Could not create two connections for user bob: " + str(e))
+
+ try:
+ sessionb3 = self.get_session_by_port('bob','bob', self.port_u())
+ self.fail("Should not be able to create third connection for user bob")
+ except Exception, e:
+ result = None
+
+ # By IP address should be able to connect twice per client address
+ try:
+ sessionb1 = self.get_session_by_port('alice','alice', self.port_i())
+ sessionb2 = self.get_session_by_port('bob','bob', self.port_i())
+ except Exception, e:
+ self.fail("Could not create two connections for client address: " + str(e))
+
+ # Third session should fail
+ try:
+ sessionb3 = self.get_session_by_port('charlie','charlie', self.port_i())
+ self.fail("Should not be able to create third connection for client address")
+ except Exception, e:
+ result = None
+
+
class BrokerAdmin:
def __init__(self, broker, username=None, password=None):
self.connection = qpid.messaging.Connection(broker)
diff --git a/cpp/src/tests/amqp_0_10/Map.cpp b/cpp/src/tests/amqp_0_10/Map.cpp
deleted file mode 100644
index ffb235829e..0000000000
--- a/cpp/src/tests/amqp_0_10/Map.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- *
- * 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 "amqp_0_10/unit_test.h"
-#include "qpid/amqp_0_10/Map.h"
-#include "qpid/amqp_0_10/Array.h"
-#include "qpid/amqp_0_10/Struct32.h"
-#include "qpid/amqp_0_10/UnknownType.h"
-#include "qpid/amqp_0_10/Codec.h"
-#include <iostream>
-
-using namespace qpid::amqp_0_10;
-using namespace std;
-
-QPID_AUTO_TEST_SUITE(MapTestSuite)
-
- QPID_AUTO_TEST_CASE(testGetSet) {
- MapValue v;
- v = Str8("foo");
- BOOST_CHECK(v.get<Str8>());
- BOOST_CHECK(!v.get<uint8_t>());
- BOOST_CHECK_EQUAL(*v.get<Str8>(), "foo");
-
- v = uint8_t(42);
- BOOST_CHECK(!v.get<Str8>());
- BOOST_CHECK(v.get<uint8_t>());
- BOOST_CHECK_EQUAL(*v.get<uint8_t>(), 42);
-
- v = uint16_t(12);
- BOOST_CHECK(v.get<uint16_t>());
- BOOST_CHECK_EQUAL(*v.get<uint16_t>(), 12);
-}
-
-template <class R> struct TestVisitor : public MapValue::Visitor<R> {
- template <class T> R operator()(const T&) const { throw MapValue::BadTypeException(); }
- R operator()(const R& r) const { return r; }
-};
-
-QPID_AUTO_TEST_CASE(testVisit) {
- MapValue v;
- v = Str8("foo");
- BOOST_CHECK_EQUAL(v.apply_visitor(TestVisitor<Str8>()), "foo");
- v = Uint16(42);
- BOOST_CHECK_EQUAL(v.apply_visitor(TestVisitor<Uint16>()), 42);
- try {
- v.apply_visitor(TestVisitor<bool>());
- BOOST_FAIL("Expecting exception");
- }
- catch(const MapValue::BadTypeException&) {}
-}
-
-
-QPID_AUTO_TEST_CASE(testEncodeMapValue) {
- MapValue mv;
- std::string data;
- mv = Str8("hello");
- Codec::encode(back_inserter(data))(mv);
- BOOST_CHECK_EQUAL(data.size(), Codec::size(mv));
- MapValue mv2;
- Codec::decode(data.begin())(mv2);
- BOOST_CHECK_EQUAL(mv2.getCode(), 0x85);
- BOOST_REQUIRE(mv2.get<Str8>());
- BOOST_CHECK_EQUAL(*mv2.get<Str8>(), "hello");
-}
-
-QPID_AUTO_TEST_CASE(testEncode) {
- Map map;
- std::string data;
- map["A"] = true;
- map["b"] = Str8("hello");
- Codec::encode(back_inserter(data))(map);
- BOOST_CHECK_EQUAL(Codec::size(map), data.size());
- Map map2;
- Codec::decode(data.begin())(map2);
- BOOST_CHECK_EQUAL(map.size(), 2u);
- BOOST_CHECK(map["A"].get<bool>());
- BOOST_CHECK_EQUAL(*map["b"].get<Str8>(), "hello");
-}
-
-
-QPID_AUTO_TEST_SUITE_END()
diff --git a/cpp/src/tests/amqp_0_10/ProxyTemplate.cpp b/cpp/src/tests/amqp_0_10/ProxyTemplate.cpp
deleted file mode 100644
index f54ee0da22..0000000000
--- a/cpp/src/tests/amqp_0_10/ProxyTemplate.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- *
- * 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 "amqp_0_10/unit_test.h"
-#include "qpid/amqp_0_10/ProxyTemplate.h"
-#include <boost/any.hpp>
-
-QPID_AUTO_TEST_SUITE(ProxyTemplateTestSuite)
-
-using namespace qpid::amqp_0_10;
-
-struct ToAny {
- template <class T>
- boost::any operator()(const T& t) { return boost::any(t); }
-};
-
-struct AnyProxy : public ProxyTemplate<ToAny, boost::any> {};
-
-QPID_AUTO_TEST_CASE(testAnyProxy) {
- AnyProxy p;
- boost::any a=p.connectionTune(1,2,3,4);
- BOOST_CHECK_EQUAL(a.type().name(), typeid(connection::Tune).name());
- connection::Tune* tune=boost::any_cast<connection::Tune>(&a);
- BOOST_REQUIRE(tune);
- BOOST_CHECK_EQUAL(tune->channelMax, 1u);
- BOOST_CHECK_EQUAL(tune->maxFrameSize, 2u);
- BOOST_CHECK_EQUAL(tune->heartbeatMin, 3u);
- BOOST_CHECK_EQUAL(tune->heartbeatMax, 4u);
-}
-
-QPID_AUTO_TEST_SUITE_END()
diff --git a/cpp/src/tests/amqp_0_10/apply.cpp b/cpp/src/tests/amqp_0_10/apply.cpp
deleted file mode 100644
index 0aa4421791..0000000000
--- a/cpp/src/tests/amqp_0_10/apply.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- *
- * 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 "amqp_0_10/unit_test.h"
-#include "qpid/amqp_0_10/specification.h"
-#include "qpid/amqp_0_10/ApplyControl.h"
-
-QPID_AUTO_TEST_SUITE(VisitorTestSuite)
-
-using namespace qpid::amqp_0_10;
-
-struct GetCode : public ApplyFunctor<uint8_t> {
- template <class T> uint8_t operator()(const T&) const { return T::CODE; }
-};
-
-struct SetChannelMax : ApplyFunctor<void> {
- template <class T> void operator()(T&) const { BOOST_FAIL(""); }
- void operator()(connection::Tune& t) const { t.channelMax=42; }
-};
-
-struct TestFunctor {
- typedef bool result_type;
- bool operator()(const connection::Tune& tune) {
- BOOST_CHECK_EQUAL(tune.channelMax, 1u);
- BOOST_CHECK_EQUAL(tune.maxFrameSize, 2u);
- BOOST_CHECK_EQUAL(tune.heartbeatMin, 3u);
- BOOST_CHECK_EQUAL(tune.heartbeatMax, 4u);
- return true;
- }
- template <class T>
- bool operator()(const T&) { return false; }
-};
-
-QPID_AUTO_TEST_CASE(testApply) {
- connection::Tune tune(1,2,3,4);
- Control* p = &tune;
-
- // boost oddity - without the cast we get undefined symbol errors.
- BOOST_CHECK_EQUAL(apply(GetCode(), *p), (uint8_t)connection::Tune::CODE);
-
- TestFunctor tf;
- BOOST_CHECK(apply(tf, *p));
-
- connection::Start start;
- p = &start;
- BOOST_CHECK(!apply(tf, *p));
-
- apply(SetChannelMax(), tune);
- BOOST_CHECK_EQUAL(tune.channelMax, 42);
-}
-
-struct VoidTestFunctor {
- typedef void result_type;
-
- int code;
- VoidTestFunctor() : code() {}
-
- void operator()(const connection::Tune& tune) {
- BOOST_CHECK_EQUAL(tune.channelMax, 1u);
- BOOST_CHECK_EQUAL(tune.maxFrameSize, 2u);
- BOOST_CHECK_EQUAL(tune.heartbeatMin, 3u);
- BOOST_CHECK_EQUAL(tune.heartbeatMax, 4u);
- code=connection::Tune::CODE;
- }
- template <class T>
- void operator()(const T&) { code=0xFF; }
-};
-
-QPID_AUTO_TEST_CASE(testApplyVoid) {
- connection::Tune tune(1,2,3,4);
- Control* p = &tune;
- VoidTestFunctor tf;
- apply(tf, *p);
- BOOST_CHECK_EQUAL(uint8_t(connection::Tune::CODE), tf.code);
-
- connection::Start start;
- p = &start;
- apply(tf, *p);
- BOOST_CHECK_EQUAL(0xFF, tf.code);
-}
-
-QPID_AUTO_TEST_SUITE_END()
diff --git a/cpp/src/tests/amqp_0_10/handlers.cpp b/cpp/src/tests/amqp_0_10/handlers.cpp
deleted file mode 100644
index 91bb304a17..0000000000
--- a/cpp/src/tests/amqp_0_10/handlers.cpp
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- *
- * 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 "amqp_0_10/unit_test.h"
-#include "qpid/Exception.h"
-#include "qpid/amqp_0_10/Unit.h"
-#include "qpid/amqp_0_10/ControlHolder.h"
-#include "qpid/amqp_0_10/CommandHolder.h"
-#include "qpid/amqp_0_10/handlers.h"
-#include "qpid/amqp_0_10/specification.h"
-
-QPID_AUTO_TEST_SUITE(handler_tests)
-
-using namespace qpid::amqp_0_10;
-using namespace std;
-
-string called; // Set by called handler function
-
-// Note on handlers:
-//
-// Control and Command handlers are separate, both behave the same way,
-// so substitute "control or command" for command in the following.
-//
-// Command handlers derive from CommandHandler and implement functions
-// for all the commands they handle. Handling an unimplemented command
-// will raise NotImplementedException.
-//
-// Using virtual inheritance from CommandHandler allows multiple
-// handlers to be aggregated into one with multiple inheritance,
-// See test code for example.
-//
-// E.g. the existing broker model would have two control handlers:
-// - ConnectionHandler: ControlHandler for connection controls.
-// - SessionHandler: ControlHandler for session controls.
-// It would have class-command handlers for each AMQP class:
-// - QueueHandler, MessageHandler etc.. handle each class.
-// And an aggregate handler in place of BrokerAdapter
-// - BrokerCommandHandler: public QueueHandler, MessageHandler ...
-//
-// In other applications (e.g. cluster) any combination of commands
-// can be handled by a given handler. It _might_ simplify the code
-// to collaps ConnectionHandler and SessionHandler into a single
-// ControlHandler (or it might not.)
-
-struct TestExecutionHandler : public virtual CommandHandler {
- void executionSync() { called = "executionSync"; }
- // ... etc. for all execution commands
-};
-
-struct TestMessageHandler : public virtual CommandHandler {
- void messageCancel(const Str8&) { called="messageCancel"; }
- // ... etc.
-};
-
-// Aggregate handler for all recognised commands.
-struct TestCommandHandler :
- public TestExecutionHandler,
- public TestMessageHandler
- // ... etc. handlers for all command classes.
-{}; // Nothing to do.
-
-
-// Sample unit handler, written as a static_visitor.
-// Note it could equally be written with if/else statements
-// in handle.
-//
-struct TestUnitHandler : public boost::static_visitor<void> {
- TestCommandHandler handler;
- void handle(const Unit& u) { u.applyVisitor(*this); }
-
- void operator()(const Body&) { called="Body"; }
- void operator()(const Header&) { called="Header"; }
- void operator()(const ControlHolder&) { throw qpid::Exception("I don't do controls."); }
- void operator()(const CommandHolder& c) { c.invoke(handler); }
-};
-
-QPID_AUTO_TEST_CASE(testHandlers) {
- TestUnitHandler handler;
- Unit u;
-
- u = Body();
- handler.handle(u);
- BOOST_CHECK_EQUAL("Body", called);
-
- u = Header();
- handler.handle(u);
- BOOST_CHECK_EQUAL("Header", called);
-
- // in_place<Foo>(...) is equivalent to Foo(...) but
- // constructs Foo directly in the holder, avoiding
- // a copy.
-
- u = CommandHolder(in_place<execution::Sync>());
- handler.handle(u);
- BOOST_CHECK_EQUAL("executionSync", called);
-
- u = ControlHolder(in_place<connection::Start>(Map(), Str16Array(), Str16Array()));
- try {
- handler.handle(u);
- } catch (const qpid::Exception&) {}
-
- u = CommandHolder(in_place<message::Cancel>(Str8()));
- handler.handle(u);
- BOOST_CHECK_EQUAL("messageCancel", called);
-}
-
-QPID_AUTO_TEST_SUITE_END()
diff --git a/cpp/src/tests/amqp_0_10/serialize.cpp b/cpp/src/tests/amqp_0_10/serialize.cpp
deleted file mode 100644
index 975d6206ec..0000000000
--- a/cpp/src/tests/amqp_0_10/serialize.cpp
+++ /dev/null
@@ -1,429 +0,0 @@
-/*
- *
- * 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 "amqp_0_10/unit_test.h"
-#include "amqp_0_10/allSegmentTypes.h"
-
-#include "qpid/framing/AMQFrame.h"
-#include "qpid/framing/Buffer.h"
-
-#include "qpid/amqp_0_10/Packer.h"
-#include "qpid/amqp_0_10/built_in_types.h"
-#include "qpid/amqp_0_10/Codec.h"
-#include "qpid/amqp_0_10/specification.h"
-#include "qpid/amqp_0_10/ControlHolder.h"
-#include "qpid/amqp_0_10/Struct32.h"
-#include "qpid/amqp_0_10/FrameHeader.h"
-#include "qpid/amqp_0_10/Map.h"
-#include "qpid/amqp_0_10/Unit.h"
-#include "allSegmentTypes.h"
-
-#include <boost/test/test_case_template.hpp>
-#include <boost/type_traits/is_arithmetic.hpp>
-#include <boost/utility/enable_if.hpp>
-#include <boost/optional.hpp>
-#include <boost/mpl/vector.hpp>
-#include <boost/mpl/back_inserter.hpp>
-#include <boost/mpl/copy.hpp>
-#include <boost/mpl/empty_sequence.hpp>
-#include <boost/current_function.hpp>
-#include <iterator>
-#include <string>
-#include <sstream>
-#include <iostream>
-#include <netinet/in.h>
-
-// Missing operators needed for tests.
-namespace boost {
-template <class T, size_t N>
-std::ostream& operator<<(std::ostream& out, const array<T,N>& a) {
- std::ostream_iterator<T> o(out, " ");
- std::copy(a.begin(), a.end(), o);
- return out;
-}
-} // boost
-
-QPID_AUTO_TEST_SUITE(SerializeTestSuite)
-
-using namespace std;
-namespace mpl=boost::mpl;
-using namespace qpid::amqp_0_10;
-using qpid::framing::in_place;
-
-template <class A, class B> struct concat2 { typedef typename mpl::copy<B, typename mpl::back_inserter<A> >::type type; };
-template <class A, class B, class C> struct concat3 { typedef typename concat2<A, typename concat2<B, C>::type>::type type; };
-template <class A, class B, class C, class D> struct concat4 { typedef typename concat2<A, typename concat3<B, C, D>::type>::type type; };
-
-typedef mpl::vector<Boolean, Char, Int32, Int64, Int8, Uint16, CharUtf32, Uint32, Uint64, Bin8, Uint8>::type IntegralTypes;
-typedef mpl::vector<Bin1024, Bin128, Bin16, Bin256, Bin32, Bin40, Bin512, Bin64, Bin72>::type BinTypes;
-typedef mpl::vector<Double, Float>::type FloatTypes;
-typedef mpl::vector<SequenceNo, Uuid, Datetime, Dec32, Dec64> FixedSizeClassTypes;
-typedef mpl::vector<Map, Vbin8, Str8Latin, Str8, Str8Utf16, Vbin16, Str16Latin, Str16, Str16Utf16, Vbin32> VariableSizeTypes;
-
-typedef concat4<IntegralTypes, BinTypes, FloatTypes, FixedSizeClassTypes>::type FixedSizeTypes;
-typedef concat2<FixedSizeTypes, VariableSizeTypes>::type AllTypes;
-
-// TODO aconway 2008-02-20: should test 64 bit integrals for order also.
-QPID_AUTO_TEST_CASE(testNetworkByteOrder) {
- string data;
-
- uint32_t l = 0x11223344;
- Codec::encode(std::back_inserter(data))(l);
- uint32_t enc=reinterpret_cast<const uint32_t&>(*data.data());
- uint32_t l2 = ntohl(enc);
- BOOST_CHECK_EQUAL(l, l2);
-
- data.clear();
- uint16_t s = 0x1122;
- Codec::encode(std::back_inserter(data))(s);
- uint32_t s2 = ntohs(*reinterpret_cast<const uint32_t*>(data.data()));
- BOOST_CHECK_EQUAL(s, s2);
-}
-
-QPID_AUTO_TEST_CASE(testSetLimit) {
- typedef Codec::Encoder<back_insert_iterator<string> > Encoder;
- string data;
- Encoder encode(back_inserter(data), 3);
- encode('1')('2')('3');
- try {
- encode('4');
- BOOST_FAIL("Expected exception");
- } catch (...) {} // FIXME aconway 2008-04-03: catch proper exception
- BOOST_CHECK_EQUAL(data, "123");
-}
-
-QPID_AUTO_TEST_CASE(testScopedLimit) {
- typedef Codec::Encoder<back_insert_iterator<string> > Encoder;
- string data;
- Encoder encode(back_inserter(data), 10);
- encode(Str8("123")); // 4 bytes
- {
- Encoder::ScopedLimit l(encode, 3);
- encode('a')('b')('c');
- try {
- encode('d');
- BOOST_FAIL("Expected exception");
- } catch(...) {} // FIXME aconway 2008-04-03: catch proper exception
- }
- BOOST_CHECK_EQUAL(data, "\003123abc");
- encode('x')('y')('z');
- try {
- encode('!');
- BOOST_FAIL("Expected exception");
- } catch(...) {} // FIXME aconway 2008-04-03: catch proper exception
- BOOST_CHECK_EQUAL(data.size(), 10u);
-}
-
-// Assign test values to the various types.
-void testValue(bool& b) { b = true; }
-void testValue(Bit&) { }
-template <class T> typename boost::enable_if<boost::is_arithmetic<T> >::type testValue(T& n) { n=42; }
-void testValue(CharUtf32& c) { c = 43; }
-void testValue(long long& l) { l = 0x012345; }
-void testValue(Datetime& dt) { dt = qpid::sys::now(); }
-void testValue(Uuid& uuid) { uuid=Uuid(true); }
-template <class E, class M> void testValue(Decimal<E,M>& d) { d.exponent=2; d.mantissa=0x1122; }
-void testValue(SequenceNo& s) { s = 42; }
-template <size_t N> void testValue(Bin<N>& a) { a.assign(42); }
-template <class T, class S, int Unique> void testValue(SerializableString<T, S, Unique>& s) {
- char msg[]="foobar";
- s.assign(msg, msg+sizeof(msg));
-}
-void testValue(Str16& s) { s = "the quick brown fox jumped over the lazy dog"; }
-void testValue(Str8& s) { s = "foobar"; }
-void testValue(Map& m) { m["s"] = Str8("foobar"); m["b"] = true; m["c"] = uint16_t(42); }
-
-//typedef mpl::vector<Str8, Str16>::type TestTypes;
-/*BOOST_AUTO_TEST_CASE_TEMPLATE(testEncodeDecode, T, AllTypes)
-{
- string data;
- T t;
- testValue(t);
- Codec::encode(std::back_inserter(data))(t);
-
- BOOST_CHECK_EQUAL(Codec::size(t), data.size());
-
- T t2;
- Codec::decode(data.begin())(t2);
- BOOST_CHECK_EQUAL(t,t2);
-}
-*/
-
-struct TestMe {
- bool encoded, decoded;
- char value;
- TestMe(char v) : encoded(), decoded(), value(v) {}
- template <class S> void encode(S& s) const {
- const_cast<TestMe*>(this)->encoded=true; s(value);
- }
- template <class S> void decode(S& s) { decoded=true; s(value); }
- template <class S> void serialize(S& s) { s.split(*this); }
-};
-
-QPID_AUTO_TEST_CASE(testSplit) {
- string data;
- TestMe t1('x');
- Codec::encode(std::back_inserter(data))(t1);
- BOOST_CHECK(t1.encoded);
- BOOST_CHECK(!t1.decoded);
- BOOST_CHECK_EQUAL(data, "x");
-
- TestMe t2('y');
- Codec::decode(data.begin())(t2);
- BOOST_CHECK(!t2.encoded);
- BOOST_CHECK(t2.decoded);
- BOOST_CHECK_EQUAL(t2.value, 'x');
-}
-
-QPID_AUTO_TEST_CASE(testControlEncodeDecode) {
- string data;
- Control::Holder h(in_place<connection::Tune>(1,2,3,4));
- Codec::encode(std::back_inserter(data))(h);
-
- BOOST_CHECK_EQUAL(data.size(), Codec::size(h));
-
- Codec::Decoder<string::iterator> decode(data.begin());
- Control::Holder h2;
- decode(h2);
-
- BOOST_REQUIRE(h2.get());
- BOOST_CHECK_EQUAL(h2.get()->getClassCode(), connection::CODE);
- BOOST_CHECK_EQUAL(h2.get()->getCode(), uint8_t(connection::Tune::CODE));
- connection::Tune& tune=static_cast<connection::Tune&>(*h2.get());
- BOOST_CHECK_EQUAL(tune.channelMax, 1u);
- BOOST_CHECK_EQUAL(tune.maxFrameSize, 2u);
- BOOST_CHECK_EQUAL(tune.heartbeatMin, 3u);
- BOOST_CHECK_EQUAL(tune.heartbeatMax, 4u);
-}
-
-QPID_AUTO_TEST_CASE(testStruct32) {
- message::DeliveryProperties dp;
- dp.priority=message::MEDIUM;
- dp.routingKey="foo";
- Struct32 s(dp);
- string data;
- Codec::encode(back_inserter(data))(s);
-
- uint32_t structSize; // Starts with size
- Codec::decode(data.begin())(structSize);
- BOOST_CHECK_EQUAL(structSize, Codec::size(dp) + 2); // +2 for code
- BOOST_CHECK_EQUAL(structSize, data.size()-4); // encoded body
-
- BOOST_CHECK_EQUAL(data.size(), Codec::size(s));
- Struct32 s2;
- Codec::decode(data.begin())(s2);
- message::DeliveryProperties* dp2 = s2.getIf<message::DeliveryProperties>();
- BOOST_REQUIRE(dp2);
- BOOST_CHECK_EQUAL(dp2->priority, message::MEDIUM);
- BOOST_CHECK_EQUAL(dp2->routingKey, "foo");
-}
-
-QPID_AUTO_TEST_CASE(testStruct32Unknown) {
- // Verify we can recode an unknown struct unchanged.
- Struct32 s;
- string data;
- Codec::encode(back_inserter(data))(uint32_t(10));
- data.append(10, 'X');
- Codec::decode(data.begin())(s);
- string data2;
- Codec::encode(back_inserter(data2))(s);
- BOOST_CHECK_EQUAL(data.size(), data2.size());
- BOOST_CHECK_EQUAL(data, data2);
-}
-
-struct DummyPacked {
- static const uint8_t PACK=1;
- boost::optional<char> i, j;
- char k;
- Bit l,m;
- DummyPacked(char a=0, char b=0, char c=0) : i(a), j(b), k(c), l(), m() {}
- template <class S> void serialize(S& s) { s(i)(j)(k)(l)(m); }
-};
-
-Packer<DummyPacked> serializable(DummyPacked& d) { return Packer<DummyPacked>(d); }
-
-QPID_AUTO_TEST_CASE(testPackBits) {
- DummyPacked d('a','b','c');
- BOOST_CHECK_EQUAL(packBits(d), 7u);
- d.j = boost::none;
- BOOST_CHECK_EQUAL(packBits(d), 5u);
- d.m = true;
- BOOST_CHECK_EQUAL(packBits(d), 0x15u);
-}
-
-
-QPID_AUTO_TEST_CASE(testPacked) {
- string data;
-
- Codec::encode(back_inserter(data))('a')(boost::optional<char>('b'))(boost::optional<char>())('c');
- BOOST_CHECK_EQUAL(data, "abc");
- data.clear();
-
- DummyPacked dummy('a','b','c');
-
- Codec::encode(back_inserter(data))(dummy);
- BOOST_CHECK_EQUAL(data.size(), 4u);
- BOOST_CHECK_EQUAL(data, string("\007abc"));
- data.clear();
-
- dummy.i = boost::none;
- Codec::encode(back_inserter(data))(dummy);
- BOOST_CHECK_EQUAL(data, string("\6bc"));
- data.clear();
-
- const char* missing = "\5xy";
- Codec::decode(missing)(dummy);
- BOOST_CHECK(dummy.i);
- BOOST_CHECK_EQUAL(*dummy.i, 'x');
- BOOST_CHECK(!dummy.j);
- BOOST_CHECK_EQUAL(dummy.k, 'y');
-}
-
-QPID_AUTO_TEST_CASE(testUnitControl) {
- string data;
- Control::Holder h(in_place<connection::Tune>(1,2,3,4));
- Codec::encode(std::back_inserter(data))(h);
-
- Unit unit(FrameHeader(FIRST_FRAME|LAST_FRAME, CONTROL));
- Codec::decode(data.begin())(unit);
-
- BOOST_REQUIRE(unit.get<ControlHolder>());
-
- string data2;
- Codec::encode(back_inserter(data2))(unit);
-
- BOOST_CHECK_EQUAL(data, data2);
-}
-
-QPID_AUTO_TEST_CASE(testArray) {
- ArrayDomain<char> a;
- a.resize(3, 'x');
- string data;
- Codec::encode(back_inserter(data))(a);
-
- ArrayDomain<char> b;
- Codec::decode(data.begin())(b);
- BOOST_CHECK_EQUAL(b.size(), 3u);
- string data3;
- Codec::encode(back_inserter(data3))(a);
- BOOST_CHECK_EQUAL(data, data3);
-
- Array x;
- Codec::decode(data.begin())(x);
- BOOST_CHECK_EQUAL(x.size(), 3u);
- BOOST_CHECK_EQUAL(x[0].size(), 1u);
- BOOST_CHECK_EQUAL(*x[0].begin(), 'x');
- BOOST_CHECK_EQUAL(*x[2].begin(), 'x');
-
- string data2;
- Codec::encode(back_inserter(data2))(x);
- BOOST_CHECK_EQUAL(data,data2);
-}
-
-QPID_AUTO_TEST_CASE(testStruct) {
- string data;
-
- message::DeliveryProperties dp;
- BOOST_CHECK(!dp.discardUnroutable);
- dp.immediate = true;
- dp.redelivered = false;
- dp.priority = message::MEDIUM;
- dp.exchange = "foo";
-
- Codec::encode(back_inserter(data))(dp);
- // Skip 4 bytes size, little-endian decode for pack bits.
- uint16_t encodedBits=uint8_t(data[5]);
- encodedBits <<= 8;
- encodedBits += uint8_t(data[4]);
- BOOST_CHECK_EQUAL(encodedBits, packBits(dp));
-
- data.clear();
- Struct32 h(dp);
- Codec::encode(back_inserter(data))(h);
-
- Struct32 h2;
- Codec::decode(data.begin())(h2);
- BOOST_CHECK_EQUAL(h2.getClassCode(), Uint8(message::DeliveryProperties::CLASS_CODE));
- BOOST_CHECK_EQUAL(h2.getCode(), Uint8(message::DeliveryProperties::CODE));
- message::DeliveryProperties* dp2 =
- dynamic_cast<message::DeliveryProperties*>(h2.get());
- BOOST_CHECK(dp2);
- BOOST_CHECK(!dp2->discardUnroutable);
- BOOST_CHECK(dp2->immediate);
- BOOST_CHECK(!dp2->redelivered);
- BOOST_CHECK_EQUAL(dp2->priority, message::MEDIUM);
- BOOST_CHECK_EQUAL(dp2->exchange, "foo");
-}
-
-struct RecodeUnit {
- template <class T>
- void operator() (const T& t) {
- BOOST_MESSAGE(BOOST_CURRENT_FUNCTION << " called with: " << t);
- using qpid::framing::Buffer;
- using qpid::framing::AMQFrame;
-
- session::Header sh;
- BOOST_CHECK_EQUAL(Codec::size(sh), 2u);
-
- // Encode unit.
- Unit u(t);
- string data;
- Codec::encode(back_inserter(data))(u.getHeader())(u);
- data.push_back(char(0xCE)); // Preview end-of-frame
-
- // Decode AMQFrame
- Buffer buf(&data[0], data.size());
- AMQFrame f;
- f.decode(buf);
- BOOST_MESSAGE("AMQFrame decoded: " << f);
- // Encode AMQFrame
- string data2(f.size(), ' ');
- Buffer buf2(&data2[0], data.size());
- f.encode(buf2);
-
- // Verify encoded by unit == encoded by AMQFrame
- BOOST_CHECK_MESSAGE(data == data2, BOOST_CURRENT_FUNCTION);
-
- // Decode unit
- // FIXME aconway 2008-04-15: must set limit to decode a header.
- Codec::Decoder<string::iterator> decode(data2.begin(), data2.size()-1);
-
- FrameHeader h;
- decode(h);
- BOOST_CHECK_EQUAL(u.getHeader(), h);
- Unit u2(h);
- decode(u2);
-
- // Re-encode unit
- string data3;
- Codec::encode(back_inserter(data3))(u2.getHeader())(u2);
- data3.push_back(char(0xCE)); // Preview end-of-frame
-
- BOOST_CHECK_MESSAGE(data3 == data2, BOOST_CURRENT_FUNCTION);
- }
-};
-
-QPID_AUTO_TEST_CASE(testSerializeAllSegmentTypes) {
- RecodeUnit recode;
- allSegmentTypes(recode);
-}
-
-QPID_AUTO_TEST_SUITE_END()
diff --git a/cpp/src/tests/brokertest.py b/cpp/src/tests/brokertest.py
index 3207a51b79..8255fbe9ac 100644
--- a/cpp/src/tests/brokertest.py
+++ b/cpp/src/tests/brokertest.py
@@ -436,6 +436,35 @@ class Cluster:
def __getitem__(self,index): return self._brokers[index]
def __iter__(self): return self._brokers.__iter__()
+
+def browse(session, queue, timeout=0, transform=lambda m: m.content):
+ """Return a list with the contents of each message on queue."""
+ r = session.receiver("%s;{mode:browse}"%(queue))
+ r.capacity = 100
+ try:
+ contents = []
+ try:
+ while True: contents.append(transform(r.fetch(timeout=timeout)))
+ except messaging.Empty: pass
+ finally: r.close()
+ return contents
+
+def assert_browse(session, queue, expect_contents, timeout=0, transform=lambda m: m.content, msg="browse failed"):
+ """Assert that the contents of messages on queue (as retrieved
+ using session and timeout) exactly match the strings in
+ expect_contents"""
+ actual_contents = browse(session, queue, timeout, transform=transform)
+ if msg: msg = "%s: %r != %r"%(msg, expect_contents, actual_contents)
+ assert expect_contents == actual_contents, msg
+
+def assert_browse_retry(session, queue, expect_contents, timeout=1, delay=.01, transform=lambda m:m.content, msg="browse failed"):
+ """Wait up to timeout for contents of queue to match expect_contents"""
+ test = lambda: browse(session, queue, 0, transform=transform) == expect_contents
+ retry(test, timeout, delay)
+ actual_contents = browse(session, queue, 0, transform=transform)
+ if msg: msg = "%s: %r != %r"%(msg, expect_contents, actual_contents)
+ assert expect_contents == actual_contents, msg
+
class BrokerTest(TestCase):
"""
Tracks processes started by test and kills at end of test.
@@ -501,30 +530,9 @@ class BrokerTest(TestCase):
cluster = Cluster(self, count, args, expect=expect, wait=wait, show_cmd=show_cmd)
return cluster
- def browse(self, session, queue, timeout=0, transform=lambda m: m.content):
- """Return a list with the contents of each message on queue."""
- r = session.receiver("%s;{mode:browse}"%(queue))
- r.capacity = 100
- try:
- contents = []
- try:
- while True: contents.append(transform(r.fetch(timeout=timeout)))
- except messaging.Empty: pass
- finally: r.close()
- return contents
-
- def assert_browse(self, session, queue, expect_contents, timeout=0, transform=lambda m: m.content):
- """Assert that the contents of messages on queue (as retrieved
- using session and timeout) exactly match the strings in
- expect_contents"""
- actual_contents = self.browse(session, queue, timeout, transform=transform)
- self.assertEqual(expect_contents, actual_contents)
-
- def assert_browse_retry(self, session, queue, expect_contents, timeout=1, delay=.01, transform=lambda m:m.content):
- """Wait up to timeout for contents of queue to match expect_contents"""
- test = lambda: self.browse(session, queue, 0, transform=transform) == expect_contents
- retry(test, timeout, delay)
- self.assertEqual(expect_contents, self.browse(session, queue, 0, transform=transform))
+ def browse(self, *args, **kwargs): browse(*args, **kwargs)
+ def assert_browse(self, *args, **kwargs): assert_browse(*args, **kwargs)
+ def assert_browse_retry(self, *args, **kwargs): assert_browse_retry(*args, **kwargs)
def join(thread, timeout=10):
thread.join(timeout)
diff --git a/cpp/src/tests/cli_tests.py b/cpp/src/tests/cli_tests.py
index 6c75927461..7ac5b1deed 100755
--- a/cpp/src/tests/cli_tests.py
+++ b/cpp/src/tests/cli_tests.py
@@ -22,7 +22,6 @@ import sys
import os
import imp
from qpid.testlib import TestBase010
-# from brokertest import import_script, checkenv
from qpid.datatypes import Message
from qpid.queue import Empty
from time import sleep
@@ -61,14 +60,13 @@ class CliTests(TestBase010):
ret = os.system(self.qpid_config_command(" add queue " + qname + " " + arguments))
self.assertEqual(ret, 0)
- queues = self.qmf.getObjects(_class="queue")
- for queue in queues:
- if queue.name == qname:
- return queue
+ queue = self.broker_access.getQueue(qname)
+ if queue:
+ return queue
assert False
def test_queue_params(self):
- self.startQmf()
+ self.startBrokerAccess()
queue1 = self.makeQueue("test_queue_params1", "--limit-policy none")
queue2 = self.makeQueue("test_queue_params2", "--limit-policy reject")
queue3 = self.makeQueue("test_queue_params3", "--limit-policy flow-to-disk")
@@ -82,29 +80,21 @@ class CliTests(TestBase010):
self.assertEqual(queue4.arguments[LIMIT], "ring")
self.assertEqual(queue5.arguments[LIMIT], "ring_strict")
- queue6 = self.makeQueue("test_queue_params6", "--order fifo")
- queue7 = self.makeQueue("test_queue_params7", "--order lvq")
- queue8 = self.makeQueue("test_queue_params8", "--order lvq-no-browse")
-
- LVQ = "qpid.last_value_queue"
- LVQNB = "qpid.last_value_queue_no_browse"
-
- assert LVQ not in queue6.arguments
- assert LVQ in queue7.arguments
- assert LVQ not in queue8.arguments
+ queue6 = self.makeQueue("test_queue_params6", "--lvq-key lkey")
- assert LVQNB not in queue6.arguments
- assert LVQNB not in queue7.arguments
- assert LVQNB in queue8.arguments
+ LVQKEY = "qpid.last_value_queue_key"
+ assert LVQKEY not in queue5.arguments
+ assert LVQKEY in queue6.arguments
+ assert queue6.arguments[LVQKEY] == "lkey"
def test_queue_params_api(self):
- self.startQmf()
- queue1 = self.makeQueue("test_queue_params1", "--limit-policy none", True)
- queue2 = self.makeQueue("test_queue_params2", "--limit-policy reject", True)
- queue3 = self.makeQueue("test_queue_params3", "--limit-policy flow-to-disk", True)
- queue4 = self.makeQueue("test_queue_params4", "--limit-policy ring", True)
- queue5 = self.makeQueue("test_queue_params5", "--limit-policy ring-strict", True)
+ self.startBrokerAccess()
+ queue1 = self.makeQueue("test_queue_params_api1", "--limit-policy none", True)
+ queue2 = self.makeQueue("test_queue_params_api2", "--limit-policy reject", True)
+ queue3 = self.makeQueue("test_queue_params_api3", "--limit-policy flow-to-disk", True)
+ queue4 = self.makeQueue("test_queue_params_api4", "--limit-policy ring", True)
+ queue5 = self.makeQueue("test_queue_params_api5", "--limit-policy ring-strict", True)
LIMIT = "qpid.policy_type"
assert LIMIT not in queue1.arguments
@@ -113,30 +103,22 @@ class CliTests(TestBase010):
self.assertEqual(queue4.arguments[LIMIT], "ring")
self.assertEqual(queue5.arguments[LIMIT], "ring_strict")
- queue6 = self.makeQueue("test_queue_params6", "--order fifo", True)
- queue7 = self.makeQueue("test_queue_params7", "--order lvq", True)
- queue8 = self.makeQueue("test_queue_params8", "--order lvq-no-browse", True)
+ queue6 = self.makeQueue("test_queue_params_api6", "--lvq-key lkey")
- LVQ = "qpid.last_value_queue"
- LVQNB = "qpid.last_value_queue_no_browse"
+ LVQKEY = "qpid.last_value_queue_key"
- assert LVQ not in queue6.arguments
- assert LVQ in queue7.arguments
- assert LVQ not in queue8.arguments
-
- assert LVQNB not in queue6.arguments
- assert LVQNB not in queue7.arguments
- assert LVQNB in queue8.arguments
+ assert LVQKEY not in queue5.arguments
+ assert LVQKEY in queue6.arguments
+ assert queue6.arguments[LVQKEY] == "lkey"
def test_qpid_config(self):
- self.startQmf();
- qmf = self.qmf
+ self.startBrokerAccess();
qname = "test_qpid_config"
ret = os.system(self.qpid_config_command(" add queue " + qname))
self.assertEqual(ret, 0)
- queues = qmf.getObjects(_class="queue")
+ queues = self.broker_access.getAllQueues()
found = False
for queue in queues:
if queue.name == qname:
@@ -146,7 +128,7 @@ class CliTests(TestBase010):
ret = os.system(self.qpid_config_command(" del queue " + qname))
self.assertEqual(ret, 0)
- queues = qmf.getObjects(_class="queue")
+ queues = self.broker_access.getAllQueues()
found = False
for queue in queues:
if queue.name == qname:
@@ -154,13 +136,12 @@ class CliTests(TestBase010):
self.assertEqual(found, False)
def test_qpid_config_api(self):
- self.startQmf();
- qmf = self.qmf
+ self.startBrokerAccess();
qname = "test_qpid_config_api"
ret = self.qpid_config_api(" add queue " + qname)
self.assertEqual(ret, 0)
- queues = qmf.getObjects(_class="queue")
+ queues = self.broker_access.getAllQueues()
found = False
for queue in queues:
if queue.name == qname:
@@ -170,7 +151,7 @@ class CliTests(TestBase010):
ret = self.qpid_config_api(" del queue " + qname)
self.assertEqual(ret, 0)
- queues = qmf.getObjects(_class="queue")
+ queues = self.broker_access.getAllQueues()
found = False
for queue in queues:
if queue.name == qname:
@@ -179,25 +160,23 @@ class CliTests(TestBase010):
def test_qpid_config_sasl_plain_expect_succeed(self):
- self.startQmf();
- qmf = self.qmf
+ self.startBrokerAccess();
qname = "test_qpid_config_sasl_plain_expect_succeed"
- cmd = " --sasl-mechanism PLAIN -a guest/guest@localhost:"+str(self.broker.port) + " add queue " + qname
+ cmd = " --sasl-mechanism PLAIN -b guest/guest@localhost:"+str(self.broker.port) + " add queue " + qname
ret = self.qpid_config_api(cmd)
self.assertEqual(ret, 0)
def test_qpid_config_sasl_plain_expect_fail(self):
"""Fails because no user name and password is supplied"""
- self.startQmf();
- qmf = self.qmf
- qname = "test_qpid_config_sasl_plain_expect_succeed"
- cmd = " --sasl-mechanism PLAIN -a localhost:"+str(self.broker.port) + " add queue " + qname
+ self.startBrokerAccess();
+ qname = "test_qpid_config_sasl_plain_expect_fail"
+ cmd = " --sasl-mechanism PLAIN -b localhost:"+str(self.broker.port) + " add queue " + qname
ret = self.qpid_config_api(cmd)
assert ret != 0
# helpers for some of the test methods
def helper_find_exchange(self, xchgname, typ, expected=True):
- xchgs = self.qmf.getObjects(_class = "exchange")
+ xchgs = self.broker_access.getAllExchanges()
found = False
for xchg in xchgs:
if xchg.name == xchgname:
@@ -221,7 +200,7 @@ class CliTests(TestBase010):
self.helper_find_exchange(xchgname, False, expected=False)
def helper_find_queue(self, qname, expected=True):
- queues = self.qmf.getObjects(_class="queue")
+ queues = self.broker_access.getAllQueues()
found = False
for queue in queues:
if queue.name == qname:
@@ -246,8 +225,7 @@ class CliTests(TestBase010):
# test the bind-queue-to-header-exchange functionality
def test_qpid_config_headers(self):
- self.startQmf();
- qmf = self.qmf
+ self.startBrokerAccess();
qname = "test_qpid_config"
xchgname = "test_xchg"
@@ -277,8 +255,7 @@ class CliTests(TestBase010):
def test_qpid_config_xml(self):
- self.startQmf();
- qmf = self.qmf
+ self.startBrokerAccess();
qname = "test_qpid_config"
xchgname = "test_xchg"
@@ -306,13 +283,12 @@ class CliTests(TestBase010):
self.helper_destroy_exchange(xchgname)
def test_qpid_config_durable(self):
- self.startQmf();
- qmf = self.qmf
+ self.startBrokerAccess();
qname = "test_qpid_config"
ret = os.system(self.qpid_config_command(" add queue --durable " + qname))
self.assertEqual(ret, 0)
- queues = qmf.getObjects(_class="queue")
+ queues = self.broker_access.getAllQueues()
found = False
for queue in queues:
if queue.name == qname:
@@ -322,7 +298,7 @@ class CliTests(TestBase010):
ret = os.system(self.qpid_config_command(" del queue " + qname))
self.assertEqual(ret, 0)
- queues = qmf.getObjects(_class="queue")
+ queues = self.broker_access.getAllQueues()
found = False
for queue in queues:
if queue.name == qname:
@@ -330,8 +306,7 @@ class CliTests(TestBase010):
self.assertEqual(found, False)
def test_qpid_config_altex(self):
- self.startQmf();
- qmf = self.qmf
+ self.startBrokerAccess();
exName = "testalt"
qName = "testqalt"
altName = "amq.direct"
@@ -339,7 +314,7 @@ class CliTests(TestBase010):
ret = os.system(self.qpid_config_command(" add exchange topic %s --alternate-exchange=%s" % (exName, altName)))
self.assertEqual(ret, 0)
- exchanges = qmf.getObjects(_class="exchange")
+ exchanges = self.broker_access.getAllExchanges()
found = False
for exchange in exchanges:
if exchange.name == altName:
@@ -349,20 +324,23 @@ class CliTests(TestBase010):
found = True
if not exchange.altExchange:
self.fail("Alternate exchange not set")
- self.assertEqual(exchange._altExchange_.name, altName)
+ self.assertEqual(exchange.altExchange, altName)
self.assertEqual(found, True)
ret = os.system(self.qpid_config_command(" add queue %s --alternate-exchange=%s" % (qName, altName)))
self.assertEqual(ret, 0)
- queues = qmf.getObjects(_class="queue")
+ ret = os.system(self.qpid_config_command(" queues"))
+ self.assertEqual(ret, 0)
+
+ queues = self.broker_access.getAllQueues()
found = False
for queue in queues:
if queue.name == qName:
found = True
if not queue.altExchange:
self.fail("Alternate exchange not set")
- self.assertEqual(queue._altExchange_.name, altName)
+ self.assertEqual(queue.altExchange, altName)
self.assertEqual(found, True)
def test_qpid_config_list_queues_arguments(self):
@@ -371,8 +349,7 @@ class CliTests(TestBase010):
actually a string (though still a valid value), it does not
upset qpid-config
"""
- self.startQmf();
- qmf = self.qmf
+ self.startBrokerAccess();
names = ["queue_capacity%s" % (i) for i in range(1, 6)]
for name in names:
@@ -386,15 +363,14 @@ class CliTests(TestBase010):
assert name in queues, "%s not in %s" % (name, queues)
def test_qpid_route(self):
- self.startQmf();
- qmf = self.qmf
+ self.startBrokerAccess();
command = self.cli_dir() + "/qpid-route dynamic add guest/guest@localhost:%d %s:%d amq.topic" %\
(self.broker.port, self.remote_host(), self.remote_port())
ret = os.system(command)
self.assertEqual(ret, 0)
- links = qmf.getObjects(_class="link")
+ links = self.broker_access.getAllLinks()
found = False
for link in links:
if link.port == self.remote_port():
@@ -402,8 +378,7 @@ class CliTests(TestBase010):
self.assertEqual(found, True)
def test_qpid_route_api(self):
- self.startQmf();
- qmf = self.qmf
+ self.startBrokerAccess();
ret = self.qpid_route_api("dynamic add "
+ "guest/guest@localhost:"+str(self.broker.port) + " "
@@ -412,7 +387,7 @@ class CliTests(TestBase010):
self.assertEqual(ret, 0)
- links = qmf.getObjects(_class="link")
+ links = self.broker_access.getAllLinks()
found = False
for link in links:
if link.port == self.remote_port():
@@ -421,8 +396,7 @@ class CliTests(TestBase010):
def test_qpid_route_api(self):
- self.startQmf();
- qmf = self.qmf
+ self.startBrokerAccess();
ret = self.qpid_route_api("dynamic add "
+ " --client-sasl-mechanism PLAIN "
@@ -432,7 +406,7 @@ class CliTests(TestBase010):
self.assertEqual(ret, 0)
- links = qmf.getObjects(_class="link")
+ links = self.broker_access.getAllLinks()
found = False
for link in links:
if link.port == self.remote_port():
@@ -440,8 +414,7 @@ class CliTests(TestBase010):
self.assertEqual(found, True)
def test_qpid_route_api_expect_fail(self):
- self.startQmf();
- qmf = self.qmf
+ self.startBrokerAccess();
ret = self.qpid_route_api("dynamic add "
+ " --client-sasl-mechanism PLAIN "
@@ -463,11 +436,11 @@ class CliTests(TestBase010):
return None
def qpid_config_command(self, arg = ""):
- return self.cli_dir() + "/qpid-config -a localhost:%d" % self.broker.port + " " + arg
+ return self.cli_dir() + "/qpid-config -b localhost:%d" % self.broker.port + " " + arg
def qpid_config_api(self, arg = ""):
script = import_script(checkenv("QPID_CONFIG_EXEC"))
- broker = ["-a", "localhost:"+str(self.broker.port)]
+ broker = ["-b", "localhost:"+str(self.broker.port)]
return script.main(broker + arg.split())
def qpid_route_api(self, arg = ""):
diff --git a/cpp/src/tests/cluster.cmake b/cpp/src/tests/cluster.cmake
index 3471173e97..31e2d337d1 100644
--- a/cpp/src/tests/cluster.cmake
+++ b/cpp/src/tests/cluster.cmake
@@ -55,7 +55,7 @@ add_test (clustered_replication_test ${CMAKE_CURRENT_SOURCE_DIR}/clustered_repli
# CLEANFILES += cluster_test.acl cluster.ports
# EXTRA_DIST += \
-# ais_check \
+# cpg_check.sh.in \
# run_cluster_test \
# cluster_read_credit \
# test_watchdog \
diff --git a/cpp/src/tests/cluster.mk b/cpp/src/tests/cluster.mk
index 199d1e7b57..852b2dda8c 100644
--- a/cpp/src/tests/cluster.mk
+++ b/cpp/src/tests/cluster.mk
@@ -25,12 +25,11 @@
CLUSTER_TEST_SCRIPTS_LIST= \
allhosts rsynchosts \
qpid-build-rinstall qpid-src-rinstall \
- qpid-test-cluster \
- qpid-cluster-benchmark
+ qpid-test-cluster
EXTRA_DIST += \
$(CLUSTER_TEST_SCRIPTS_LIST) \
- ais_check \
+ cpg_check.sh.in \
run_cluster_test \
cluster_read_credit \
test_watchdog \
@@ -55,14 +54,12 @@ if HAVE_LIBCPG
#
# Cluster tests makefile fragment, to be included in Makefile.am
-#
+#
# NOTE: Programs using the openais library must be run with gid=ais
# You should do "newgrp ais" before running the tests to run these.
-#
-
+#
-# ais_check checks pre-requisites for cluster tests and runs them if ok.
TESTS += \
run_cluster_test \
cluster_read_credit \
diff --git a/cpp/src/tests/cluster_failover b/cpp/src/tests/cluster_failover
new file mode 100755
index 0000000000..43170c731a
--- /dev/null
+++ b/cpp/src/tests/cluster_failover
@@ -0,0 +1,19 @@
+#!/bin/sh
+# A simple manual failover test, sends a stream of numbered messages.
+# You can kill the connected broker and verify that the clients reconnect
+# and no messages are lost.
+
+URL=$1
+test -n "$URL" || { echo Usage: $0 URL ; exit 1; }
+SEND=$(mktemp /tmp/send.XXXXXXXXXX)
+RECV=$(mktemp /tmp/recv.XXXXXXXXXX)
+echo $SEND $RECV
+
+seq 1000000 > $SEND
+
+qpid-send -a 'cluster_failover;{create:always}' -b $URL --connection-options "{reconnect:true}" --send-rate 10 --content-stdin < $SEND &
+
+while msg=$(qpid-receive -m1 -f -a 'cluster_failover;{create:always}' -b $URL --connection-options "{reconnect:true,heartbeat:1}"); do
+ echo -n $msg; date
+done
+wait
diff --git a/cpp/src/tests/cluster_python_tests b/cpp/src/tests/cluster_python_tests
index 8e17ffc8bc..25c7889246 100755
--- a/cpp/src/tests/cluster_python_tests
+++ b/cpp/src/tests/cluster_python_tests
@@ -20,7 +20,8 @@
#
# Skip if cluster services not running.
-. `dirname $0`/ais_check
+. cpg_check.sh
+cpg_enabled || exit 0
FAILING=`dirname $0`/cluster_python_tests_failing.txt
source `dirname $0`/python_tests
diff --git a/cpp/src/tests/cluster_read_credit b/cpp/src/tests/cluster_read_credit
index fb3b72fbaf..552ffee53b 100755
--- a/cpp/src/tests/cluster_read_credit
+++ b/cpp/src/tests/cluster_read_credit
@@ -21,7 +21,9 @@
# Regression test for http://issues.apache.org/jira/browse/QPID-2086
srcdir=`dirname $0`
-. $srcdir/ais_check
+source cpg_check.sh
+cpg_enabled || exit 0
+
$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/cluster_test_logs.py b/cpp/src/tests/cluster_test_logs.py
index 3c7e8e8020..003d82c619 100755
--- a/cpp/src/tests/cluster_test_logs.py
+++ b/cpp/src/tests/cluster_test_logs.py
@@ -60,11 +60,13 @@ def filter_log(log):
'task late',
'task overran',
'warning CLOSING .* unsent data',
- 'Inter-broker link ',
+ 'Inter-broker link ', # ignore link state changes
+ 'Updated link key from ', # ignore link state changes
'Running in a cluster, marking store',
'debug Sending keepalive signal to watchdog', # Watchdog timer thread
'last broker standing joined by 1 replicas, updating queue policies.',
- 'Connection .* timed out: closing' # heartbeat connection close
+ 'Connection .* timed out: closing', # heartbeat connection close
+ "org.apache.qpid.broker:bridge:" # ignore bridge index
])
# Regex to match a UUID
uuid='\w\w\w\w\w\w\w\w-\w\w\w\w-\w\w\w\w-\w\w\w\w-\w\w\w\w\w\w\w\w\w\w\w\w'
diff --git a/cpp/src/tests/cluster_tests.py b/cpp/src/tests/cluster_tests.py
index cbc3df4a6b..8952f5de7b 100755
--- a/cpp/src/tests/cluster_tests.py
+++ b/cpp/src/tests/cluster_tests.py
@@ -277,7 +277,7 @@ acl deny all all
QMF-based tools - regression test for BZ615300."""
broker1 = self.cluster(1)[0]
broker2 = self.cluster(1)[0]
- qs = subprocess.Popen(["qpid-stat", "-e", broker1.host_port()], stdout=subprocess.PIPE)
+ qs = subprocess.Popen(["qpid-stat", "-e", "-b", broker1.host_port()], stdout=subprocess.PIPE)
out = qs.communicate()[0]
assert out.find("amq.failover") > 0
@@ -767,6 +767,124 @@ acl deny all all
cluster.start()
fetch(cluster[2])
+
+ def test_federation_failover(self):
+ """
+ Verify that federation operates across failures occuring in a cluster.
+ Specifically:
+ 1) Destination cluster learns of membership changes in the source
+ cluster
+ 2) Destination cluster replicates the current state of the source
+ cluster to newly-added members
+ """
+
+ TIMEOUT = 30
+ def verify(src_broker, src, dst_broker, dst, timeout=TIMEOUT):
+ """ Prove that traffic can pass from source fed broker to
+ destination fed broker
+ """
+ tot_time = 0
+ active = False
+ send_session = src_broker.connect().session()
+ sender = send_session.sender(src)
+ receive_session = dst_broker.connect().session()
+ receiver = receive_session.receiver(dst)
+ while not active and tot_time < timeout:
+ sender.send(Message("Hello from Source!"))
+ try:
+ receiver.fetch(timeout = 1)
+ receive_session.acknowledge()
+ # Get this far without Empty exception, and the link is good!
+ active = True
+ while True:
+ # Keep receiving msgs, as several may have accumulated
+ receiver.fetch(timeout = 1)
+ receive_session.acknowledge()
+ except Empty:
+ if not active:
+ tot_time += 1
+ receiver.close()
+ receive_session.close()
+ sender.close()
+ send_session.close()
+ self.assertTrue(active, "Bridge failed to become active")
+
+
+ # 2 node cluster source, 2 node cluster destination
+ src_cluster = self.cluster(2, expect=EXPECT_EXIT_FAIL)
+ src_cluster.ready();
+ dst_cluster = self.cluster(2, expect=EXPECT_EXIT_FAIL)
+ dst_cluster.ready();
+
+ cmd = self.popen(["qpid-config",
+ "--broker", src_cluster[0].host_port(),
+ "add", "queue", "srcQ"], EXPECT_EXIT_OK)
+ cmd.wait()
+
+ cmd = self.popen(["qpid-config",
+ "--broker", dst_cluster[0].host_port(),
+ "add", "exchange", "fanout", "destX"], EXPECT_EXIT_OK)
+ cmd.wait()
+
+ cmd = self.popen(["qpid-config",
+ "--broker", dst_cluster[0].host_port(),
+ "add", "queue", "destQ"], EXPECT_EXIT_OK)
+ cmd.wait()
+
+ cmd = self.popen(["qpid-config",
+ "--broker", dst_cluster[0].host_port(),
+ "bind", "destX", "destQ"], EXPECT_EXIT_OK)
+ cmd.wait()
+
+ # federate the srcQ to the destination exchange
+ dst_cluster[0].startQmf()
+ dst_broker = dst_cluster[0].qmf_session.getObjects(_class="broker")[0]
+ result = dst_broker.connect(src_cluster[0].host(), src_cluster[0].port(), False, "PLAIN",
+ "guest", "guest", "tcp")
+ self.assertEqual(result.status, 0, result);
+
+ link = dst_cluster[0].qmf_session.getObjects(_class="link")[0]
+ result = link.bridge(False, "srcQ", "destX", "", "", "", True, False, False, 10)
+ self.assertEqual(result.status, 0, result)
+
+ # check that traffic passes
+ verify(src_cluster[0], "srcQ", dst_cluster[0], "destQ")
+
+ # add src[2] broker to source cluster
+ src_cluster.start(expect=EXPECT_EXIT_FAIL);
+ src_cluster.ready();
+ verify(src_cluster[2], "srcQ", dst_cluster[0], "destQ")
+
+ # Kill src[0]. dst[0] should fail over to src[1]
+ src_cluster[0].kill()
+ for b in src_cluster[1:]: b.ready()
+ verify(src_cluster[1], "srcQ", dst_cluster[0], "destQ")
+
+ # Kill src[1], dst[0] should fail over to src[2]
+ src_cluster[1].kill()
+ for b in src_cluster[2:]: b.ready()
+ verify(src_cluster[2], "srcQ", dst_cluster[0], "destQ")
+
+ # Kill dest[0], force failover to dest[1]
+ dst_cluster[0].kill()
+ for b in dst_cluster[1:]: b.ready()
+ verify(src_cluster[2], "srcQ", dst_cluster[1], "destQ")
+
+ # Add dest[2]
+ # dest[1] syncs dest[2] to current remote state
+ dst_cluster.start(expect=EXPECT_EXIT_FAIL);
+ for b in dst_cluster[1:]: b.ready()
+ verify(src_cluster[2], "srcQ", dst_cluster[1], "destQ")
+
+ # Kill dest[1], force failover to dest[2]
+ dst_cluster[1].kill()
+ for b in dst_cluster[2:]: b.ready()
+ verify(src_cluster[2], "srcQ", dst_cluster[2], "destQ")
+
+ for i in range(2, len(src_cluster)): src_cluster[i].kill()
+ for i in range(2, len(dst_cluster)): dst_cluster[i].kill()
+
+
# Some utility code for transaction tests
XA_RBROLLBACK = 1
XA_RBTIMEOUT = 2
@@ -1160,7 +1278,7 @@ class LongTests(BrokerTest):
def start_mclients(broker):
"""Start management clients that make multiple connections."""
- cmd = ["qpid-stat", "-b", "localhost:%s" %(broker.port())]
+ cmd = ["qpid-cluster", "-C", "localhost:%s" %(broker.port())]
mclients.append(ClientLoop(broker, cmd))
endtime = time.time() + self.duration()
diff --git a/cpp/src/tests/clustered_replication_test b/cpp/src/tests/clustered_replication_test
index 4a57502f39..5a9f143eb4 100755
--- a/cpp/src/tests/clustered_replication_test
+++ b/cpp/src/tests/clustered_replication_test
@@ -8,9 +8,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
@@ -34,11 +34,11 @@ stop_brokers() {
if [[ $PRIMARY1 ]] ; then
$QPIDD_EXEC --no-module-dir -q --port $PRIMARY1
unset PRIMARY1
- fi
+ fi
if [[ $PRIMARY2 ]] ; then
$QPIDD_EXEC --no-module-dir -q --port $PRIMARY2
unset PRIMARY2
- fi
+ fi
if [[ $DR1 ]] ; then
$QPIDD_EXEC --no-module-dir -q --port $DR1
unset DR1
@@ -50,7 +50,8 @@ stop_brokers() {
}
if test -d $PYTHON_DIR; then
- . $srcdir/ais_check
+ . cpg_check.sh
+ cpg_enabled || exit 0
#todo: these cluster names need to be unique to prevent clashes
PRIMARY_CLUSTER=PRIMARY_$(hostname)_$$
@@ -65,8 +66,8 @@ if test -d $PYTHON_DIR; then
#start first node of primary cluster and set up test queue
echo Starting primary cluster
PRIMARY1=$(with_ais_group $QPIDD_EXEC $GENERAL_OPTS $PRIMARY_OPTS --log-to-file repl.primary.1.tmp) || fail "Could not start PRIMARY1"
- $PYTHON_COMMANDS/qpid-config -a "localhost:$PRIMARY1" add queue test-queue --generate-queue-events 2
- $PYTHON_COMMANDS/qpid-config -a "localhost:$PRIMARY1" add queue control-queue --generate-queue-events 1
+ $PYTHON_COMMANDS/qpid-config -b "localhost:$PRIMARY1" add queue test-queue --generate-queue-events 2
+ $PYTHON_COMMANDS/qpid-config -b "localhost:$PRIMARY1" add queue control-queue --generate-queue-events 1
#send 10 messages, consume 5 of them
for i in `seq 1 10`; do echo Message$i; done | ./sender --port $PRIMARY1
@@ -81,28 +82,28 @@ if test -d $PYTHON_DIR; then
DR1=$(with_ais_group $QPIDD_EXEC $GENERAL_OPTS $DR_OPTS --log-to-file repl.dr.1.tmp) || fail "Could not start DR1"
DR2=$(with_ais_group $QPIDD_EXEC $GENERAL_OPTS $DR_OPTS --log-to-file repl.dr.2.tmp) || fail "Could not start DR2"
- $PYTHON_COMMANDS/qpid-config -a "localhost:$DR1" add queue test-queue
- $PYTHON_COMMANDS/qpid-config -a "localhost:$DR1" add queue control-queue
- $PYTHON_COMMANDS/qpid-config -a "localhost:$DR1" add exchange replication REPLICATION_EXCHANGE
+ $PYTHON_COMMANDS/qpid-config -b "localhost:$DR1" add queue test-queue
+ $PYTHON_COMMANDS/qpid-config -b "localhost:$DR1" add queue control-queue
+ $PYTHON_COMMANDS/qpid-config -b "localhost:$DR1" add exchange replication REPLICATION_EXCHANGE
$PYTHON_COMMANDS/qpid-route queue add localhost:$DR2 localhost:$PRIMARY2 REPLICATION_EXCHANGE REPLICATION_QUEUE || fail "Could not add route."
#send more messages to primary
for i in `seq 11 20`; do echo Message$i; done | ./sender --port $PRIMARY1 --send-eos 1
- #wait for replication events to all be processed:
+ #wait for replication events to all be processed:
echo Waiting for replication to complete
echo Done | ./sender --port $PRIMARY1 --routing-key control-queue --send-eos 1
./receiver --queue control-queue --port $DR1 > /dev/null
#verify contents of test queue on dr cluster:
- echo Verifying...
+ echo Verifying...
./receiver --port $DR2 > repl.out.tmp
for i in `seq 6 20`; do echo Message$i; done | diff repl.out.tmp - || FAIL=1
if [[ $FAIL ]]; then
echo Clustered replication test failed: expectations not met!
exit 1
- else
+ else
echo Clustered replication test passed
rm -f repl*.tmp
fi
diff --git a/cpp/src/tests/ais_check b/cpp/src/tests/cpg_check.sh.in
index a865260543..ed97776218 100755
--- a/cpp/src/tests/ais_check
+++ b/cpp/src/tests/cpg_check.sh.in
@@ -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
@@ -18,12 +18,16 @@
# under the License.
#
-srcdir=`dirname $0`
+QPID_USE_CPG=${QPID_USE_CPG:-@USE_CPG@}
-# Check AIS requirements and run tests if found.
-ps -u root | grep 'aisexec\|corosync' >/dev/null || {
- echo WARNING: Skipping cluster tests, the aisexec or corosync daemon is not running.
- exit 0; # A warning, not a failure.
+# Check if CPG is enabled
+cpg_enabled() {
+ test x$QPID_USE_CPG = xyes || return 1 # disabled
+ ps -u root | grep 'aisexec\|corosync' >/dev/null || {
+ echo WARNING: Skip cluster tests, aisexec or corosync daemon is not running.
+ return 1; # A warning, not a failure.
+ }
+ return 0
}
# Execute command with the ais group set if user is a member.
diff --git a/cpp/src/tests/federated_cluster_test b/cpp/src/tests/federated_cluster_test
index b32455259e..f42b7501b8 100755
--- a/cpp/src/tests/federated_cluster_test
+++ b/cpp/src/tests/federated_cluster_test
@@ -8,9 +8,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
@@ -35,7 +35,7 @@ stop_brokers() {
if [[ $BROKER_A ]] ; then
../qpidd --no-module-dir -q --port $BROKER_A
unset BROKER_A
- fi
+ fi
if [[ $NODE_1 ]] ; then
../qpidd --no-module-dir -q --port $NODE_1
unset NODE_1
@@ -63,20 +63,20 @@ start_brokers() {
setup() {
#create exchange on both cluster and single broker
- $PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_A" add exchange direct test-exchange
- $PYTHON_COMMANDS/qpid-config -a "localhost:$NODE_1" add exchange direct test-exchange
+ $PYTHON_COMMANDS/qpid-config -b "localhost:$BROKER_A" add exchange direct test-exchange
+ $PYTHON_COMMANDS/qpid-config -b "localhost:$NODE_1" add exchange direct test-exchange
#create dynamic routes for test exchange
$PYTHON_COMMANDS/qpid-route dynamic add "localhost:$NODE_2" "localhost:$BROKER_A" test-exchange
$PYTHON_COMMANDS/qpid-route dynamic add "localhost:$BROKER_A" "localhost:$NODE_2" test-exchange
#create test queue on cluster and bind it to the test exchange
- $PYTHON_COMMANDS/qpid-config -a "localhost:$NODE_1" add queue test-queue
- $PYTHON_COMMANDS/qpid-config -a "localhost:$NODE_1" bind test-exchange test-queue to-cluster
+ $PYTHON_COMMANDS/qpid-config -b "localhost:$NODE_1" add queue test-queue
+ $PYTHON_COMMANDS/qpid-config -b "localhost:$NODE_1" bind test-exchange test-queue to-cluster
#create test queue on single broker and bind it to the test exchange
- $PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_A" add queue test-queue
- $PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_A" bind test-exchange test-queue from-cluster
+ $PYTHON_COMMANDS/qpid-config -b "localhost:$BROKER_A" add queue test-queue
+ $PYTHON_COMMANDS/qpid-config -b "localhost:$BROKER_A" bind test-exchange test-queue from-cluster
}
run_test_pull_to_cluster_two_consumers() {
@@ -92,7 +92,7 @@ run_test_pull_to_cluster_two_consumers() {
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
}
@@ -106,7 +106,7 @@ run_test_pull_to_cluster() {
#verify all messages are received
diff fed.in.tmp fed.out.tmp || fail "federated link to cluster failed: expectations not met!"
-
+
rm -f fed*.tmp #cleanup
}
@@ -121,22 +121,23 @@ run_test_pull_from_cluster() {
#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
- . $srcdir/ais_check
+ . cpg_check.sh
+ cpg_enabled || exit 0
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_two_consumers
+ run_test_pull_to_cluster_two_consumers
echo "federated link to cluster verified"
- run_test_pull_from_cluster
+ run_test_pull_from_cluster
echo "federated link from cluster verified"
if [[ $TEST_NODE_FAILURE ]] ; then
#kill first cluster node and retest
@@ -146,7 +147,7 @@ if test -d ${PYTHON_DIR}; then
echo "retesting..."
run_test_pull_to_cluster
echo "federated link to cluster verified"
- run_test_pull_from_cluster
- echo "federated link from cluster verified"
+ run_test_pull_from_cluster
+ echo "federated link from cluster verified"
fi
fi
diff --git a/cpp/src/tests/ha_tests.py b/cpp/src/tests/ha_tests.py
index 97de0d1f77..827cb7dca9 100755
--- a/cpp/src/tests/ha_tests.py
+++ b/cpp/src/tests/ha_tests.py
@@ -18,71 +18,125 @@
# under the License.
#
-import os, signal, sys, time, imp, re, subprocess, glob, random, logging, shutil
-from qpid.messaging import Message, NotFound, ConnectionError, Connection
+import os, signal, sys, time, imp, re, subprocess, glob, random, logging, shutil, math
+from qpid.messaging import Message, NotFound, ConnectionError, ReceiverError, Connection
+from qpid.datatypes import uuid4
from brokertest import *
from threading import Thread, Lock, Condition
from logging import getLogger, WARN, ERROR, DEBUG
+from qpidtoollibs import BrokerAgent
-
-log = getLogger("qpid.ha-tests")
+log = getLogger(__name__)
class HaBroker(Broker):
- def __init__(self, test, args=[], broker_url=None, **kwargs):
+ def __init__(self, test, args=[], broker_url=None, ha_cluster=True,
+ ha_replicate="all", **kwargs):
assert BrokerTest.ha_lib, "Cannot locate HA plug-in"
- args=["--load-module", BrokerTest.ha_lib,
- # FIXME aconway 2012-02-13: workaround slow link failover.
- "--link-maintenace-interval=0.1",
- "--ha-enable=yes"]
- if broker_url: args += [ "--ha-broker-url", broker_url ]
+ args = copy(args)
+ args += ["--load-module", BrokerTest.ha_lib,
+ "--log-enable=info+", "--log-enable=debug+:ha::",
+ # FIXME aconway 2012-02-13: workaround slow link failover.
+ "--link-maintenace-interval=0.1",
+ "--ha-cluster=%s"%ha_cluster]
+ if ha_replicate is not None:
+ args += [ "--ha-replicate=%s"%ha_replicate ]
+ if broker_url: args.extend([ "--ha-brokers", broker_url ])
Broker.__init__(self, test, args, **kwargs)
+ self.commands=os.getenv("PYTHON_COMMANDS")
+ assert os.path.isdir(self.commands)
+ getLogger().setLevel(ERROR) # Hide expected WARNING log messages from failover.
def promote(self):
- assert os.system("qpid-ha-tool --promote %s"%(self.host_port())) == 0
+ assert os.system("%s/qpid-ha promote -b %s"%(self.commands, self.host_port())) == 0
def set_client_url(self, url):
assert os.system(
- "qpid-ha-tool --client-addresses=%s %s"%(url,self.host_port())) == 0
+ "%s/qpid-ha set --public-brokers=%s -b %s"%(self.commands, url,self.host_port())) == 0
def set_broker_url(self, url):
assert os.system(
- "qpid-ha-tool --broker-addresses=%s %s"%(url, self.host_port())) == 0
-
-
-class ShortTests(BrokerTest):
- """Short HA functionality tests."""
-
- # Wait for an address to become valid.
- def wait(self, session, address):
- def check():
- try:
- session.sender(address)
- return True
- except NotFound: return False
- assert retry(check), "Timed out waiting for %s"%(address)
-
- # Wait for address to become valid on a backup broker.
- def wait_backup(self, backup, address):
- bs = self.connect_admin(backup).session()
- self.wait(bs, address)
- bs.connection.close()
-
- # Combines wait_backup and assert_browse_retry
- def assert_browse_backup(self, backup, queue, expected, **kwargs):
- bs = self.connect_admin(backup).session()
- self.wait(bs, queue)
- self.assert_browse_retry(bs, queue, expected, **kwargs)
- bs.connection.close()
-
- def assert_missing(self, session, address):
+ "%s/qpid-ha set --brokers=%s -b %s"%(self.commands, url, self.host_port())) == 0
+
+ def replicate(self, from_broker, queue):
+ assert os.system(
+ "%s/qpid-ha replicate -b %s %s %s"%(self.commands, self.host_port(), from_broker, queue)) == 0
+
+ def config_replicate(self, from_broker, queue):
+ assert os.system(
+ "%s/qpid-config --broker=%s add queue --start-replica %s %s"%(self.commands, self.host_port(), from_broker, queue)) == 0
+
+ def config_declare(self, queue, replication):
+ assert os.system(
+ "%s/qpid-config --broker=%s add queue %s --replicate %s"%(self.commands, self.host_port(), queue, replication)) == 0
+
+ def connect_admin(self, **kwargs):
+ return Broker.connect(self, client_properties={"qpid.ha-admin":1}, **kwargs)
+
+ def wait_backup(self, address):
+ """Wait for address to become valid on a backup broker."""
+ bs = self.connect_admin().session()
+ try: wait_address(bs, address)
+ finally: bs.connection.close()
+
+ def assert_browse_backup(self, queue, expected, **kwargs):
+ """Combines wait_backup and assert_browse_retry."""
+ bs = self.connect_admin().session()
try:
- session.receiver(address)
- self.fail("Should not have been replicated: %s"%(address))
- except NotFound: pass
+ wait_address(bs, queue)
+ assert_browse_retry(bs, queue, expected, **kwargs)
+ finally: bs.connection.close()
+
+class HaCluster(object):
+ _cluster_count = 0
+
+ def __init__(self, test, n, **kwargs):
+ """Start a cluster of n brokers"""
+ self.test = test
+ self._brokers = [ HaBroker(test, name="broker%s-%s"%(HaCluster._cluster_count, i), **kwargs) for i in xrange(n)]
+ HaCluster._cluster_count += 1
+ self.url = ",".join([b.host_port() for b in self])
+ for b in self: b.set_broker_url(self.url)
+ self[0].promote()
+
+ def connect(self, i):
+ """Connect with reconnect_urls"""
+ return self[i].connect(reconnect=True, reconnect_urls=self.url.split(","))
+
+ def kill(self, i):
+ """Kill broker i, promote broker i+1"""
+ self[i].kill()
+ self[i].expect = EXPECT_EXIT_FAIL
+ self[(i+1) % len(self)].promote()
+
+ def bounce(self, i):
+ """Stop and restart a broker in a cluster."""
+ self.kill(i)
+ b = self[i]
+ self._brokers[i] = HaBroker(self.test, name=b.name, port=b.port(), broker_url=self.url)
+
+ # Behave like a list of brokers.
+ def __len__(self): return len(self._brokers)
+ def __getitem__(self,index): return self._brokers[index]
+ def __iter__(self): return self._brokers.__iter__()
+
+def wait_address(session, address):
+ """Wait for an address to become valid."""
+ def check():
+ try:
+ session.sender(address)
+ return True
+ except NotFound: return False
+ assert retry(check), "Timed out waiting for address %s"%(address)
+
+def assert_missing(session, address):
+ """Assert that the address is _not_ valid"""
+ try:
+ session.receiver(address)
+ self.fail("Expected NotFound: %s"%(address))
+ except NotFound: pass
- def connect_admin(self, backup, **kwargs):
- """Connect to a backup broker as an admin connection"""
- return backup.connect(client_properties={"qpid.ha-admin":1}, **kwargs)
+class ReplicationTests(BrokerTest):
+ """Correctness tests for HA replication."""
def test_replication(self):
"""Test basic replication of configuration and messages before and
@@ -95,21 +149,21 @@ class ShortTests(BrokerTest):
return"%s;{create:always,node:{type:topic,x-declare:{arguments:{'qpid.replicate':%s}, type:'fanout'},x-bindings:[{exchange:'%s',queue:'%s'}]}}"%(name, replicate, name, bindq)
def setup(p, prefix, primary):
"""Create config, send messages on the primary p"""
- s = p.sender(queue(prefix+"q1", "messages"))
+ s = p.sender(queue(prefix+"q1", "all"))
for m in ["a", "b", "1"]: s.send(Message(m))
# Test replication of dequeue
self.assertEqual(p.receiver(prefix+"q1").fetch(timeout=0).content, "a")
p.acknowledge()
p.sender(queue(prefix+"q2", "configuration")).send(Message("2"))
p.sender(queue(prefix+"q3", "none")).send(Message("3"))
- p.sender(exchange(prefix+"e1", "messages", prefix+"q1")).send(Message("4"))
- p.sender(exchange(prefix+"e2", "messages", prefix+"q2")).send(Message("5"))
+ p.sender(exchange(prefix+"e1", "all", prefix+"q1")).send(Message("4"))
+ p.sender(exchange(prefix+"e2", "all", prefix+"q2")).send(Message("5"))
# Test unbind
- p.sender(queue(prefix+"q4", "messages")).send(Message("6"))
- s3 = p.sender(exchange(prefix+"e4", "messages", prefix+"q4"))
+ p.sender(queue(prefix+"q4", "all")).send(Message("6"))
+ s3 = p.sender(exchange(prefix+"e4", "all", prefix+"q4"))
s3.send(Message("7"))
# Use old connection to unbind
- us = primary.connect_old().session(str(qpid.datatypes.uuid4()))
+ us = primary.connect_old().session(str(uuid4()))
us.exchange_unbind(exchange=prefix+"e4", binding_key="", queue=prefix+"q4")
p.sender(prefix+"e4").send(Message("drop1")) # Should be dropped
# Need a marker so we can wait till sync is done.
@@ -117,9 +171,8 @@ class ShortTests(BrokerTest):
def verify(b, prefix, p):
"""Verify setup was replicated to backup b"""
-
# Wait for configuration to replicate.
- self.wait(b, prefix+"x");
+ wait_address(b, prefix+"x");
self.assert_browse_retry(b, prefix+"q1", ["b", "1", "4"])
self.assertEqual(p.receiver(prefix+"q1").fetch(timeout=0).content, "b")
@@ -127,7 +180,7 @@ class ShortTests(BrokerTest):
self.assert_browse_retry(b, prefix+"q1", ["1", "4"])
self.assert_browse_retry(b, prefix+"q2", []) # configuration only
- self.assert_missing(b, prefix+"q3")
+ assert_missing(b, prefix+"q3")
b.sender(prefix+"e1").send(Message(prefix+"e1")) # Verify binds with replicate=all
self.assert_browse_retry(b, prefix+"q1", ["1", "4", prefix+"e1"])
b.sender(prefix+"e2").send(Message(prefix+"e2")) # Verify binds with replicate=configuration
@@ -147,12 +200,12 @@ class ShortTests(BrokerTest):
setup(p, "2", primary)
# Verify the data on the backup
- b = self.connect_admin(backup).session()
+ b = backup.connect_admin().session()
verify(b, "1", p)
verify(b, "2", p)
# Test a series of messages, enqueue all then dequeue all.
- s = p.sender(queue("foo","messages"))
- self.wait(b, "foo")
+ s = p.sender(queue("foo","all"))
+ wait_address(b, "foo")
msgs = [str(i) for i in range(10)]
for m in msgs: s.send(Message(m))
self.assert_browse_retry(p, "foo", msgs)
@@ -173,16 +226,11 @@ class ShortTests(BrokerTest):
self.assert_browse_retry(p, "foo", msgs[i+1:])
self.assert_browse_retry(b, "foo", msgs[i+1:])
- def qpid_replicate(self, value="messages"):
- return "node:{x-declare:{arguments:{'qpid.replicate':%s}}}" % value
-
def test_sync(self):
- def queue(name, replicate):
- return "%s;{create:always,%s}"%(name, self.qpid_replicate(replicate))
primary = HaBroker(self, name="primary")
primary.promote()
p = primary.connect().session()
- s = p.sender(queue("q","messages"))
+ s = p.sender("q;{create:always}")
for m in [str(i) for i in range(0,10)]: s.send(m)
s.sync()
backup1 = HaBroker(self, name="backup1", broker_url=primary.host_port())
@@ -193,49 +241,39 @@ class ShortTests(BrokerTest):
s.sync()
msgs = [str(i) for i in range(30)]
- b1 = self.connect_admin(backup1).session()
- self.wait(b1, "q");
+ b1 = backup1.connect_admin().session()
+ wait_address(b1, "q");
self.assert_browse_retry(b1, "q", msgs)
- b2 = self.connect_admin(backup2).session()
- self.wait(b2, "q");
+ b2 = backup2.connect_admin().session()
+ wait_address(b2, "q");
self.assert_browse_retry(b2, "q", msgs)
def test_send_receive(self):
"""Verify sequence numbers of messages sent by qpid-send"""
- primary = HaBroker(self, name="primary")
- primary.promote()
- backup1 = HaBroker(self, name="backup1", broker_url=primary.host_port())
- backup2 = HaBroker(self, name="backup2", broker_url=primary.host_port())
+ brokers = HaCluster(self, 3)
sender = self.popen(
["qpid-send",
- "--broker", primary.host_port(),
- "--address", "q;{create:always,%s}"%(self.qpid_replicate("messages")),
+ "--broker", brokers[0].host_port(),
+ "--address", "q;{create:always}",
"--messages=1000",
"--content-string=x"
])
receiver = self.popen(
["qpid-receive",
- "--broker", primary.host_port(),
- "--address", "q;{create:always,%s}"%(self.qpid_replicate("messages")),
+ "--broker", brokers[0].host_port(),
+ "--address", "q;{create:always}",
"--messages=990",
"--timeout=10"
])
- try:
- self.assertEqual(sender.wait(), 0)
- self.assertEqual(receiver.wait(), 0)
- expect = [long(i) for i in range(991, 1001)]
- sn = lambda m: m.properties["sn"]
- self.assert_browse_retry(self.connect_admin(backup1).session(), "q", expect, transform=sn)
- self.assert_browse_retry(self.connect_admin(backup2).session(), "q", expect, transform=sn)
- except:
- print self.browse(primary.connect().session(), "q", transform=sn)
- print self.browse(self.connect_admin(backup1).session(), "q", transform=sn)
- print self.browse(self.connect_admin(backup2).session(), "q", transform=sn)
- raise
+ self.assertEqual(sender.wait(), 0)
+ self.assertEqual(receiver.wait(), 0)
+ expect = [long(i) for i in range(991, 1001)]
+ sn = lambda m: m.properties["sn"]
+ brokers[1].assert_browse_backup("q", expect, transform=sn)
+ brokers[2].assert_browse_backup("q", expect, transform=sn)
def test_failover_python(self):
"""Verify that backups rejects connections and that fail-over works in python client"""
- getLogger().setLevel(ERROR) # Disable WARNING log messages due to failover messages
primary = HaBroker(self, name="primary", expect=EXPECT_EXIT_FAIL)
primary.promote()
backup = HaBroker(self, name="backup", broker_url=primary.host_port())
@@ -245,13 +283,13 @@ class ShortTests(BrokerTest):
self.fail("Expected connection to backup to fail")
except ConnectionError: pass
# Check that admin connections are allowed to backup.
- self.connect_admin(backup).close()
+ backup.connect_admin().close()
# Test discovery: should connect to primary after reject by backup
c = backup.connect(reconnect_urls=[primary.host_port(), backup.host_port()], reconnect=True)
s = c.session()
- sender = s.sender("q;{create:always,%s}"%(self.qpid_replicate()))
- self.wait_backup(backup, "q")
+ sender = s.sender("q;{create:always}")
+ backup.wait_backup("q")
sender.send("foo")
primary.kill()
assert retry(lambda: not is_running(primary.pid))
@@ -265,14 +303,14 @@ class ShortTests(BrokerTest):
primary.promote()
backup = HaBroker(self, name="backup", broker_url=primary.host_port())
url="%s,%s"%(primary.host_port(), backup.host_port())
- primary.connect().session().sender("q;{create:always,%s}"%(self.qpid_replicate()))
- self.wait_backup(backup, "q")
+ primary.connect().session().sender("q;{create:always}")
+ backup.wait_backup("q")
sender = NumberedSender(primary, url=url, queue="q", failover_updates = False)
receiver = NumberedReceiver(primary, url=url, queue="q", failover_updates = False)
receiver.start()
sender.start()
- self.wait_backup(backup, "q")
+ backup.wait_backup("q")
assert retry(lambda: receiver.received > 10) # Wait for some messages to get thru
primary.kill()
@@ -284,19 +322,276 @@ class ShortTests(BrokerTest):
receiver.stop()
def test_backup_failover(self):
- brokers = [ HaBroker(self, name=name, expect=EXPECT_EXIT_FAIL)
- for name in ["a","b","c"] ]
- url = ",".join([b.host_port() for b in brokers])
- for b in brokers: b.set_broker_url(url)
- brokers[0].promote()
- brokers[0].connect().session().sender(
- "q;{create:always,%s}"%(self.qpid_replicate())).send("a")
- for b in brokers[1:]: self.assert_browse_backup(b, "q", ["a"])
- brokers[0].kill()
- brokers[2].promote() # c must fail over to b.
- brokers[2].connect().session().sender("q").send("b")
- self.assert_browse_backup(brokers[1], "q", ["a","b"])
- for b in brokers[1:]: b.kill()
+ """Verify that a backup broker fails over and recovers queue state"""
+ brokers = HaCluster(self, 3)
+ brokers[0].connect().session().sender("q;{create:always}").send("a")
+ for b in brokers[1:]: b.assert_browse_backup("q", ["a"], msg=b)
+ brokers[0].expect = EXPECT_EXIT_FAIL
+ brokers.kill(0)
+ brokers[1].connect().session().sender("q").send("b")
+ brokers[2].assert_browse_backup("q", ["a","b"])
+ s = brokers[1].connect().session()
+ self.assertEqual("a", s.receiver("q").fetch().content)
+ s.acknowledge()
+ brokers[2].assert_browse_backup("q", ["b"])
+
+ def test_qpid_config_replication(self):
+ """Set up replication via qpid-config"""
+ brokers = HaCluster(self,2)
+ brokers[0].config_declare("q","all")
+ brokers[0].connect().session().sender("q").send("foo")
+ brokers[1].assert_browse_backup("q", ["foo"])
+
+ def test_standalone_queue_replica(self):
+ """Test replication of individual queues outside of cluster mode"""
+ primary = HaBroker(self, name="primary", ha_cluster=False)
+ pc = primary.connect()
+ ps = pc.session().sender("q;{create:always}")
+ pr = pc.session().receiver("q;{create:always}")
+ backup = HaBroker(self, name="backup", ha_cluster=False)
+ br = backup.connect().session().receiver("q;{create:always}")
+
+ # Set up replication with qpid-ha
+ backup.replicate(primary.host_port(), "q")
+ ps.send("a")
+ backup.assert_browse_backup("q", ["a"])
+ ps.send("b")
+ backup.assert_browse_backup("q", ["a", "b"])
+ self.assertEqual("a", pr.fetch().content)
+ pr.session.acknowledge()
+ backup.assert_browse_backup("q", ["b"])
+
+ # Set up replication with qpid-config
+ ps2 = pc.session().sender("q2;{create:always}")
+ backup.config_replicate(primary.host_port(), "q2");
+ ps2.send("x")
+ backup.assert_browse_backup("q2", ["x"])
+
+
+ def test_queue_replica_failover(self):
+ """Test individual queue replication from a cluster to a standalone backup broker, verify it fails over."""
+ cluster = HaCluster(self, 2)
+ primary = cluster[0]
+ pc = cluster.connect(0)
+ ps = pc.session().sender("q;{create:always}")
+ pr = pc.session().receiver("q;{create:always}")
+ backup = HaBroker(self, name="backup", ha_cluster=False)
+ br = backup.connect().session().receiver("q;{create:always}")
+ backup.replicate(cluster.url, "q")
+ ps.send("a")
+ backup.assert_browse_backup("q", ["a"])
+ cluster.bounce(0)
+ backup.assert_browse_backup("q", ["a"])
+ ps.send("b")
+ backup.assert_browse_backup("q", ["a", "b"])
+ cluster.bounce(1)
+ self.assertEqual("a", pr.fetch().content)
+ pr.session.acknowledge()
+ backup.assert_browse_backup("q", ["b"])
+
+ def test_lvq(self):
+ """Verify that we replicate to an LVQ correctly"""
+ primary = HaBroker(self, name="primary")
+ primary.promote()
+ backup = HaBroker(self, name="backup", broker_url=primary.host_port())
+ s = primary.connect().session().sender("lvq; {create:always, node:{x-declare:{arguments:{'qpid.last_value_queue_key':lvq-key}}}}")
+ def send(key,value): s.send(Message(content=value,properties={"lvq-key":key}))
+ for kv in [("a","a-1"),("b","b-1"),("a","a-2"),("a","a-3"),("c","c-1"),("c","c-2")]:
+ send(*kv)
+ backup.assert_browse_backup("lvq", ["b-1", "a-3", "c-2"])
+ send("b","b-2")
+ backup.assert_browse_backup("lvq", ["a-3", "c-2", "b-2"])
+ send("c","c-3")
+ backup.assert_browse_backup("lvq", ["a-3", "b-2", "c-3"])
+ send("d","d-1")
+ backup.assert_browse_backup("lvq", ["a-3", "b-2", "c-3", "d-1"])
+
+ def test_ring(self):
+ """Test replication with the ring queue policy"""
+ primary = HaBroker(self, name="primary")
+ primary.promote()
+ backup = HaBroker(self, name="backup", broker_url=primary.host_port())
+ s = primary.connect().session().sender("q; {create:always, node:{x-declare:{arguments:{'qpid.policy_type':ring, 'qpid.max_count':5}}}}")
+ for i in range(10): s.send(Message(str(i)))
+ backup.assert_browse_backup("q", [str(i) for i in range(5,10)])
+
+ def test_reject(self):
+ """Test replication with the reject queue policy"""
+ primary = HaBroker(self, name="primary")
+ primary.promote()
+ backup = HaBroker(self, name="backup", broker_url=primary.host_port())
+ s = primary.connect().session().sender("q; {create:always, node:{x-declare:{arguments:{'qpid.policy_type':reject, 'qpid.max_count':5}}}}")
+ try:
+ for i in range(10): s.send(Message(str(i)), sync=False)
+ except qpid.messaging.exceptions.TargetCapacityExceeded: pass
+ backup.assert_browse_backup("q", [str(i) for i in range(0,5)])
+
+ def test_priority(self):
+ """Verify priority queues replicate correctly"""
+ primary = HaBroker(self, name="primary")
+ primary.promote()
+ backup = HaBroker(self, name="backup", broker_url=primary.host_port())
+ session = primary.connect().session()
+ s = session.sender("priority-queue; {create:always, node:{x-declare:{arguments:{'qpid.priorities':10}}}}")
+ priorities = [8,9,5,1,2,2,3,4,9,7,8,9,9,2]
+ for p in priorities: s.send(Message(priority=p))
+ # Can't use browse_backup as browser sees messages in delivery order not priority.
+ backup.wait_backup("priority-queue")
+ r = backup.connect_admin().session().receiver("priority-queue")
+ received = [r.fetch().priority for i in priorities]
+ self.assertEqual(sorted(priorities, reverse=True), received)
+
+ def test_priority_fairshare(self):
+ """Verify priority queues replicate correctly"""
+ primary = HaBroker(self, name="primary")
+ primary.promote()
+ backup = HaBroker(self, name="backup", broker_url=primary.host_port())
+ session = primary.connect().session()
+ levels = 8
+ priorities = [4,5,3,7,8,8,2,8,2,8,8,16,6,6,6,6,6,6,8,3,5,8,3,5,5,3,3,8,8,3,7,3,7,7,7,8,8,8,2,3]
+ limits={7:0,6:4,5:3,4:2,3:2,2:2,1:2}
+ limit_policy = ",".join(["'qpid.fairshare':5"] + ["'qpid.fairshare-%s':%s"%(i[0],i[1]) for i in limits.iteritems()])
+ s = session.sender("priority-queue; {create:always, node:{x-declare:{arguments:{'qpid.priorities':%s, %s}}}}"%(levels,limit_policy))
+ messages = [Message(content=str(uuid4()), priority = p) for p in priorities]
+ for m in messages: s.send(m)
+ backup.wait_backup(s.target)
+ r = backup.connect_admin().session().receiver("priority-queue")
+ received = [r.fetch().content for i in priorities]
+ sort = sorted(messages, key=lambda m: priority_level(m.priority, levels), reverse=True)
+ fair = [m.content for m in fairshare(sort, lambda l: limits.get(l,0), levels)]
+ self.assertEqual(received, fair)
+
+ def test_priority_ring(self):
+ primary = HaBroker(self, name="primary")
+ primary.promote()
+ backup = HaBroker(self, name="backup", broker_url=primary.host_port())
+ s = primary.connect().session().sender("q; {create:always, node:{x-declare:{arguments:{'qpid.policy_type':ring, 'qpid.max_count':5, 'qpid.priorities':10}}}}")
+ priorities = [8,9,5,1,2,2,3,4,9,7,8,9,9,2]
+ for p in priorities: s.send(Message(priority=p))
+
+ # FIXME aconway 2012-02-22: there is a bug in priority ring
+ # queues that allows a low priority message to displace a high
+ # one. The following commented-out assert_browse is for the
+ # correct result, the uncommented one is for the actualy buggy
+ # result. See https://issues.apache.org/jira/browse/QPID-3866
+ #
+ # backup.assert_browse_backup("q", sorted(priorities,reverse=True)[0:5], transform=lambda m: m.priority)
+ backup.assert_browse_backup("q", [9,9,9,9,2], transform=lambda m: m.priority)
+
+ def test_backup_acquired(self):
+ """Verify that acquired messages are backed up, for all queue types."""
+ class Test:
+ def __init__(self, queue, arguments, expect):
+ self.queue = queue
+ self.address = "%s;{create:always,node:{x-declare:{arguments:{%s}}}}"%(
+ self.queue, ",".join(arguments + ["'qpid.replicate':all"]))
+ self.expect = [str(i) for i in expect]
+
+ def send(self, connection):
+ """Send messages, then acquire one but don't acknowledge"""
+ s = connection.session()
+ for m in range(10): s.sender(self.address).send(str(m))
+ s.receiver(self.address).fetch()
+
+ def wait(self, brokertest, backup):
+ backup.wait_backup(self.queue)
+
+ def verify(self, brokertest, backup):
+ backup.assert_browse_backup(self.queue, self.expect, msg=self.queue)
+
+ tests = [
+ Test("plain",[],range(10)),
+ Test("ring", ["'qpid.policy_type':ring", "'qpid.max_count':5"], range(5,10)),
+ Test("priority",["'qpid.priorities':10"], range(10)),
+ Test("fairshare", ["'qpid.priorities':10,'qpid.fairshare':5"], range(10)),
+ Test("lvq", ["'qpid.last_value_queue_key':lvq-key"], [9])
+ ]
+
+ primary = HaBroker(self, name="primary")
+ primary.promote()
+ backup1 = HaBroker(self, name="backup1", broker_url=primary.host_port())
+ c = primary.connect()
+ for t in tests: t.send(c) # Send messages, leave one unacknowledged.
+
+ backup2 = HaBroker(self, name="backup2", broker_url=primary.host_port())
+ # Wait for backups to catch up.
+ for t in tests:
+ t.wait(self, backup1)
+ t.wait(self, backup2)
+ # Verify acquired message was replicated
+ for t in tests: t.verify(self, backup1)
+ for t in tests: t.verify(self, backup2)
+
+ def test_replicate_default(self):
+ """Make sure we don't replicate if ha-replicate is unspecified or none"""
+ cluster1 = HaCluster(self, 2, ha_replicate=None)
+ c1 = cluster1[0].connect().session().sender("q;{create:always}")
+ cluster2 = HaCluster(self, 2, ha_replicate="none")
+ cluster2[0].connect().session().sender("q;{create:always}")
+ time.sleep(.1) # Give replication a chance.
+ try:
+ cluster1[1].connect_admin().session().receiver("q")
+ self.fail("Excpected no-such-queue exception")
+ except NotFound: pass
+ try:
+ cluster2[1].connect_admin().session().receiver("q")
+ self.fail("Excpected no-such-queue exception")
+ except NotFound: pass
+
+ def test_invalid_default(self):
+ """Verify that a queue with an invalid qpid.replicate gets default treatment"""
+ cluster = HaCluster(self, 2, ha_replicate="all")
+ c = cluster[0].connect().session().sender("q;{create:always, node:{x-declare:{arguments:{'qpid.replicate':XXinvalidXX}}}}")
+ cluster[1].wait_backup("q")
+
+ def test_exclusive_queue(self):
+ """Ensure that we can back-up exclusive queues, i.e. the replicating
+ subscriptions are exempt from the exclusivity"""
+ cluster = HaCluster(self, 2)
+ def test(addr):
+ c = cluster[0].connect()
+ q = addr.split(";")[0]
+ r = c.session().receiver(addr)
+ try: c.session().receiver(addr); self.fail("Expected exclusive exception")
+ except ReceiverError: pass
+ s = c.session().sender(q).send(q)
+ cluster[1].assert_browse_backup(q, [q])
+ test("excl_sub;{create:always, link:{x-subscribe:{exclusive:True}}}");
+ test("excl_queue;{create:always, node:{x-declare:{exclusive:True}}}")
+
+def fairshare(msgs, limit, levels):
+ """
+ Generator to return prioritised messages in expected order for a given fairshare limit
+ """
+ count = 0
+ last_priority = None
+ postponed = []
+ while msgs or postponed:
+ if not msgs:
+ msgs = postponed
+ count = 0
+ last_priority = None
+ postponed = []
+ msg = msgs.pop(0)
+ if last_priority and priority_level(msg.priority, levels) == last_priority:
+ count += 1
+ else:
+ last_priority = priority_level(msg.priority, levels)
+ count = 1
+ l = limit(last_priority)
+ if (l and count > l):
+ postponed.append(msg)
+ else:
+ yield msg
+ return
+
+def priority_level(value, levels):
+ """
+ Method to determine which of a distinct number of priority levels
+ a given value falls into.
+ """
+ offset = 5-math.ceil(levels/2.0)
+ return min(max(value - offset, 0), levels-1)
class LongTests(BrokerTest):
"""Tests that can run for a long time if -DDURATION=<minutes> is set"""
@@ -311,7 +606,7 @@ class LongTests(BrokerTest):
"""Test failover with continuous send-receive"""
# FIXME aconway 2012-02-03: fails due to dropped messages,
# known issue: sending messages to new primary before
- # backups are ready.
+ # backups are ready. Enable when fixed.
# Start a cluster, all members will be killed during the test.
brokers = [ HaBroker(self, name=name, expect=EXPECT_EXIT_FAIL)
@@ -352,4 +647,10 @@ class LongTests(BrokerTest):
if __name__ == "__main__":
shutil.rmtree("brokertest.tmp", True)
- os.execvp("qpid-python-test", ["qpid-python-test", "-m", "ha_tests"] + sys.argv[1:])
+ qpid_ha = os.getenv("QPID_HA_EXEC")
+ if qpid_ha and os.path.exists(qpid_ha):
+ os.execvp("qpid-python-test",
+ ["qpid-python-test", "-m", "ha_tests"] + sys.argv[1:])
+ else:
+ print "Skipping ha_tests, qpid_ha not available"
+
diff --git a/cpp/src/tests/install_env.sh.in b/cpp/src/tests/install_env.sh.in
index 2231954cb8..d29a23930d 100644
--- a/cpp/src/tests/install_env.sh.in
+++ b/cpp/src/tests/install_env.sh.in
@@ -23,4 +23,4 @@ prefix=`absdir @prefix@`
export QPID_INSTALL_PREFIX=$prefix
export PATH=$prefix/bin:$prefix/sbin:$prefix/libexec/qpid/tests:$PATH
export LD_LIBRARY_PATH=$prefix/lib:$LD_LIBRARY_PATH
-export PYTHONPATH=$prefix/lib/python2.4/site-packages:$PYTHONPATH
+export PYTHONPATH=$prefix/lib/python2.6/site-packages:$PYTHONPATH
diff --git a/cpp/src/tests/ipv6_test b/cpp/src/tests/ipv6_test
index d75d50fd0a..6becfd8c96 100755
--- a/cpp/src/tests/ipv6_test
+++ b/cpp/src/tests/ipv6_test
@@ -93,10 +93,10 @@ else
BROKER1="[::1]:${PORTS[1]}"
TEST_QUEUE=ipv6-fed-test
- $QPID_CONFIG_EXEC -a $BROKER0 add queue $TEST_QUEUE
- $QPID_CONFIG_EXEC -a $BROKER1 add queue $TEST_QUEUE
+ $QPID_CONFIG_EXEC -b $BROKER0 add queue $TEST_QUEUE
+ $QPID_CONFIG_EXEC -b $BROKER1 add queue $TEST_QUEUE
$QPID_ROUTE_EXEC dynamic add $BROKER1 $BROKER0 amq.direct
- $QPID_CONFIG_EXEC -a $BROKER1 bind amq.direct $TEST_QUEUE $TEST_QUEUE
+ $QPID_CONFIG_EXEC -b $BROKER1 bind amq.direct $TEST_QUEUE $TEST_QUEUE
$QPID_ROUTE_EXEC route map $BROKER1
./datagen --count 100 | tee rdata-in |
@@ -113,7 +113,8 @@ fi
test -z $CLUSTER_LIB && exit 0 # Exit if cluster not supported.
## Test failover in a cluster using IPv6 only
-. $srcdir/ais_check # Will exit if clustering not enabled.
+. cpg_check.sh
+cpg_enabled || exit 0
pick_port() {
# We need a fixed port to set --cluster-url. Use qpidd to pick a free port.
diff --git a/cpp/src/tests/logging.cpp b/cpp/src/tests/logging.cpp
index fc55d642c3..5d5bb1feef 100644
--- a/cpp/src/tests/logging.cpp
+++ b/cpp/src/tests/logging.cpp
@@ -29,6 +29,7 @@
#endif
#include <boost/test/floating_point_comparison.hpp>
+#include <boost/algorithm/string/predicate.hpp>
#include <boost/format.hpp>
#include "unit_test.h"
@@ -43,8 +44,10 @@ namespace tests {
QPID_AUTO_TEST_SUITE(loggingTestSuite)
using namespace std;
-using namespace boost;
using namespace qpid::log;
+using boost::ends_with;
+using boost::contains;
+using boost::format;
QPID_AUTO_TEST_CASE(testStatementInit) {
Statement s=QPID_LOG_STATEMENT_INIT(debug); int line=__LINE__;
@@ -176,7 +179,9 @@ QPID_AUTO_TEST_CASE(testLoggerFormat) {
l.format(Logger::FUNCTION);
QPID_LOG(critical, "foo");
- BOOST_CHECK_EQUAL(string(BOOST_CURRENT_FUNCTION) + ": foo\n", out->last());
+ BOOST_CHECK( ends_with( out->last(), ": foo\n"));
+ string name = out->last().substr(0, out->last().length() - 6);
+ BOOST_CHECK( contains( string(BOOST_CURRENT_FUNCTION), name));
l.format(Logger::LEVEL);
QPID_LOG(critical, "foo");
diff --git a/cpp/src/tests/python_tests.ps1 b/cpp/src/tests/python_tests.ps1
index 9f8b9890c4..f7caa8f75a 100644
--- a/cpp/src/tests/python_tests.ps1
+++ b/cpp/src/tests/python_tests.ps1
@@ -26,8 +26,7 @@ if (!(Test-Path $PYTHON_DIR -pathType Container)) {
exit 1
}
-$PYTHON_TEST_DIR = "$srcdir\..\..\..\tests\src\py"
-$QMF_LIB = "$srcdir\..\..\..\extras\qmf\src\py"
+. .\test_env.ps1
if (Test-Path env:FAILING) {
$fails = "-I $env:FAILING"
@@ -39,7 +38,5 @@ else {
$tests = "$args"
}
-#cd $PYTHON_DIR
-$env:PYTHONPATH="$PYTHON_DIR;$PYTHON_TEST_DIR;$env:PYTHONPATH;$QMF_LIB"
python $PYTHON_DIR/qpid-python-test -m qpid_tests.broker_0_10 -m qpid.tests -b localhost:$env:QPID_PORT $fails $tests
exit $LASTEXITCODE
diff --git a/cpp/src/tests/qpid-cluster-benchmark b/cpp/src/tests/qpid-cluster-benchmark
index d836ed709c..610beacebd 100755
--- a/cpp/src/tests/qpid-cluster-benchmark
+++ b/cpp/src/tests/qpid-cluster-benchmark
@@ -22,38 +22,45 @@
# Default options
MESSAGES="-m 10000"
-FLOW="--flow-control 100" # Flow control limit on queue depth for latency.
REPEAT="--repeat 10"
QUEUES="-q 6"
SENDERS="-s 3"
RECEIVERS="-r 3"
BROKERS= # Local broker
CLIENT_HOSTS= # No ssh, all clients are local
+# Connection options
+TCP_NODELAY=false
+RECONNECT=true
+HEARTBEAT=1
-while getopts "m:f:n:b:q:s:r:c:txyv-" opt; do
+while getopts "m:f:n:b:q:s:r:c:h:i:txyv-" opt; do
case $opt in
+ b) BROKERS="-b $OPTARG";;
+ c) CLIENT_HOSTS="-c $OPTARG";;
+ h) HEARTBEAT=$OPTARG;;
+ i) RECONNECT=$OPTARG;;
m) MESSAGES="-m $OPTARG";;
- f) FLOW="--flow-control $OPTARG";;
n) REPEAT="--repeat $OPTARG";;
- b) BROKERS="-b $OPTARG";;
q) QUEUES="-q $OPTARG";;
- s) SENDERS="-s $OPTARG";;
r) RECEIVERS="-r $OPTARG";;
- c) CLIENT_HOSTS="-c $OPTARG";;
- t) TCP_NODELAY="--connection-options {tcp-nodelay:true}";;
+ s) SENDERS="-s $OPTARG";;
+ t) TCP_NODELAY=true;;
+ v) OPTS="--verbose";;
x) SAVE_RECEIVED="--save-received";;
y) NO_DELETE="--no-delete";;
- v) OPTS="--verbose";;
-) break ;;
*) echo "Unknown option"; exit 1;;
esac
done
shift $(($OPTIND-1))
-REPLICATE="node:{x-declare:{arguments:{'qpid.replicate':all}}}"
+CONNECTION_OPTIONS="--connection-options {tcp-nodelay:$TCP_NODELAY,reconnect:$RECONNECT,heartbeat:$HEARTBEAT}"
+CREATE_OPTIONS="node:{x-declare:{arguments:{'qpid.replicate':all}}}"
+
BROKER=$(echo $BROKERS | sed s/,.*//)
run_test() { echo $*; shift; "$@"; echo; echo; echo; }
-OPTS="$OPTS $REPEAT $BROKERS --summarize $QUEUES $SENDERS $RECEIVERS $MESSAGES $CLIENT_HOSTS $SAVE_RECEIVED $TCP_NODELAY $NO_DELETE"
-OPTS="$OPTS --create-option $REPLICATE"
+OPTS="$OPTS $REPEAT $BROKERS --summarize $QUEUES $SENDERS $RECEIVERS $MESSAGES $CLIENT_HOSTS $SAVE_RECEIVED $CONNECTION_OPTIONS $NO_DELETE"
+OPTS="$OPTS --create-option $CREATE_OPTIONS"
+
run_test "Benchmark:" qpid-cpp-benchmark $OPTS "$@"
diff --git a/cpp/src/tests/qpid-cpp-benchmark b/cpp/src/tests/qpid-cpp-benchmark
index 19c01dd08a..d5ad5191ca 100755
--- a/cpp/src/tests/qpid-cpp-benchmark
+++ b/cpp/src/tests/qpid-cpp-benchmark
@@ -37,7 +37,7 @@ op.add_option("-r", "--receivers", default=1, type="int", metavar="N",
op.add_option("-m", "--messages", default=100000, type="int", metavar="N",
help="send N messages per sender (default %default)")
op.add_option("--queue-name", default="benchmark", metavar="NAME",
- help="base name for queues (default %default)")
+ help="base name for queues (default %default)")
op.add_option("--send-rate", default=0, metavar="N",
help="send rate limited to N messages/second, 0 means no limit (default %default)")
op.add_option("--receive-rate", default=0, metavar="N",
@@ -67,18 +67,16 @@ op.add_option("--sequence", dest="sequence", default=False,
action="store_true", help="add a sequence number to each message")
op.add_option("--connection-options", type="str",
help="Connection options for senders & receivers")
-op.add_option("--flow-control", default=0, type="int", metavar="N",
- help="Flow control each sender to limit queue depth to 2*N. 0 means no flow control.")
op.add_option("--durable", default=False, action="store_true",
help="Use durable queues and messages")
op.add_option("--save-received", default=False, action="store_true",
help="Save received message content to files <queuename>-receiver-<n>.msg")
-op.add_option("--group-receivers", default=False, action="store_true",
- help="Run receivers for the same queue on the same host.")
op.add_option("--verbose", default=False, action="store_true",
help="Show commands executed")
op.add_option("--no-delete", default=False, action="store_true",
help="Don't delete the test queues.")
+op.add_option("--fill-drain", default=False, action="store_true",
+ help="First fill the queues, then drain them")
single_quote_re = re.compile("'")
def posix_quote(string):
@@ -150,7 +148,6 @@ def start_send(queue, opts, broker, host):
"--report-header=no",
"--timestamp=%s"%(opts.timestamp and "yes" or "no"),
"--sequence=%s"%(opts.sequence and "yes" or "no"),
- "--flow-control", str(opts.flow_control),
"--durable", str(opts.durable)
]
command += opts.send_arg
@@ -169,18 +166,6 @@ def first_line(p):
raise Exception("Process exit %d: %s"%(p.returncode, error_msg(out,err)))
return out.split("\n")[0]
-def queue_exists(queue,broker):
- c = qpid.messaging.Connection(broker)
- c.open()
- try:
- s = c.session()
- try:
- s.sender(queue)
- return True
- except qpid.messaging.exceptions.NotFound:
- return False
- finally: c.close()
-
def recreate_queues(queues, brokers, no_delete, opts):
c = qpid.messaging.Connection(brokers[0])
c.open()
@@ -189,15 +174,9 @@ def recreate_queues(queues, brokers, no_delete, opts):
if not no_delete:
try: s.sender("%s;{delete:always}"%(q)).close()
except qpid.messaging.exceptions.NotFound: pass
- # FIXME aconway 2011-05-04: new cluster async wiring, wait for changes to propagate
- for b in brokers:
- while queue_exists(q,b): time.sleep(0.1);
address = "%s;{%s}"%(q, ",".join(opts.create_option + ["create:always"]))
if opts.verbose: print "Creating", address
s.sender(address)
- # FIXME aconway 2011-05-04: new cluster async wiring, wait for changes to propagate
- for b in brokers:
- while not queue_exists(q,b): time.sleep(0.1);
c.close()
def print_header(timestamp):
@@ -295,24 +274,32 @@ def main():
recreate_queues(queues, opts.broker, opts.no_delete, opts)
ready_receiver = ReadyReceiver(ready_queue, opts.broker[0])
- if opts.group_receivers: # Run receivers for same queue against same broker.
- receivers = []
- for q in queues:
- b = brokers.next()
- for j in xrange(opts.receivers):
- receivers.append(
- start_receive(q, j, opts, ready_queue, b, client_hosts.next()))
- else: # Don't group receivers
- receivers = [start_receive(q, j, opts, ready_queue,
- brokers.next(), client_hosts.next())
- for q in queues for j in xrange(opts.receivers)]
-
- ready_receiver.wait(filter(None, receivers)) # Wait for receivers to be ready.
- start = time.time()
- senders = [start_send(q, opts,brokers.next(), client_hosts.next())
- for q in queues for j in xrange(opts.senders)]
+ def start_receivers():
+ return [ start_receive(q, j, opts, ready_queue, brokers.next(), client_hosts.next())
+ for q in queues for j in xrange(opts.receivers) ]
+
+
+ def start_senders():
+ return [ start_send(q, opts,brokers.next(), client_hosts.next())
+ for q in queues for j in xrange(opts.senders) ]
+
if opts.report_header and i == 0: print_header(opts.timestamp)
- for p in senders + receivers: p.wait()
+
+ if opts.fill_drain:
+ # First fill the queues, then drain them
+ start = time.time()
+ senders = start_senders()
+ for p in senders: p.wait()
+ receivers = start_receivers()
+ for p in receivers: p.wait()
+ else:
+ # Run senders and receivers in parallel
+ receivers = start_receivers()
+ ready_receiver.wait(filter(None, receivers)) # Wait for receivers ready
+ start = time.time()
+ senders = start_senders()
+ for p in senders + receivers: p.wait()
+
total_sent = opts.queues * opts.senders * opts.messages
total_tp = total_sent / (time.time()-start)
send_stats=parse_senders(senders)
diff --git a/cpp/src/tests/qpid-perftest.cpp b/cpp/src/tests/qpid-perftest.cpp
index 664f0cf877..c28bdfe5f8 100644
--- a/cpp/src/tests/qpid-perftest.cpp
+++ b/cpp/src/tests/qpid-perftest.cpp
@@ -85,6 +85,7 @@ struct Opts : public TestOptions {
size_t pubs;
size_t count ;
size_t size;
+ size_t headers;
bool confirm;
bool durable;
bool uniqueData;
@@ -112,7 +113,7 @@ struct Opts : public TestOptions {
Opts() :
TestOptions(helpText),
setup(false), control(false), publish(false), subscribe(false), baseName("qpid-perftest"),
- pubs(1), count(500000), size(1024), confirm(true), durable(false), uniqueData(false), syncPub(false),
+ pubs(1), count(500000), size(1024), headers(0), confirm(true), durable(false), uniqueData(false), syncPub(false),
subs(1), ack(0),
qt(1),singleConnect(false), iterations(1), mode(SHARED), summary(false),
intervalSub(0), intervalPub(0), tx(0), txPub(0), txSub(0), commitAsync(false)
@@ -131,6 +132,7 @@ struct Opts : public TestOptions {
("npubs", optValue(pubs, "N"), "Create N publishers.")
("count", optValue(count, "N"), "Each publisher sends N messages.")
("size", optValue(size, "BYTES"), "Size of messages in bytes.")
+ ("headers", optValue(headers, "N"), "Number of headers to add to each message.")
("pub-confirm", optValue(confirm, "yes|no"), "Publisher use confirm-mode.")
("durable", optValue(durable, "yes|no"), "Publish messages as durable.")
("unique-data", optValue(uniqueData, "yes|no"), "Make data for each message unique.")
@@ -503,7 +505,13 @@ struct PublishThread : public Client {
Message msg(data, routingKey);
if (opts.durable)
msg.getDeliveryProperties().setDeliveryMode(framing::PERSISTENT);
-
+ if (opts.headers) {
+ for (size_t i = 0; i < opts.headers; ++i) {
+ std::stringstream h;
+ h << "hdr" << i;
+ msg.getMessageProperties().getApplicationHeaders().setString(h.str(), h.str());
+ }
+ }
if (opts.txPub){
session.txSelect();
diff --git a/cpp/src/tests/qpid-ping.cpp b/cpp/src/tests/qpid-ping.cpp
index 0cb4afa0ee..52331499e7 100644
--- a/cpp/src/tests/qpid-ping.cpp
+++ b/cpp/src/tests/qpid-ping.cpp
@@ -32,11 +32,20 @@
#include <string>
#include <iostream>
-using namespace std;
-using namespace qpid::sys;
-using namespace qpid::framing;
-using namespace qpid::client;
-using namespace qpid;
+using std::cerr;
+using std::cout;
+using std::endl;
+using std::exception;
+using std::string;
+using namespace qpid::client::arg; // For keyword args
+using qpid::client::AsyncSession;
+using qpid::client::Connection;
+using qpid::client::Message;
+using qpid::client::SubscriptionManager;
+using qpid::framing::Uuid;
+
+namespace qpid {
+namespace tests {
struct PingOptions : public qpid::TestOptions {
int timeout; // Timeout in seconds.
@@ -48,9 +57,11 @@ struct PingOptions : public qpid::TestOptions {
}
};
+}} // namespace qpid::tests
+
int main(int argc, char** argv) {
try {
- PingOptions opts;
+ qpid::tests::PingOptions opts;
opts.parse(argc, argv);
opts.con.heartbeat = (opts.timeout+1)/2;
Connection connection;
@@ -58,8 +69,8 @@ int main(int argc, char** argv) {
if (!opts.quiet) cout << "Opened connection." << endl;
AsyncSession s = connection.newSession();
string qname(Uuid(true).str());
- s.queueDeclare(arg::queue=qname,arg::autoDelete=true,arg::exclusive=true);
- s.messageTransfer(arg::content=Message("hello", qname));
+ s.queueDeclare(queue=qname, autoDelete=true, exclusive=true);
+ s.messageTransfer(content=Message("hello", qname));
if (!opts.quiet) cout << "Sent message." << endl;
SubscriptionManager subs(s);
subs.get(qname);
diff --git a/cpp/src/tests/qpid-send.cpp b/cpp/src/tests/qpid-send.cpp
index b1213a484f..b1c4f2be38 100644
--- a/cpp/src/tests/qpid-send.cpp
+++ b/cpp/src/tests/qpid-send.cpp
@@ -36,15 +36,26 @@
#include <iostream>
#include <memory>
-using namespace std;
-using namespace qpid::messaging;
-using namespace qpid::types;
-
-typedef std::vector<std::string> string_vector;
+using std::string;
+using std::ios_base;
+
+using qpid::messaging::Address;
+using qpid::messaging::Connection;
+using qpid::messaging::Duration;
+using qpid::messaging::FailoverUpdates;
+using qpid::messaging::Message;
+using qpid::messaging::Receiver;
+using qpid::messaging::Session;
+using qpid::messaging::Sender;
+using qpid::types::Exception;
+using qpid::types::Uuid;
+using qpid::types::Variant;
namespace qpid {
namespace tests {
+typedef std::vector<std::string> string_vector;
+
struct Options : public qpid::Options
{
bool help;
@@ -74,7 +85,6 @@ struct Options : public qpid::Options
uint reportEvery;
bool reportHeader;
uint sendRate;
- uint flowControl;
bool sequence;
bool timestamp;
std::string groupKey;
@@ -104,7 +114,6 @@ struct Options : public qpid::Options
reportEvery(0),
reportHeader(true),
sendRate(0),
- flowControl(0),
sequence(true),
timestamp(true),
groupPrefix("GROUP-"),
@@ -138,7 +147,6 @@ struct Options : public qpid::Options
("report-every", qpid::optValue(reportEvery,"N"), "Report throughput statistics every N messages")
("report-header", qpid::optValue(reportHeader, "yes|no"), "Headers on report.")
("send-rate", qpid::optValue(sendRate,"N"), "Send at rate of N messages/second. 0 means send as fast as possible.")
- ("flow-control", qpid::optValue(flowControl,"N"), "Do end to end flow control to limit queue depth to 2*N. 0 means no flow control.")
("sequence", qpid::optValue(sequence, "yes|no"), "Add a sequence number messages property (required for duplicate/lost message detection)")
("timestamp", qpid::optValue(timestamp, "yes|no"), "Add a time stamp messages property (required for latency measurement)")
("group-key", qpid::optValue(groupKey, "KEY"), "Generate groups of messages using message header 'KEY' to hold the group identifier")
@@ -223,10 +231,6 @@ const string EOS("eos");
const string SN("sn");
const string TS("ts");
-}} // namespace qpid::tests
-
-using namespace qpid::tests;
-
class ContentGenerator {
public:
virtual ~ContentGenerator() {}
@@ -329,6 +333,20 @@ public:
}
};
+}} // namespace qpid::tests
+
+using qpid::tests::Options;
+using qpid::tests::Reporter;
+using qpid::tests::Throughput;
+using qpid::tests::ContentGenerator;
+using qpid::tests::GroupGenerator;
+using qpid::tests::GetlineContentGenerator;
+using qpid::tests::MapContentGenerator;
+using qpid::tests::FixedContentGenerator;
+using qpid::tests::SN;
+using qpid::tests::TS;
+using qpid::tests::EOS;
+
int main(int argc, char ** argv)
{
Connection connection;
@@ -350,8 +368,6 @@ int main(int argc, char ** argv)
msg.setPriority(opts.priority);
}
if (!opts.replyto.empty()) {
- if (opts.flowControl)
- throw Exception("Can't use reply-to and flow-control together");
msg.setReplyTo(Address(opts.replyto));
}
if (!opts.userid.empty()) msg.setUserId(opts.userid);
@@ -385,26 +401,10 @@ int main(int argc, char ** argv)
int64_t interval = 0;
if (opts.sendRate) interval = qpid::sys::TIME_SEC/opts.sendRate;
- Receiver flowControlReceiver;
- Address flowControlAddress("flow-"+Uuid(true).str()+";{create:always,delete:always}");
- uint flowSent = 0;
- if (opts.flowControl) {
- flowControlReceiver = session.createReceiver(flowControlAddress);
- flowControlReceiver.setCapacity(2);
- }
-
while (contentGen->setContent(msg)) {
++sent;
if (opts.sequence)
msg.getProperties()[SN] = sent;
- if (opts.flowControl) {
- if ((sent % opts.flowControl) == 0) {
- msg.setReplyTo(flowControlAddress);
- ++flowSent;
- }
- else
- msg.setReplyTo(Address()); // Clear the reply address.
- }
if (groupGen.get())
groupGen->setGroupInfo(msg);
@@ -423,19 +423,12 @@ int main(int argc, char ** argv)
}
if (opts.messages && sent >= opts.messages) break;
- if (opts.flowControl && flowSent == 2) {
- flowControlReceiver.get(Duration::SECOND);
- --flowSent;
- }
-
if (opts.sendRate) {
qpid::sys::AbsTime waitTill(start, sent*interval);
int64_t delay = qpid::sys::Duration(qpid::sys::now(), waitTill);
if (delay > 0) qpid::sys::usleep(delay/qpid::sys::TIME_USEC);
}
}
- for ( ; flowSent>0; --flowSent)
- flowControlReceiver.get(Duration::SECOND);
if (opts.reportTotal) reporter.report();
for (uint i = opts.sendEos; i > 0; --i) {
if (opts.sequence)
diff --git a/cpp/src/tests/qpid-txtest.cpp b/cpp/src/tests/qpid-txtest.cpp
index d0ba2f1245..6e7d46802c 100644
--- a/cpp/src/tests/qpid-txtest.cpp
+++ b/cpp/src/tests/qpid-txtest.cpp
@@ -33,6 +33,7 @@
#include "qpid/client/SubscriptionManager.h"
#include "qpid/framing/Array.h"
#include "qpid/framing/Buffer.h"
+#include "qpid/framing/FieldValue.h"
#include "qpid/framing/Uuid.h"
#include "qpid/sys/Thread.h"
@@ -245,10 +246,10 @@ struct Controller : public Client
// Recover DTX transactions (if any)
if (opts.dtx) {
- std::vector<std::string> inDoubtXids;
framing::DtxRecoverResult dtxRes = session.dtxRecover().get();
const framing::Array& xidArr = dtxRes.getInDoubt();
- xidArr.collect(inDoubtXids);
+ std::vector<std::string> inDoubtXids(xidArr.size());
+ std::transform(xidArr.begin(), xidArr.end(), inDoubtXids.begin(), framing::Array::get<std::string, framing::Array::ValuePtr>);
if (inDoubtXids.size()) {
if (!opts.quiet) std::cout << "Recovering DTX in-doubt transaction(s):" << std::endl;
diff --git a/cpp/src/tests/qpidd-empty.conf b/cpp/src/tests/qpidd-empty.conf
new file mode 100644
index 0000000000..bbf52bf446
--- /dev/null
+++ b/cpp/src/tests/qpidd-empty.conf
@@ -0,0 +1,3 @@
+# An empty configuration file.
+# Used when running tests to avoid picking up configuration
+# installed in the default place.
diff --git a/cpp/src/tests/queue_flow_limit_tests.py b/cpp/src/tests/queue_flow_limit_tests.py
index dec7cfb3af..d51b26a821 100644
--- a/cpp/src/tests/queue_flow_limit_tests.py
+++ b/cpp/src/tests/queue_flow_limit_tests.py
@@ -117,7 +117,7 @@ class QueueFlowLimitTests(TestBase010):
tool = environ.get("QPID_CONFIG_EXEC")
if tool:
command = tool + \
- " --broker-addr=%s:%s " % (self.broker.host, self.broker.port) \
+ " --broker=%s:%s " % (self.broker.host, self.broker.port) \
+ "add queue test01 --flow-stop-count=999" \
+ " --flow-resume-count=55 --flow-stop-size=5000000" \
+ " --flow-resume-size=100000"
diff --git a/cpp/src/tests/reliable_replication_test b/cpp/src/tests/reliable_replication_test
index 1f1dac5f2d..c660f751e5 100755
--- a/cpp/src/tests/reliable_replication_test
+++ b/cpp/src/tests/reliable_replication_test
@@ -47,12 +47,12 @@ setup() {
echo "Testing replication from port $BROKER_A to port $BROKER_B"
- $PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_B" add exchange replication replication
+ $PYTHON_COMMANDS/qpid-config -b "localhost:$BROKER_B" add exchange replication replication
$PYTHON_COMMANDS/qpid-route --ack 500 queue add "localhost:$BROKER_B" "localhost:$BROKER_A" replication replication
#create test queue (only replicate enqueues for this test):
- $PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_A" add queue queue-a --generate-queue-events 1
- $PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_B" add queue queue-a
+ $PYTHON_COMMANDS/qpid-config -b "localhost:$BROKER_A" add queue queue-a --generate-queue-events 1
+ $PYTHON_COMMANDS/qpid-config -b "localhost:$BROKER_B" add queue queue-a
}
send() {
diff --git a/cpp/src/tests/replication_test b/cpp/src/tests/replication_test
index 8c37568875..f8b2136396 100755
--- a/cpp/src/tests/replication_test
+++ b/cpp/src/tests/replication_test
@@ -46,21 +46,21 @@ if test -d ${PYTHON_DIR} && test -f "$REPLICATING_LISTENER_LIB" && test -f "$REP
BROKER_B=`cat qpidd.port`
echo "Running replication test between localhost:$BROKER_A and localhost:$BROKER_B"
- $PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_B" add exchange replication replication
+ $PYTHON_COMMANDS/qpid-config -b "localhost:$BROKER_B" add exchange replication replication
$PYTHON_COMMANDS/qpid-route --ack 5 queue add "localhost:$BROKER_B" "localhost:$BROKER_A" replication replication
#create test queues
- $PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_A" add queue queue-a --generate-queue-events 2
- $PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_A" add queue queue-b --generate-queue-events 2
- $PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_A" add queue queue-c --generate-queue-events 1
- $PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_A" add queue queue-d --generate-queue-events 2
- $PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_A" add queue queue-e --generate-queue-events 1
+ $PYTHON_COMMANDS/qpid-config -b "localhost:$BROKER_A" add queue queue-a --generate-queue-events 2
+ $PYTHON_COMMANDS/qpid-config -b "localhost:$BROKER_A" add queue queue-b --generate-queue-events 2
+ $PYTHON_COMMANDS/qpid-config -b "localhost:$BROKER_A" add queue queue-c --generate-queue-events 1
+ $PYTHON_COMMANDS/qpid-config -b "localhost:$BROKER_A" add queue queue-d --generate-queue-events 2
+ $PYTHON_COMMANDS/qpid-config -b "localhost:$BROKER_A" add queue queue-e --generate-queue-events 1
- $PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_B" add queue queue-a
- $PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_B" add queue queue-b
- $PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_B" add queue queue-c
- $PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_B" add queue queue-e
+ $PYTHON_COMMANDS/qpid-config -b "localhost:$BROKER_B" add queue queue-a
+ $PYTHON_COMMANDS/qpid-config -b "localhost:$BROKER_B" add queue queue-b
+ $PYTHON_COMMANDS/qpid-config -b "localhost:$BROKER_B" add queue queue-c
+ $PYTHON_COMMANDS/qpid-config -b "localhost:$BROKER_B" add queue queue-e
#queue-d deliberately not declared on DR; this error case should be handled
#publish and consume from test queues on broker A:
@@ -124,13 +124,13 @@ if test -d ${PYTHON_DIR} && test -f "$REPLICATING_LISTENER_LIB" && test -f "$REP
$QPIDD_EXEC --daemon --port 0 --no-data-dir --no-module-dir --auth no --load-module $REPLICATION_EXCHANGE_LIB --log-enable info+ --log-to-file replication-dest.log --log-to-stderr 0 > qpidd.port
BROKER_B=`cat qpidd.port`
- $PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_B" add exchange replication replication
+ $PYTHON_COMMANDS/qpid-config -b "localhost:$BROKER_B" add exchange replication replication
$PYTHON_COMMANDS/qpid-route --ack 5 queue add "localhost:$BROKER_B" "localhost:$BROKER_A" replication replication
- $PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_A" add queue queue-e --generate-queue-events 2
- $PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_B" add queue queue-e
- $PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_A" add queue queue-d --generate-queue-events 1
- $PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_B" add queue queue-d
+ $PYTHON_COMMANDS/qpid-config -b "localhost:$BROKER_A" add queue queue-e --generate-queue-events 2
+ $PYTHON_COMMANDS/qpid-config -b "localhost:$BROKER_B" add queue queue-e
+ $PYTHON_COMMANDS/qpid-config -b "localhost:$BROKER_A" add queue queue-d --generate-queue-events 1
+ $PYTHON_COMMANDS/qpid-config -b "localhost:$BROKER_B" add queue queue-d
i=1
while [ $i -le 10 ]; do
@@ -152,8 +152,8 @@ if test -d ${PYTHON_DIR} && test -f "$REPLICATING_LISTENER_LIB" && test -f "$REP
$QPIDD_EXEC --daemon --port 0 --no-data-dir --no-module-dir --auth no --load-module $REPLICATION_EXCHANGE_LIB --log-enable info+ --log-to-file replication-dest.log --log-to-stderr 0 > qpidd.port
BROKER_B=`cat qpidd.port`
- $PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_B" add queue queue-e
- $PYTHON_COMMANDS/qpid-config -a "localhost:$BROKER_B" add exchange replication replication
+ $PYTHON_COMMANDS/qpid-config -b "localhost:$BROKER_B" add queue queue-e
+ $PYTHON_COMMANDS/qpid-config -b "localhost:$BROKER_B" add exchange replication replication
$PYTHON_COMMANDS/qpid-route --ack 5 queue add "localhost:$BROKER_B" "localhost:$BROKER_A" replication replication
# now send another 15
i=11
diff --git a/cpp/src/tests/ring_queue_test b/cpp/src/tests/ring_queue_test
index 553746eb49..271b46183e 100755
--- a/cpp/src/tests/ring_queue_test
+++ b/cpp/src/tests/ring_queue_test
@@ -28,7 +28,7 @@ MESSAGES=10000
SENDERS=1
RECEIVERS=1
CONCURRENT=0
-BROKER_URL="-a ${QPID_BROKER:-localhost}:${QPID_PORT:-5672}"
+BROKER_URL="-b ${QPID_BROKER:-localhost}:${QPID_PORT:-5672}"
setup() {
if [[ $DURABLE -gt 0 ]]; then
diff --git a/cpp/src/tests/run_acl_tests b/cpp/src/tests/run_acl_tests
index 41f41e20e1..3a8c03eda6 100755
--- a/cpp/src/tests/run_acl_tests
+++ b/cpp/src/tests/run_acl_tests
@@ -22,23 +22,31 @@
# Run the acl tests. $srcdir is set by the Makefile.
source ./test_env.sh
DATA_DIR=`pwd`/data_dir
+DATA_DIRI=`pwd`/data_diri
+DATA_DIRU=`pwd`/data_diru
trap stop_brokers INT TERM QUIT
start_brokers() {
- ../qpidd --daemon --port 0 --no-module-dir --data-dir $DATA_DIR --load-module $ACL_LIB --acl-file policy.acl --auth no > qpidd.port
+ ../qpidd --daemon --port 0 --no-module-dir --data-dir $DATA_DIR --load-module $ACL_LIB --acl-file policy.acl --auth no --log-to-file local.log > qpidd.port
LOCAL_PORT=`cat qpidd.port`
+ ../qpidd --daemon --port 0 --no-module-dir --data-dir $DATA_DIRI --load-module $ACL_LIB --acl-file policy.acl --auth no --acl-max-connect-per-ip 2 --log-to-file locali.log > qpiddi.port
+ LOCAL_PORTI=`cat qpiddi.port`
+ ../qpidd --daemon --port 0 --no-module-dir --data-dir $DATA_DIRU --load-module $ACL_LIB --acl-file policy.acl --auth no --acl-max-connect-per-user 2 --log-to-file localu.log > qpiddu.port
+ LOCAL_PORTU=`cat qpiddu.port`
}
stop_brokers() {
$QPIDD_EXEC --no-module-dir -q --port $LOCAL_PORT
+ $QPIDD_EXEC --no-module-dir -q --port $LOCAL_PORTI
+ $QPIDD_EXEC --no-module-dir -q --port $LOCAL_PORTU
}
test_loading_acl_from_absolute_path(){
POLICY_FILE=$srcdir/policy.acl
rm -f temp.log
PORT=`../qpidd --daemon --port 0 --no-module-dir --no-data-dir --auth no --load-module $ACL_LIB --acl-file $POLICY_FILE -t --log-to-file temp.log 2>/dev/null`
- ACL_FILE=`grep "notice Read ACL file" temp.log | sed 's/^.*Read ACL file //'`
+ ACL_FILE=`grep "notice ACL: Read file" temp.log | sed 's/^.*Read file //'`
$QPIDD_EXEC --no-module-dir -q --port $PORT
if test "$ACL_FILE" != "\"$POLICY_FILE\""; then
echo "unable to load policy file from an absolute path";
@@ -49,14 +57,22 @@ test_loading_acl_from_absolute_path(){
if test -d ${PYTHON_DIR} ; then
rm -rf $DATA_DIR
+ rm -rf $DATA_DIRI
+ rm -rf $DATA_DIRU
mkdir -p $DATA_DIR
+ mkdir -p $DATA_DIRI
+ mkdir -p $DATA_DIRU
cp $srcdir/policy.acl $DATA_DIR
+ cp $srcdir/policy.acl $DATA_DIRI
+ cp $srcdir/policy.acl $DATA_DIRU
start_brokers
- echo "Running acl tests using brokers on ports $LOCAL_PORT"
- $QPID_PYTHON_TEST -b localhost:$LOCAL_PORT -m acl || EXITCODE=1
+ echo "Running acl tests using brokers on ports $LOCAL_PORT, $LOCAL_PORTI, and $LOCAL_PORTU"
+ $QPID_PYTHON_TEST -b localhost:$LOCAL_PORT -m acl -Dport-i=$LOCAL_PORTI -Dport-u=$LOCAL_PORTU || EXITCODE=1
stop_brokers || EXITCODE=1
test_loading_acl_from_absolute_path || EXITCODE=1
rm -rf $DATA_DIR
+ rm -rf $DATA_DIRI
+ rm -rf $DATA_DIRU
exit $EXITCODE
fi
diff --git a/cpp/src/tests/run_acl_tests.ps1 b/cpp/src/tests/run_acl_tests.ps1
index 46e070477f..8279d87e54 100644
--- a/cpp/src/tests/run_acl_tests.ps1
+++ b/cpp/src/tests/run_acl_tests.ps1
@@ -20,15 +20,12 @@
# Run the acl tests.
$srcdir = Split-Path $myInvocation.InvocationName
-$PYTHON_DIR = "$srcdir\..\..\..\python"
+. .\test_env.ps1
if (!(Test-Path $PYTHON_DIR -pathType Container)) {
"Skipping acl tests as python libs not found"
exit 1
}
-$PYTHON_TEST_DIR = "$srcdir\..\..\..\tests\src\py"
-$QMF_LIB = "$srcdir\..\..\..\extras\qmf\src\py"
-$env:PYTHONPATH="$PYTHON_DIR;$srcdir;$PYTHON_TEST_DIR;$QMF_LIB"
$Global:BROKER_EXE = ""
Function start_broker($acl_options)
diff --git a/cpp/src/tests/run_cli_tests b/cpp/src/tests/run_cli_tests
index ec5c71b646..ea44437c0d 100755
--- a/cpp/src/tests/run_cli_tests
+++ b/cpp/src/tests/run_cli_tests
@@ -56,9 +56,9 @@ start_brokers() {
targs="--ignore=*xml*"
fi
- ../qpidd --daemon --port 0 --no-data-dir --no-module-dir --auth no $xargs > qpidd.port
+ ../qpidd --daemon --port 0 --no-data-dir --no-module-dir --mgmt-publish no --auth no $xargs > qpidd.port
LOCAL_PORT=`cat qpidd.port`
- ../qpidd --daemon --port 0 --no-data-dir --no-module-dir --auth no $xargs > qpidd.port
+ ../qpidd --daemon --port 0 --no-data-dir --no-module-dir --mgmt-publish no --auth no $xargs > qpidd.port
REMOTE_PORT=`cat qpidd.port`
}
diff --git a/cpp/src/tests/run_cluster_authentication_soak b/cpp/src/tests/run_cluster_authentication_soak
index 7bc406c4ca..24befa28ba 100755
--- a/cpp/src/tests/run_cluster_authentication_soak
+++ b/cpp/src/tests/run_cluster_authentication_soak
@@ -19,8 +19,9 @@
source ./test_env.sh
-source $srcdir/ais_check
source sasl_test_setup.sh
+source cpg_check.sh
+cpg_enabled || exit 0
with_ais_group ./cluster_authentication_soak 500
diff --git a/cpp/src/tests/run_cluster_authentication_test b/cpp/src/tests/run_cluster_authentication_test
index 647200b869..844807a857 100755
--- a/cpp/src/tests/run_cluster_authentication_test
+++ b/cpp/src/tests/run_cluster_authentication_test
@@ -19,8 +19,9 @@
source ./test_env.sh
-source $srcdir/ais_check
source sasl_test_setup.sh
+source cpg_check.sh
+cpg_enabled || exit 0
with_ais_group ./cluster_authentication_soak
diff --git a/cpp/src/tests/run_cluster_test b/cpp/src/tests/run_cluster_test
index c022eea1fe..11df3d63a3 100755
--- a/cpp/src/tests/run_cluster_test
+++ b/cpp/src/tests/run_cluster_test
@@ -22,5 +22,6 @@
# Run the tests
srcdir=`dirname $0`
-. $srcdir/ais_check
+source cpg_check.sh
+cpg_enabled || exit 0
with_ais_group $srcdir/run_test ./cluster_test
diff --git a/cpp/src/tests/run_cluster_tests b/cpp/src/tests/run_cluster_tests
index e136d3810a..a5cea5ff6e 100755
--- a/cpp/src/tests/run_cluster_tests
+++ b/cpp/src/tests/run_cluster_tests
@@ -20,7 +20,9 @@
#
source ./test_env.sh
-source $srcdir/ais_check
+source cpg_check.sh
+cpg_enabled || exit 0
+
test -x $QPID_PYTHON_TEST || { echo Skipping test, $QPID_PYTHON_TEST not found; exit 0; }
diff --git a/cpp/src/tests/run_failover_soak b/cpp/src/tests/run_failover_soak
index 4c2e8cc188..2c56bf7d6b 100755
--- a/cpp/src/tests/run_failover_soak
+++ b/cpp/src/tests/run_failover_soak
@@ -20,7 +20,8 @@
#
source ./test_env.sh
-. $srcdir/ais_check
+source cpg_check.sh
+cpg_enabled || exit 0
host=127.0.0.1
diff --git a/cpp/src/tests/run_federation_sys_tests b/cpp/src/tests/run_federation_sys_tests
index f5f772d72e..76da176914 100755
--- a/cpp/src/tests/run_federation_sys_tests
+++ b/cpp/src/tests/run_federation_sys_tests
@@ -26,12 +26,8 @@ source ./test_env.sh
MODULENAME=federation_sys
# Test for clustering
-ps -u root | grep 'aisexec\|corosync' > /dev/null
-if (( $? == 0 )); then
- CLUSTERING_ENABLED=1
-else
- echo "WARNING: No clustering detected; tests using it will be ignored."
-fi
+source cpg_check.sh
+if cpg_enabled; then CLUSTERING_ENABLED=1; fi
# Test for long test
if [[ "$1" == "LONG_TEST" ]]; then
diff --git a/cpp/src/tests/run_federation_tests b/cpp/src/tests/run_federation_tests
index b71fa14c47..7735b559cf 100755
--- a/cpp/src/tests/run_federation_tests
+++ b/cpp/src/tests/run_federation_tests
@@ -33,16 +33,13 @@ else
SKIPTESTS='-i *_xml' # note: single quotes prevent expansion of *
fi
+QPIDD_CMD="../qpidd --daemon --port 0 --no-data-dir $MODULES --auth no --log-enable=info+ --log-enable=debug+:Bridge --log-to-file"
start_brokers() {
- ../qpidd --daemon --port 0 --no-data-dir $MODULES --auth no > qpidd.port
- LOCAL_PORT=`cat qpidd.port`
- ../qpidd --daemon --port 0 --no-data-dir $MODULES --auth no > qpidd.port
- REMOTE_PORT=`cat qpidd.port`
-
- ../qpidd --daemon --port 0 --no-data-dir $MODULES --auth no > qpidd.port
- REMOTE_B1=`cat qpidd.port`
- ../qpidd --daemon --port 0 --no-data-dir $MODULES --auth no > qpidd.port
- REMOTE_B2=`cat qpidd.port`
+ rm -f fed_local.log fed_remote.log fed_b1.log fed_b2.log
+ LOCAL_PORT=$($QPIDD_CMD fed_local.log)
+ REMOTE_PORT=$($QPIDD_CMD fed_remote.log)
+ REMOTE_B1=$($QPIDD_CMD fed_b1.log)
+ REMOTE_B2=$($QPIDD_CMD fed_b2.log)
}
stop_brokers() {
diff --git a/cpp/src/tests/run_federation_tests.ps1 b/cpp/src/tests/run_federation_tests.ps1
index 35353a870f..803b3eef6f 100644
--- a/cpp/src/tests/run_federation_tests.ps1
+++ b/cpp/src/tests/run_federation_tests.ps1
@@ -26,8 +26,7 @@ if (!(Test-Path $PYTHON_DIR -pathType Container)) {
exit 1
}
-$PYTHON_TEST_DIR = "$srcdir\..\..\..\tests\src\py"
-$QMF_LIB = "$srcdir\..\..\..\extras\qmf\src\py"
+. .\test_env.ps1
# Test runs from the tests directory but the broker executable is one level
# up, and most likely in a subdirectory from there based on what build type.
diff --git a/cpp/src/tests/run_header_test.ps1 b/cpp/src/tests/run_header_test.ps1
index 7d3e43a30f..344fac9cf9 100644
--- a/cpp/src/tests/run_header_test.ps1
+++ b/cpp/src/tests/run_header_test.ps1
@@ -28,6 +28,8 @@ if (!(Test-Path $PYTHON_DIR -pathType Container)) {
exit 0
}
+. .\test_env.ps1
+
if (Test-Path qpidd.port) {
set-item -path env:QPID_PORT -value (get-content -path qpidd.port -totalcount 1)
}
@@ -42,6 +44,5 @@ if (!(Test-Path $prog)) {
}
Invoke-Expression "$prog -p $env:QPID_PORT" | Write-Output
-$env:PYTHONPATH="$PYTHON_DIR;$env:PYTHONPATH"
Invoke-Expression "python $srcdir/header_test.py localhost $env:QPID_PORT" | Write-Output
exit $LASTEXITCODE
diff --git a/cpp/src/tests/run_msg_group_tests b/cpp/src/tests/run_msg_group_tests
index 5a6da546f3..4e82759866 100755
--- a/cpp/src/tests/run_msg_group_tests
+++ b/cpp/src/tests/run_msg_group_tests
@@ -44,19 +44,19 @@ run_test() {
declare -i i=0
declare -a tests
-tests=("qpid-config -a $BROKER_URL add queue $QUEUE_NAME --group-header=${GROUP_KEY} --shared-groups"
+tests=("qpid-config -b $BROKER_URL add queue $QUEUE_NAME --group-header=${GROUP_KEY} --shared-groups"
"msg_group_test -b $BROKER_URL -a $QUEUE_NAME --group-key $GROUP_KEY --messages 103 --group-size 13 --receivers 2 --senders 3 --capacity 3 --ack-frequency 7 --randomize-group-size --interleave 3"
"msg_group_test -b $BROKER_URL -a $QUEUE_NAME --group-key $GROUP_KEY --messages 103 --group-size 13 --receivers 2 --senders 3 --capacity 7 --ack-frequency 7 --randomize-group-size"
- "qpid-config -a $BROKER_URL add queue ${QUEUE_NAME}-two --group-header=${GROUP_KEY} --shared-groups"
+ "qpid-config -b $BROKER_URL add queue ${QUEUE_NAME}-two --group-header=${GROUP_KEY} --shared-groups"
"msg_group_test -b $BROKER_URL -a $QUEUE_NAME --group-key $GROUP_KEY --messages 103 --group-size 13 --receivers 2 --senders 3 --capacity 7 --ack-frequency 3 --randomize-group-size"
"msg_group_test -b $BROKER_URL -a ${QUEUE_NAME}-two --group-key $GROUP_KEY --messages 103 --group-size 13 --receivers 2 --senders 3 --capacity 3 --ack-frequency 7 --randomize-group-size --interleave 5"
"msg_group_test -b $BROKER_URL -a $QUEUE_NAME --group-key $GROUP_KEY --messages 59 --group-size 5 --receivers 2 --senders 3 --capacity 1 --ack-frequency 3 --randomize-group-size"
- "qpid-config -a $BROKER_URL del queue ${QUEUE_NAME}-two --force"
+ "qpid-config -b $BROKER_URL del queue ${QUEUE_NAME}-two --force"
"msg_group_test -b $BROKER_URL -a $QUEUE_NAME --group-key $GROUP_KEY --messages 59 --group-size 3 --receivers 2 --senders 3 --capacity 1 --ack-frequency 1 --randomize-group-size"
"msg_group_test -b $BROKER_URL -a $QUEUE_NAME --group-key $GROUP_KEY --messages 211 --group-size 13 --receivers 2 --senders 3 --capacity 47 --ack-frequency 79 --interleave 53"
"msg_group_test -b $BROKER_URL -a $QUEUE_NAME --group-key $GROUP_KEY --messages 10000 --group-size 1 --receivers 0 --senders 1"
"msg_group_test -b $BROKER_URL -a $QUEUE_NAME --group-key $GROUP_KEY --messages 10000 --receivers 5 --senders 0"
- "qpid-config -a $BROKER_URL del queue $QUEUE_NAME --force")
+ "qpid-config -b $BROKER_URL del queue $QUEUE_NAME --force")
while [ -n "${tests[i]}" ]; do
run_test ${tests[i]}
diff --git a/cpp/src/tests/run_msg_group_tests_soak b/cpp/src/tests/run_msg_group_tests_soak
index 44995423cc..2ebbaf4efd 100755
--- a/cpp/src/tests/run_msg_group_tests_soak
+++ b/cpp/src/tests/run_msg_group_tests_soak
@@ -44,13 +44,13 @@ run_test() {
declare -i i=0
declare -a tests
-tests=("qpid-config -a $BROKER_URL add queue $QUEUE_NAME --group-header=${GROUP_KEY} --shared-groups"
+tests=("qpid-config -b $BROKER_URL add queue $QUEUE_NAME --group-header=${GROUP_KEY} --shared-groups"
"msg_group_test -b $BROKER_URL -a $QUEUE_NAME --group-key $GROUP_KEY --messages 10007 --receivers 3 --senders 5 --group-size 211 --randomize-group-size --capacity 47 --ack-frequency 97"
"msg_group_test -b $BROKER_URL -a $QUEUE_NAME --group-key $GROUP_KEY --messages 10007 --receivers 3 --senders 5 --group-size 211 --randomize-group-size --capacity 79 --ack-frequency 79"
"msg_group_test -b $BROKER_URL -a $QUEUE_NAME --group-key $GROUP_KEY --messages 10007 --receivers 3 --senders 5 --group-size 211 --randomize-group-size --capacity 97 --ack-frequency 47"
"msg_group_test -b $BROKER_URL -a $QUEUE_NAME --group-key $GROUP_KEY --messages 40000 --receivers 0 --senders 5 --group-size 13 --randomize-group-size"
"msg_group_test -b $BROKER_URL -a $QUEUE_NAME --group-key $GROUP_KEY --messages 200000 --receivers 3 --senders 0 --capacity 23 --ack-frequency 7"
- "qpid-config -a $BROKER_URL del queue $QUEUE_NAME --force")
+ "qpid-config -b $BROKER_URL del queue $QUEUE_NAME --force")
while [ -n "${tests[i]}" ]; do
run_test ${tests[i]}
diff --git a/cpp/src/tests/run_store_tests.ps1 b/cpp/src/tests/run_store_tests.ps1
index b2f0b1ccd8..0683892393 100644
--- a/cpp/src/tests/run_store_tests.ps1
+++ b/cpp/src/tests/run_store_tests.ps1
@@ -30,14 +30,14 @@ if ($test_store -ne "MSSQL" -and $test_store -ne "MSSQL-CLFS") {
}
$srcdir = Split-Path $myInvocation.InvocationName
-$PYTHON_DIR = "$srcdir\..\..\..\python"
+
+. .\test_env.ps1
+
if (!(Test-Path $PYTHON_DIR -pathType Container)) {
"Skipping store tests as python libs not found"
exit 1
}
-$QMF_LIB = "$srcdir\..\..\..\extras\qmf\src\py"
-
# Test runs from the tests directory but the broker executable is one level
# up, and most likely in a subdirectory from there based on what build type.
# Look around for it before trying to start it.
@@ -97,7 +97,7 @@ set-item -path env:QPID_PORT -value (get-content -path qpidd-store.port -totalco
Remove-Item qpidd-store.port
$PYTHON_TEST_DIR = "$srcdir\..\..\..\tests\src\py\qpid_tests\broker_0_10"
-$env:PYTHONPATH="$PYTHON_DIR;$PYTHON_TEST_DIR;$env:PYTHONPATH;$QMF_LIB"
+$env:PYTHONPATH="$PYTHON_TEST_DIR;$srcdir;$env:PYTHONPATH"
python $PYTHON_DIR/qpid-python-test -m dtx -m persistence -b localhost:$env:QPID_PORT $fails $tests
$RETCODE=$LASTEXITCODE
if ($RETCODE -ne 0) {
@@ -111,7 +111,6 @@ Invoke-Expression "$prog --quit --port $env:QPID_PORT" | Write-Output
# Test 2... store.py starts/stops/restarts its own brokers
$tests = "*"
-$env:PYTHONPATH="$PYTHON_DIR;$QMF_LIB;$srcdir"
$env:QPIDD_EXEC="$prog"
$env:STORE_LIB="$store_dir\store$suffix.dll"
if ($test_store -eq "MSSQL") {
diff --git a/cpp/src/tests/run_test.ps1 b/cpp/src/tests/run_test.ps1
index ca990bc057..872e1dddb1 100644
--- a/cpp/src/tests/run_test.ps1
+++ b/cpp/src/tests/run_test.ps1
@@ -20,8 +20,7 @@
$srcdir = Split-Path $myInvocation.InvocationName
# Set up environment and run a test executable or script.
-$env:QPID_DATA_DIR = ""
-$env:BOOST_TEST_SHOW_PROGRESS = "yes"
+. .\test_env.ps1
# The test exe is probably not in the current binary dir - it's usually
# placed in a subdirectory based on the configuration built in Visual Studio.
@@ -30,7 +29,7 @@ $env:BOOST_TEST_SHOW_PROGRESS = "yes"
# one level up.
$prog = $args[0]
$is_script = $prog -match ".ps1$"
-if (!$is_script) {
+if (!$is_script -and !(Test-Path "$prog")) {
. $srcdir\find_prog.ps1 $prog
$args[0] = $prog
$env:QPID_LIB_DIR = "..\$sub"
diff --git a/cpp/src/tests/sasl.mk b/cpp/src/tests/sasl.mk
index 69b24c3f8a..11731dcf40 100644
--- a/cpp/src/tests/sasl.mk
+++ b/cpp/src/tests/sasl.mk
@@ -20,18 +20,37 @@
# Test that are only relevant if SASL is enabled.
if HAVE_SASL
+if HAVE_LIBCPG
check_PROGRAMS+=cluster_authentication_soak
cluster_authentication_soak_INCLUDES=$(PUBLIC_INCLUDES)
cluster_authentication_soak_SOURCES=cluster_authentication_soak.cpp ForkedBroker.h ForkedBroker.cpp
cluster_authentication_soak_LDADD=$(lib_client) $(lib_broker)
+endif HAVE_LIBCPG
# Note: sasl_version is not a test -- it is a tool used by tests.
check_PROGRAMS+=sasl_version
sasl_version_SOURCES=sasl_version.cpp
sasl_version_LDADD=$(lib_client)
-TESTS += run_cluster_authentication_test sasl_fed sasl_fed_ex_dynamic sasl_fed_ex_link sasl_fed_ex_queue sasl_fed_ex_route sasl_fed_ex_route_cluster sasl_fed_ex_link_cluster sasl_fed_ex_queue_cluster sasl_fed_ex_dynamic_cluster sasl_no_dir
+TESTS += sasl_fed
+ sasl_fed_ex_dynamic
+ sasl_fed_ex_link
+ sasl_fed_ex_queue
+ sasl_fed_ex_route
+ sasl_no_dir
+
+if HAVE_LIBCPG
+
+TESTS += run_cluster_authentication_test \
+ sasl_fed_ex_route_cluster \
+ sasl_fed_ex_link_cluster \
+ sasl_fed_ex_queue_cluster \
+ sasl_fed_ex_dynamic_cluster
+
LONG_TESTS += run_cluster_authentication_soak
+
+endif HAVE_LIBCPG
+
EXTRA_DIST += run_cluster_authentication_test \
sasl_fed \
sasl_fed_ex \
diff --git a/cpp/src/tests/sasl_fed b/cpp/src/tests/sasl_fed
index 884c44177c..9dc2dd46e2 100755
--- a/cpp/src/tests/sasl_fed
+++ b/cpp/src/tests/sasl_fed
@@ -90,23 +90,23 @@ EXCHANGE_NAME=sasl_fedex
#--------------------------------------------------
#echo " add exchanges"
#--------------------------------------------------
-$QPID_CONFIG_EXEC -a localhost:$broker_1_port add exchange direct $EXCHANGE_NAME
-$QPID_CONFIG_EXEC -a localhost:$broker_2_port add exchange direct $EXCHANGE_NAME
+$QPID_CONFIG_EXEC -b localhost:$broker_1_port add exchange direct $EXCHANGE_NAME
+$QPID_CONFIG_EXEC -b localhost:$broker_2_port add exchange direct $EXCHANGE_NAME
#--------------------------------------------------
#echo " add queues"
#--------------------------------------------------
-$QPID_CONFIG_EXEC -a localhost:$broker_1_port add queue $QUEUE_NAME
-$QPID_CONFIG_EXEC -a localhost:$broker_2_port add queue $QUEUE_NAME
+$QPID_CONFIG_EXEC -b localhost:$broker_1_port add queue $QUEUE_NAME
+$QPID_CONFIG_EXEC -b localhost:$broker_2_port add queue $QUEUE_NAME
sleep 5
#--------------------------------------------------
#echo " create bindings"
#--------------------------------------------------
-$QPID_CONFIG_EXEC -a localhost:$broker_1_port bind $EXCHANGE_NAME $QUEUE_NAME $ROUTING_KEY
-$QPID_CONFIG_EXEC -a localhost:$broker_2_port bind $EXCHANGE_NAME $QUEUE_NAME $ROUTING_KEY
+$QPID_CONFIG_EXEC -b localhost:$broker_1_port bind $EXCHANGE_NAME $QUEUE_NAME $ROUTING_KEY
+$QPID_CONFIG_EXEC -b localhost:$broker_2_port bind $EXCHANGE_NAME $QUEUE_NAME $ROUTING_KEY
sleep 5
@@ -130,13 +130,13 @@ sleep 5
#--------------------------------------------------
#echo " Examine Broker $broker_1_port"
#--------------------------------------------------
-broker_1_message_count=`$PYTHON_COMMANDS/qpid-stat -q localhost:$broker_1_port | grep sasl_fed_queue | awk '{print $2}'`
+broker_1_message_count=`$PYTHON_COMMANDS/qpid-stat -q -b localhost:$broker_1_port | grep sasl_fed_queue | awk '{print $2}'`
#echo " "
#--------------------------------------------------
#echo " Examine Broker $broker_2_port"
#--------------------------------------------------
-broker_2_message_count=`$PYTHON_COMMANDS/qpid-stat -q localhost:$broker_2_port | grep sasl_fed_queue | awk '{print $2}'`
+broker_2_message_count=`$PYTHON_COMMANDS/qpid-stat -q -b localhost:$broker_2_port | grep sasl_fed_queue | awk '{print $2}'`
#echo " "
#--------------------------------------------------
diff --git a/cpp/src/tests/sasl_fed_ex b/cpp/src/tests/sasl_fed_ex
index 716a806874..cc5b310067 100755
--- a/cpp/src/tests/sasl_fed_ex
+++ b/cpp/src/tests/sasl_fed_ex
@@ -280,18 +280,18 @@ EXCHANGE_NAME=sasl_fedex
print "add exchanges"
-$QPID_CONFIG_EXEC -a localhost:${SRC_TCP_PORT} add exchange direct $EXCHANGE_NAME
-$QPID_CONFIG_EXEC -a localhost:${DST_TCP_PORT} add exchange direct $EXCHANGE_NAME
+$QPID_CONFIG_EXEC -b localhost:${SRC_TCP_PORT} add exchange direct $EXCHANGE_NAME
+$QPID_CONFIG_EXEC -b localhost:${DST_TCP_PORT} add exchange direct $EXCHANGE_NAME
print "add queues"
-$QPID_CONFIG_EXEC -a localhost:${SRC_TCP_PORT} add queue $QUEUE_NAME
-$QPID_CONFIG_EXEC -a localhost:${DST_TCP_PORT} add queue $QUEUE_NAME
+$QPID_CONFIG_EXEC -b localhost:${SRC_TCP_PORT} add queue $QUEUE_NAME
+$QPID_CONFIG_EXEC -b localhost:${DST_TCP_PORT} add queue $QUEUE_NAME
print "create bindings"
-$QPID_CONFIG_EXEC -a localhost:${SRC_TCP_PORT} bind $EXCHANGE_NAME $QUEUE_NAME $ROUTING_KEY
-$QPID_CONFIG_EXEC -a localhost:${DST_TCP_PORT} bind $EXCHANGE_NAME $QUEUE_NAME $ROUTING_KEY
+$QPID_CONFIG_EXEC -b localhost:${SRC_TCP_PORT} bind $EXCHANGE_NAME $QUEUE_NAME $ROUTING_KEY
+$QPID_CONFIG_EXEC -b localhost:${DST_TCP_PORT} bind $EXCHANGE_NAME $QUEUE_NAME $ROUTING_KEY
#
diff --git a/cpp/src/tests/sasl_fed_ex_dynamic_cluster b/cpp/src/tests/sasl_fed_ex_dynamic_cluster
index b0cceccecb..fd6b72a4f2 100755
--- a/cpp/src/tests/sasl_fed_ex_dynamic_cluster
+++ b/cpp/src/tests/sasl_fed_ex_dynamic_cluster
@@ -21,7 +21,9 @@
source ./test_env.sh
-source $srcdir/ais_check
+source cpg_check.sh
+cpg_enabled || exit 0
+
with_ais_group ${srcdir}/sasl_fed_ex dynamic cluster
diff --git a/cpp/src/tests/sasl_fed_ex_link_cluster b/cpp/src/tests/sasl_fed_ex_link_cluster
index 4139300b12..34b2aa4a5f 100755
--- a/cpp/src/tests/sasl_fed_ex_link_cluster
+++ b/cpp/src/tests/sasl_fed_ex_link_cluster
@@ -21,7 +21,8 @@
source ./test_env.sh
-source $srcdir/ais_check
+source cpg_check.sh
+cpg_enabled || exit 0
with_ais_group ${srcdir}/sasl_fed_ex link cluster
diff --git a/cpp/src/tests/sasl_fed_ex_queue_cluster b/cpp/src/tests/sasl_fed_ex_queue_cluster
index f251420e08..14f36f6fc4 100755
--- a/cpp/src/tests/sasl_fed_ex_queue_cluster
+++ b/cpp/src/tests/sasl_fed_ex_queue_cluster
@@ -21,7 +21,8 @@
source ./test_env.sh
-source ${srcdir}/ais_check
+source cpg_check.sh
+cpg_enabled || exit 0
with_ais_group ${srcdir}/sasl_fed_ex queue cluster
diff --git a/cpp/src/tests/sasl_fed_ex_route_cluster b/cpp/src/tests/sasl_fed_ex_route_cluster
index a5d1542def..756476056e 100755
--- a/cpp/src/tests/sasl_fed_ex_route_cluster
+++ b/cpp/src/tests/sasl_fed_ex_route_cluster
@@ -21,7 +21,8 @@
source ./test_env.sh
-source ${srcdir}/ais_check
+source cpg_check.sh
+cpg_enabled || exit 0
with_ais_group ${srcdir}/sasl_fed_ex route cluster
diff --git a/cpp/src/tests/ssl_test b/cpp/src/tests/ssl_test
index 4dbb7df392..91ff8eec1e 100755
--- a/cpp/src/tests/ssl_test
+++ b/cpp/src/tests/ssl_test
@@ -100,8 +100,10 @@ start_ssl_mux_broker() {
PORTS=( ${PORTS[@]} $1 )
}
+sasl_config_dir=$builddir/sasl_config
+
start_authenticating_broker() {
- start_brokers 1 "--transport ssl --ssl-port 0 --require-encryption --ssl-sasl-no-dict --ssl-require-client-authentication --auth yes"
+ start_brokers 1 "--transport ssl --ssl-port 0 --require-encryption --ssl-sasl-no-dict --ssl-require-client-authentication --auth yes --sasl-config=${sasl_config_dir}"
}
ssl_cluster_broker() { # $1 = port
@@ -140,6 +142,12 @@ URL=amqp:ssl:$TEST_HOSTNAME:$PORT
MSG=`./qpid-receive -b $URL -a "foo;{create:always}" --messages 1`
test "$MSG" = "hello" || { echo "receive failed '$MSG' != 'hello'"; exit 1; }
+## Test connection with a combination of URL and connection options (in messaging API)
+URL=$TEST_HOSTNAME:$PORT
+./qpid-send -b $URL --connection-options '{transport:ssl,heartbeat:2}' --content-string='hello again' -a "foo;{create:always}"
+MSG=`./qpid-receive -b $URL --connection-options '{transport:ssl,heartbeat:2}' -a "foo;{create:always}" --messages 1`
+test "$MSG" = "hello again" || { echo "receive failed '$MSG' != 'hello again'"; exit 1; }
+
#### Client Authentication tests
start_authenticating_broker
@@ -184,7 +192,8 @@ stop_brokers
test -z $CLUSTER_LIB && exit 0 # Exit if cluster not supported.
## Test failover in a cluster using SSL only
-. $srcdir/ais_check # Will exit if clustering not enabled.
+source cpg_check.sh
+cpg_enabled || exit 0
PORT1=`pick_port`; ssl_cluster_broker $PORT1
echo "Running SSL cluster broker on port $PORT1"
diff --git a/cpp/src/tests/start_cluster b/cpp/src/tests/start_cluster
index 84f98b3b2d..78fd104d9c 100755
--- a/cpp/src/tests/start_cluster
+++ b/cpp/src/tests/start_cluster
@@ -24,7 +24,8 @@
# Execute command with the ais group set.
source ./test_env.sh
-. `dirname $0`/ais_check
+source cpg_check.sh
+cpg_enabled || exit 0
rm -f cluster*.log cluster.ports qpidd.port
diff --git a/cpp/src/tests/test_env.ps1.in b/cpp/src/tests/test_env.ps1.in
new file mode 100644
index 0000000000..60ba4305a5
--- /dev/null
+++ b/cpp/src/tests/test_env.ps1.in
@@ -0,0 +1,78 @@
+#
+# 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.
+#
+
+# Environment variables substituted by configure/cmake.
+$srcdir="@abs_srcdir@"
+$builddir="@abs_builddir@"
+$top_srcdir="@abs_top_srcdir@"
+$top_builddir="@abs_top_builddir@"
+$moduledir="$top_builddir\src@builddir_lib_suffix@"
+$testmoduledir="$builddir@builddir_lib_suffix@"
+
+# Python paths and directories
+$PYTHON_DIR="$builddir\python"
+$QPID_PYTHON_TEST="$PYTHON_DIR\commands\qpid-python-test"
+if ( !(Test-Path "$PYTHON_DIR") -and (Test-Path "$top_srcdir\..\python")) {
+ $PYTHON_DIR="$top_srcdir\..\python"
+ $QPID_PYTHON_TEST="$PYTHON_DIR\qpid-python-test"
+}
+$QPID_TESTS="$top_srcdir\..\tests"
+$QPID_TESTS_PY="$QPID_TESTS\src\py"
+$QPID_TOOLS="$top_srcdir\..\tools"
+$QPID_TOOLS_LIBS="$QPID_TOOLS\src\py"
+$QMF_LIB="$top_srcdir\..\extras\qmf\src\py"
+$PYTHON_COMMANDS="$QPID_TOOLS\src\py"
+$env:PYTHONPATH="$srcdir;$PYTHON_DIR;$PYTHON_COMMANDS;$QPID_TESTS_PY;$QPID_TOOLS_LIBS;$QMF_LIB;$env:PYTHONPATH"
+$QPID_CONFIG_EXEC="$PYTHON_COMMANDS\qpid-config"
+$QPID_ROUTE_EXEC="$PYTHON_COMMANDS\qpid-route"
+$QPID_CLUSTER_EXEC="$PYTHON_COMMANDS\qpid-cluster"
+$QPID_HA_TOOL_EXEC="$PYTHON_COMMANDS\qpid-ha-tool"
+
+# Executables
+$env:QPIDD_EXEC="$top_builddir\src\qpidd"
+$env:QPID_WATCHDOG_EXEC="$top_builddir\src\qpidd_watchdog"
+
+# Test executables
+$QPID_TEST_EXEC_DIR="$builddir"
+$RECEIVER_EXEC="$QPID_TEST_EXEC_DIR\receiver"
+$SENDER_EXEC="$QPID_TEST_EXEC_DIR\sender"
+
+# Path
+$env:PATH="$top_builddir\src;$builddir;$srcdir;$PYTHON_COMMANDS;$QPID_TEST_EXEC_DIR;$env:PATH"
+
+# Modules
+$env:TEST_STORE_LIB="$testmoduledir\test_store.so"
+
+#exportmodule() { test -f $moduledir/$2 && eval "export $1=$moduledir/$2"; }
+#exportmodule ACL_LIB acl.so
+#exportmodule CLUSTER_LIB cluster.so
+#exportmodule REPLICATING_LISTENER_LIB replicating_listener.so
+#exportmodule REPLICATION_EXCHANGE_LIB replication_exchange.so
+#exportmodule SSLCONNECTOR_LIB sslconnector.so
+#exportmodule SSL_LIB ssl.so
+#exportmodule WATCHDOG_LIB watchdog.so
+#exportmodule XML_LIB xml.so
+
+# Qpid options
+$env:QPID_NO_MODULE_DIR="1" # Don't accidentally load installed modules
+$env:QPID_DATA_DIR= # Default to no data dir, not ~/.qpidd
+
+# Options for boost test framework
+$env:BOOST_TEST_SHOW_PROGRESS="yes"
+$env:BOOST_TEST_CATCH_SYSTEM_ERRORS="no"
diff --git a/cpp/src/tests/test_env.sh.in b/cpp/src/tests/test_env.sh.in
index 0cd658bd80..cee36843ae 100644
--- a/cpp/src/tests/test_env.sh.in
+++ b/cpp/src/tests/test_env.sh.in
@@ -44,6 +44,7 @@ export PYTHONPATH=$srcdir:$PYTHON_DIR:$PYTHON_COMMANDS:$QPID_TESTS_PY:$QMF_LIB:$
export QPID_CONFIG_EXEC=$PYTHON_COMMANDS/qpid-config
export QPID_ROUTE_EXEC=$PYTHON_COMMANDS/qpid-route
export QPID_CLUSTER_EXEC=$PYTHON_COMMANDS/qpid-cluster
+export QPID_HA_EXEC=$PYTHON_COMMANDS/qpid-ha
# Executables
export QPIDD_EXEC=$top_builddir/src/qpidd
@@ -74,6 +75,7 @@ exportmodule XML_LIB xml.so
# Qpid options
export QPID_NO_MODULE_DIR=1 # Don't accidentally load installed modules
export QPID_DATA_DIR=
+export QPID_CONFIG=$srcdir/qpidd-empty.conf
# Use temporary directory if $HOME does not exist
if [ ! -e "$HOME" ]; then
diff --git a/cpp/src/tests/testagent.cpp b/cpp/src/tests/testagent.cpp
index 98520b424a..e6010a8e00 100644
--- a/cpp/src/tests/testagent.cpp
+++ b/cpp/src/tests/testagent.cpp
@@ -36,9 +36,12 @@
#include <sstream>
+namespace qpid {
+namespace tests {
+
static bool running = true;
-using namespace std;
+using std::string;
using qpid::management::ManagementAgent;
using qpid::management::ManagementObject;
using qpid::management::Manageable;
@@ -191,12 +194,14 @@ int main_int(int argc, char** argv)
return 0;
}
+}} // namespace qpid::tests
+
int main(int argc, char** argv)
{
try {
- return main_int(argc, argv);
+ return qpid::tests::main_int(argc, argv);
} catch(std::exception& e) {
- cerr << "Top Level Exception: " << e.what() << endl;
+ std::cerr << "Top Level Exception: " << e.what() << std::endl;
return 1;
}
}
diff --git a/cpp/src/tests/testlib.py b/cpp/src/tests/testlib.py
index fe57a84a81..71ad59e5c1 100644
--- a/cpp/src/tests/testlib.py
+++ b/cpp/src/tests/testlib.py
@@ -348,8 +348,8 @@ class TestBaseCluster(TestBase):
def _qpidConfig(self, nodeNumber, clusterName, action):
"""Configure some aspect of a qpid broker using the qpid_config executable"""
port = self.getNodeTuple(nodeNumber, clusterName)[self.PORT]
- #print "%s -a localhost:%d %s" % (self._qpidConfigExec, port, action)
- ret = os.spawnl(os.P_WAIT, self._qpidConfigExec, self._qpidConfigExec, "-a", "localhost:%d" % port, *action.split())
+ #print "%s -b localhost:%d %s" % (self._qpidConfigExec, port, action)
+ ret = os.spawnl(os.P_WAIT, self._qpidConfigExec, self._qpidConfigExec, "-b", "localhost:%d" % port, *action.split())
if ret != 0:
raise Exception("_qpidConfig(): cluster=\"%s\" nodeNumber=%d port=%d action=\"%s\" returned %d" % \
(clusterName, nodeNumber, port, action, ret))
diff --git a/cpp/src/tests/windows/DisableWin32ErrorWindows.cpp b/cpp/src/tests/windows/DisableWin32ErrorWindows.cpp
index 024f20b147..14f1e46606 100644
--- a/cpp/src/tests/windows/DisableWin32ErrorWindows.cpp
+++ b/cpp/src/tests/windows/DisableWin32ErrorWindows.cpp
@@ -32,7 +32,9 @@
#include <windows.h>
#include <iostream>
-namespace {
+namespace qpid {
+namespace tests {
+namespace windows {
// Instead of popping up a window for exceptions, just print something out
LONG _stdcall UnhandledExceptionFilter (PEXCEPTION_POINTERS pExceptionInfo)
@@ -73,4 +75,4 @@ redirect_errors_to_stderr::redirect_errors_to_stderr()
SetUnhandledExceptionFilter (&UnhandledExceptionFilter);
}
-} // namespace
+}}} // namespace