Repository navigation
Expand file tree
/
Copy pathTestPrioritisedProcess.hs
More file actions
633 lines (540 loc) · 24.6 KB
/
Copy pathTestPrioritisedProcess.hs
File metadata and controls
633 lines (540 loc) · 24.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
{-# LANGUAGE CPP #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
module Main where
import Control.Concurrent.MVar
import Control.Concurrent.STM.TQueue
( newTQueueIO
, readTQueue
, writeTQueue
)
import Control.Exception (SomeException)
import Control.DeepSeq (NFData)
import Control.Distributed.Process hiding (call, send, catch, sendChan, wrapMessage)
import Control.Distributed.Process.Node
import Control.Distributed.Process.Extras hiding (monitor)
import Control.Distributed.Process.Async hiding (check)
import Control.Distributed.Process.ManagedProcess hiding (reject, Message)
import qualified Control.Distributed.Process.ManagedProcess.Server.Priority as P (Message)
import Control.Distributed.Process.ManagedProcess.Server.Priority hiding (Message)
import qualified Control.Distributed.Process.ManagedProcess.Server.Gen as Gen
( dequeue
, continue
, lift
)
import Control.Distributed.Process.SysTest.Utils
import Control.Distributed.Process.Extras.Time
import Control.Distributed.Process.Extras.Timer hiding (runAfter)
import Control.Distributed.Process.Serializable()
import Control.Monad
import Control.Monad.Catch (catch)
import Data.Binary
import Data.Either (rights)
import Data.List (isInfixOf)
import Data.Maybe (isNothing, isJust)
import Data.Typeable (Typeable)
import Test.Tasty (TestTree, testGroup)
import Test.Tasty.HUnit (testCase)
import TestUtils
import ManagedProcessCommon
import qualified Network.Transport as NT
import GHC.Generics (Generic)
-- utilities
server :: Process (ProcessId, (MVar ExitReason))
server = mkServer Terminate
mkServer :: UnhandledMessagePolicy
-> Process (ProcessId, (MVar ExitReason))
mkServer policy =
let s = standardTestServer policy
p = s `prioritised` ([] :: [DispatchPriority ()])
in do
exitReason <- liftIO $ newEmptyMVar
pid <- spawnLocal $ do
catch ((pserve () (statelessInit Infinity) p >> stash exitReason ExitNormal)
`catchesExit` [
(\_ msg -> do
mEx <- unwrapMessage msg :: Process (Maybe ExitReason)
case mEx of
Nothing -> return Nothing
Just r -> stash exitReason r >>= return . Just
)
])
(\(e :: SomeException) -> stash exitReason $ ExitOther (show e))
return (pid, exitReason)
explodingServer :: ProcessId
-> Process (ProcessId, MVar ExitReason)
explodingServer pid =
let srv = explodingTestProcess pid
pSrv = srv `prioritised` ([] :: [DispatchPriority s])
in do
exitReason <- liftIO newEmptyMVar
spid <- spawnLocal $ do
catch (pserve () (statelessInit Infinity) pSrv >> stash exitReason ExitNormal)
(\(e :: SomeException) -> do
-- say "died in handler..."
stash exitReason $ ExitOther (show e))
return (spid, exitReason)
data GetState = GetState
deriving (Typeable, Generic, Show, Eq)
instance Binary GetState where
instance NFData GetState where
data MyAlarmSignal = MyAlarmSignal
deriving (Typeable, Generic, Show, Eq)
instance Binary MyAlarmSignal where
instance NFData MyAlarmSignal where
mkPrioritisedServer :: Process ProcessId
mkPrioritisedServer =
let p = procDef `prioritised` ([
prioritiseInfo_ (\MyAlarmSignal -> setPriority 10)
, prioritiseCast_ (\(_ :: String) -> setPriority 2)
, prioritiseCall_ (\(cmd :: String) -> (setPriority (length cmd)) :: Priority ())
] :: [DispatchPriority [Either MyAlarmSignal String]]
) :: PrioritisedProcessDefinition [(Either MyAlarmSignal String)]
in spawnLocal $ pserve () (initWait Infinity) p
where
initWait :: Delay
-> InitHandler () [Either MyAlarmSignal String]
initWait d () = do
() <- expect
return $ InitOk [] d
procDef :: ProcessDefinition [(Either MyAlarmSignal String)]
procDef =
defaultProcess {
apiHandlers = [
handleCall (\s GetState -> reply (reverse s) s)
, handleCall (\s (cmd :: String) -> reply () ((Right cmd):s))
, handleCast (\s (cmd :: String) -> continue ((Right cmd):s))
]
, infoHandlers = [
handleInfo (\s (sig :: MyAlarmSignal) -> continue ((Left sig):s))
]
, unhandledMessagePolicy = Drop
, timeoutHandler = \_ _ -> stop $ ExitOther "timeout"
} :: ProcessDefinition [(Either MyAlarmSignal String)]
mkOverflowHandlingServer :: (PrioritisedProcessDefinition Int ->
PrioritisedProcessDefinition Int)
-> Process ProcessId
mkOverflowHandlingServer modIt =
let p = procDef `prioritised` ([
prioritiseCall_ (\GetState -> setPriority 99 :: Priority Int)
, prioritiseCast_ (\(_ :: String) -> setPriority 1)
] :: [DispatchPriority Int]
) :: PrioritisedProcessDefinition Int
in spawnLocal $ pserve () (initWait Infinity) (modIt p)
where
initWait :: Delay
-> InitHandler () Int
initWait d () = return $ InitOk 0 d
procDef :: ProcessDefinition Int
procDef =
defaultProcess {
apiHandlers = [
handleCall (\s GetState -> reply s s)
, handleCast (\s (_ :: String) -> continue $ s + 1)
]
} :: ProcessDefinition Int
launchStmServer :: CallHandler () String String -> Process StmServer
launchStmServer handler = do
(inQ, replyQ) <- liftIO $ do
cIn <- newTQueueIO
cOut <- newTQueueIO
return (cIn, cOut)
let procDef = statelessProcess {
externHandlers = [
handleCallExternal
(readTQueue inQ)
(writeTQueue replyQ)
handler
]
, apiHandlers = [
action (\() -> stop_ ExitNormal)
]
}
let p = procDef `prioritised` ([
prioritiseCast_ (\() -> setPriority 99 :: Priority ())
, prioritiseCast_ (\(_ :: String) -> setPriority 100)
] :: [DispatchPriority ()]
) :: PrioritisedProcessDefinition ()
pid <- spawnLocal $ pserve () (statelessInit Infinity) p
return $ StmServer pid inQ replyQ
launchStmOverloadServer :: Process (ProcessId, ControlPort String)
launchStmOverloadServer = do
cc <- newControlChan :: Process (ControlChannel String)
let cp = channelControlPort cc
let procDef = statelessProcess {
externHandlers = [
handleControlChan_ cc (\(_ :: String) -> continue_)
]
, apiHandlers = [
handleCast (\s sp -> sendChan sp () >> continue s)
]
}
let p = procDef `prioritised` ([
prioritiseCast_ (\() -> setPriority 99 :: Priority ())
] :: [DispatchPriority ()]
) :: PrioritisedProcessDefinition ()
pid <- spawnLocal $ pserve () (statelessInit Infinity) p
return (pid, cp)
data Foo = Foo deriving (Show)
launchFilteredServer :: ProcessId -> Process (ProcessId, ControlPort (SendPort Int))
launchFilteredServer us = do
cc <- newControlChan :: Process (ControlChannel (SendPort Int))
let cp = channelControlPort cc
let procDef = defaultProcess {
externHandlers = [
handleControlChan cc (\s (p :: SendPort Int) -> sendChan p s >> continue s)
]
, apiHandlers = [
handleCast (\s sp -> sendChan sp () >> continue s)
, handleCall_ (\(s :: String) -> return s)
, handleCall_ (\(i :: Int) -> return i)
]
, unhandledMessagePolicy = DeadLetter us
} :: ProcessDefinition Int
let p = procDef `prioritised` ([
prioritiseCast_ (\() -> setPriority 1 :: Priority ())
, prioritiseCall_ (\(_ :: String) -> setPriority 100 :: Priority String)
] :: [DispatchPriority Int]
) :: PrioritisedProcessDefinition Int
let rejectUnchecked =
rejectApi Foo :: Int -> P.Message String String -> Process (Filter Int)
let p' = p {
filters = [
store (+1)
, ensure (>0) -- a bit pointless, but we're just checking the API
, check $ api_ (\(s :: String) -> return $ "checked-" `isInfixOf` s) rejectUnchecked
, check $ info (\_ (_ :: MonitorRef, _ :: ProcessId) -> return False) $ reject Foo
, refuse ((> 10) :: Int -> Bool)
]
}
pid <- spawnLocal $ pserve 0 (\c -> return $ InitOk c Infinity) p'
return (pid, cp)
testStupidInfiniteLoop :: TestResult Bool -> Process ()
testStupidInfiniteLoop result = do
let def = statelessProcess {
apiHandlers = [
handleCast (\_ sp -> eval $ do q <- processQueue
m <- Gen.dequeue
Gen.lift $ sendChan sp (length q, m)
Gen.continue)
]
, infoHandlers = [
handleInfo (\_ (m :: String) -> eval $ do enqueue (wrapMessage m)
Gen.continue)
]
} :: ProcessDefinition ()
let prio = def `prioritised` []
pid <- spawnLocal $ pserve () (statelessInit Infinity) prio
-- this message should create an infinite loop
send pid "fooboo"
(sp, rp) <- newChan :: Process (SendPort (Int, Maybe Message), ReceivePort (Int, Maybe Message))
cast pid sp
(i, m) <- receiveChan rp
cast pid sp
(i', m') <- receiveChan rp
stash result $ (i == 1 && isJust m && i' == 0 && isNothing m')
testFilteringBehavior :: TestResult Bool -> Process ()
testFilteringBehavior result = do
us <- getSelfPid
(sp, rp) <- newChan
(pid, cp) <- launchFilteredServer us
mRef <- monitor pid
sendControlMessage cp sp
r <- receiveChan rp :: Process Int
when (r > 1) $ stash result False >> die "we're done..."
Left _ <- safeCall pid "bad-input" :: Process (Either ExitReason String)
send pid (mRef, us) -- server doesn't like this, dead letters it...
-- back to us
void $ receiveWait [ matchIf (\(m, p) -> m == mRef && p == us) return ]
sendControlMessage cp sp
r2 <- receiveChan rp :: Process Int
when (r2 < 3) $ stash result False >> die "we're done again..."
-- server also doesn't like this, and sends it right back (via \DeadLetter us/)
send pid (25 :: Int)
m <- receiveWait [ matchIf (== 25) return ] :: Process Int
stash result $ m == 25
kill pid "done"
testServerSwap :: TestResult Bool -> Process ()
testServerSwap result = do
us <- getSelfPid
let def2 = statelessProcess { apiHandlers = [ handleCast (\s (i :: Int) -> send us (i, i+1) >> continue s)
, handleCall_ (\(i :: Int) -> return (i * 5))
]
, unhandledMessagePolicy = Drop -- otherwise `call` would fail
}
let def = statelessProcess
{ apiHandlers = [ handleCall_ (\(m :: String) -> return m) ]
, infoHandlers = [ handleInfo (\s () -> become def2 s) ]
} `prioritised` []
pid <- spawnLocal $ pserve () (statelessInit Infinity) def
m1 <- call pid "hello there"
let a1 = m1 == "hello there"
send pid () --changeover
m2 <- callTimeout pid "are you there?" (seconds 5) :: Process (Maybe String)
let a2 = isNothing m2
cast pid (45 :: Int)
res <- receiveWait [ matchIf (\(i :: Int) -> i == 45) (return . Left)
, match (\(_ :: Int, j :: Int) -> return $ Right j) ]
let a3 = res == (Right 46)
m4 <- call pid (20 :: Int) :: Process Int
let a4 = m4 == 100
stash result $ a1 && a2 && a3 && a4
testSafeExecutionContext :: TestResult Bool -> Process ()
testSafeExecutionContext result = do
let t = (asTimeout $ seconds 5)
(sigSp, rp) <- newChan
(wp, lp) <- newChan
let def = statelessProcess
{ apiHandlers = [ handleCall_ (\(m :: String) -> stranded rp wp Nothing >> return m) ]
, infoHandlers = [ handleInfo (\s (m :: String) -> stranded rp wp (Just m) >> continue s) ]
, exitHandlers = [ handleExit (\_ s (_ :: String) -> continue s) ]
} `prioritised` []
let spec = def { filters = [
safe (\_ (_ :: String) -> True)
, apiSafe (\_ (_ :: String) (_ :: Maybe String) -> True)
]
}
pid <- spawnLocal $ pserve () (statelessInit Infinity) spec
send pid "hello" -- pid can't process this as it's stuck waiting on rp
sleep $ seconds 3
exit pid "ooops" -- now we force an exit signal once the receiveWait finishes
sendChan sigSp () -- and allow the receiveWait to complete
send pid "hi again"
-- at this point, "hello" should still be in the backing queue/mailbox
sleep $ seconds 3
-- We should still be seeing "hello", since the 'safe' block saved us from
-- losing a message when we handled and swallowed the exit signal.
-- We should not see "hi again" until after "hello" has been processed
h <- receiveChanTimeout t lp
-- say $ "first response: " ++ (show h)
let a1 = h == (Just "hello")
sleep $ seconds 3
-- now we should have "hi again" waiting in the mailbox...
sendChan sigSp () -- we must release the handler a second time...
h2 <- receiveChanTimeout t lp
-- say $ "second response: " ++ (show h2)
let a2 = h2 == (Just "hi again")
void $ spawnLocal $ call pid "reply-please" >>= sendChan wp
-- the call handler should be stuck waiting on rp
Nothing <- receiveChanTimeout (asTimeout $ seconds 2) lp
-- now let's force an exit, then release the handler to see if it runs again...
exit pid "ooops2"
sleep $ seconds 2
sendChan sigSp ()
h3 <- receiveChanTimeout t lp
-- say $ "third response: " ++ (show h3)
let a3 = h3 == (Just "reply-please")
stash result $ a1 && a2 && a3
where
stranded :: ReceivePort () -> SendPort String -> Maybe String -> Process ()
stranded gate chan str = do
-- say $ "stranded with " ++ (show str)
void $ receiveWait [ matchChan gate return ]
sleep $ seconds 1
case str of
Nothing -> return ()
Just s -> sendChan chan s
testExternalTimedOverflowHandling :: TestResult Bool -> Process ()
testExternalTimedOverflowHandling result = do
(pid, cp) <- launchStmOverloadServer -- default 10k mailbox drain limit
wrk <- spawnLocal $ mapM_ (sendControlMessage cp . show) ([1..500000] :: [Int])
sleep $ milliSeconds 250 -- give the worker time to start spamming the server...
(sp, rp) <- newChan
cast pid sp -- tell the server we're expecting a reply
-- it might take "a while" for us to get through the first 10k messages
-- from our chatty friend wrk, before we finally get our control message seen
-- by the reader/listener loop, and in fact timing wise we don't even know when
-- our message will arrive, since we're racing with wrk to communicate with
-- the server. It's important therefore to give sufficient time for the right
-- conditions to occur so that our message is finally received and processed,
-- yet we don't want to lock up the build for 10-20 mins either. This value
-- of 30 seconds seems like a reasonable compromise.
answer <- receiveChanTimeout (asTimeout $ seconds 30) rp
stash result $ answer == Just ()
kill wrk "done"
kill pid "done"
testExternalCall :: TestResult Bool -> Process ()
testExternalCall result = do
let txt = "hello stm-call foo"
srv <- launchStmServer (\st (msg :: String) -> reply msg st)
echoStm srv txt >>= stash result . (== Right txt)
killProc srv "done"
testTimedOverflowHandling :: TestResult Bool -> Process ()
testTimedOverflowHandling result = do
pid <- mkOverflowHandlingServer (\s -> s { recvTimeout = RecvTimer $ within 3 Seconds })
wrk <- spawnLocal $ mapM_ (cast pid . show) ([1..500000] :: [Int])
sleep $ seconds 1 -- give the worker time to start spamming us...
cast pid "abc" -- just getting in line here...
st <- call pid GetState :: Process Int
-- the result of GetState is a list of messages in reverse insertion order
stash result $ st > 0
kill wrk "done"
kill pid "done"
testOverflowHandling :: TestResult Bool -> Process ()
testOverflowHandling result = do
pid <- mkOverflowHandlingServer (\s -> s { recvTimeout = RecvMaxBacklog 100 })
wrk <- spawnLocal $ mapM_ (cast pid . show) ([1..50000] :: [Int])
sleep $ seconds 1
cast pid "abc" -- just getting in line here...
st <- call pid GetState :: Process Int
-- the result of GetState is a list of messages in reverse insertion order
stash result $ st > 0
kill wrk "done"
kill pid "done"
testInfoPrioritisation :: TestResult Bool -> Process ()
testInfoPrioritisation result = do
pid <- mkPrioritisedServer
-- the server (pid) is configured to wait for () during its init
-- so we can fill up its mailbox with String messages, and verify
-- that the alarm signal (which is prioritised *above* these)
-- actually gets processed first despite the delivery order
cast pid "hello"
cast pid "prioritised"
cast pid "world"
-- note that these have to be a "bare send"
send pid MyAlarmSignal
-- tell the server it can move out of init and start processing messages
send pid ()
st <- call pid GetState :: Process [Either MyAlarmSignal String]
-- the result of GetState is a list of messages in reverse insertion order
case head st of
Left MyAlarmSignal -> stash result True
_ -> stash result False
testUserTimerHandling :: TestResult Bool -> Process ()
testUserTimerHandling result = do
us <- getSelfPid
let p = (procDef us) `prioritised` ([
prioritiseInfo_ (\MyAlarmSignal -> setPriority 100)
] :: [DispatchPriority ()]
) :: PrioritisedProcessDefinition ()
pid <- spawnLocal $ pserve () (statelessInit Infinity) p
cast pid ()
expect >>= stash result . (== MyAlarmSignal)
kill pid "goodbye..."
where
procDef :: ProcessId -> ProcessDefinition ()
procDef us =
statelessProcess {
apiHandlers = [
handleCast (\s () -> evalAfter (seconds 5) MyAlarmSignal s)
]
, infoHandlers = [
handleInfo (\s (sig :: MyAlarmSignal) -> send us sig >> continue s)
]
, unhandledMessagePolicy = Drop
} :: ProcessDefinition ()
testCallPrioritisation :: TestResult Bool -> Process ()
testCallPrioritisation result = do
pid <- mkPrioritisedServer
asyncRefs <- (mapM (callAsync pid)
["first", "the longest", "commands", "we do prioritise"])
:: Process [Async ()]
-- NB: This sleep is really important - the `init' function is waiting
-- (selectively) on the () signal to go, and if it receives this *before*
-- the async worker has had a chance to deliver the longest string message,
-- our test will fail. Such races are /normal/ given that the async worker
-- runs in another process and delivery order between multiple processes
-- is undefined (and in practise, partially depenendent on the scheduler)
sleep $ seconds 1
send pid ()
_ <- mapM wait asyncRefs :: Process [AsyncResult ()]
st <- call pid GetState :: Process [Either MyAlarmSignal String]
let ms = rights st
stash result $ ms == ["we do prioritise", "the longest", "commands", "first"]
tests :: NT.Transport -> IO TestTree
tests transport = do
localNode <- newLocalNode transport
return $ testGroup "" [
testGroup "basic server functionality matches un-prioritised processes" [
testCase "basic call with explicit server reply"
(delayedAssertion
"expected a response from the server"
localNode (Just "foo") (testBasicCall $ wrap server))
, testCase "basic call with implicit server reply"
(delayedAssertion
"expected n * 2 back from the server"
localNode (Just 4) (testBasicCall_ $ wrap server))
, testCase "basic deferred call handling"
(delayedAssertion "expected a response sent via replyTo"
localNode (AsyncDone "Hello There") testDeferredCallResponse)
, testCase "basic cast with manual send and explicit server continue"
(delayedAssertion
"expected pong back from the server"
localNode (Just "pong") (testBasicCast $ wrap server))
, testCase "cast and explicit server timeout"
(delayedAssertion
"expected the server to stop after the timeout"
localNode (Just $ ExitOther "timeout") (testControlledTimeout $ wrap server))
, testCase "unhandled input when policy = Terminate"
(delayedAssertion
"expected the server to stop upon receiving unhandled input"
localNode (Just $ ExitOther "UnhandledInput")
(testTerminatePolicy $ wrap server))
, testCase "unhandled input when policy = Drop"
(delayedAssertion
"expected the server to ignore unhandled input and exit normally"
localNode Nothing (testDropPolicy $ wrap (mkServer Drop)))
, testCase "unhandled input when policy = DeadLetter"
(delayedAssertion
"expected the server to forward unhandled messages"
localNode (Just ("UNSOLICITED_MAIL", 500 :: Int))
(testDeadLetterPolicy $ \p -> mkServer (DeadLetter p)))
, testCase "incoming messages are ignored whilst hibernating"
(delayedAssertion
"expected the server to remain in hibernation"
localNode True (testHibernation $ wrap server))
, testCase "long running call cancellation"
(delayedAssertion "expected to get AsyncCancelled"
localNode True (testKillMidCall $ wrap server))
, testCase "server rejects call"
(delayedAssertion "expected server to send CallRejected"
localNode (ExitOther "invalid-call") (testServerRejectsMessage $ wrap server))
, testCase "simple exit handling"
(delayedAssertion "expected handler to catch exception and continue"
localNode Nothing (testSimpleErrorHandling $ explodingServer))
, testCase "alternative exit handlers"
(delayedAssertion "expected handler to catch exception and continue"
localNode Nothing (testAlternativeErrorHandling $ explodingServer))
]
, testGroup "Prioritised Mailbox Handling" [
testCase "Info Message Prioritisation"
(delayedAssertion "expected the info handler to be prioritised"
localNode True testInfoPrioritisation)
, testCase "Call Message Prioritisation"
(delayedAssertion "expected the longest strings to be prioritised"
localNode True testCallPrioritisation)
, testCase "Size-Based Mailbox Overload Management"
(delayedAssertion "expected the server loop to stop reading the mailbox"
localNode True testOverflowHandling)
, testCase "Timeout-Based Mailbox Overload Management"
(delayedAssertion "expected the server loop to stop reading the mailbox"
localNode True testTimedOverflowHandling)
]
, testGroup "Advanced Server Interactions" [
testCase "using callSTM to manage non-CH interactions"
(delayedAssertion
"expected the server to reply back via the TQueue"
localNode True testExternalCall)
, testCase "Timeout-Based Overload Management with Control Channels"
(delayedAssertion "expected the server loop to reply"
localNode True testExternalTimedOverflowHandling)
, testCase "Complex pre/before filters"
(delayedAssertion "expected verifiable filter actions"
localNode True testFilteringBehavior)
, testCase "Firing internal timeouts"
(delayedAssertion "expected our info handler to run after the timeout"
localNode True testUserTimerHandling)
, testCase "Creating 'Safe' Handlers"
(delayedAssertion "expected our handler to run on the old message"
localNode True testSafeExecutionContext)
, testCase "Swapping ProcessDefinitions at runtime"
(delayedAssertion "expected our handler to exist in the new handler list"
localNode True testServerSwap)
, testCase "Accessing the internal process implementation"
(delayedAssertion "it should allow us to modify the internal q"
localNode True testStupidInfiniteLoop)
]
]
main :: IO ()
main = testMain $ tests