From 83b4417af81df92cb640de1694488156ba29d85f Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Mon, 2 Jul 2007 22:35:33 +0000 Subject: 2007-06-30 * 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/qpid@552614 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/tests/Cluster.cpp | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) (limited to 'cpp/src/tests/Cluster.cpp') diff --git a/cpp/src/tests/Cluster.cpp b/cpp/src/tests/Cluster.cpp index 008575140b..2ec140b924 100644 --- a/cpp/src/tests/Cluster.cpp +++ b/cpp/src/tests/Cluster.cpp @@ -20,51 +20,52 @@ #include #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 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)); } } -- cgit v1.2.1