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

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Tue May 3 17:25:58 CDT 2011


branch "route_replica" has been updated
       via  ee1ba9122aaf6a3b0c6dfb877cb73454ce1b83ca (commit)
      from  5371f62b5bd84e2371d8ecfbe51e429a09f5a74d (commit)

Summary of changes:
 local-slice/BasicRoutingStateReplicationIf.ice     |    6 ++-
 ...nectBridgedSessionsWithDestinationOperation.cpp |    8 ++-
 ...onnectBridgedSessionsWithDestinationOperation.h |    6 ++
 src/RoutingStateReplicatorListener.cpp             |   46 ++++++++++++++++++
 test/TestRouting.cpp                               |   51 +++++++++++++++-----
 5 files changed, 99 insertions(+), 18 deletions(-)


- Log -----------------------------------------------------------------
commit ee1ba9122aaf6a3b0c6dfb877cb73454ce1b83ca
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Tue May 3 17:25:15 2011 -0500

    Some final testing of operation replication.

diff --git a/local-slice/BasicRoutingStateReplicationIf.ice b/local-slice/BasicRoutingStateReplicationIf.ice
index c039f0f..c1cb49b 100644
--- a/local-slice/BasicRoutingStateReplicationIf.ice
+++ b/local-slice/BasicRoutingStateReplicationIf.ice
@@ -143,18 +143,20 @@ module V1
     const string ConnectBridgedSessionsWithDestStartKeyMod = ".START";
 
     /**
-     * Indicates the ConnectBridgedSessionsWithDestinationOperation completed an AMI endpoint lookup(). 
+     * Indicates the ConnectBridgedSessionsWithDestinationOperation completed 
+     * an AMI endpoint lookup(). 
      * The key (in the base state item) is the operationId of this 
      * operation + ConnectBridgedSessionsWithDestWaitLookupKeyMod
      */
     class ConnectBridgedSessionsWithDestinationOpWaitLookupState extends OperationStateItem
     {
         AsteriskSCF::Core::Endpoint::V1::EndpointSeq endpoints;
+        AsteriskSCF::SessionCommunications::V1::SessionSeq remainingSessions;
     };
     const string ConnectBridgedSessionsWithDestWaitLookupKeyMod = ".WAITLOOKUP";
 
     /**
-     * Indicates the ConnectBridgedSessionsWithDestinationOperation has created the bridge. 
+     * Indicates the ConnectBridgedSessionsWithDestinationOperation has modified the bridge. 
      * The key (in the base state item) is the operationId of this 
      * operation + ConnectBridgedSessionsWithDestBridgingKeyMod
      */
diff --git a/src/ConnectBridgedSessionsWithDestinationOperation.cpp b/src/ConnectBridgedSessionsWithDestinationOperation.cpp
index e985f52..f563d47 100644
--- a/src/ConnectBridgedSessionsWithDestinationOperation.cpp
+++ b/src/ConnectBridgedSessionsWithDestinationOperation.cpp
@@ -94,6 +94,7 @@ public:
             waitLookup->key = mOperation->getOperationId() + 
                  AsteriskSCF::BasicRoutingService::V1::RouteSessionOpWaitLookupKeyMod;
             waitLookup->endpoints = mOperation->getLookupResult();
+            waitLookup->remainingSessions = mOperation->getRemainingSessions();
 
             pushState(waitLookup);
             }
@@ -313,6 +314,7 @@ void ConnectBridgedSessionsWithDestinationOperation::reflectUpdate(AsteriskSCF::
 void ConnectBridgedSessionsWithDestinationOperation::reflectUpdate(AsteriskSCF::BasicRoutingService::V1::ConnectBridgedSessionsWithDestinationOpWaitLookupStatePtr item)
 {
     mLookupResult = item->endpoints;
+    mRemainingSessions = item->remainingSessions;
 
     mReplicatedStates.push_back(ConnectBridgedSessionsWithDestinationOp::STATE_WAIT_LOOKUP_RESULTS);
 }
@@ -491,6 +493,9 @@ void ConnectBridgedSessionsWithDestinationOperation::establishBridgeState()
         return;
     }
 
+    // Set the state handler to exectute once we've looked up our endpoints. 
+    mStateMachine.setNextState(ConnectBridgedSessionsWithDestinationOp::STATE_SEND_RESPONSE);
+
     // Test instrumentation
     if (mSessionContext->replicationContext->getTestContext().get() != 0)
     {
@@ -503,9 +508,6 @@ void ConnectBridgedSessionsWithDestinationOperation::establishBridgeState()
         }
     }
 
-    // Set the state handler to exectute once we've looked up our endpoints. 
-    mStateMachine.setNextState(ConnectBridgedSessionsWithDestinationOp::STATE_SEND_RESPONSE);
-
     // Keep executing.
     mOperationsManager->reschedule(this);
 }
