-
Notifications
You must be signed in to change notification settings - Fork 271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(http/retry): add more replay body test coverage #3583
Merged
cratelyn
merged 10 commits into
main
from
kate/http-retry.add-more-replay-body-test-coverage
Jan 30, 2025
Merged
feat(http/retry): add more replay body test coverage #3583
cratelyn
merged 10 commits into
main
from
kate/http-retry.add-more-replay-body-test-coverage
Jan 30, 2025
Conversation
This file contains 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
there are more than 500 lines of unit tests. let's move them into a submodule, for convenience. Signed-off-by: katelyn martin <kate@buoyant.io>
this is a small cosmetic change reording some test helpers. there is a common convention of affixing a banner comment above groups of `impl T {}` blocks, which is useful when top-level blocks are folded in an editor. similarly, there is a convention of defining structures at the top of a file. this commit reorganizes the replay body tests to follow each of these conventions. Signed-off-by: katelyn martin <kate@buoyant.io>
just to be extra sure! Signed-off-by: katelyn martin <kate@buoyant.io>
this is part of a family of other tests called `replays_one_chunk()`, `replays_several_chunks()`, and `replays_trailers()`. let's name this something that lines up with this convention. Signed-off-by: katelyn martin <kate@buoyant.io>
we have a unit test, called `eos_only_when_fully_replayed` that confirms `Body::end_of_stream()` reports the stream ending properly. soon, we aim to introduce additional test coverage that exercises this when a body has trailers, as well. this will be useful for assurance related to upgrading to http-body v1.x. see linkerd/linkerd2#8733 for more information. unfortunately, hyper 0.14's channel-backed body does not report itself as having reached the end of the stream. this is an unfortunate quality that prevents us from using `Test::new()`. this commit adds a `TestBody` type that we can use in place of `BoxBody::from_static(..)`, which boxes a static string, but does not send trailers. Signed-off-by: katelyn martin <kate@buoyant.io>
this commit introduces additional test coverage that exercises `is_end_stream()` when a replay body is wrapping a body with trailers. this will be useful for assurance related to upgrading to http-body v1.x. see linkerd/linkerd2#8733 for more information. Signed-off-by: katelyn martin <kate@buoyant.io>
Signed-off-by: katelyn martin <kate@buoyant.io>
we want to show that exceeding the capacity is the point at which replays will fail. this commit defines some constants to further communicate and encode this relationship between the bytes sent, and the capacity of the replay body. further, it shortens the second frame sent so that we ensure precisely when a body becomes capped. Signed-off-by: katelyn martin <kate@buoyant.io>
Signed-off-by: katelyn martin <kate@buoyant.io>
for now, a replaying body that will not yield trailers must be polled to the `None` before reporting itself as reaching the end of the stream. this isn't hugely important, but does affect some test control flow. leave two todo comments so that if/when upgrading to hyper 1.0, it is clear that these are not load-bearing or otherwise expected behavior, should this behavior be rectified. Signed-off-by: katelyn martin <kate@buoyant.io>
e246186
to
50c2d6f
Compare
olix0r
approved these changes
Jan 30, 2025
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.
see linkerd/linkerd2#8733.
we are currently in the process of upgrading our hyper, http, and http-body dependencies to their 1.0 major releases.
this branch introduces additional test coverage, and further refines existing test coverage, concerning how a
ReplayBody<B>
behaves when it reaches the "end of stream" of its internalB
-typed body.additional assertions are added to show that bodies with trailers may be replayed an arbitrary number of times, and that capacity errors occur precisely at their expected boundary. additional assertions are added to confirm that
ReplayBody::is_capped()
reports these conditions properly.this branch also notably outlines the unit test suite into a separate file, due to its size. as a result, reviewers are encouraged to walk through this branch on a commit-by-commit basis when reading these changes.
i noticed some relatively minor issues with
is_end_stream()
andsize_hint()
while i was reviewing this middleware, in preparation to port it to http-body 1.0. i have leftTODO
comments noting where today's behavior is slightly askew, but intentionally avoided fixing them here. my goal on that front is to highlight those wrinkles so that later fixes to these edges are more easily reviewable.