Skip to content

Cover the server-id append into an existing server-wide file - #17

Merged
dmccoystephenson merged 1 commit into
mainfrom
feature/server-id-append-tests
Oct 12, 2026
Merged

dmccoystephenson merged 1 commit into
mainfrom
feature/server-id-append-tests

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Stage B — unit-test expansion for the server-id: append path in resolveInstallId. Only TraceClientTest.java is changed; no production code is touched.

Summary

Four characterization tests are added for branches of the append path that no existing test drove:

  • installId_anUnreadableConfigIsLoggedFineAndNotAppendedTo: when the server-wide file cannot be read, both FINE lines (could not read server-wide config … and using an in-memory server-id for this process: server-wide config was not readable) are asserted. Before this, only the fallback ID was checked, and neither message was.
  • installId_isAppendedToAnEmptyConfigWithoutALeadingBlankLine: covers the existing.length > 0 false branch. A 0-byte file that already exists gets the comment block and the server-id: line with no leading newline, and it counts as enabled.
  • installId_isAppendedDirectlyBelowAConfigThatEndsInANewline: covers an existing file that ends in \n, where no extra newline is inserted. Before this, only the no-trailing-newline case was covered for a file that was not freshly created.
  • installId_anUnusableServerIdLineGetsAUsableOneAppendedAndKept: an operator's invalid server-id: has space is left in place. A valid line is appended, the read-back picks it, and a second build appends nothing more.

All four pass against the current code. None of them revealed a bug.

Test plan

  • mvn -B verify locally (Java 21): Tests run: 76, Failures: 0, Errors: 0, Skipped: 0 (72 before this change, plus 4)
  • CI matrix build (8), build (17), build (21) green on the PR head

Deferred

No tracking issue: this coverage gap was found during triage.

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

An empty file, one ending in a newline, one whose server-id: line is
unusable, and the FINE lines logged when the file cannot be read.

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

Copy link
Copy Markdown
Member Author

Self-review rubric (anchored on CI run 38225373526 and gh pr diff 17):

  • Scope: PASS. Only src/test/java/software/stephenson/trace/TraceClientTest.java is modified (+83 lines). Every addition is one of the four tests in the PR body.
  • Tests-new: PASS (n/a). No new public members were added.
  • Tests-fix: n/a. This is a characterization-only PR. No production code changed, and no bug was found.
  • Sibling structure: PASS. The tests follow the file's subject_behaviourInPlainWords naming and Arrange/Act/Assert comments. They use @TempDir together with writeServerWideConfigExactly, and they reuse RecordingHandler with a uniquely named Logger at Level.ALL, as report_doesNotThrowWhenTheServerRejectsTheKey does.
  • Sibling renames: n/a. Nothing was renamed.
  • Docs: PASS. Behaviour is unchanged, and the asserted behaviour matches the resolveInstallId Javadoc and the Builder.serverWideConfig Javadoc ("appends one … and otherwise never changes the file").
  • Issue resolution: n/a. There is no Closes. The PR body notes that the gap was found during triage.
  • CI: PASS. build (8), build (17) and build (21) are all green on the head. Locally, mvn -B verify reported Tests run: 76, Failures: 0.
  • No dependencies / Single file / Java 8: PASS. pom.xml and src/main are untouched. The new test code uses only Java 8 APIs, and the build (8) leg is green.
  • Never throws / Non-blocking & bounded / Environment seam / Version agreement / Opt-out contract: n/a. Production code is untouched.

Judgment call flagged for the maintainer:

  • TraceClientTest.java installId_anUnreadableConfigIsLoggedFineAndNotAppendedTo: assertEquals(2, log.records.size()) pins the exact number of FINE lines that build() emits for an unreadable server-wide file. This is intentional for a characterization test, but it will need updating if another diagnostic line is added to that path. The test does not wait on the log because both lines are written synchronously on the building thread, inside build(). This also means it cannot flake on timing.

No do-not-auto-merge path is touched; the PR is test-only.

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 75d95b6 into main Oct 12, 2026
3 checks passed
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