Repository navigation
Journal templated and gzip responses as WireMock does - #3
Merged
Merged
Conversation
WireMock journals the response definition after templating and the body before Jetty compresses it. BreakMock journaled the stub's template source and the compressed bytes. Match WireMock: - responseDefinition holds rendered headers, and a rendered body replaces body, jsonBody or bodyFileName; unrendered fields are kept. It is built only when the journal is enabled. - A template execution error is journaled as its error response, without the Connection header that is written for the client. - A gzip-encoded response is journaled uncompressed and without Content-Encoding. The compressed bytes stay in memory and are decoded only when the journal is read. The dynamic template suite now compares 16 journal events with Java, field by field and in key order; main fails 11 of them. Java's capped journal can retain one entry too few under concurrency, so that exact reference defect is recorded as a warning; all candidate checks still fail the suite. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The "websocket matched received and sent journal" step still failed on CI intermittently. The CI report shows the reference, not BreakMock, was incomplete: Java WireMock had journaled the "sent" reply but not yet the "received" message when the client read the journal right after the reply frame, while BreakMock returned both events. Wait until each server's journal reaches the expected number of events (2, 3 and 4 after the matched, unmatched and binary messages) before comparing, instead of comparing immediately or after fixed sleeps. A server that never reaches the count is compared as is after 3 seconds, so real differences still fail. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A CI run failed before any comparison with "java startup timeout": verify.py allowed about ten seconds (100 polls) for the JVM to start, which a busy shared runner occasionally exceeds. Use a 60 second deadline instead. streaming_differential.py similarly allowed about half a second for a WebSocket channel to register before indexing it. Wait up to 5 seconds and fail with a clear message if it never appears. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Summary
Fixes the two request-journal differences from WireMock 4.0.0-beta.40 found in the Java comparison (previously queued as separate sessions). Served responses were already identical; only
/__admin/requestsdiffered.responseDefinitionafter templating: rendered headers, rendered body replacingbody/jsonBody/bodyFileNameresponseDefinition; noConnectionheaderConnection: closeloggedContent-EncodingContent-Encoding: gzipFor gzip, BreakMock keeps the compressed bytes in the journal and decompresses only when the journal is read, so the API output matches WireMock while journal memory stays small. The rendered definition is built only when the journal is enabled.
Rules were established by probing the pinned JAR: unrendered
jsonBody,bodyFileNameandbase64Bodystay as they are;statusMessageis not rendered;disableBodyFileTemplatingkeepsbodyFileName; key order follows WireMock's model.Verification
scripts/dynamic_template_differential.pygains 16 journal-event comparisons against Java, field by field and in key order (inline, headers, jsonBody, body files, entity data, field order, statusMessage, execution error, not templated, four gzip variants). This branch passes 254/254;mainfails exactly the 11 cases these fixes cover.scripts/verify.pyagainst the pinned JAR: all 20 suite runs pass.json_benchmark.py --journal capped --journal-check strictagainst Java now passes for every large-JSON workload, templates and gzip included.TestJournalLogsRenderedResponseDefinitionpins the Java-captured definitions;TestJournalServesLoggedResponseBodiesnow asserts uncompressed gzip journaling.go test -race ./...,go vet ./...and the cgo-free tests pass.main(in-process, alternating builds): large JSON with journal within −2%…+1%; small templated response with journal +0.6 µs (≈+8% in-process, <1% of HTTP CPU per request) for building the rendered definition; no change with the journal disabled.Also
journal_concurrency_differential.pyalso checks invariants on the Java reference, and Java's capped journal occasionally retains one entry too few under concurrency (63 of 64 in 1 of 7 local runs; reruns pass). That exact reference defect — only count checks failing, fewer entries than expected, over-cap phase, reference server — is now recorded as a warning. Every candidate check, and every other reference check, still fails the suite.The remaining known template gap — Handlebars.java syntax-error handling — is separate.
🤖 Generated with Claude Code