Add pure server tests using lori's TCPBackend generic - #173
Open
SeanTAllen wants to merge 1 commit into
Open
Conversation
Propagates lori 0.19.0's `TCPBackend` type parameter through `HTTPServer`, `HTTPServerActor`, and `_ConnectionState` with a `RuntimeBackend` default, so existing users see no API change. Adds a package-private `_install_send_capture` hook on `HTTPServer` that lets pure tests observe the wire bytes handed to lori's `send` for the connection. Replaces the majority of the TCP-backed server test suite with pure equivalents that drive `HTTPServer[_TestFakeBackend]` directly through `_on_received`, respond from `on_request_complete`, and assert on the captured wire bytes or on lifecycle callbacks. The whole scenario runs inside one actor behavior, so no listener, client, port, or timeout is involved. Kept as TCP-backed tests: the smoke suite (`server/hello world`, `server/keep-alive`), the ASIO timer tests (which need real timers), all SSL tests (TLS sits between HTTPServer and the backend, so the fake sees ciphertext), and the pure property-based tests that were already pure. Deletes `_test_server_conformance.pony`, `_test_server_pipeline.pony`, `_test_server_close_ordering.pony`, and `_test_server_body.pony`. Moves `_TestTimerFiresWhileClosing` into `_test_server_timer.pony`. Moves `_TestStreamServer` and its factory into `_test_server_ssl.pony`, where the last remaining caller lives.
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.
Propagates lori 0.19.0's
TCPBackendtype parameter throughHTTPServer,HTTPServerActor, and_ConnectionStatewith aRuntimeBackenddefault (no user-facing API change). Adds a package-private_install_send_capturehook onHTTPServerso pure tests can observe wire bytes handed to lori'ssend.Replaces most of the TCP-backed server test suite with pure equivalents that drive
HTTPServer[_TestFakeBackend]through_on_received, respond fromon_request_complete, and assert on the captured wire bytes or lifecycle callbacks — no listener, client, port, or timeout.Kept TCP-backed: the smoke suite (
server/hello world,server/keep-alive), ASIO timer tests (need real timers), all SSL tests (TLS sits between HTTPServer and the backend), and the pure property tests that were already pure.204 tests pass; lint clean.
Parked for your input
HTTPServer.request_receivedoverflow path (stallion/http_server.pony:312-321) calls_close_connection()but not_parser.stop(). Consequence: the parser finishes the overflow-rejected request, which callsHTTPServer.request_complete, which fireson_request_completeon the actor for the overflow-rejected request (the docstring at line 337-340 claims the else branch is unreachable — it isn't reachable, but the request_complete itself is reachable for the overflow case).parse_errorsidesteps this by callingstop(). I did not fix this in this PR — it is a production behavior change outside the scope of "test refactor + type parameter". Filing as a follow-up unless you want it here._TestFakeBackendnaming. The API-design reviewer flagged that_Testis narrower than the reusable role. Rename to_FakeBackend(matching lori's_FBSendOk…style)? Cosmetic.HTTPServer[TCP]is a public class parameter, but every mechanism a caller needs to use it (_TestFakeBackend,_install_send_capture,_TestSendCapture,_SendCaptureNotify) is package-private. An external user canHTTPServer[MyBackend]and get no way to observe wire bytes. Options: commit to a public capability, hide the parameter, or leave it and say why it's asymmetric. Docstrings currently say "primarily for stallion's own pure-test suite" — is that the right message?TCPBackend,_TestFakeBackendmust gain the same method or every pure test stops compiling. I documented this in_TestFakeBackend's docstring; should it also go inAGENTS.md?_send_capturehook exists becauseTCPConnection[TCP]field-inits_tcp: TCP = TCP, so tests can't inject a pre-built fake to observe later. A lori change to accept a caller-built backend would let stallion drop the production-side hook. Worth exploring in a separate discussion._flush_data'sSendErrorbranch (fake sendv always returns OK); no test exercises lori's own throttle detection end-to-end. Both existed before this branch.