Skip to content

Test which thread the Logger is called on - #25

Merged
dmccoystephenson merged 2 commits into
mainfrom
feature/logger-thread-tests
Nov 4, 2026
Merged

dmccoystephenson merged 2 commits into
mainfrom
feature/logger-thread-tests

Conversation

@dmccoystephenson

@dmccoystephenson dmccoystephenson commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

Summary

Stage B test expansion: the Logger's threading promise is now asserted. No production code is changed.

  • aFailedDeliveryIsLoggedOnTheClientsOwnThread — both failed-delivery messages (trace server answered 500 and could not deliver, against a closed port) are checked not to arrive on the thread that called report.
  • aFullQueueIsLoggedOnTheThreadThatCalledReport — a flood past QUEUE_CAPACITY from a dedicated thread is checked to log every queue full message on that thread, so it cannot be confused with the thread that built the client.
  • Log now records the calling thread beside each line, with a countOn(needle, thread) lookup. Both tests observe through the stub server and the Logger, and no new sleeps are added.

Closes #23

Deferred issues

Test plan

  • make clean && make test (g++, C++11): 61 tests, 0 failed checks, up from 59, with 61 entries in tests[]
  • Mutation probe, reverted before commit: with delivery moved onto the reporting thread and the full-queue message moved onto another thread, each new test failed on its thread assertion (expected [0] got [1] twice, and expected [511] got [0])
  • CI Build green on the PR head, including both linux-sanitizers legs, macos and windows: all 11 jobs printed 61 tests, 0 failed checks

make test-libcurl and clang++ were not run locally; both were covered by CI.

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

dmccoystephenson and others added 2 commits November 3, 2026 21:38
The README and the Logger typedef both say a failed delivery is mentioned
on the client's own thread and a full queue on the thread that called
report, and nothing asserted either. Log now records the calling thread
with each line.

Closes #23

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
clang rejects the explicit capture of a constant under -Werror
(-Wunused-lambda-capture); a default capture builds on every compiler.

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

Copy link
Copy Markdown
Member Author

Self-review rubric (performed inline in a headless dispatch; not an independent review):

  • Scope: PASS — one file, test/test_trace_client.cpp, 57 lines added and none removed from existing code; every hunk serves No test asserts which thread the Logger is called on #23.
  • Tests-new: PASS — no new production function; Log::countOn is exercised by both new tests.
  • Tests-fix: PASS (n/a) — no bug fix. In place of a revert, a mutation of trace_client.hpp (reverted before commit) proved both tests can fail: expected [0] got [1] on both failed-delivery thread checks, expected [511] got [0] on the full-queue check. The probe ran before the capture change below, which does not alter what is asserted.
  • Sibling structure / renames: PASS (n/a) — no new files, no renamed identifiers.
  • Docs: PASS — the tests assert what the README "Never throws" row and the Logger typedef comment already say; no doc change is needed.
  • Issue resolution: PASS — No test asserts which thread the Logger is called on #23 asks for both thread observations, through the stub server and the Logger, with no new sleeps; both are present and no sleep was added. The test thread's id is compared rather than the sending thread's, because the client does not expose the latter.
  • CI: PASS — all 11 Build jobs succeeded on head 191050f, and each printed 61 tests, 0 failed checks. The first run was red: linux (c++11, clang++) and macos failed on -Wunused-lambda-capture, the other red legs were fail-fast cancellations, and the capture was changed to [&].
  • Registered: PASS — both new names appear twice in the file (definition and tests[]); the count rose from 59 to 61.
  • C++11: PASS — make test (g++, -std=c++11 -Werror) built clean, and both CI c++11 legs are green.
  • No new dependency / Never throws / Curl argv fixed / Version triple: PASS (n/a) — trace_client.hpp, Makefile and CMakeLists.txt are untouched.
  • Sanitizers: PASS — both linux-sanitizers legs are green with the new threaded test included.

Findings:

  • test/test_trace_client.cpp:483 — the failed-delivery checks assert "not the reporting thread", which is weaker than "the sending thread"; the sending thread's id is not visible to a test. The check is accepted as what the promise can observe from outside.
  • Local verification missed the first CI failure because clang++ is not installed here; -Wunused-lambda-capture is clang-only.
  • report() hangs forever when a Logger reports while the queue is full #24 was found while these tests were being prepared: a Logger that reports while the queue is full hangs report(). It is not addressed here because a test-expansion cycle does not change production code.

Do-not-auto-merge paths: none touched (no workflow, Makefile, CMakeLists, curl/spawn code, version or wire-format change).

This 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 32c2827 into main Nov 4, 2026
11 checks passed
@dmccoystephenson
dmccoystephenson deleted the feature/logger-thread-tests branch November 4, 2026 04:42
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.

No test asserts which thread the Logger is called on

1 participant