Skip to content

Commit a064d81

Browse files
committed
Fix the potential for a clash/race over named management agents across test cases
1 parent 62329ce commit a064d81

File tree

1 file changed

+11
-7
lines changed
  • distributed-process-tests/src/Control/Distributed/Process/Tests

1 file changed

+11
-7
lines changed

distributed-process-tests/src/Control/Distributed/Process/Tests/Mx.hs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,11 @@ testAgentPrioritisation result = do
117117
testAgentMailboxHandling :: TestResult (Maybe ()) -> Process ()
118118
testAgentMailboxHandling result = do
119119
(sp, rp) <- newChan
120-
agent <- mxAgent (MxAgentId "listener-agent") () [
120+
agent <- mxAgent (MxAgentId "mailbox-agent") () [
121121
mxSink $ \() -> (liftMX $ sendChan sp ()) >> mxReady
122122
]
123123

124-
nsend "listener-agent" ()
124+
nsend "mailbox-agent" ()
125125

126126
stash result =<< receiveChanTimeout 1000000 rp
127127
kill agent "finished"
@@ -184,7 +184,7 @@ testMxRegEvents = do
184184
behaviour of the node controller are contained in the CH test suite. -}
185185

186186
let label = "testMxRegEvents"
187-
let agentLabel = "listener-agent"
187+
let agentLabel = "mxRegEvents-agent"
188188
let delay = 1000000
189189
(regChan, regSink) <- newChan
190190
(unRegChan, unRegSink) <- newChan
@@ -231,8 +231,8 @@ testMxRegMon remoteNode = do
231231

232232
let label1 = "aaaaa"
233233
let label2 = "bbbbb"
234-
let isValid l = l ==label1 || l == label2
235-
let agentLabel = "listener-agent"
234+
let isValid l = l == label1 || l == label2
235+
let agentLabel = "mxRegMon-agent"
236236
let delay = 1000000
237237
(regChan, regSink) <- newChan
238238
(unRegChan, unRegSink) <- newChan
@@ -273,8 +273,12 @@ testMxRegMon remoteNode = do
273273
unreg1 <- receiveChanTimeout delay unRegSink
274274
unreg2 <- receiveChanTimeout delay unRegSink
275275

276-
sort [unreg1, unreg2]
277-
`shouldBe` equalTo [Just (label1, p1), Just (label2, p1)]
276+
let evts = [unreg1, unreg2]
277+
-- we can't rely on the order of the values in the node controller's
278+
-- map (it's either racy to do so, or no such guarantee exists for Data.Map),
279+
-- so we simply verify that we received the un-registration events we expect
280+
evts `shouldContain` (Just (label1, p1))
281+
evts `shouldContain` (Just (label2, p1))
278282

279283
kill agent "test-complete"
280284

0 commit comments

Comments
 (0)