Skip to content

Speed up Lite tests: enable parallelization + share DuckDB in FinOpsTests#924

Merged
erikdarlingdata merged 1 commit intodevfrom
feature/lite-tests-parallel
May 2, 2026
Merged

Speed up Lite tests: enable parallelization + share DuckDB in FinOpsTests#924
erikdarlingdata merged 1 commit intodevfrom
feature/lite-tests-parallel

Conversation

@erikdarlingdata
Copy link
Copy Markdown
Owner

Summary

The CI test step was averaging ~7 minutes for 257 Lite tests because xUnit's default parallelization was implicit and slow classes (FactCollectorTests, ScenarioTests) blocked the pipeline. Local runs of the full suite drop to ~2m21s with explicit parallelization config.

Changes

  • Lite.Tests/xunit.runner.json: explicit parallelization settings (parallelizeAssembly=true, parallelizeTestCollections=true, maxParallelThreads=-1, parallelAlgorithm=aggressive), with CopyToOutputDirectory wired up in the csproj.
  • BaselineProviderCollection: serialize BaselineProviderTests and AnomalyDetectorTests into a shared collection (DisableParallelization=true). Both mutate the static BaselineProvider.CacheTtl field, so they must run sequentially relative to each other or they'd race on the static state.
  • FinOpsTestsIClassFixture<FinOpsDuckDbFixture>: shares one DuckDB across the class. Every seeder in TestDataSeeder.Seed* already calls ClearTestDataAsync first, so cross-test pollution is prevented without rewriting test code. Saves the schema-init cost on each test.

This is a pilot for the IClassFixture approach. Converting other classes (FactCollectorTests etc.) would require adding ClearTestDataAsync calls to many tests, so leaving those for a follow-up. The bigger win is parallel execution across classes, which is fully covered by the runner.json settings.

Test plan

  • dotnet test Lite.Tests — 257 passed, 0 failed, 2m 21s locally
  • Confirm CI's "Run Lite tests" step drops noticeably below the prior ~7 min baseline

🤖 Generated with Claude Code

…ests

The CI test step was averaging ~7 minutes for 257 tests because xUnit's
default parallelization was implicit and slow classes (FactCollectorTests,
ScenarioTests) blocked the pipeline. Local runs of the full suite went
from sequential-feeling runs to ~2m21s with explicit parallelization
config.

Changes:

- Add Lite.Tests/xunit.runner.json with explicit parallelization settings:
  parallelizeAssembly=true, parallelizeTestCollections=true,
  maxParallelThreads=-1 (use all cores), parallelAlgorithm=aggressive.
  CopyToOutputDirectory wired up in the csproj.

- Serialize BaselineProviderTests and AnomalyDetectorTests into a shared
  collection (BaselineProviderCollection, DisableParallelization=true).
  Both classes mutate the static BaselineProvider.CacheTtl field, so they
  must run sequentially relative to each other; without this, parallel
  runs would race on the static state.

- Convert FinOpsTests to IClassFixture<FinOpsDuckDbFixture>, sharing one
  DuckDB across the class. Every seeder in TestDataSeeder.SeedFinOps*
  already calls ClearTestDataAsync first, so cross-test pollution is
  prevented without rewriting test code. Saves the schema-init cost on
  each test (modest, but free).

This is a pilot for the IClassFixture approach. The agent's analysis flagged
that converting other classes (FactCollectorTests etc.) would require
adding ClearTestDataAsync calls to many tests, so leaving those alone for
now. Parallel execution across classes is the bigger win and is fully
covered by the runner.json settings.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@erikdarlingdata erikdarlingdata merged commit 987dc61 into dev May 2, 2026
2 checks passed
@erikdarlingdata erikdarlingdata deleted the feature/lite-tests-parallel branch May 2, 2026 15:23
erikdarlingdata added a commit that referenced this pull request May 2, 2026
Revert PR #924: Lite tests parallelization (slowed CI)
pull Bot pushed a commit to ehtick/PerformanceMonitor that referenced this pull request May 5, 2026
…eature/lite-tests-parallel"

This reverts commit 987dc61, reversing
changes made to 76d825f.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant