[asterisk-scf-commits] asterisk-scf/integration/routing.git branch "retry_deux" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Mon Apr 16 12:42:39 CDT 2012


branch "retry_deux" has been updated
       via  e5215d3ced9f44957497b74152c687c7c9e6cfdb (commit)
      from  c94100e55d40217387944ec8d339281cde69dfe2 (commit)

Summary of changes:
 src/EndpointRegistry.cpp       |   86 +++++++++++++++++++--
 test/CMakeLists.txt            |    2 +
 test/MockBridgeManager.cpp     |    2 +
 test/MockBridgeManager.h       |    4 +-
 test/MockEndpointLocator.cpp   |    6 +-
 test/MockEndpointLocator.h     |    4 +-
 test/RoutingEventsListener.cpp |   91 ++++++++++++++++++++++
 test/RoutingEventsListener.h   |   76 ++++++++++++++++++
 test/SharedTestData.h          |    3 +
 test/TestRouting.cpp           |  164 ++++++++++++++++++++++++++++++++++++++--
 10 files changed, 416 insertions(+), 22 deletions(-)
 create mode 100644 test/RoutingEventsListener.cpp
 create mode 100644 test/RoutingEventsListener.h


- Log -----------------------------------------------------------------
commit e5215d3ced9f44957497b74152c687c7c9e6cfdb
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Mon Apr 16 12:42:06 2012 -0500

    Updated unit tests to test the retry logic. Also fixed a replication issue for the clearEndpointLocators() operation.

