Skip to content

Test reporting from several threads and Close racing Report - #19

Merged
dmccoystephenson merged 1 commit into
mainfrom
feature/concurrent-report-tests
Oct 28, 2026
Merged

dmccoystephenson merged 1 commit into
mainfrom
feature/concurrent-report-tests

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Summary

Stage B (unit-test expansion) cycle: concurrent use of TraceClient. No test exercised Report from more than one thread, and nothing drove the could not queue branch in Report (the catch taken when Close lands between the IsEnabled check and _queue.TryAdd).

  • Report_DeliversEveryEventReportedFromSeveralThreadsAtOnce — four threads report 40 distinct events each (160, well under QueueCapacity); every event is asserted delivered exactly once, untorn, with nothing logged.
  • Report_NeverThrowsWhileAnotherThreadCloses — a background thread keeps reporting while Close runs on the test thread and for 100 ms afterwards; no exception may escape Report, the client ends disabled, and the only log lines allowed are could not queue busy: ... (the race) or queue full, dropped busy (a cold-runner first request letting the queue fill). Every delivered body is asserted intact.

Characterization only — no production code changed. Test-only diff (+79 lines in tests/TraceClient.Tests/TraceClientTest.cs).

Test plan

  • Build workflow green on ubuntu-latest (net8.0)
  • Build workflow green on windows-latest (net8.0 + net48)

dotnet is not installed in the dispatch sandbox, so the local run is UNVERIFIED; the CI matrix on the PR head is the anchor.

Skipped backlog

This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).

🤖 Generated with Claude Code


drafted by Claude on behalf of Daniel Stephenson

Nothing exercised Report from more than one thread, nor the
"could not queue" path when Close lands between Report's enabled check
and its enqueue. Lock in that concurrent reports are all delivered
intact and that a Close on another thread never throws into the
reporting thread.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dmccoystephenson

Copy link
Copy Markdown
Member Author

Self-review rubric (head fc5af9b):

  • Scope: PASS — git diff --stat origin/main shows one file, tests/TraceClient.Tests/TraceClientTest.cs, +79 lines; no production, docs or config change.
  • Tests-new: PASS (not applicable) — no new public member; the two tests cover existing Report/Close behaviour under concurrency.
  • Tests-fix: not applicable — characterization only, no bug fix in the diff.
  • Sibling structure: PASS — no new file; tests follow Subject_BehaviourInPlainWords naming, use the shared _server fixture, log: queue.Enqueue, WaitFor(...) before Close(), and close the client.
  • Sibling renames: PASS (not applicable) — nothing renamed.
  • Docs: PASS — README and XML docs make no claim about multi-threaded use that the tests contradict; no doc source needed an update.
  • Issue resolution: not applicable — Stage B cycle, no Closes.
  • CI: PASS — run 40635803302 green on both legs; the summary lines show Passed: 89 on ubuntu net8.0, windows net8.0 and windows net48, against 87 on main (run 40050562720), so both new tests executed on every target.
  • No dependencies / single file / vendoring floor / environment seam / version agreement / opt-out contract: PASS — src/ is untouched.

Judgment calls noted for a human reader:

  • tests/TraceClient.Tests/TraceClientTest.cs:919 — Report_NeverThrowsWhileAnotherThreadCloses cannot force the race window deterministically. It is a smoke guard: it fails if any exception ever escapes Report during Close, but a green run does not prove the could not queue branch was hit.
  • tests/TraceClient.Tests/TraceClientTest.cs:957 — queue full, dropped busy is also allowed in the log, because a cold first request on a slow runner can let the 5 ms-paced reporter fill the queue. Without that allowance the test could flake.
  • Local dotnet test was UNVERIFIED (no SDK in the dispatch sandbox), so the CI matrix on the head SHA served as the anchor.

The diff is test-only and touches no do-not-auto-merge path.

This review comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).


drafted by Claude on behalf of Daniel Stephenson

@dmccoystephenson
dmccoystephenson merged commit d077872 into main Oct 28, 2026
2 checks passed
@dmccoystephenson
dmccoystephenson deleted the feature/concurrent-report-tests branch October 28, 2026 05:06
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