git.iko.soy/distributed-process
on mxsend-fix help sign in
47 lines 1.7 kB history raw
1-- Run tests using the TCP transport.
2--
3module Main where
5import TEST_SUITE_MODULE (tests)
7import Network.Transport.Test (TestTransport(..))
8import Network.Socket (sClose)
9import Network.Transport.TCP
10 ( createTransportExposeInternals
11 , TransportInternals(socketBetween)
12 , defaultTCPParameters
13 , defaultTCPAddr
14 , TCPParameters(..)
15 )
16import Test.Framework (defaultMainWithArgs)
18import Control.Concurrent (threadDelay)
19import Control.Exception (IOException, try)
20import System.Environment (getArgs)
21import System.IO
23main :: IO ()
24main = do
25 hSetBuffering stdout LineBuffering
26 hSetBuffering stderr LineBuffering
27 Right (transport, internals) <-
28 createTransportExposeInternals (defaultTCPAddr "127.0.0.1" "8080")
29 defaultTCPParameters { transportConnectTimeout = Just 3000000 }
30 ts <- tests TestTransport
31 { testTransport = transport
32 , testBreakConnection = \addr1 addr2 -> do
33 esock <- try $ socketBetween internals addr1 addr2
34 either (\e -> const (return ()) (e :: IOException)) sClose esock
35 threadDelay 10000
36 }
37 args <- getArgs
38 -- Tests are time sensitive. Running the tests concurrently can slow them
39 -- down enough that threads using threadDelay would wake up later than
40 -- expected, thus changing the order in which messages were expected.
41 -- Therefore we run the tests sequentially by passing "-j 1" to
42 -- test-framework. This does not solve the issue but makes it less likely.
43 --
44 -- The problem was first detected with
45 -- 'Control.Distributed.Process.Tests.CH.testMergeChannels'
46 -- in particular.
47 defaultMainWithArgs ts ("-j" : "1" : args)