Skip to content

Test _json's infinity/empty-tag rules and close() on a full queue - #11

Open
dmccoystephenson wants to merge 1 commit into
mainfrom
trace/test-json-and-close-edges
Open

dmccoystephenson wants to merge 1 commit into
mainfrom
trace/test-json-and-close-edges

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Stage B — unit-test expansion (_json cleaning rules and close() edge paths). Characterization only: no production code is changed.

Summary

  • test_json_drops_infinite_values_but_keeps_zero — ±inf is omitted from the payload (JSON has no infinity), while 0 is kept as a real value rather than being treated as missing.
  • test_json_omits_tags_that_are_empty_after_cleaning_and_stringifies_the_rest — an empty mapping, or one containing only None values, produces no tags key; non-string keys/values are stringified.
  • test_report_after_close_sends_nothing — report() on a closed client is a silent no-op.
  • test_close_on_a_full_queue_drops_the_oldest_report_and_still_stops_the_sender — with one report in flight and the queue full, close() displaces the oldest queued report so the sentinel fits, returns within its timeout, and the sender thread exits once the server answers. Exactly QUEUE_CAPACITY reports are delivered (in flight + capacity − the displaced one).

These four branches of _json and close() were previously unexercised by tests/test_trace_client.py.

Test plan

  • python3 -m unittest locally on Python 3.8.10 — Ran 45 tests, OK
  • CI Build matrix: test (3.8), test (3.10), test (3.12)

No tracking issue — gap found during triage (no open issues existed at triage time). No open issues were skipped.

Java parity: no Java-visible behavior changed (tests only).

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

Characterization tests for branches with no coverage: infinite values are
dropped while zero is kept, tags empty after cleaning are omitted and the
rest stringified, report() after close() sends nothing, and close() on a
full queue displaces the oldest report so the sentinel still stops the
sender within the timeout.

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

Copy link
Copy Markdown
Member Author

Self-review rubric (anchored on CI run 37907573755, all three matrix jobs green on the PR head):

  • Scope: PASS — git diff --stat origin/main shows only tests/test_trace_client.py, +43/−0.
  • Tests-new: PASS (n/a) — no new public names; the PR adds four tests for previously unexercised branches of _json and close().
  • Tests-fix: n/a — no bug fix; characterization tests only, all asserting current behavior.
  • Sibling structure: PASS — the new tests sit in the existing TraceClientTest class next to related tests (test_json_drops_nan_and_none_tags, the close tests). They reuse _server/_Capture and capture.release and close every enabled client.
  • Sibling renames: n/a — nothing renamed.
  • Docs: PASS (n/a) — no behavior changed. The README promises the tests assert (bounded queue, close() bounded by the timeout) already match.
  • Issue resolution: n/a — no tracking issue; this gap was found during triage.
  • CI: PASS — test (3.8), test (3.10), test (3.12) all pass.
  • Stdlib-only: PASS — the only added import is from trace_client.trace_client import _json (local), and pyproject.toml is untouched.
  • Py3.8 floor: PASS — test (3.8) is green. The tests also passed locally on 3.8.10 (Ran 45 tests, OK).
  • Never-raises / never-blocks, Log level, Version agreement, Exports: n/a — no production code changed.
  • Java parity noted: PASS — the PR body says no Java-visible behavior changed.

Judgment call flagged for a human reviewer:

  • tests/test_trace_client.py:394 — the full-queue test relies on timing. It polls until the sender has taken the first report (5 s deadline) and asserts close(timeout=0.5) returns in under 2 s. The held request is released well inside the client's 5 s urlopen timeout, so a slow runner should not flake it. Its timing headroom is still narrower than the close tests that already exist.

Summary: a tests-only PR with no production, version or wire-format changes. None of the do-not-auto-merge paths are touched.

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


drafted by Claude on behalf of Daniel Stephenson

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