diff --git a/cardano-tracer/test/Cardano/Tracer/Test/Logs/Tests.hs b/cardano-tracer/test/Cardano/Tracer/Test/Logs/Tests.hs index 5f235a3e80a..cf15fd78eda 100644 --- a/cardano-tracer/test/Cardano/Tracer/Test/Logs/Tests.hs +++ b/cardano-tracer/test/Cardano/Tracer/Test/Logs/Tests.hs @@ -1,7 +1,8 @@ {-# LANGUAGE LambdaCase #-} module Cardano.Tracer.Test.Logs.Tests - ( tests + ( testsLogs + , testsJson ) where import Control.Concurrent.Async (withAsync) @@ -24,28 +25,22 @@ import Cardano.Tracer.Utils (applyBrake, initProtocolsBrake, initDataP import Cardano.Tracer.Test.Forwarder import Cardano.Tracer.Test.Utils -tests :: TestTree -tests = localOption (QuickCheckTests 1) $ testGroup "Test.Logs" - [ tests1 -- testProperty ".log" $ propRunInLogsStructure (propLogs ForHuman) - , tests2 -- testProperty ".json" $ propRunInLogsStructure (propLogs ForMachine) - --, testProperty "multi, initiator" $ propRunInLogsStructure2 (propMultiInit ForMachine) - --, testProperty "multi, responder" $ propRunInLogsStructure (propMultiResp ForMachine) - ] - -tests1 :: TestTree -tests1 = localOption (QuickCheckTests 1) $ testGroup "Test.Logs.Log" +testsLogs :: TestTree +testsLogs = localOption (QuickCheckTests 1) $ testGroup "Test.Logs" [ testProperty ".log" $ propRunInLogsStructure (propLogs ForHuman) ] -tests2 :: TestTree -tests2 = localOption (QuickCheckTests 1) $ testGroup "Test.Logs.Json" +testsJson :: TestTree +testsJson = localOption (QuickCheckTests 1) $ testGroup "Test.Logs" [ testProperty ".json" $ propRunInLogsStructure (propLogs ForMachine) + --, testProperty "multi, initiator" $ propRunInLogsStructure2 (propMultiInit ForMachine) + --, testProperty "multi, responder" $ propRunInLogsStructure (propMultiResp ForMachine) ] propLogs :: LogFormat -> FilePath -> FilePath -> IO Property propLogs format rootDir localSock = do - traceIO $ "rootDir: " <> rootDir - traceIO $ "localSock: " <> localSock + removeDirectoryContent rootDir + stopProtocols <- initProtocolsBrake dpRequestors <- initDataPointRequestors withAsync (doRunCardanoTracer (config rootDir localSock) stopProtocols dpRequestors) . const $ @@ -55,19 +50,26 @@ propLogs format rootDir localSock = do sleep 0.5 doesDirectoryExist rootDir >>= \case - True -> + True -> do + traceIO "Logs, 1__" -- ... and contains one node's subdir... listDirectory rootDir >>= \case [] -> false "root dir is empty" - (subDir:_) -> - withCurrentDirectory rootDir $ + (subDir:_) -> do + traceIO "Logs, 2__" + withCurrentDirectory rootDir $ do + traceIO $ "Logs, 3__. rootDir " <> rootDir -- ... with *.log-files inside... listDirectory subDir >>= \case [] -> false "subdir is empty" - logsAndSymLink -> - withCurrentDirectory subDir $ + logsAndSymLink -> do + traceIO $ "Logs, 3__. subDir " <> subDir + withCurrentDirectory subDir $ do + traceIO $ "Logs, 4__" case filter (isItLog format) logsAndSymLink of - [] -> false "subdir doesn't contain expected logs" + [] -> do + traceIO $ "Logs, 5__, logsAndSymLink " <> show logsAndSymLink + false "subdir doesn't contain expected logs" logsWeNeed -> if length logsWeNeed > 1 then diff --git a/cardano-tracer/test/Cardano/Tracer/Test/Utils.hs b/cardano-tracer/test/Cardano/Tracer/Test/Utils.hs index 21aa6e53b83..2eb4884c604 100644 --- a/cardano-tracer/test/Cardano/Tracer/Test/Utils.hs +++ b/cardano-tracer/test/Cardano/Tracer/Test/Utils.hs @@ -23,7 +23,6 @@ propRunInLogsStructure -> Property propRunInLogsStructure testAction = ioProperty $ do (rootDir, deleteDir) <- newTempDir - removeDirectoryContent rootDir (localSock, _) <- newTempFile let preparedLocalSock = prepareLocalSock localSock testAction rootDir preparedLocalSock diff --git a/cardano-tracer/test/cardano-tracer-test.hs b/cardano-tracer/test/cardano-tracer-test.hs index 6457e95d45a..446dadd34d4 100644 --- a/cardano-tracer/test/cardano-tracer-test.hs +++ b/cardano-tracer/test/cardano-tracer-test.hs @@ -8,7 +8,8 @@ import qualified Cardano.Tracer.Test.Logs.Tests as Logs main :: IO () main = defaultMain $ testGroup "cardano-tracer" - [ Logs.tests + [ Logs.testsLogs + , Logs.testsJson --, DataPoint.tests --, Network.tests --, Queue.tests