diff --git a/src/EndpointRegistry.cpp b/src/EndpointRegistry.cpp
index add7281..211ed4b 100644
--- a/src/EndpointRegistry.cpp
+++ b/src/EndpointRegistry.cpp
@@ -131,8 +131,11 @@ public:
         const std::string& locatorId, 
         Event::OperationResult result)
     {
-        // Forward to event publisher.
-        mEventPublisher->removeEndpointLocatorEvent(operationContext, locatorId, result);
+        if (mReplicationContext->isActive())
+        {
+            // Forward to event publisher.
+            mEventPublisher->removeEndpointLocatorEvent(operationContext, locatorId, result);
+        }
 
         if (!mReplicationContext->isReplicating())
         {
@@ -163,6 +166,47 @@ public:
     }
 
     /**
+     * Forwards the result of processing a clearEndpointLocators() operation. 
+     */
+    void forwardClearEndpointLocators(
+        const OperationContextPtr& operationContext,
+        const vector<string>& keys)
+    {
+        if (mReplicationContext->isActive())
+        {
+            // Forward to event publisher.
+            mEventPublisher->clearEndpointLocatorsEvent(operationContext);
+        }
+
+        if (!mReplicationContext->isReplicating())
+        {
+            return;
+        }
+
+        // Forward to state replicator
+        try
+        {
+            // Push this information to the state replicator.
+            RoutingStateItemSeq removeItems;
+
+            vector<string>::const_iterator iter;
+            for (iter = keys.begin(); iter != keys.end(); iter++)
+            {
+                EndpointLocatorStatePtr addEndpointItem(new EndpointLocatorState());
+                addEndpointItem->initiatingContext = operationContext;
+                addEndpointItem->key = *iter;
+                removeItems.push_back(addEndpointItem);
+            }
+            lg(Debug) << BOOST_CURRENT_FUNCTION << ": Sending replicator state removal for all locators. ";
+            mReplicationContext->getReplicator()->removeStateForItems(AsteriskSCF::Operations::createContext(), removeItems);
+        }
+        catch(const Ice::Exception& e)
+        {
+                lg(Debug) << "EndpointRegistry unable to replicate clearEndpointLocator(): " << e.what();
+        }
+    }
+
+    /**
      * Forwards the result of processing a remove endpoint operation. 
      */
     void forwardAddEndpointLocator(const OperationContextPtr& operationContext,
@@ -171,8 +215,11 @@ public:
                                    const EndpointLocatorPrx& locator, 
                                    Event::OperationResult result)
     {
-        // Forward to event publisher.
-        mEventPublisher->addEndpointLocatorEvent(operationContext, locatorId, regexList, locator, result);
+        if (mReplicationContext->isActive())
+        {
+            // Forward to event publisher.
+            mEventPublisher->addEndpointLocatorEvent(operationContext, locatorId, regexList, locator, result);
+        }
 
         if (!mReplicationContext->isReplicating())
         {
@@ -213,7 +260,10 @@ public:
                                             const EndpointLocatorPrx& locator, 
                                             OperationResult result)
     {
-        mEventPublisher->setEndpointLocatorDestinationIdsEvent(operationContext, locatorId, regexList, result);
+        if (mReplicationContext->isActive())
+        {
+            mEventPublisher->setEndpointLocatorDestinationIdsEvent(operationContext, locatorId, regexList, result);
+        }
 
         if (!mReplicationContext->isReplicating())
         {
@@ -603,8 +653,23 @@ void EndpointRegistry::clearEndpointLocators(const OperationContextPtr& operatio
         return;
     }
 
-    mImpl->clearEndpointLocatorMap();
-    mImpl->mEventPublisher->clearEndpointLocatorsEvent(operationContext);
+    // Grab the keys being removed. 
+    vector<string> keys;
+    { // scope the lock
+        boost::unique_lock<boost::shared_mutex> lock(mImpl->mLock);
+        map<std::string, RegisteredLocator>::const_iterator iter;
+
+        for (iter = mImpl->mEndpointLocatorMap.begin(); iter != mImpl->mEndpointLocatorMap.end(); ++iter) 
+        {
+            keys.push_back(iter->first);
+        }
+
+        // Since we've got the lock, clear the map now.
+        mImpl->mEndpointLocatorMap.clear();
+    }
+
+    mImpl->forwardClearEndpointLocators(operationContext, keys);
+
     contextData->setCompleted();
 }
 
@@ -626,7 +691,12 @@ void EndpointRegistry::setPolicy(const OperationContextPtr& operationContext, co
     try
     {
         mImpl->mScriptProcessor->setPolicy(policy);
-        mImpl->mEventPublisher->setPolicyEvent(operationContext, policy);
+
+        if (mImpl->mReplicationContext->isActive())
+        {
+            mImpl->mEventPublisher->setPolicyEvent(operationContext, policy);
+        }
+
         contextData->setCompleted();
     }
     catch (const std::exception& e)
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 4acc107..f620789 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -14,6 +14,8 @@ astscf_component_add_files(RoutingTest MockSessionEndpoint.h)
 astscf_component_add_files(RoutingTest MockSessionEndpoint.cpp)
 astscf_component_add_files(RoutingTest MockEndpointLocator.h)
 astscf_component_add_files(RoutingTest MockEndpointLocator.cpp)
+astscf_component_add_files(RoutingTest RoutingEventsListener.h)
+astscf_component_add_files(RoutingTest RoutingEventsListener.cpp)
 astscf_component_add_ice_libraries(RoutingTest IceStorm)
 astscf_component_add_boost_libraries(RoutingTest unit_test_framework)
 astscf_component_add_slice_collection_libraries(RoutingTest ASTSCF)
diff --git a/test/MockBridgeManager.cpp b/test/MockBridgeManager.cpp
index e12a4e2..d8d003c 100644
--- a/test/MockBridgeManager.cpp
+++ b/test/MockBridgeManager.cpp
@@ -50,6 +50,8 @@ void MockBridgeManager::createBridge_async(const AMD_BridgeManager_createBridgeP
         mBridges.push_back(bridgePrx);
 
         callback->ice_response(bridgePrx);
+
+        mBridgeCreationCount++;
     }
     catch (const std::exception& ex)
     {
diff --git a/test/MockBridgeManager.h b/test/MockBridgeManager.h
index 4387f6c..71c9c11 100644
--- a/test/MockBridgeManager.h
+++ b/test/MockBridgeManager.h
@@ -26,7 +26,7 @@ namespace RoutingTest
 class MockBridgeManager : public AsteriskSCF::SessionCommunications::V1::BridgeManager
 {
 public:
-    MockBridgeManager()
+    MockBridgeManager() : mBridgeCreationCount(0)
     {
     }
 
@@ -50,6 +50,8 @@ public:
     AsteriskSCF::SessionCommunications::V1::BridgeSeq listBridges(const Ice::Current&);
     void shutdown(const AsteriskSCF::System::V1::OperationContextPtr &,const ::Ice::Current&);
 
+    int mBridgeCreationCount;
+
 private:
     std::vector<AsteriskSCF::SessionCommunications::V1::BridgePtr> mBridgeServants;
     AsteriskSCF::SessionCommunications::V1::BridgeSeq mBridges;
diff --git a/test/MockEndpointLocator.cpp b/test/MockEndpointLocator.cpp
index 32036c2..a7402a2 100644
--- a/test/MockEndpointLocator.cpp
+++ b/test/MockEndpointLocator.cpp
@@ -64,7 +64,7 @@ void MockEndpointLocator::lookup_async(const ::AsteriskSCF::Core::Routing::V1::A
     }
     cb->ice_response(endpoints);
 
-    mLookupCalled = true;
+    mLookupCount++;
 }
 
 void MockEndpointLocator::perTestCleanup()
@@ -74,7 +74,7 @@ void MockEndpointLocator::perTestCleanup()
         (*i)->perTestCleanup();
     }
 
-    mLookupCalled = false;
+    mLookupCount = 0;
 }
 
 void MockEndpointLocator::clear()
@@ -87,7 +87,7 @@ void MockEndpointLocator::clear()
     mEndpointPrxList.clear();
     mEndpoints.clear();
 
-    mLookupCalled = false;
+    mLookupCount = 0;
 }
 
 MockSessionEndpointPtr MockEndpointLocator::addEndpoint(const string& id)
diff --git a/test/MockEndpointLocator.h b/test/MockEndpointLocator.h
index 9eb20f3..7020cd9 100644
--- a/test/MockEndpointLocator.h
+++ b/test/MockEndpointLocator.h
@@ -30,7 +30,7 @@ namespace RoutingTest
 class MockEndpointLocator : public AsteriskSCF::Core::Routing::V1::EndpointLocator
 {
 public:
-    MockEndpointLocator() : mLookupCalled(false) {}
+    MockEndpointLocator() : mLookupCount(0) {}
 
     // Overrides
     virtual void lookup_async(const ::AsteriskSCF::Core::Routing::V1::AMD_EndpointLocator_lookupPtr& cb, const ::std::string& destination, const ::Ice::Current& = ::Ice::Current());
@@ -45,7 +45,7 @@ public:
      */
     MockSessionEndpointPtr localLookup(const std::string& id);
 
-    bool mLookupCalled;
+    int mLookupCount;
 
 private:
     AsteriskSCF::Core::Endpoint::V1::EndpointSeq mEndpointPrxList;
diff --git a/test/RoutingEventsListener.cpp b/test/RoutingEventsListener.cpp
new file mode 100644
index 0000000..19bb284
--- /dev/null
+++ b/test/RoutingEventsListener.cpp
@@ -0,0 +1,91 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2012, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk SCF project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE.txt file
+ * at the top of the source tree.
+ */
+#include"RoutingEventsListener.h"
+
+using namespace AsteriskSCF::Core::Routing::V1::Event;
+using namespace AsteriskSCF::System::V1;
+using namespace AsteriskSCF::Core::Routing::V1;
+using namespace std;
+
+namespace AsteriskSCF
+{
+namespace RoutingTest
+{
+
+RoutingEventsListener::RoutingEventsListener() 
+    : mLookupEventCount(0),
+        mAddEndpointLocatorEventCount(0)
+{
+
+}
+
+void RoutingEventsListener::lookupEvent(
+    const OperationContextPtr& operationContext, 
+    const string& destinationId, 
+    OperationResult result, 
+    const Ice::Current&)
+{
+    if (result == SUCCESS)
+    {
+        mLookupEventCount++;
+    }
+}
+
+void RoutingEventsListener::addEndpointLocatorEvent(
+    const OperationContextPtr& operationContext, 
+    const string& id, const RegExSeq& destinationIdRangeList, 
+    const EndpointLocatorPrx& locator, 
+    OperationResult result, 
+    const Ice::Current&)
+{
+    if (result == SUCCESS)
+    {
+        mAddEndpointLocatorEventCount++;
+    }
+}
+
+void RoutingEventsListener::removeEndpointLocatorEvent(
+    const ::AsteriskSCF::System::V1::OperationContextPtr&, 
+    const ::std::string&, 
+    AsteriskSCF::Core::Routing::V1::Event::OperationResult, 
+    const Ice::Current&)
+{
+}
+
+void RoutingEventsListener::setEndpointLocatorDestinationIdsEvent(
+    const ::AsteriskSCF::System::V1::OperationContextPtr&, 
+    const ::std::string&, 
+    const ::AsteriskSCF::Core::Routing::V1::RegExSeq&, 
+    ::AsteriskSCF::Core::Routing::V1::Event::OperationResult, 
+    const Ice::Current&)
+{
+}
+
+void RoutingEventsListener::clearEndpointLocatorsEvent(
+    const ::AsteriskSCF::System::V1::OperationContextPtr&, 
+    const Ice::Current&)
+{
+}
+
+void RoutingEventsListener::setPolicyEvent(
+    const ::AsteriskSCF::System::V1::OperationContextPtr&, 
+    const ::std::string&, 
+    const Ice::Current&)
+{
+}
+
+} // RoutingTest
+} // AsteriskSCF
diff --git a/test/RoutingEventsListener.h b/test/RoutingEventsListener.h
new file mode 100644
index 0000000..5024256
--- /dev/null
+++ b/test/RoutingEventsListener.h
@@ -0,0 +1,76 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2012, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk SCF project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE.txt file
+ * at the top of the source tree.
+ */
+#pragma once
+
+#include <IceStorm/IceStorm.h>
+#include <AsteriskSCF/Core/Routing/RoutingIf.h>
+
+namespace AsteriskSCF
+{
+namespace RoutingTest
+{
+
+class RoutingEventsListener : public AsteriskSCF::Core::Routing::V1::Event::RoutingEvents
+{
+public:
+    RoutingEventsListener();
+
+    void lookupEvent(
+        const ::AsteriskSCF::System::V1::OperationContextPtr& operationContext, 
+        const ::std::string& destinationId, 
+        ::AsteriskSCF::Core::Routing::V1::Event::OperationResult result, 
+        const Ice::Current&);
+
+    void addEndpointLocatorEvent(
+        const ::AsteriskSCF::System::V1::OperationContextPtr& operationContext, 
+        const ::std::string& id, const ::AsteriskSCF::Core::Routing::V1::RegExSeq& destinationIdRangeList, 
+        const ::AsteriskSCF::Core::Routing::V1::EndpointLocatorPrx& locator, 
+        ::AsteriskSCF::Core::Routing::V1::Event::OperationResult result, 
+        const Ice::Current&);
+
+    void removeEndpointLocatorEvent(
+        const ::AsteriskSCF::System::V1::OperationContextPtr& operationContext, 
+        const Ice::Current&);
+
+    void removeEndpointLocatorEvent(
+        const ::AsteriskSCF::System::V1::OperationContextPtr&, 
+        const ::std::string&, 
+        AsteriskSCF::Core::Routing::V1::Event::OperationResult, 
+        const Ice::Current&);
+
+    void setEndpointLocatorDestinationIdsEvent(
+        const ::AsteriskSCF::System::V1::OperationContextPtr&, 
+        const ::std::string&, 
+        const ::AsteriskSCF::Core::Routing::V1::RegExSeq&, 
+        ::AsteriskSCF::Core::Routing::V1::Event::OperationResult, 
+        const Ice::Current&);
+
+    void clearEndpointLocatorsEvent(
+        const ::AsteriskSCF::System::V1::OperationContextPtr&, 
+        const Ice::Current&);
+
+    void setPolicyEvent(
+        const ::AsteriskSCF::System::V1::OperationContextPtr&, 
+        const ::std::string&, 
+        const Ice::Current&);
+
+    int mLookupEventCount;
+    int mAddEndpointLocatorEventCount;
+};
+typedef ::IceInternal::Handle<RoutingEventsListener> RoutingEventsListenerPtr;
+
+} // RoutingTest
+} // AsteriskSCF
diff --git a/test/SharedTestData.h b/test/SharedTestData.h
index 8d34545..adafa61 100644
--- a/test/SharedTestData.h
+++ b/test/SharedTestData.h
@@ -24,6 +24,7 @@
 
 #include "MockBridgeManager.h"
 #include "MockEndpointLocator.h"
+#include "RoutingEventsListener.h"
 
 namespace AsteriskSCF
 {
@@ -67,6 +68,8 @@ struct SharedTestData
 
     MockBridgeManagerPtr bridgeManager;
 
+    RoutingEventsListenerPtr routingEventsListener;
+
     bool mBridgeConnected;
     bool mSessionReplaced;
 };
diff --git a/test/TestRouting.cpp b/test/TestRouting.cpp
index 3dee530..8b36be8 100644
--- a/test/TestRouting.cpp
+++ b/test/TestRouting.cpp
@@ -23,6 +23,7 @@
 #include <Ice/Ice.h>
 #include <IceBox/IceBox.h>
 #include <IceUtil/UUID.h>
+#include <IceStorm/IceStorm.h>
 
 #include <AsteriskSCF/Testing/IceBoxBoostTest.h>
 #include <AsteriskSCF/Core/Routing/RoutingIf.h>
@@ -38,6 +39,7 @@
 
 using namespace std;
 using namespace AsteriskSCF::Core::Routing::V1;
+using namespace AsteriskSCF::Core::Routing::V1::Event;
 using namespace AsteriskSCF::Core::Endpoint::V1;
 using namespace AsteriskSCF::SessionCommunications::V1;
 using namespace AsteriskSCF::SessionCommunications::PartyIdentification::V1;
@@ -167,6 +169,54 @@ struct GlobalIceFixture
         }
 
         RegisterWithServiceLocator();
+
+        // Get IceStorm 
+        IceStorm::TopicManagerPrx topicManager(0);
+        try
+        {
+            topicManager = IceStorm::TopicManagerPrx::checkedCast(SharedTestData::instance.communicatorIn->propertyToProxy("TopicManager.Proxy"));
+
+            if(!topicManager)
+            {
+                throw std::exception("Invalid proxy to IceStorm. Missing config for TopicManager.Proxy?");
+            }
+        }
+        catch(const IceUtil::Exception&)
+        {
+
+            throw std::exception("Can't get IceStorm TopicManager. Check config, and make sure IceStorm is running.");
+        }
+
+        IceStorm::TopicPrx topic;
+        try
+        {
+            topic = topicManager->retrieve(AsteriskSCF::Core::Routing::V1::Event::TopicId);
+        }
+        catch(const IceStorm::NoSuchTopic&)
+        {
+            try
+            {
+                topic = topicManager->create(AsteriskSCF::Core::Routing::V1::Event::TopicId);
+            }
+            catch(const IceStorm::TopicExists&)
+            {
+                // Topic didn't exist so I tried to create it. But now it exists. Someone else beat me to the punch.
+            }
+        }
+
+        SharedTestData::instance.routingEventsListener = new RoutingEventsListener();
+
+        Ice::ObjectPrx listenerProxy = SharedTestData::instance.adapterIn->addWithUUID(SharedTestData::instance.routingEventsListener);
+        try
+        {
+            IceStorm::QoS qos;
+            topic->subscribeAndGetPublisher(qos, listenerProxy);
+        }
+        catch (const IceStorm::NoSuchTopic&) 
+        {
+            throw std::exception("No such topic.");
+        }
+
     } // end Fixture() constructor
 
     void RegisterWithServiceLocator()
@@ -307,9 +357,39 @@ BOOST_AUTO_TEST_CASE(AddAndRemoveEndpointLocator)
 }
 
 /**
+ * Test the retry handling for addEndpointLocator() operation.
+ */
+BOOST_AUTO_TEST_CASE(RetryAddEndpointLocator)
+{
+    SharedTestData::instance.routingEventsListener->mAddEndpointLocatorEventCount = 0;
+
+    try
+    {
+        OperationContextPtr retryContext = createContext();
+        SharedTestData::instance.locatorRegistry->addEndpointLocator(retryContext, "TestChannel", SharedTestData::instance.regExIds, SharedTestData::instance.endpointLocatorPrx);
+        SharedTestData::instance.locatorRegistry->addEndpointLocator(retryContext, "TestChannel", SharedTestData::instance.regExIds, SharedTestData::instance.endpointLocatorPrx);
+    }
+    catch (...)
+    {
+        BOOST_FAIL("Exception adding EndpointLocator.");
+    }
+
+    BOOST_CHECK(SharedTestData::instance.routingEventsListener->mAddEndpointLocatorEventCount == 1);
+
+    try
+    {
+        SharedTestData::instance.locatorRegistry->removeEndpointLocator(createContext(), "TestChannel");
+    }
+    catch (...)
+    {
+        BOOST_FAIL("Exception removing EndpointLocator.");
+    }
+}
+
+/**
  * Test adding a locator twice with the service's Locator Registry.
- * This was supposed to throw exception in the past, but is now allowed. The second
- * registration replaces the existing registration.
+ * The second registration replaces the existing registration.
+ * NOTE: This is not a retry test. A unique context is used for each call to addEndpointLocator(). 
  */
 BOOST_AUTO_TEST_CASE(AddEndpointLocatorTwice)
 {
@@ -416,6 +496,74 @@ BOOST_FIXTURE_TEST_CASE(RouteSession, PerTestFixture)
 }
 
 /**
+ * This tests the retry handling when routing a session. 
+ */
+BOOST_FIXTURE_TEST_CASE(RouteSessionWithRetry, PerTestFixture)
+{
+    try
+    {
+        BOOST_TEST_MESSAGE("Local lookup of an endpoint...");
+
+       SharedTestData::instance.endpointLocator->mLookupCount = 0;
+       SharedTestData::instance.bridgeManager->mBridgeCreationCount = 0;
+
+        // Get our local 101 endpoint
+        MockSessionEndpointPtr session101Endpoint = SharedTestData::instance.endpointLocator->localLookup("101");
+
+        BOOST_TEST_MESSAGE("Creating a session on our test endpoint...");
+        SessionPrx session = session101Endpoint->createSession(createContext(), "102", 0, 0, Ice::Current());
+        BOOST_CHECK(session != 0);
+
+        SharedTestData::instance.mBridgeConnected = false;
+
+        BOOST_TEST_MESSAGE("Routing the session...");
+        OperationContextPtr retryContext = createContext();
+        SharedTestData::instance.sessionRouter->routeSession(retryContext, session, "102", 0, session->getCaller(), session->getRedirections());
+ 
+        // Try it again, using the same operation context. This is analogous to Ice retrying the 
+        // operation.
+        SharedTestData::instance.sessionRouter->routeSession(retryContext, session, "102", 0, session->getCaller(), session->getRedirections());
+
+        BOOST_CHECK(SharedTestData::instance.mBridgeConnected);
+
+        BridgePrx bridge = session->getBridge();
+        BOOST_CHECK(bridge != 0);
+
+        SessionSeq sessions = bridge->listSessions();
+        BOOST_CHECK(sessions.size() == 2);
+
+        for(SessionSeq::iterator s = sessions.begin(); s != sessions.end(); ++s)
+        {
+            SessionInfoPtr sessionInfo = (*s)->getInfo();
+
+            // For testing we put the leg id in the role field.
+            BOOST_CHECK(sessionInfo->role == "101" || sessionInfo->role == "102");
+
+            // For testing, we put the number of listeners in the connectedTime field.
+            // Only the bridge should still be listening.
+            BOOST_CHECK(sessionInfo->connectedTime == 1);
+        }
+
+        // A lookup is called during routeSession. It should have only been invoked once, 
+        // since the retry could be resolved with the operation result cache. 
+        BOOST_CHECK(SharedTestData::instance.endpointLocator->mLookupCount == 1);
+
+        // Ditto for bridge creation
+        BOOST_CHECK(SharedTestData::instance.bridgeManager->mBridgeCreationCount == 1);
+    }
+    catch(const IceUtil::Exception &ie)
+    {
+        string msg = "Exception in RouteSession: ";
+        msg += ie.what();
+        BOOST_FAIL(msg);
+    }
+    catch (...)
+    {
+        BOOST_FAIL("Unknown exception in RouteSession:");
+    }
+}
+
+/**
  * This tests blind transfer.
  */
 BOOST_FIXTURE_TEST_CASE(BlindTransfer, PerTestFixture)
