Skip to content

Commit 9671e7b

Browse files
authored
Merge pull request #5992 from IntersectMBO/mgalazyn/test/reenable-chairman
cardano-testnet | Reenable chairman test
2 parents 950659e + cbd1f72 commit 9671e7b

File tree

7 files changed

+37
-29
lines changed

7 files changed

+37
-29
lines changed

cardano-node-chairman/app/Cardano/Chairman.hs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,12 @@ runChairman ::
253253
(Anchor (Header (CardanoBlock StandardCrypto)))
254254
(Header (CardanoBlock StandardCrypto))))
255255
runChairman tracer networkId runningTime socketPaths cModeParams secParam = do
256-
let initialChains :: Map SocketPath (AF.AnchoredSeq (WithOrigin SlotNo) (Anchor (Header (CardanoBlock StandardCrypto))) (Header (CardanoBlock StandardCrypto)))
256+
let initialChains :: Map
257+
SocketPath
258+
(AF.AnchoredSeq
259+
(WithOrigin SlotNo)
260+
(Anchor (Header (CardanoBlock StandardCrypto)))
261+
(Header (CardanoBlock StandardCrypto)))
257262
initialChains = Map.fromList
258263
[ (socketPath, AF.Empty AF.AnchorGenesis)
259264
| socketPath <- socketPaths]

cardano-node-chairman/cardano-node-chairman.cabal

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ test-suite chairman-tests
6868

6969
type: exitcode-stdio-1.0
7070

71-
build-depends: cardano-testnet
71+
build-depends: , cardano-api
72+
, cardano-testnet
7273
, cardano-crypto-class ^>= 2.1.2
7374
, data-default-class
7475
, filepath
@@ -79,7 +80,6 @@ test-suite chairman-tests
7980
, random
8081
, resourcet
8182
, tasty
82-
, tasty-hedgehog
8383
, unliftio
8484

8585
other-modules: Spec.Chairman.Chairman

cardano-node-chairman/test/Main.hs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,27 @@ import qualified Cardano.Crypto.Init as Crypto
88

99
import Prelude
1010

11-
import Data.String (IsString (..))
1211
import qualified System.Environment as E
1312
import System.IO (BufferMode (LineBuffering), hSetBuffering, hSetEncoding, stdout, utf8)
1413

14+
import Testnet.Property.Run (ignoreOnWindows)
15+
1516
import qualified Test.Tasty as T
16-
import qualified Test.Tasty.Hedgehog as H
1717
import qualified Test.Tasty.Ingredients as T
1818

19+
import qualified Spec.Chairman.Cardano
1920
import qualified Spec.Network
2021

2122
tests :: IO T.TestTree
2223
tests = do
23-
let t0 = H.testPropertyNamed "isPortOpen False" (fromString "isPortOpen False") Spec.Network.hprop_isPortOpen_False
24-
let t1 = H.testPropertyNamed "isPortOpen True" (fromString "isPortOpen True" ) Spec.Network.hprop_isPortOpen_True
25-
-- TODO: Conway broken in conway
26-
-- let t2 = H.testPropertyNamed "chairman" (fromString "chairman" ) Spec.Chairman.Cardano.hprop_chairman
24+
let t0 = ignoreOnWindows "isPortOpen False" Spec.Network.hprop_isPortOpen_False
25+
let t1 = ignoreOnWindows "isPortOpen True" Spec.Network.hprop_isPortOpen_True
26+
let t2 = ignoreOnWindows "chairman" Spec.Chairman.Cardano.hprop_chairman
2727

