@@ -479,7 +479,8 @@ functionalAPITests ps = do
479479 withSmpServer ps testTwoUsers
480480 describe " Client service certificates" $ do
481481 it " should connect, subscribe and reconnect as a service" $ testClientServiceConnection ps
482- it " should re-subscribe when service ID changed" $ testClientServiceIDChange ps
482+ fit " should re-subscribe when service ID changed" $ testClientServiceIDChange ps
483+ fit " migrate connections to and from service" $ testMigrateConnectionsToService ps
483484 describe " Connection switch" $ do
484485 describe " should switch delivery to the new queue" $
485486 testServerMatrix2 ps testSwitchConnection
@@ -3743,7 +3744,7 @@ testClientServiceIDChange ps@(_, ASType qs _) = do
37433744 liftIO $ getInAnyOrder service
37443745 [ \ case (" " , " " , AEvt SAENone (SERVICE_UP _ (SMP. ServiceSubResult (Just (SMP. SSErrorQueueCount 1 0 )) (SMP. ServiceSub _ 0 _)))) -> True ; _ -> False ,
37453746 \ case (" " , " " , AEvt SAENone (SERVICE_ALL _)) -> True ; _ -> False ,
3746- \ case (" " , " " , AEvt SAENone (UP _ _ )) -> True ; _ -> False
3747+ \ case (" " , " " , AEvt SAENone (UP _ [_] )) -> True ; _ -> False
37473748 ]
37483749 subscribeAllConnections user False Nothing
37493750 (" " , " " , UP _ [_]) <- nGet user
@@ -3759,6 +3760,36 @@ testClientServiceIDChange ps@(_, ASType qs _) = do
37593760 (" " , " " , UP _ [_]) <- nGet user
37603761 exchangeGreetingsMsgId 6 notService uId user sId
37613762
3763+ testMigrateConnectionsToService :: HasCallStack => (ASrvTransport , AStoreType ) -> IO ()
3764+ testMigrateConnectionsToService ps =
3765+ withSmpServerStoreLogOn ps testPort $ \ _ -> do
3766+ ((sId1, uId1), (sId2, uId2)) <-
3767+ withAgentClientsServers2 (agentCfg, initAgentServers) (agentCfg, initAgentServers) $ \ notService user ->
3768+ runRight $ (,) <$> makeConnection notService user <*> makeConnection notService user
3769+ ((sId3, uId3), (sId4, uId4)) <-
3770+ withAgentClientsServers2 (agentCfg, initAgentServersClientService) (agentCfg, initAgentServers) $ \ service user -> runRight $ do
3771+ subscribeAllConnections service False Nothing
3772+ (" " , " " , UP _ [_, _]) <- nGet service
3773+ subscribeAllConnections user False Nothing
3774+ (" " , " " , UP _ [_, _]) <- nGet user
3775+ exchangeGreetings service uId1 user sId1
3776+ exchangeGreetings service uId2 user sId2
3777+ (,) <$> makeConnection service user <*> makeConnection service user
3778+ withAgentClientsServers2 (agentCfg, initAgentServersClientService) (agentCfg, initAgentServers) $ \ service user -> runRight $ do
3779+ subscribeAllConnections service False Nothing
3780+ r <- nGet service
3781+ liftIO $ print r
3782+ liftIO $ getInAnyOrder service
3783+ [ \ case (" " , " " , AEvt SAENone (SERVICE_UP _ (SMP. ServiceSubResult Nothing (SMP. ServiceSub _ 4 _)))) -> True ; _ -> False ,
3784+ \ case (" " , " " , AEvt SAENone (SERVICE_ALL _)) -> True ; _ -> False
3785+ ]
3786+ subscribeAllConnections user False Nothing
3787+ (" " , " " , UP _ [_, _, _, _]) <- nGet user
3788+ exchangeGreetings service uId1 user sId1
3789+ exchangeGreetings service uId2 user sId2
3790+ exchangeGreetings service uId3 user sId3
3791+ exchangeGreetings service uId4 user sId4
3792+
37623793getSMPAgentClient' :: Int -> AgentConfig -> InitialAgentServers -> String -> IO AgentClient
37633794getSMPAgentClient' clientId cfg' initServers dbPath = do
37643795 Right st <- liftIO $ createStore dbPath
0 commit comments