diff --git a/src/ConnectBridgedSessionsWithDestinationOperation.h b/src/ConnectBridgedSessionsWithDestinationOperation.h
index ce1fa63..ca1d904 100644
--- a/src/ConnectBridgedSessionsWithDestinationOperation.h
+++ b/src/ConnectBridgedSessionsWithDestinationOperation.h
@@ -100,6 +100,12 @@ public:
      */
     bool fastForwardReplica();
 
+    /**
+     * Get the set of sessions that remain in the bridge after the session to 
+     * be replaced has been removed. 
+     */
+    AsteriskSCF::SessionCommunications::V1::SessionSeq getRemainingSessions() {return mRemainingSessions;}
+
 protected:
     ConnectBridgedSessionsWithDestinationOperation(const AsteriskSCF::SessionCommunications::V1::AMD_SessionRouter_connectBridgedSessionsWithDestinationPtr& cb,
                         const std::string& operationId,
diff --git a/src/RoutingStateReplicatorListener.cpp b/src/RoutingStateReplicatorListener.cpp
index f811416..3f4a729 100644
--- a/src/RoutingStateReplicatorListener.cpp
+++ b/src/RoutingStateReplicatorListener.cpp
@@ -63,6 +63,52 @@ public:
         private:
             RoutingStateReplicatorListenerPriv *mImpl;
 
+            // Used an intermediate class in the slice types, and the visitor didn't pick up the leaf classes to visit. 
+            void visitOperationStateItem(const ::AsteriskSCF::BasicRoutingService::V1::OperationStateItemPtr& operation)
+            {
+                RouteSessionOpStartPtr routeSessinOpStart = RouteSessionOpStartPtr::dynamicCast(operation);
+                if (routeSessinOpStart != 0)
+                {
+                    visitRouteSessionOpStart(routeSessinOpStart);
+                    return;
+                }
+
+                RouteSessionOpWaitLookupStatePtr routeSessionWait = RouteSessionOpWaitLookupStatePtr::dynamicCast(operation);
+                if (routeSessionWait != 0)
+                {
+                    visitRouteSessionOpWaitLookupState(routeSessionWait);
+                    return;
+                }
+
+                RouteSessionOpBridgingStatePtr routeBridging = RouteSessionOpBridgingStatePtr::dynamicCast(operation);
+                if (routeBridging != 0)
+                {
+                    visitRouteSessionOpBridgingState(routeBridging);
+                    return;
+                }
+                  
+                ConnectBridgedSessionsWithDestinationOpStartPtr connectWithDestStart = ConnectBridgedSessionsWithDestinationOpStartPtr::dynamicCast(operation);
+                if (connectWithDestStart != 0)
+                {
+                    visitConnectBridgedSessionsWithDestinationOpStart(connectWithDestStart);
+                    return;
+                }
+
+                ConnectBridgedSessionsWithDestinationOpWaitLookupStatePtr connectWithDestLookup = ConnectBridgedSessionsWithDestinationOpWaitLookupStatePtr::dynamicCast(operation);
+                if (connectWithDestLookup != 0)
+                {
+                    visitConnectBridgedSessionsWithDestinationOpWaitLookupState(connectWithDestLookup);
+                    return;
+                }
+
+                ConnectBridgedSessionsWithDestinationOpBridgingStatePtr connectWithDestBridge = ConnectBridgedSessionsWithDestinationOpBridgingStatePtr::dynamicCast(operation);
+                if (connectWithDestBridge != 0)
+                {
+                    visitConnectBridgedSessionsWithDestinationOpBridgingState(connectWithDestBridge);
+                    return;
+                }
+            }
+
             void visitRouteSessionOpStart(const ::AsteriskSCF::BasicRoutingService::V1::RouteSessionOpStartPtr& opState)
             {
                 // The operation cache keeps all the collected state for an operation under the transaction id. 
diff --git a/test/TestRouting.cpp b/test/TestRouting.cpp
index 48abb23..3dcc3d8 100644
--- a/test/TestRouting.cpp
+++ b/test/TestRouting.cpp
@@ -633,6 +633,7 @@ BOOST_FIXTURE_TEST_CASE(BackupEndpointLocatorInStandby, PerTestFixture)
     try
     {
         // Give the state replicator time to push the EndpointLocator to the standby component. 
+        // (The EndpointLocator is added by the PerTestFixture)
         IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500));
 
         // Do a lookup on the backup while it is in standby mode. 
@@ -689,6 +690,10 @@ BOOST_FIXTURE_TEST_CASE(BackupEndpointLocatorActive, PerTestFixture)
     }
 }
 
+/**
+ * A simple test to swich the standby/active status of the two
+ * running instances of the routing service. 
+ */
 BOOST_FIXTURE_TEST_CASE(SwitchActiveAndStandby, PerTestFixture)
 {
     try
@@ -712,8 +717,19 @@ BOOST_FIXTURE_TEST_CASE(SwitchActiveAndStandby, PerTestFixture)
 
 }
 
