Repository navigation
test: find startup and bootstrap events through a shared JSON-lines helper - #3495
Merged
Merged
Conversation
…elper jsonEvent(text, event, options) in tests/helpers/json-lines.mjs returns the first JSON line with that event and fails with the whole text when there is none. jsonLines gains a strict mode for callers that parsed every non-empty line of the trimmed output, so a plain-text line still fails them; the production image callers keep skipping unparsable lines through lenient mode.
Contributor
|
🦞👀 Pull request received. I will update this pull request when review starts. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Several tests find one structured event in a process's output by hand: split the output,
JSON.parsethe lines,findthe event,assert.okit with the output as the message. They differ in strictness. Some parse every non-empty line, so a plain-text line fails them; the production image checks skip lines that do not parse. The sharedjsonLineshelper skips every line that does not start with{, so moving the strict copies onto it would loosen them.Change
tests/helpers/json-lines.mjs:jsonLines(text, { strict: true })parses every non-empty line of the trimmed text, exactly as the strict copies did (trim().split("\n").filter(Boolean).map(JSON.parse)). Passing bothstrictandlenientthrows.jsonEvent(text, event, options)returns the first line whoseeventmatches and fails with the whole text when none does.workspace-files-configurationandstartup-ipv6-loopback: strict.production-image-startup(both finders): lenient. They parsed every line and skipped failures; only{lines can hold an event, so lenient mode finds the same record.postgres-bootstrap-failures: the three sites that already usedjsonLines(...).find(...)followed byassert.ok(found, output). Default mode, as before.configuration-startup,sandbox-driver-startup,common-logging,repository-credentials-packageandpostgres-migration-compatibility, which an open PR rewrites;sign-in-chart-parity, whosestartsWith("{") && endsWith("}")filter matches none of the modes exactly; and thepostgres-bootstrap-failuressites whose assertion differs (failure?.codechecks, or a custom message), since converting them would change the failure message.Verification
workspace-files-configuration8/8,startup-ipv6-loopback4/4.postgres-bootstrap-failures22/22.production-image-startupneeds the built images; the Images and Packaging lane is the authority.workspace-files-configuration2/8 andstartup-ipv6-loopback4/4.jsonEventnever finding the event failsworkspace-files-configuration2/8 andstartup-ipv6-loopback4/4.jsonEventthat ignores the event name and returns the first record. On passing runs each process prints only one JSON event (postgres-bootstrap-failures22/22 under this mutant too), so no caller can tell the two apart.tsc --build tsconfig.json tests/tsconfig.json, ESLint and Prettier are clean on the touched files.git merge-treeagainst every open PR touching these files (feat: add Agent workload tags #115, Draft implementation: managed outbound HTTPS for dedicated Gateways #2518, feat: add Gateway managed mode to Agent deployments #2982) shows the same conflicts as against main.Risks
Test-only. No product code or timeout changes. The production image callers would skip an event on a first line that starts with a byte-order mark or no-break space (the old code trimmed those away first); the structured logger never writes one. A strict-mode mutant that falls back to the default mode survives on passing runs (the processes print only JSON there), so strictness is kept by construction rather than proven by a failing caller.