From 1c7393e11c5501cac781c113f8d23977b433fa49 Mon Sep 17 00:00:00 2001 From: Michael Karg Date: Thu, 12 Dec 2024 16:02:07 +0100 Subject: [PATCH] resolve test input file mainnet-config.json --- .../Cardano/Tracing/NewTracing/Consistency.hs | 50 +++++++++++-------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/cardano-node/test/Test/Cardano/Tracing/NewTracing/Consistency.hs b/cardano-node/test/Test/Cardano/Tracing/NewTracing/Consistency.hs index c0d55f5e2d7..2a7a99bcab8 100644 --- a/cardano-node/test/Test/Cardano/Tracing/NewTracing/Consistency.hs +++ b/cardano-node/test/Test/Cardano/Tracing/NewTracing/Consistency.hs @@ -8,6 +8,7 @@ import Cardano.Node.Tracing.Consistency (checkNodeTraceConfiguration) import Control.Monad.IO.Class (MonadIO, liftIO) import Data.Text +import qualified System.Directory as IO import System.FilePath (()) import Hedgehog (Property) @@ -21,40 +22,45 @@ tests = do H.checkSequential $ H.Group "Configuration Consistency tests" $ Prelude.map test - [ {--( [] - -- This file name shoud reference the current standard config with new tracing - -- Add this testcase when hydra has access to a config file with new tracing config + [ ( [] + -- This file name should reference the current standard config with new tracing + , configSubdir , "mainnet-config.json" - , configPrefix) - ,--} + ) + , ( [] + , testSubdir , "goodConfig.yaml" - , testPrefix) + ) , ( [ "Config namespace error: Illegal namespace ChainDB.CopyToImmutableDBEvent2.CopiedBlockToImmutableDB" , "Config namespace error: Illegal namespace SubscriptionDNS" ] + , testSubdir , "badConfig.yaml" - , testPrefix) + ) ] where - test (actualValue, goldenBaseName, prefix) = - (PropertyName goldenBaseName, goldenTestJSON actualValue goldenBaseName prefix) + test (actualValue, subDir, goldenBaseName) = + (PropertyName goldenBaseName, goldenTestJSON actualValue subDir goldenBaseName) - -goldenTestJSON :: [Text] -> FilePath -> (FilePath -> IO FilePath) -> Property -goldenTestJSON expectedOutcome goldenFileBaseName prefixFunc = +goldenTestJSON :: [Text] -> SubdirSelection -> FilePath -> Property +goldenTestJSON expectedOutcome subDir goldenFileBaseName = H.withTests 1 $ H.withShrinks 0 $ H.property $ do - basePath <- H.getProjectBase - prefixPath <- liftIO $ prefixFunc basePath - goldenFp <- H.note $ prefixPath goldenFileBaseName + base <- resolveDir subDir + goldenFp <- H.note $ base goldenFileBaseName actualValue <- liftIO $ checkNodeTraceConfiguration goldenFp actualValue H.=== expectedOutcome + where + resolveDir (ExternalSubdir d) = do + base <- H.evalIO . IO.canonicalizePath =<< H.getProjectBase + pure $ base d + resolveDir (InternalSubdir d) = + pure d +data SubdirSelection = + InternalSubdir FilePath + | ExternalSubdir FilePath --- configPrefix :: FilePath -> IO FilePath --- configPrefix projectBase = do --- base <- canonicalizePath projectBase --- return $ base "configuration/cardano/" - -testPrefix :: FilePath -> IO FilePath -testPrefix _ = pure "test/Test/Cardano/Tracing/NewTracing/data/" +testSubdir, configSubdir :: SubdirSelection +testSubdir = InternalSubdir "test/Test/Cardano/Tracing/NewTracing/data" +configSubdir = ExternalSubdir "configuration/cardano"