+/**
+ * This test uses the test interface of the
+ * active routing service to simulate a failure. The service doesn't actually
+ * shutdown. It simply fails to complete an operation after having executed
+ * the operation up to a known state. We then test to see if the standby
+ * component can pick the operation up in mid-process and complete it.
+ *
+ * This particular operation is testing the routeSession
+ * operation. 
+ */
 BOOST_FIXTURE_TEST_CASE(FailoverRouteSession, PerTestFixture)
 {
+    // This test can be turned off in the config file. 
     if (SharedTestData::instance.componentTest == 0)
     {
         BOOST_TEST_MESSAGE("Component test interface not configured. Skipping test FailoverRouteSession.");
@@ -789,8 +805,19 @@ BOOST_FIXTURE_TEST_CASE(FailoverRouteSession, PerTestFixture)
 
 }
 
+/**
+ * This test uses the test interface of the
+ * active routing service to simulate a failure. The service doesn't actually
+ * shutdown; rather, it fails to complete an operation after having executed
+ * the operation up to a known state. We then test to see if the standby
+ * component can pick the operation up in mid-process and complete it. 
+ *
+ * This particular operation is testing the connectBridgedSessionsWithDestination
+ * operation. 
+ */
 BOOST_FIXTURE_TEST_CASE(FailoverConnectBridgedSessWithDest, PerTestFixture)
 {
+    // This test can be turned off in the config file. 
     if (SharedTestData::instance.componentTest == 0)
     {
         BOOST_TEST_MESSAGE("Component test interface not configured. Skipping test FailoverConnectBridgedSessWithDest.");
@@ -816,17 +843,18 @@ BOOST_FIXTURE_TEST_CASE(FailoverConnectBridgedSessWithDest, PerTestFixture)
         SharedTestData::instance.mSessionReplaced = false;
 
         BOOST_TEST_MESSAGE("Routing the session...");
-        string operationId = IceUtil::generateUUID();
-        SharedTestData::instance.sessionRouter->routeSession(operationId, session, "102");
+        SharedTestData::instance.sessionRouter->routeSession(IceUtil::generateUUID(), session, "102");
 
         BridgePrx bridge = session->getBridge();
         BOOST_CHECK(bridge != 0);
         BOOST_CHECK(SharedTestData::instance.mBridgeConnected);
 
+        string operationId = IceUtil::generateUUID();
+
         // Now transfer to a new extension. In our test mode, this operation will never complete.
-        SharedTestData::instance.sessionRouter->begin_connectBridgedSessionsWithDestination(IceUtil::generateUUID(), session, "103");
+        SharedTestData::instance.sessionRouter->begin_connectBridgedSessionsWithDestination(operationId, session, "103");
 
-        for (int counter=0; SharedTestData::instance.endpointLocator->mLookupCalled == false; counter++)
+        for (int counter=0; SharedTestData::instance.mSessionReplaced == false; counter++)
         {
            // Give the main routing service time to do the lookup. 
             IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500));
@@ -838,29 +866,26 @@ BOOST_FIXTURE_TEST_CASE(FailoverConnectBridgedSessWithDest, PerTestFixture)
             }
         }
 
-        // The lookup should have completed prior to the simulated failure.
-        BOOST_CHECK(SharedTestData::instance.endpointLocator->mLookupCalled);
-
-        // In this test mode, the active routing service will abort after
-        // createing the bridge.
-        BOOST_CHECK(SharedTestData::instance.mBridgeConnected == true);
+        // The session should have been replaced prior to the simulated failure.
+        BOOST_CHECK(SharedTestData::instance.mSessionReplaced);
 
         // Reset the local flags. 
         SharedTestData::instance.endpointLocator->mLookupCalled = false;
         SharedTestData::instance.mBridgeConnected = false;
+        SharedTestData::instance.mSessionReplaced = false;
 
         // Switch standby component to active. 
         SharedTestData::instance.serviceReplicaMgmt->activate();
         BOOST_CHECK(SharedTestData::instance.serviceReplicaMgmt->isActive() == true);
 
         // Let the backup session router try to route using same operationId. Synchronous call.
-        SharedTestData::instance.backupSessionRouter->routeSession(operationId, session, "103");
+        SharedTestData::instance.backupSessionRouter->connectBridgedSessionsWithDestination(operationId, session, "103");
 
         // The lookup should not be done again. 
         BOOST_CHECK(SharedTestData::instance.endpointLocator->mLookupCalled == false);
 
-        // The bridge shouldn't be created again.
-        BOOST_CHECK(SharedTestData::instance.mBridgeConnected == false);
+        // The session shouldn't be replaced again.
+        BOOST_CHECK(SharedTestData::instance.mSessionReplaced == false);
 
         // Set the backup back into standby mode.
         SharedTestData::instance.backupServiceReplicaMgmt->standby();

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


-- 
asterisk-scf/integration/routing.git



More information about the asterisk-scf-commits mailing list