GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||
GeezerVison is showing github.com — Add copy-both and replication support to the test server mock by Brar · Pull Request #6689 · npgsql/npgsql Conversation
|
| File | Description |
|---|---|
| test/Npgsql.Tests/Support/ReplicationMock.cs | Adds replication connection and response helpers. |
| test/Npgsql.Tests/Support/PgServerMock.cs | Adds replication protocol support and fixes message framing. |
| test/Npgsql.Tests/Support/PgPostmasterMock.cs | Makes the advertised server version configurable. |
| test/Npgsql.Tests/Replication/ReplicationMockTests.cs | Tests replication startup, streaming, feedback, and cancellation. |
Review effort: Balanced
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The core direction is justified. I found no correctness blocker in the exercised paths. I would keep the replication mock and smoke tests, trim unused future-facing helpers, and preserve the important transport fixes with focused regression coverage.
There is a real testability gap: the existing physical replication fixture is explicitly disabled for flakiness, and its streaming tests depend on cluster-wide WAL activity. The shared replication fixture also requires a specially configured live server. A mock cannot replace those integration tests, but it can make client protocol sequencing deterministic.
Independently of this implementation, I would extend the existing wire mock with CopyBothResponse, WAL and keepalive writers, feedback parsing, and a small connection helper that disables automatic feedback. A few hundred lines of C# test-only code is reasonable; no production API or user-documentation change is needed. The essential scenarios are startup/IDENTIFY_SYSTEM, a streamed payload, requested feedback, and cancellation followed by connection reuse.
The PR follows that design without adding a separate mocking framework. Its physical smoke test drives the real replication API while scripting the peer. For example, after starting a client MoveNextAsync:
await server.ExpectSimpleQuery("START_REPLICATION PHYSICAL 0/1000000"); await server.WriteCopyBothResponse() .WriteXLogData(new(0x1000000), new(0x1000003), "abc"u8) .FlushAsync();
The NULL DataRow support is relevant to physical IDENTIFY_SYSTEM. The adjacent length corrections are also legitimate: ParameterDescription previously counted the message-type byte, CopyInResponse declared 5 bytes while emitting 9, and ErrorResponse omitted three string terminators from its declared length. The asynchronous skip fixes consumption of fragmented frontend bodies rather than merely changing style.
The new tests do not exercise the changed ExpectMessage skip or the large-payload flushing writer; the inline comments suggest narrow regression cases. Also, CopyOutResponse, raw CopyData/CopyDone writers, and server-version configurability have no consuming tests in this PR. I would defer that unused surface until a concrete scenario needs it rather than treating this as a general protocol-mock expansion. These are coverage/scope recommendations, not demonstrated runtime defects. The smoke tests establish the foundation; they do not yet cover timeline switches, server shutdown, or logical decoding streams.
I built a separate console program against the exact PR mock sources and drove real logical and physical replication connections, independently of NUnit. It verified a 24,593-byte WAL payload, high-bit LSNs, an exact server timestamp, notice handling, all three feedback LSNs, cancellation routing, connection reuse, a NULL database name, and Terminate. A separate raw TCP peer checked the corrected frame lengths, COPY/NULL encodings, a WAL header near the buffer boundary, and a 20 KB frontend body delivered separately from its header, including alignment of subsequent messages. All passed. The two new smoke tests and eight selected existing mock tests also passed. Validation used an extracted source copy and the installed .NET 11 preview SDK because the pinned 10.0.402 SDK was unavailable; no reviewed source was changed.
Posted by copilot
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Please see agentic review below, am otherwise approving as this is test infra only.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
- The mock writes the fields of error and notice messages as UTF-8, which their declared lengths already assumed. It wrote them as ASCII, so a non-ASCII message arrived with '?' and was shorter than its declared length. - Regression tests for skipping a frontend message that is larger than the mock's read buffer, and for writing WAL data larger than the write buffer when the buffer has no room left for its header. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
The other helpers without a caller here are used by the PRs that build on this one: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
No active review issues were identified in the PostgreSQL replication mock changes.
No open issues 🎉
Review effort: Balanced
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.