From bfbb22b7b548fe7d259c7e8cbe889af57f9d05dc Mon Sep 17 00:00:00 2001 From: Eric <5089238+emizzle@users.noreply.github.com> Date: Thu, 16 Jan 2025 11:52:02 +1100 Subject: [PATCH] cleanup # Conflicts: # tests/testIntegration.nim --- tests/integration/testmanager.nim | 33 +++++----------- tests/testIntegration.nim | 66 ++++++++++++++++++++----------- 2 files changed, 54 insertions(+), 45 deletions(-) diff --git a/tests/integration/testmanager.nim b/tests/integration/testmanager.nim index dc5d3512..fbdf0bf6 100644 --- a/tests/integration/testmanager.nim +++ b/tests/integration/testmanager.nim @@ -25,11 +25,17 @@ type lastHardhatPort: int lastCodexApiPort: int lastCodexDiscPort: int - debugTestHarness: bool # output chronicles logs for the manager and multinodes harness + # Echoes stderr if there's a test failure (eg test failed, compilation + # error) or error (eg test manager error) + debugTestHarness: bool + # Echoes stdout from Hardhat process debugHardhat: bool - debugCodexNodes: bool # output chronicles logs for the codex nodes running in the tests - timeStart: Moment - timeEnd: Moment + # Echoes stdout from the integration test file process. Codex process logs + # can also be output if a test uses a multinodesuite, requires + # CodexConfig.debug to be enabled + debugCodexNodes: bool + timeStart: ?Moment + timeEnd: ?Moment codexPortLock: AsyncLock hardhatPortLock: AsyncLock hardhatProcessLock: AsyncLock @@ -92,25 +98,6 @@ proc new*( debugCodexNodes = false, testTimeout = 60.minutes): TestManager = - if debugTestHarness: - when enabledLogLevel != LogLevel.TRACE: - echoStyled bgWhite, fgBlack, styleBright, "\n\n ", - styleUnderscore, "ADDITIONAL LOGGING AVAILABILE\n\n", - resetStyle, bgWhite, fgBlack, styleBright, """ - More integration test harness logs available by running with - -d:chronicles_log_level=TRACE, eg:""", - resetStyle, bgWhite, fgBlack, - "\n\n nim c -d:chronicles_log_level=TRACE -r ./testIntegration.nim\n\n" - - if debugCodexNodes: - echoStyled bgWhite, fgBlack, styleBright, "\n\n ", - styleUnderscore, "ENABLE CODEX LOGGING\n\n", - resetStyle, bgWhite, fgBlack, styleBright, """ - For integration test suites that are multinodesuites, or for - tests launching a CodexProcess, ensure that CodexConfig.debug - is enabled. - """ - TestManager( configs: configs, lastHardhatPort: 8545, diff --git a/tests/testIntegration.nim b/tests/testIntegration.nim index d1f347b7..7a26751b 100644 --- a/tests/testIntegration.nim +++ b/tests/testIntegration.nim @@ -9,6 +9,7 @@ # import ./integration/testvalidator # import ./integration/testecbug +import std/terminal import pkg/chronos import pkg/codex/logutils import ./integration/testmanager @@ -18,33 +19,54 @@ import ./integration/testmanager const TestConfigs = @[ IntegrationTestConfig.init("./integration/testcli", startHardhat = true), - IntegrationTestConfig.init("./integration/testrestapi", startHardhat = false), - # IntegrationTestConfig.init("./integration/testupdownload", startHardhat = true), - # IntegrationTestConfig.init("./integration/testsales", startHardhat = true), - # IntegrationTestConfig.init("./integration/testpurchasing", startHardhat = true), - # IntegrationTestConfig.init("./integration/testblockexpiration", startHardhat = true), - # IntegrationTestConfig.init( - # name = "Basic Marketplace and payout tests", - # testFile = "./integration/testmarketplace", - # startHardhat = true, - ), - # IntegrationTestConfig("./integration/testproofs", startHardhat = true), - # IntegrationTestConfig("./integration/testvalidator", startHardhat = true), - IntegrationTestConfig.init( - name = "Erasure Coding Bug", - testFile = "./integration/testecbug", - startHardhat = true, - ) + IntegrationTestConfig.init("./integration/testrestapi", startHardhat = true), + IntegrationTestConfig.init("./integration/testupdownload", startHardhat = true), + IntegrationTestConfig.init("./integration/testsales", startHardhat = true), + IntegrationTestConfig.init("./integration/testpurchasing", startHardhat = true), + IntegrationTestConfig.init("./integration/testblockexpiration", startHardhat = true), + IntegrationTestConfig.init("./integration/testmarketplace", startHardhat = true), + IntegrationTestConfig.init("./integration/testproofs", startHardhat = true), + IntegrationTestConfig.init("./integration/testvalidator", startHardhat = true), + IntegrationTestConfig.init("./integration/testecbug", startHardhat = true) ] proc run() {.async.} = + # Echoes stderr if there's a test failure (eg test failed, compilation error) + # or error (eg test manager error) + const debugTestHarness = false + # Echoes stdout from Hardhat process + const debugHardhat = false + # Echoes stdout from the integration test file process. Codex process logs can + # also be output if a test uses a multinodesuite, requires CodexConfig.debug + # to be enabled + const debugCodexNodes = true + + when debugTestHarness and enabledLogLevel != LogLevel.TRACE: + styledEcho bgWhite, + fgBlack, styleBright, "\n\n ", styleUnderscore, + "ADDITIONAL LOGGING AVAILABILE\n\n", resetStyle, bgWhite, fgBlack, styleBright, + """ +More integration test harness logs available by running with +-d:chronicles_log_level=TRACE, eg:""", + resetStyle, bgWhite, fgBlack, + "\n\n nim c -d:chronicles_log_level=TRACE -r ./testIntegration.nim\n\n" + + when debugCodexNodes: + styledEcho bgWhite, + fgBlack, styleBright, "\n\n ", styleUnderscore, "ENABLE CODEX LOGGING\n\n", + resetStyle, bgWhite, fgBlack, styleBright, + """ + For integration test suites that are multinodesuites, or for + tests launching a CodexProcess, ensure that CodexConfig.debug + is enabled. + """ + let manager = TestManager.new( configs = TestConfigs, - debugTestHarness = true, - # Echos stderr if there's a test failure or error (error in running the test) - debugCodexNodes = true, - # Echos stdout from the Codex process (chronicles logs). If test uses a multinodesuite, requires CodexConfig.debug to be enabled - debugHardhat = false, + debugTestHarness, + debugHardhat, + debugCodexNodes, + testTimeout = 60.minutes, ) try: trace "starting test manager"