2828
pure $ T.testGroup "test/Spec.hs"
2929
[ T.testGroup "Spec"
3030
[ T.testGroup "Chairman"
31-
[ T.testGroup "Cardano" [] -- [t2]
31+
[ T.testGroup "Cardano" [t2]
3232
]
3333
, T.testGroup "Network" [t0, t1]
3434
]

cardano-node-chairman/test/Spec/Chairman/Cardano.hs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,20 @@
44

55
module Spec.Chairman.Cardano where
66

7-
import Cardano.Testnet (NodeRuntime (nodeName), allNodes,
8-
cardanoTestnetDefault, mkConf)
7+
import Cardano.Testnet (allNodes, cardanoTestnetDefault, mkConf)
98

109
import Data.Default.Class
10+
1111
import Testnet.Property.Util (integrationRetryWorkspace)
1212

1313
import qualified Hedgehog as H
1414

1515
import Spec.Chairman.Chairman (chairmanOver)
1616

17-
-- TODO: Conway broken in conway
1817
hprop_chairman :: H.Property
1918
hprop_chairman = integrationRetryWorkspace 2 "cardano-chairman" $ \tempAbsPath' -> do
2019
conf <- mkConf tempAbsPath'
2120

22-
allNodes' <- fmap nodeName . allNodes <$> cardanoTestnetDefault def def conf
21+
allNodes' <- allNodes <$> cardanoTestnetDefault def def conf
2322

2423
chairmanOver 120 50 conf allNodes'

cardano-node-chairman/test/Spec/Chairman/Chairman.hs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,44 +6,41 @@ module Spec.Chairman.Chairman
66
( chairmanOver
77
) where
88

9+
import Cardano.Api (unFile)
10+
911
import Cardano.Testnet (TmpAbsolutePath (TmpAbsolutePath), makeLogDir)
1012
import qualified Cardano.Testnet as H
1113

1214
import Control.Monad (when)
1315
import Data.Functor ((<&>))
16+
import GHC.Stack
1417
import qualified System.Environment as IO
1518
import System.Exit (ExitCode (..))
1619
import System.FilePath.Posix ((</>))
1720
import qualified System.IO as IO
1821
import qualified System.Process as IO
1922

23+
import Testnet.Types (NodeRuntime, nodeSocketPath)
24+
2025
import qualified Hedgehog as H
21-
import Hedgehog.Extras.Stock.IO.Network.Sprocket (Sprocket (..))
22-
import qualified Hedgehog.Extras.Stock.IO.Network.Sprocket as IO
2326
import Hedgehog.Extras.Test.Base (Integration)
2427
import qualified Hedgehog.Extras.Test.Base as H
2528
import qualified Hedgehog.Extras.Test.File as H
2629
import qualified Hedgehog.Extras.Test.Process as H
2730

28-
{- HLINT ignore "Reduce duplication" -}
2931
{- HLINT ignore "Redundant <&>" -}
30-
{- HLINT ignore "Redundant flip" -}
31-
32-
mkSprocket :: FilePath -> FilePath -> String -> Sprocket
33-
mkSprocket tempBaseAbsPath socketDir node = Sprocket tempBaseAbsPath (socketDir </> node)
3432

35-
chairmanOver :: Int -> Int -> H.Conf -> [String] -> Integration ()
33+
chairmanOver :: HasCallStack => Int -> Int -> H.Conf -> [NodeRuntime] -> Integration ()
3634
chairmanOver timeoutSeconds requiredProgress H.Conf {H.tempAbsPath} allNodes = do
3735
maybeChairman <- H.evalIO $ IO.lookupEnv "DISABLE_CHAIRMAN"
3836
let tempAbsPath' = H.unTmpAbsPath tempAbsPath
3937
logDir = makeLogDir $ TmpAbsolutePath tempAbsPath'
4038
tempBaseAbsPath = H.makeTmpBaseAbsPath $ TmpAbsolutePath tempAbsPath'
41-
socketDir = H.makeSocketDir $ TmpAbsolutePath tempAbsPath'
4239
when (maybeChairman /= Just "1") $ do
4340
nodeStdoutFile <- H.noteTempFile logDir $ "chairman" <> ".stdout.log"
4441
nodeStderrFile <- H.noteTempFile logDir $ "chairman" <> ".stderr.log"
4542

46-
sprockets <- H.noteEach $ fmap (mkSprocket tempBaseAbsPath socketDir) allNodes
43+
sprockets <- H.noteEach $ unFile . nodeSocketPath <$> allNodes
4744

4845
hNodeStdout <- H.evalIO $ IO.openFile nodeStdoutFile IO.WriteMode
4946
hNodeStderr <- H.evalIO $ IO.openFile nodeStderrFile IO.WriteMode
@@ -54,7 +51,7 @@ chairmanOver timeoutSeconds requiredProgress H.Conf {H.tempAbsPath} allNodes = d
5451
, "--config", tempAbsPath' </> "configuration.yaml"
5552
, "--require-progress", show @Int requiredProgress
5653
]
57-
<> (sprockets >>= (\sprocket -> ["--socket-path", IO.sprocketArgumentName sprocket]))
54+
<> (sprockets >>= (\sprocket -> ["--socket-path", sprocket]))
5855
) <&>
5956
( \cp -> cp
6057
{ IO.std_in = IO.CreatePipe

cardano-testnet/src/Testnet/Start/Cardano.hs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ import qualified Hedgehog.Extras.Stock.OS as OS
7171

7272
-- | There are certain conditions that need to be met in order to run
7373
-- a valid node cluster.
74-
testnetMinimumConfigurationRequirements :: MonadTest m => NumPools -> m ()
75-
testnetMinimumConfigurationRequirements (NumPools n) =
74+
testnetMinimumConfigurationRequirements :: HasCallStack => MonadTest m => NumPools -> m ()
75+
testnetMinimumConfigurationRequirements (NumPools n) = withFrozenCallStack $
7676
when (n < 2) $ do
7777
H.noteShow_ ("Need at least two nodes to run a cluster, but got: " <> show n)
7878
H.failure
@@ -348,6 +348,8 @@ cardanoTestnet
348348
H.noteShow_ . vsep $ prettyError <$> failedNodes
349349
H.failure
350350

351+
H.annotateShow $ nodeSprocket . poolRuntime <$> poolNodes
352+
351353
-- FIXME: use foldEpochState waiting for chain extensions
352354
now <- H.noteShowIO DTC.getCurrentTime
353355
deadline <- H.noteShow $ DTC.addUTCTime 45 now

nix/haskell.nix

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,16 @@ let
228228
# This define files included in the directory that will be passed to `H.getProjectBase` for this test:
229229
filteredProjectBase = incl ../. cardanoTestnetGoldenFiles;
230230
in
231+
# work around 104 chars socket path limit by using a different temporary directory
231232
''
232233
${exportCliPath}
233234
${exportNodePath}
234235
${exportChairmanPath}
235236
export CARDANO_NODE_SRC=${filteredProjectBase}
237+
# unset TMPDIR, otherwise mktemp will use that as a base
238+
unset TMPDIR
239+
export TMPDIR=$(mktemp -d)
240+
export TMP=$TMPDIR
236241
'';
237242
# cardano-testnet depends on cardano-node, cardano-cli, cardano-submit-api and some config files
238243
packages.cardano-node.components.tests.cardano-node-test.preCheck =
@@ -259,13 +264,13 @@ let
259264
${exportSubmitApiPath}
260265
export CARDANO_NODE_SRC=${filteredProjectBase}
261266
''
262-
# the cardano-testnet-tests, use sockets stored in a temporary directory
267+
# the cardano-testnet-tests and chairman-tests, use sockets stored in a temporary directory
263268
# however on macOS the socket path's max is 104 chars. The package name
264269
# is already long, and as such the constructed socket path
265270
#
266271
# /private/tmp/nix-build-cardano-testnet-test-cardano-testnet-tests-1.36.0-check.drv-1/chairman-test-93c5d9288dd8e6bc/socket/node-bft1
267272
#
268-
# exceeds taht limit easily. We therefore set a different tmp directory
273+
# exceeds that limit easily. We therefore set a different tmp directory
269274
# during the preBuild phase.
270275
+ ''
271276
# unset TMPDIR, otherwise mktemp will use that as a base

0 commit comments

Comments
 (0)