From 42152773cea2a52761e4592c1df9afe319534ba9 Mon Sep 17 00:00:00 2001 From: Eric <5089238+emizzle@users.noreply.github.com> Date: Mon, 3 Feb 2025 19:04:24 +1100 Subject: [PATCH] Allow parallel integration tests to be disabled Disable with `make ENABLE_PARALLEL_TESTS=0 testIntegration` --- .github/workflows/ci-reusable.yml | 6 +++++- .github/workflows/ci.yml | 6 +++--- Makefile | 3 +++ build.nims | 1 + tests/testIntegration.nim | 17 ++++++++++++++++- 5 files changed, 28 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci-reusable.yml b/.github/workflows/ci-reusable.yml index d9b23007..cd0d8d7e 100644 --- a/.github/workflows/ci-reusable.yml +++ b/.github/workflows/ci-reusable.yml @@ -62,7 +62,7 @@ jobs: npm install - name: Run Ethereum node with Codex contracts - if: matrix.tests == 'contract' || matrix.tests == 'tools' || matrix.tests == 'all' + if: matrix.tests == 'contract' || matrix.tests == 'integration' || matrix.tests == 'tools' || matrix.tests == 'all' working-directory: vendor/codex-contracts-eth env: MSYS2_PATH_TYPE: inherit @@ -77,6 +77,10 @@ jobs: ## Part 3 Tests ## - name: Integration tests if: matrix.tests == 'integration' || matrix.tests == 'all' + run: make -j${ncpu} ENABLE_PARALLEL_TESTS=0 testIntegration + + - name: Parallel integration tests + if: matrix.tests == 'integration-parallel' run: make -j${ncpu} DEBUG_CODEXNODES=1 DEBUG_TESTHARNESS=1 DEBUG_UPDATES=1 testIntegration - name: Upload integration tests log files diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c3edeffc..369f091e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,9 +27,9 @@ jobs: uses: fabiocaccamo/create-matrix-action@v5 with: matrix: | - os {linux}, cpu {amd64}, builder {runner-node-01-linux-02-eu-hel1}, tests {integration}, nim_version {${{ env.nim_version }}}, shell {bash --noprofile --norc -e -o pipefail} - os {macos}, cpu {amd64}, builder {macos-14-large}, tests {integration}, nim_version {${{ env.nim_version }}}, shell {bash --noprofile --norc -e -o pipefail} - os {windows}, cpu {amd64}, builder {windows-latest-amd64-32vcpu}, tests {integration}, nim_version {${{ env.nim_version }}}, shell {msys2} + os {linux}, cpu {amd64}, builder {runner-node-01-linux-03-eu-hel1}, tests {integration-parallel}, nim_version {${{ env.nim_version }}}, shell {bash --noprofile --norc -e -o pipefail} + os {macos}, cpu {amd64}, builder {macos-14-large}, tests {integration-parallel}, nim_version {${{ env.nim_version }}}, shell {bash --noprofile --norc -e -o pipefail} + os {windows}, cpu {amd64}, builder {windows-latest-amd64-32vcpu}, tests {integration-parallel}, nim_version {${{ env.nim_version }}}, shell {msys2} build: diff --git a/Makefile b/Makefile index fbbfb912..6e1c81a8 100644 --- a/Makefile +++ b/Makefile @@ -157,6 +157,9 @@ endif ifdef TEST_TIMEOUT TEST_PARAMS := $(TEST_PARAMS) -d:TestTimeout=$(TEST_TIMEOUT) endif +ifdef ENABLE_PARALLEL_TESTS + TEST_PARAMS := $(TEST_PARAMS) -d:EnableParallelTests=$(ENABLE_PARALLEL_TESTS) +endif # Builds and runs the integration tests testIntegration: | build deps diff --git a/build.nims b/build.nims index 9ff8c5ce..573115aa 100644 --- a/build.nims +++ b/build.nims @@ -55,6 +55,7 @@ task testIntegration, "Run integration tests": for i in 2 ..< paramCount(): if "DebugTestHarness" in paramStr(i) and truthy paramStr(i).split('=')[1]: testParams = "-d:chronicles_log_level=TRACE -d:chronicles_sinks=textlines[stdout]" + break test "testIntegration", params = testParams # use params to enable logging from the integration test executable # test "testIntegration", params = "-d:chronicles_sinks=textlines[notimestamps,stdout],textlines[dynamic] " & diff --git a/tests/testIntegration.nim b/tests/testIntegration.nim index 9ece9542..9ed70a48 100644 --- a/tests/testIntegration.nim +++ b/tests/testIntegration.nim @@ -34,6 +34,8 @@ const ShowContinuousStatusUpdates {.booldefine.} = false # Timeout duration (in mimutes) for EACH integration test file. const TestTimeout {.intdefine.} = 60 +const EnableParallelTests {.booldefine.} = true + proc run() {.async.} = when DebugTestHarness and enabledLogLevel != LogLevel.TRACE: styledEcho bgWhite, @@ -78,4 +80,17 @@ proc run() {.async.} = if not wasSuccessful: quit(1) # indicate with a non-zero exit code that the tests failed -waitFor run() +when EnableParallelTests: + waitFor run() +else: + # run tests serially + import ./integration/testcli + import ./integration/testrestapi + import ./integration/testupdownload + import ./integration/testsales + import ./integration/testpurchasing + import ./integration/testblockexpiration + import ./integration/testmarketplace + import ./integration/testproofs + import ./integration/testvalidator + import ./integration/testecbug