@@ -702,7 +850,7 @@ BOOST_FIXTURE_TEST_CASE(FailoverRouteSession, PerTestFixture)
         OperationContextPtr contextToRetry = createContext();
         SharedTestData::instance.sessionRouter->begin_routeSession(contextToRetry, session, "102", 0, session->getCaller(), session->getRedirections());
 
-        for (int counter=0; SharedTestData::instance.endpointLocator->mLookupCalled == false; counter++)
+        for (int counter=0; SharedTestData::instance.endpointLocator->mLookupCount == 0; counter++)
         {
            // Give the main routing service time to do the lookup. 
             IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500));
@@ -715,14 +863,14 @@ BOOST_FIXTURE_TEST_CASE(FailoverRouteSession, PerTestFixture)
         }
 
         // The lookup should have completed prior to the simulated failure.
-        BOOST_CHECK(SharedTestData::instance.endpointLocator->mLookupCalled);
+        BOOST_CHECK(SharedTestData::instance.endpointLocator->mLookupCount == 1);
 
         // In test mode, the active routing service will abort the operation prior to
         // createing the bridge.
         BOOST_CHECK(SharedTestData::instance.mBridgeConnected == false);
 
         // Reset the lookup flag. 
-        SharedTestData::instance.endpointLocator->mLookupCalled = false;
+        SharedTestData::instance.endpointLocator->mLookupCount = 0;
 
         // Switch standby component to active. 
         SharedTestData::instance.serviceReplicaMgmt->activate(createContext());
