diff options
author | Alan Conway <aconway@apache.org> | 2007-07-02 22:35:33 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2007-07-02 22:35:33 +0000 |
commit | eb7f88e2818ddb98bc02ff7fc39c936d421d16d8 (patch) | |
tree | bd50d2cae9f686436513620f50eecfeac06d5585 /qpid/cpp/src/tests/Cluster.cpp | |
parent | 8380592eddec548cf70bc63cd43be886ea68a57f (diff) | |
download | qpid-python-eb7f88e2818ddb98bc02ff7fc39c936d421d16d8.tar.gz |
2007-06-30 <aconway@redhat.com>
* src/qpid/cluster/Cluster.cpp: Refactor - expose 4 handler points
for all traffic to/from cluster. Removed HandlerUpdater functionality,
separate class. Cluster only deals with membership and connecting
the 4 handler points to CPG multicast.
* src/tests/cluster.mk: Dropped newgrp ais wrapper scripts, its
much simpler if the user just does "newgrp ais" before building.
* src/tests/ais_check: Test script to check if users gid is ais
and give clear notice if not.
* src/tests/Cluster.cpp: Updated for changes to Cluster.
* src/qpid/cluster/Cpg.cpp: Better messages for common errors.
* Handler.h: Remove nextHandler() minor convenience is outweighted
by risk of undetected errors if handlers that expect next() to be
set are called when it's not set.
* src/qpid/cluster/Cpg.cpp: Added logging. Replaced boost::function
with traditional virtual interface (nasty stack traces.)
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@552614 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src/tests/Cluster.cpp')
-rw-r--r-- | qpid/cpp/src/tests/Cluster.cpp | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/qpid/cpp/src/tests/Cluster.cpp b/qpid/cpp/src/tests/Cluster.cpp index 008575140b..2ec140b924 100644 --- a/qpid/cpp/src/tests/Cluster.cpp +++ b/qpid/cpp/src/tests/Cluster.cpp @@ -20,51 +20,52 @@ #include <boost/test/auto_unit_test.hpp> #include "test_tools.h" #include "Cluster.h" +#include "qpid/framing/ChannelPingBody.h" #include "qpid/framing/ChannelOkBody.h" -#include "qpid/framing/BasicGetOkBody.h" - static const ProtocolVersion VER; -/** Verify membership ind a cluster with one member. */ +using namespace qpid::log; + +/** Verify membership in a cluster with one member. */ BOOST_AUTO_TEST_CASE(clusterOne) { - Cluster cluster("Test", "amqp:one:1"); - TestClusterHandler handler(cluster); - AMQFrame frame(VER, 1, new ChannelOkBody(VER)); - cluster.handle(frame); - BOOST_REQUIRE(handler.waitFrames(1)); + TestCluster cluster("clusterOne", "amqp:one:1"); + AMQFrame frame(VER, 1, new ChannelPingBody(VER)); + cluster.getToChains().in->handle(frame); + BOOST_REQUIRE(cluster.in.waitFor(1)); + + BOOST_CHECK_TYPEID_EQUAL(ChannelPingBody, *cluster.in[0].getBody()); BOOST_CHECK_EQUAL(1u, cluster.size()); Cluster::MemberList members = cluster.getMembers(); BOOST_CHECK_EQUAL(1u, members.size()); - BOOST_REQUIRE_EQUAL(members.front()->url, "amqp:one:1"); - BOOST_CHECK_EQUAL(1u, handler.size()); - BOOST_CHECK_TYPEID_EQUAL(ChannelOkBody, *handler[0].getBody()); + shared_ptr<const Cluster::Member> me=members.front(); + BOOST_REQUIRE_EQUAL(me->url, "amqp:one:1"); } -/** Fork a process to verify membership in a cluster with two members */ +/** Fork a process to test a cluster with two members */ BOOST_AUTO_TEST_CASE(clusterTwo) { pid_t pid=fork(); BOOST_REQUIRE(pid >= 0); - if (pid) { // Parent see Cluster_child.cpp for child. - Cluster cluster("Test", "amqp::1"); - TestClusterHandler handler(cluster); - BOOST_REQUIRE(handler.waitMembers(2)); + if (pid) { // Parent, see Cluster_child.cpp for child. + TestCluster cluster("clusterTwo", "amqp::1"); + BOOST_REQUIRE(cluster.waitFor(2)); // Myself and child. // Exchange frames with child. - AMQFrame frame(VER, 1, new ChannelOkBody(VER)); - cluster.handle(frame); - BOOST_REQUIRE(handler.waitFrames(2)); - BOOST_CHECK_TYPEID_EQUAL(ChannelOkBody, *handler[0].getBody()); - BOOST_CHECK_TYPEID_EQUAL(BasicGetOkBody, *handler[1].getBody()); + AMQFrame frame(VER, 1, new ChannelPingBody(VER)); + cluster.getToChains().in->handle(frame); + BOOST_REQUIRE(cluster.in.waitFor(1)); + BOOST_CHECK_TYPEID_EQUAL(ChannelPingBody, *cluster.in[0].getBody()); + BOOST_REQUIRE(cluster.out.waitFor(1)); + BOOST_CHECK_TYPEID_EQUAL(ChannelOkBody, *cluster.out[0].getBody()); // Wait for child to exit. int status; BOOST_CHECK_EQUAL(::wait(&status), pid); BOOST_CHECK_EQUAL(0, status); - BOOST_CHECK(handler.waitMembers(1)); + BOOST_CHECK(cluster.waitFor(1)); BOOST_CHECK_EQUAL(1u, cluster.size()); } else { // Child - BOOST_REQUIRE(execl("Cluster_child", "Cluster_child", NULL)); + BOOST_REQUIRE(execl("./Cluster_child", "./Cluster_child", NULL)); } } |