test(mongodb): assert graceful backend errors on an unreachable server#211
Open
mauripunzueta wants to merge 1 commit into
Open
test(mongodb): assert graceful backend errors on an unreachable server#211mauripunzueta wants to merge 1 commit into
mauripunzueta wants to merge 1 commit into
Conversation
Add a reusable error-handling test pattern for the MongoDB backend: point a MongoBackend at a dead address and assert its operations surface a StorageError::Backend rather than panicking, hanging, or returning a misleading result (e.g. a read that reports "not found" when it never reached the server). - unreachable_backend(): builds a backend at 127.0.0.1:1 (refused) with a short connect timeout; construction is lazy so it never connects. - assert_backend_error(): asserts a storage Result is Err(Backend(_)) — the uniform way an unreachable server surfaces. - One test drives read/count/create concurrently (so the server-selection timeout is paid once) and asserts each fails with a backend error. Needs no server, so it always runs — in CI and locally — without Docker, and it's a template future tests can copy to drive Mongo error paths.
Open
3 tasks
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
Adds a reusable error-handling test pattern for the MongoDB backend: point a
MongoBackendat an unreachable address and assert its operations surface aStorageError::Backend— rather than panicking, hanging, or returning a misleading result (e.g. areadthat reports "not found" when it never actually reached the server).This is the reusable, team-wide kind of test requested: it validates the backend's error-handling contract across operations and is a template future tests copy to drive any Mongo error path.
What it adds
unreachable_backend()— builds a backend at127.0.0.1:1(connection refused, deterministic) with a short connect timeout. Construction is lazy, sonewnever connects; the error surfaces when an operation runs.assert_backend_error()— asserts a storageResultisErr(StorageError::Backend(_)), the uniform way an unreachable server surfaces.mongodb_integration_unreachable_server_surfaces_backend_error— drivesread/count/createconcurrently (so the driver's bounded server-selection timeout is paid once) and asserts each fails with a backend error.Unlike the rest of the suite, this needs no server at all — it always runs in CI and locally, no Docker required.
Stacking
Validation note
Because this PR targets a non-
mainbase, the HFS CI workflow does not run on it (CI is gated tobase=main). The addition was hand-verified against the exactResourceStoragesignatures (create/read/count) andMongoBackendConfigfields, and is rustfmt-clean, but it is not yet machine-validated. It will get full CI once #209 merges and this rebases ontomain— or on request I can run a one-off validation by temporarily retargeting it tomain.