Skip to content
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

refactor(http/retry): port remaining ReplayBody tests to Frame<T> #3567

Merged
merged 5 commits into from
Jan 27, 2025

Conversation

cratelyn
Copy link
Collaborator

based on #3564. see linkerd/linkerd2#8733.

this branch upgrades the remaining parts of the ReplayBody<B> test suite to poll bodies in terms of Frame<T>s.

see linkerd/linkerd2#8733.

this commit upgrades a test that uses defunct `data()` and `trailers()`
futures.

Signed-off-by: katelyn martin <[email protected]>
see linkerd/linkerd2#8733.

this commit upgrades a test that uses defunct `data()` and `trailers()`
futures.

Signed-off-by: katelyn martin <[email protected]>
this commit adds a method that exposes the inner `B`-typed body's
`is_end_stream()` trait method, gated for use in tests.

Signed-off-by: katelyn martin <[email protected]>
this is a refactoring commit, upgrading more of the replay body test to
work in terms of `Frame<T>`. this updates the `body_to_string()` helper
in particular.

Signed-off-by: katelyn martin <[email protected]>
Copy link
Collaborator Author

@cratelyn cratelyn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

review notes...

@@ -808,40 +803,58 @@ mod tests {
async fn eos_only_when_fully_replayed() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test was marginally tricky to port.

i discovered a small, interesting tidbit in that the replay body won't report itself as finished until the trailers are (not) yielded. that matches the existing behavior, it's just slightly more noticeable in the poll_frame(..) era.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nb: that's fine, in fact.

A return value of false does not guarantee that a value will be returned from poll_frame.

it's okay if we are slightly pessimistic about returning true; a false negative is acceptable, a false positive is not.

Comment on lines -818 to +822
initial.trailers().await.expect("trailers should not error");
// Read the initial body, show that the replay does not consider itself to have reached the
// end-of-stream. Then drop the initial body, show that the replay is still not done.
assert!(!initial.is_end_stream());
initial
.frame()
.await
.expect("yields a result")
.expect("yields a frame")
.into_data()
.expect("yields a data frame");
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nb: we don't use the body_to_string() helper, or a closure, in this test because we're explicitly concerned with the outcome of is_end_stream() before/after a previous replay is dropped.

Comment on lines -1015 to +1032
async fn body_to_string<T>(mut body: T) -> String
async fn body_to_string<B>(body: B) -> (String, Option<HeaderMap>)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now that we have a single frame() method, this function knows the body is done when it gets either a None or a Some(Ok(trailers)). as a result, we return a (data, trls) tuple here.

@cratelyn cratelyn marked this pull request as ready for review January 27, 2025 19:02
@cratelyn cratelyn requested a review from a team as a code owner January 27, 2025 19:02
Base automatically changed from kate/http-retry.upgrade-replay-body-tests.pt-1 to main January 27, 2025 20:44
@cratelyn cratelyn merged commit 3204278 into main Jan 27, 2025
15 checks passed
@cratelyn cratelyn deleted the kate/http-retry.upgrade-replay-body-tests.pt-2 branch January 27, 2025 20:45
cratelyn added a commit that referenced this pull request Jan 28, 2025
pr's #3564 and #3567, 1eb822f and 3204278 respectively, replaced uses
of defunct `http_body::Body` trait methods — namely, `data()` and
`trailers()`.

this commit updates two remaining uses of `data()` that were missed
in this initial pass.

see linkerd/linkerd2#8733 for more information.

Signed-off-by: katelyn martin <[email protected]>
cratelyn added a commit that referenced this pull request Jan 28, 2025
pr's #3564 and #3567, 1eb822f and 3204278 respectively, replaced uses
of defunct `http_body::Body` trait methods — namely, `data()` and
`trailers()`.

this commit updates two remaining uses of `data()` that were missed
in this initial pass.

see linkerd/linkerd2#8733 for more information.

Signed-off-by: katelyn martin <[email protected]>
cratelyn added a commit that referenced this pull request Jan 30, 2025
pr's #3564 and #3567, 1eb822f and 3204278 respectively, replaced uses
of defunct `http_body::Body` trait methods — namely, `data()` and
`trailers()`.

this commit updates two remaining uses of `data()` that were missed
in this initial pass.

see linkerd/linkerd2#8733 for more information.

Signed-off-by: katelyn martin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants