Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/cabal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ jobs:
- name: Generate freeze file
run: |
# Cloud Haskell tests using the QUIC backend are quite flaky, but in CI only.
# Therefore, the 'quic' flag is normally enabled locally, but disabled in CI.
cabal configure --enable-tests --test-show-details=direct --flags "-quic" ${{matrix.cabal-flags}}
# Therefore, the 'quic' flag is normally enabled locally, but disabled in CI.
cabal configure --test-show-details=direct --flags "-quic" ${{matrix.cabal-flags}}
cabal freeze --minimize-conflict-set
cat cabal.project.freeze

Expand All @@ -82,5 +82,5 @@ jobs:
# The timeout below should be plenty
timeout-minutes: 10
# We run each test suite one-by-one to better observe problems.
run: cabal test all -j1
run: cabal test all -j1

1 change: 1 addition & 0 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
packages: packages/*/**.cabal
tests: true

package distributed-process-tests
flags: +tcp
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,19 @@ import Control.Exception (bracket)
import Control.Monad (replicateM_)
import Data.ByteString qualified as BS
import Data.List.NonEmpty (NonEmpty (..))
import Network.Transport (EndPoint (..), Event (ConnectionClosed, ConnectionOpened, Received), Reliability (..), Transport (..), close, defaultConnectHints, send)
import Network.Transport (EndPoint (..), Event (ConnectionClosed), Reliability (..), Transport (..), close, defaultConnectHints, send)
import Network.Transport.QUIC (QUICTransportConfig (..))
import Network.Transport.QUIC qualified as QUIC
import Network.Transport.Tests (echoServer)
import Network.Transport.Tests qualified as Tests
import Network.Transport.Tests.Auxiliary (forkTry)
import Network.Transport.Tests.Expect (expectConnectionOpened, expectEq, expectReceived, expectRight)
import Network.Transport.Util (spawn)
import System.FilePath ((</>))
import System.Timeout (timeout)
import Test.Tasty (TestName, TestTree, testGroup)
import Test.Tasty.Flaky (flakyTest, limitRetries)
import Test.Tasty.HUnit (Assertion, assertBool, assertFailure, testCase, (@?=))
import Test.Tasty.Flaky (flakyTest, limitRetries, constantDelay)
import Test.Tasty.HUnit (Assertion, assertFailure, testCase, (@?=))

tests :: TestTree
tests =
Expand All @@ -47,7 +48,7 @@ tests =
]

flaky :: TestTree -> TestTree
flaky = flakyTest (limitRetries 3)
flaky = flakyTest (limitRetries 3 <> constantDelay 1_000)

-- | Ensure that a test does not run for too long
testCaseWithTimeout :: TestName -> Assertion -> TestTree
Expand Down Expand Up @@ -91,21 +92,22 @@ testSendVeryLargeMessages = testCase "Send very large messages" $ withQUICTransp
let numPings = 10
let bigMessage = BS.replicate 4091 66 -- Using an odd number of bytes (4091) to test message boundaries
_ <- forkTry $ do
Right endpoint <- newEndPoint transport
endpoint <- expectRight "newEndPoint" =<< newEndPoint transport
ping endpoint server numPings bigMessage
putMVar result ()

takeMVar result
where
ping endpoint serverAddr numPings message = do
Right conn <- connect endpoint serverAddr ReliableOrdered defaultConnectHints
conn <- expectRight "connect" =<< connect endpoint serverAddr ReliableOrdered defaultConnectHints

ConnectionOpened cid _ _ <- receive endpoint
(cid, _, _) <- expectConnectionOpened =<< receive endpoint

replicateM_ numPings $ do
_ <- send conn [message]
Received cid' [reply] <- receive endpoint
assertBool mempty $ cid == cid' && reply == message
(cid', payload) <- expectReceived =<< receive endpoint
expectEq "connection id" cid cid'
expectEq "payload" [message] payload

close conn

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ library
exposed-modules: Network.Transport.Tests,
Network.Transport.Tests.Multicast,
Network.Transport.Tests.Auxiliary,
Network.Transport.Tests.Expect,
Network.Transport.Tests.Traced
-- other-modules:
build-depends: base >= 4.14 && < 5,
Expand Down
Loading
Loading