git.iko.soy/distributed-process
on 85b0f85 help sign in
45 lines 1.5 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 , TCPParameters(..)
14 )
15import Test.Framework (defaultMainWithArgs)
17import Control.Concurrent (threadDelay)
18import System.Environment (getArgs)
19import System.IO
21main :: IO ()
22main = do
23 hSetBuffering stdout LineBuffering
24 hSetBuffering stderr LineBuffering
25 Right (transport, internals) <-
26 createTransportExposeInternals "127.0.0.1" "8080"
27 defaultTCPParameters { transportConnectTimeout = Just 3000000 }
28 ts <- tests TestTransport
29 { testTransport = transport
30 , testBreakConnection = \addr1 addr2 -> do
31 sock <- socketBetween internals addr1 addr2
32 sClose sock
33 threadDelay 10000
34 }
35 args <- getArgs
36 -- Tests are time sensitive. Running the tests concurrently can slow them
37 -- down enough that threads using threadDelay would wake up later than
38 -- expected, thus changing the order in which messages were expected.
39 -- Therefore we run the tests sequentially by passing "-j 1" to
40 -- test-framework. This does not solve the issue but makes it less likely.
41 --
42 -- The problem was first detected with
43 -- 'Control.Distributed.Process.Tests.CH.testMergeChannels'
44 -- in particular.
45 defaultMainWithArgs ts ("-j" : "1" : args)