Repository navigation
feat(responses): a canned reply can carry an error status, and the history records it as error - #169
Merged
Merged
Conversation
…story records it as error A router test needs a node that answers an error status with a body that mode "error" cannot build, for example a 503 whose body holds both result and error. The canned body of a responses entry took a 2xx status only. The control API now accepts a canned status from 400 to 599 beside 2xx. A 1xx, a 3xx and a status that is not an int are still refused with 400. The history row of a canned reply follows its status: success inside 2xx, error outside it. The body is never read for the label. JSON-RPC and GraphQL serve the canned reply, so both follow the rule. Tests: a JSON-RPC canned body with status 400, 503 or 599 is accepted, sent as given and recorded as error; status 199, 300, 399, 600 and the text "503" are refused; a canned GraphQL body is labelled by its status, not by its body. The new cases failed before the change. A label that always reads success fails 4 of them, and a range of 200 to 599 fails the 300 and 399 cases.
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.
Why
A router test needs a node that answers an error status with a body that the simulator cannot build today, for example a 503 whose body holds both
resultanderror.mode: "error"builds its own error envelope, and the cannedbodyof aresponsesentry took a 2xx status only. A test in smart-router-automation checks that such a reply reaches the caller unchanged, and it waits on this change.What changed
provider_simulator/control_api.py: the cannedbodyof aresponsesentry takes a status from 200 to 299, as before, and an error status from 400 to 599. A 1xx (not a final reply), a 3xx (neither a success nor an error) and a status that is not an int are still refused with HTTP 400.provider_simulator/listeners/base.py: the history row of a canned reply follows its status:successinside 2xx,erroroutside it. The body is never read for the label. JSON-RPC and GraphQL serve the canned reply, so both follow the rule.jsonrpc.py,graphql.pyandListener.build_body_override, the comment above the status check, anddocs/using_the_simulator.mdstate the rule.tests/test_simulator_per_method_overrides.py: a canned body with status 400, 503 or 599 is accepted, sent with that status and the exact body, and recorded aserror. Status 199, 300, 399, 600 and the text"503"are refused with HTTP 400. These two tests replace the test that refused a 500.tests/test_listener_graphql.py: a canned GraphQL body is labelled by its status and not by its body: a 200 that holdserrorsreadssuccess, and a 503 readserror.How to verify
Results
success.successfails 4 cases, and a status range of 200 to 599 fails the 300 and 399 cases.