git.iko.soy/distributed-process
on master help sign in
test remove getProcessInfo calls
commit1825b0cbf0e01164849d102a96d969e4a09d877b authorTim Watson <tim@rabbitmq.com> dateSat 5 Jan 2013, 11:57 (14 years ago) parent5ce2927
2 files changed+39−3
distributed-process/distributed-process.cabal+1 distributed-process/tests/TestStats.hs+38−3
distributed-process/distributed-process.cabal+1
@@ -132,6 +132,7 @@ Test-Suite TestStats
132132 random >= 1.0 && < 1.1,
133133 ansi-terminal >= 0.5 && < 0.6,
134134 containers >= 0.4 && < 0.6,
135+ stm >= 2.3 && < 2.5,
135136 distributed-process,
136137 network-transport >= 0.3 && < 0.4,
137138 network-transport-tcp >= 0.3 && < 0.4,
distributed-process/tests/TestStats.hs+38−3
@@ -1,8 +1,8 @@
11{-# LANGUAGE DeriveDataTypeable #-}
2−{-# OPTIONS_GHC -fno-warn-orphans #-}
2+{-# OPTIONS_GHC -fno-warn-orphans #-}
33module Main where
44
5−import Prelude hiding (catch)
5+import Prelude hiding (catch, log)
66import Test.Framework
77 ( Test
88 , defaultMain
@@ -97,6 +97,40 @@ testLocalLiveProcessInfo result = do
9797-- infoMessageQueueLength pInfo == Just 4 &&
9898 infoRegisteredNames pInfo == ["foobar"]
9999
100+testRemoteLiveProcessInfo :: LocalNode -> Assertion
101+testRemoteLiveProcessInfo node1 = do
102+ serverAddr <- liftIO $ newEmptyMVar :: IO (MVar ProcessId)
103+ liftIO $ launchRemote serverAddr
104+ serverPid <- liftIO $ takeMVar serverAddr
105+ withActiveRemote node1 $ \result -> do
106+ self <- getSelfPid
107+ link serverPid
108+ -- our send op shouldn't overtake link or monitor requests AFAICT
109+ -- so a little table tennis should get us synchronised properly
110+ send serverPid (self, "ping")
111+ "pong" <- expect
112+ pInfo <- getProcessInfo serverPid
113+ stash result $ pInfo /= Nothing
114+ where
115+ launchRemote :: MVar ProcessId -> IO ()
116+ launchRemote locMV = do
117+ node2 <- liftIO $ mkNode "8082"
118+ _ <- liftIO $ forkProcess node2 $ do
119+ self <- getSelfPid
120+ liftIO $ putMVar locMV self
121+ _ <- receiveWait [
122+ match (\(pid, "ping") -> send pid "pong")
123+ ]
124+ "stop" <- expect
125+ return ()
126+ return ()
127+
128+ withActiveRemote :: LocalNode
129+ -> ((TestResult Bool -> Process ()) -> Assertion)
130+ withActiveRemote n = do
131+ a <- delayedAssertion "getProcessInfo remotePid failed" n True
132+ return a
133+
100134tests :: LocalNode -> IO [Test]
101135tests node1 = do
102136 return [
@@ -109,6 +143,8 @@ tests node1 = do
109143 (delayedAssertion
110144 "expected process-info to be correctly populated"
111145 node1 True testLocalLiveProcessInfo)
146+ , testCase "testRemoveLiveProcessInfo"
147+ (testRemoteLiveProcessInfo node1)
112148 ] ]
113149
114150mkNode :: String -> IO LocalNode
@@ -124,4 +160,3 @@ main = do
124160 defaultMain testData
125161 closeLocalNode node1
126162 return ()
127−