From 7306e695b7d68318c96431e1f9d8aab04c062f1e Mon Sep 17 00:00:00 2001 From: Daniel Firth Date: Wed, 22 May 2024 15:13:07 +0000 Subject: [PATCH] Denote supportedNetworks in hydra-cluster tests --- .github/workflows/check-tutorial.yaml | 2 +- hydra-cluster/test/Test/CardanoNodeSpec.hs | 23 ++++++++++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/.github/workflows/check-tutorial.yaml b/.github/workflows/check-tutorial.yaml index 8ea361cfcc5..11722d8904d 100644 --- a/.github/workflows/check-tutorial.yaml +++ b/.github/workflows/check-tutorial.yaml @@ -35,7 +35,7 @@ jobs: with open("hydra-cluster/test/Test/CardanoNodeSpec.hs", "r") as cardanoNodeSpecFile: body = cardanoNodeSpecFile.read() - expectedCardanoNodeVersion = re.findall(r"getCardanoNodeVersion.*([0-9]+\.[0-9]+\.[0-9]+)", body)[0] + expectedCardanoNodeVersion = re.findall(r"supportedCardanoNodeVersion.*([0-9]+\.[0-9]+\.[0-9]+)", body)[0] print("Checking used cardano-node version") if all(v == expectedCardanoNodeVersion for v in usedCardanoNodeVersions): diff --git a/hydra-cluster/test/Test/CardanoNodeSpec.hs b/hydra-cluster/test/Test/CardanoNodeSpec.hs index 970508038a7..f3b0c209898 100644 --- a/hydra-cluster/test/Test/CardanoNodeSpec.hs +++ b/hydra-cluster/test/Test/CardanoNodeSpec.hs @@ -17,13 +17,26 @@ import Hydra.Logging (Tracer, showLogsOnFailure) import System.Directory (doesFileExist) import Test.Hydra.Cluster.Utils (forEachKnownNetwork) +supportedNetworks :: [KnownNetwork] +supportedNetworks = [Preview, Preproduction, Mainnet] + +supportedCardanoNodeVersion :: String +supportedCardanoNodeVersion = "8.9.0" + +forSupportedKnownNetworks :: String -> (KnownNetwork -> IO ()) -> Spec +forSupportedKnownNetworks msg action = forEachKnownNetwork msg $ \network -> do + unless (network `elem` supportedNetworks) $ + pendingWith $ + "cardano-node " <> supportedCardanoNodeVersion <> " is only supported on " ++ show supportedNetworks + action network + spec :: Spec spec = do -- NOTE: We also hard-code the cardano-node version here to allow prevent -- false positives test errors in case someone uses an "untested" / -- different than in shell.nix version of cardano-node and cardano-cli. it "has expected cardano-node version available" $ - getCardanoNodeVersion >>= (`shouldContain` "8.9.0") + getCardanoNodeVersion >>= (`shouldContain` supportedCardanoNodeVersion) around (failAfter 5 . setupTracerAndTempDir) $ do it "withCardanoNodeDevnet does start a block-producing devnet within 5 seconds" $ \(tr, tmp) -> @@ -41,16 +54,18 @@ spec = do describe "findRunningCardanoNode" $ do it "returns Nothing on non-matching network" $ \(tr, tmp) -> do + unless (Preview `elem` supportedNetworks) $ + pendingWith "Preview is not supported so skipping this test." withCardanoNodeOnKnownNetwork tr tmp Preview $ \_ -> do findRunningCardanoNode tr tmp Preproduction `shouldReturn` Nothing it "returns Just running node on matching network" $ \(tr, tmp) -> do + unless (Preview `elem` supportedNetworks) $ + pendingWith "Preview is not supported so skipping this test." withCardanoNodeOnKnownNetwork tr tmp Preview $ \runningNode -> do findRunningCardanoNode tr tmp Preview `shouldReturn` Just runningNode - forEachKnownNetwork "withCardanoNodeOnKnownNetwork starts synchronizing within 10 seconds" $ \network -> do - when (network == Sanchonet) $ - pendingWith "cardano-node 8.9 not anymore supported on sanchonet" + forSupportedKnownNetworks "withCardanoNodeOnKnownNetwork starts synchronizing within 10 seconds" $ \network -> do -- NOTE: This implies that withCardanoNodeOnKnownNetwork does not -- synchronize the whole chain before continuing. setupTracerAndTempDir $ \(tr, tmp) ->