Skip to content

Dockerize integration tests to isolate Application event log pollution#535

Merged
NikTilton merged 1 commit into
mainfrom
jschick/dockerize-integration-tests
May 20, 2026
Merged

Dockerize integration tests to isolate Application event log pollution#535
NikTilton merged 1 commit into
mainfrom
jschick/dockerize-integration-tests

Conversation

@jschick04
Copy link
Copy Markdown
Collaborator

@jschick04 jschick04 commented May 20, 2026

Why

Integration tests (especially EventLogWatcherTests) write to the host's Application event log and depend on host-specific provider inventory. Running them during normal development pollutes the dev's event log with test noise.

What

Default behavior — integration tests excluded from "Run All Tests"

  • Switch xunit.v3 to xunit.v3.mtp-off (VSTest mode instead of Microsoft.Testing.Platform) so VS Test Explorer honors .runsettings filters.
  • Add EventLogExpert.runsettings with FullyQualifiedName!~IntegrationTests filter, wired via RunSettingsFilePath in Directory.Build.props.
  • Result: "Run All Tests" in VS Test Explorer runs only unit tests. Zero event log pollution. Zero config for new contributors.

Docker Compose for running integration tests

  • compose.yml with three services (eventing, runtime, eventdbtool) running inside Windows Server Core containers via Hyper-V isolation.
  • docker/integration-tests-entrypoint.ps1 ensures the EventLog service is healthy, then runs dotnet test with artifacts-output layout and -p:RunSettingsFilePath= to override the default filter.
  • ApplicationLogSeedFixture (assembly-level IAsyncLifetime) seeds 10 Application records on cold containers (guarded by EVENTLOG_CONTAINER env var — no-op on host).
  • testenvironments.json for VS Remote Testing dropdown (run tests in container with per-test granularity from Test Explorer).

CI

  • .github/workflows/PullRequest.yml integration test step passes -p:RunSettingsFilePath= to run the full suite on ephemeral runners.

Test race fix

  • DatabaseServiceTests.DisposeAsync_WithPendingBatches had a pre-existing race: DisposeAsync's CancelAsync propagates to linked batch tokens via async ThreadPool callbacks — fast container I/O raced past ThrowIfCancellationRequested before propagation arrived. Added a 250ms yield with justifying comment. Passes on both host and container.

Verification

  • dotnet test EventLogExpert.slnx --settings EventLogExpert.runsettings: 2,161 unit tests pass, 0 integration tests run.
  • docker compose run --rm eventing: 334 passed, 2 skipped, 0 failed.
  • docker compose run --rm runtime: 124 passed, 0 failed.
  • docker compose run --rm eventdbtool: 38 passed, 0 failed.
  • Host Application event log: zero container-originated entries after Docker runs.

Copilot AI review requested due to automatic review settings May 20, 2026 16:54
@jschick04 jschick04 requested a review from a team as a code owner May 20, 2026 16:54
@jschick04 jschick04 marked this pull request as draft May 20, 2026 16:56
NikTilton
NikTilton previously approved these changes May 20, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a Windows-container-based harness to run the integration test projects in isolation so integration tests that write to the Application event log don’t pollute the developer host’s real event log, plus a small test-race mitigation in the Runtime integration tests.

Changes:

  • Introduces a repo-root compose.yml with three services to run each integration test project in an isolated Windows Server Core container.
  • Adds a PowerShell entrypoint that ensures the Windows Event Log service is running, seeds Application records for cold containers, and runs dotnet test using artifacts output and TRX results to a bind-mounted host directory.
  • Updates integration-test docs and gitignore, and adds a timing-based mitigation for a disposal/cancellation race in DatabaseServiceTests.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/Integration/README.md Documents Docker-based integration test workflow, prerequisites, output locations, cleanup, and host fallback.
tests/Integration/EventLogExpert.Runtime.IntegrationTests/Database/DatabaseServiceTests.cs Adds a delay to reduce a cancellation propagation race during disposal with pending batches.
docker/integration-tests-entrypoint.ps1 Container entrypoint: validate eventlog service, seed Application events, run dotnet test with artifacts output + TRX.
compose.yml Defines three Windows-container services (one per integration test project) with shared NuGet/artifacts volumes.
.gitignore Ignores TRX output directory written via Docker bind-mount.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/Integration/README.md Outdated
Comment thread tests/Integration/README.md Outdated
Comment thread docker/integration-tests-entrypoint.ps1
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 14 changed files in this pull request and generated 3 comments.

Comment thread EventLogExpert.runsettings Outdated
Comment thread EventLogExpert.runsettings Outdated
Comment thread tests/Integration/README.md Outdated
@jschick04 jschick04 force-pushed the jschick/dockerize-integration-tests branch from 55314ee to 1f0874a Compare May 20, 2026 21:33
@jschick04 jschick04 requested a review from Copilot May 20, 2026 21:37
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 12 changed files in this pull request and generated no new comments.

@jschick04 jschick04 marked this pull request as ready for review May 20, 2026 21:51
@jschick04 jschick04 requested a review from NikTilton May 20, 2026 21:51
@NikTilton NikTilton merged commit 0f34fa9 into main May 20, 2026
7 checks passed
@NikTilton NikTilton deleted the jschick/dockerize-integration-tests branch May 20, 2026 22:47
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.

3 participants