@@ -732,7 +880,7 @@ BOOST_FIXTURE_TEST_CASE(FailoverRouteSession, PerTestFixture)
         SharedTestData::instance.backupSessionRouter->routeSession(contextToRetry, session, "102", 0, session->getCaller(), session->getRedirections());
 
         // The lookup should not be done again. 
-        BOOST_CHECK(!SharedTestData::instance.endpointLocator->mLookupCalled);
+        BOOST_CHECK(SharedTestData::instance.endpointLocator->mLookupCount == 0);
 
         BOOST_CHECK(SharedTestData::instance.mBridgeConnected == true);
 
@@ -812,7 +960,7 @@ BOOST_FIXTURE_TEST_CASE(FailoverConnectBridgedSessWithDest, PerTestFixture)
         BOOST_CHECK(SharedTestData::instance.mSessionReplaced);
 
         // Reset the local flags. 
-        SharedTestData::instance.endpointLocator->mLookupCalled = false;
+        SharedTestData::instance.endpointLocator->mLookupCount = 0;
         SharedTestData::instance.mBridgeConnected = false;
         SharedTestData::instance.mSessionReplaced = false;
 
@@ -828,7 +976,7 @@ BOOST_FIXTURE_TEST_CASE(FailoverConnectBridgedSessWithDest, PerTestFixture)
         SharedTestData::instance.backupSessionRouter->connectBridgedSessionsWithDestination(contextToRetry, session, "103", true, 0);
 
         // The lookup should not be done again. 
-        BOOST_CHECK(SharedTestData::instance.endpointLocator->mLookupCalled == false);
+        BOOST_CHECK(SharedTestData::instance.endpointLocator->mLookupCount == 0);
 
         // The session shouldn't be replaced again.
         BOOST_CHECK(SharedTestData::instance.mSessionReplaced == false);

-----------------------------------------------------------------------


-- 
asterisk-scf/integration/routing.git



More information about the asterisk-scf-commits mailing list