Skip to content

Commit d02c377

Browse files
authored
refactor(app/inbound): forward-compatible test code (#3671)
see linkerd/linkerd2#8733 for more information. see #3559 and #3614 for more information on the `ForwardCompatibleBody<B>` wrapper. this branch updates test code in `linkerd-app-inbound` so that it interacts with request and response bodies via an adapter that polls for frames in a manner consistent with the 1.0 api of `http_body`. this allows us to limit the diff in #3504, which will only need to remove this adapter once using hyper 1.0. see #3672 and #3673, which perform the same change for `linkerd-app-outbound` and `linkerd-app-integration`, respectively. --- * refactor(app/inbound): `linkerd-http-body-compat` test dependency Signed-off-by: katelyn martin <[email protected]> * refactor(app/inbound): use `ForwardCompatibleBody` see linkerd/linkerd2#8733. Signed-off-by: katelyn martin <[email protected]> --------- Signed-off-by: katelyn martin <[email protected]>
1 parent ecbc3ec commit d02c377

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,6 +1442,7 @@ dependencies = [
14421442
"linkerd-app-core",
14431443
"linkerd-app-test",
14441444
"linkerd-http-access-log",
1445+
"linkerd-http-body-compat",
14451446
"linkerd-http-metrics",
14461447
"linkerd-idle-cache",
14471448
"linkerd-io",

linkerd/app/inbound/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ linkerd-meshtls-rustls = { path = "../../meshtls/rustls", features = [
5656
[dev-dependencies]
5757
hyper = { workspace = true, features = ["deprecated", "http1", "http2"] }
5858
linkerd-app-test = { path = "../test" }
59+
linkerd-http-body-compat = { path = "../../http/body-compat" }
5960
linkerd-http-metrics = { path = "../../http/metrics", features = ["test-util"] }
6061
linkerd-idle-cache = { path = "../../idle-cache", features = ["test-util"] }
6162
linkerd-io = { path = "../../io", features = ["tokio-test"] }

linkerd/app/inbound/src/http/tests.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use linkerd_app_core::{
1111
classify,
1212
errors::header::L5D_PROXY_ERROR,
1313
identity, io, metrics,
14-
proxy::http::{self, Body as _, BoxBody},
14+
proxy::http::{self, BoxBody},
1515
svc::{self, http::TracingExecutor, NewService, Param},
1616
tls,
1717
transport::{ClientAddr, OrigDstAddr, Remote, ServerAddr},
@@ -631,15 +631,21 @@ async fn grpc_response_class() {
631631
.body(hyper::Body::default())
632632
.unwrap();
633633

634-
let mut rsp = client
634+
let rsp = client
635635
.send_request(req)
636636
.await
637637
.expect("HTTP client request failed");
638638
tracing::info!(?rsp);
639639
assert_eq!(rsp.status(), http::StatusCode::OK);
640640

641-
rsp.body_mut().data().await;
642-
let trls = rsp.body_mut().trailers().await.unwrap().unwrap();
641+
let mut body = linkerd_http_body_compat::ForwardCompatibleBody::new(rsp.into_body());
642+
let trls = body
643+
.frame()
644+
.await
645+
.unwrap()
646+
.unwrap()
647+
.into_trailers()
648+
.expect("trailers frame");
643649
assert_eq!(trls.get("grpc-status").unwrap().to_str().unwrap(), "2");
644650

645651
let response_total = metrics

0 commit comments

Comments
 (0)