-
Notifications
You must be signed in to change notification settings - Fork 283
chore(app/inbound): address hyper deprecations in http/2 tests #3445
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,25 +2,75 @@ | |
app_core::{svc, Error}, | ||
io, ContextError, | ||
}; | ||
use hyper::{body::HttpBody, Body}; | ||
use http_body::Body; | ||
use tokio::task::JoinSet; | ||
use tower::ServiceExt; | ||
use tracing::Instrument; | ||
|
||
#[allow(deprecated)] // linkerd/linkerd2#8733 | ||
use hyper::client::conn::{Builder as ClientBuilder, SendRequest}; | ||
|
||
type BoxServer = svc::BoxTcp<io::DuplexStream>; | ||
|
||
/// Connects a client and server, running a proxy between them. | ||
/// | ||
/// Returns a tuple containing (1) a [`SendRequest`] that can be used to transmit a request and | ||
Check warning on line 14 in linkerd/app/test/src/http_util.rs
|
||
/// await a response, and (2) a [`JoinSet<T>`] running background tasks. | ||
#[allow(deprecated)] // linkerd/linkerd2#8733 | ||
pub async fn connect_and_accept( | ||
client_settings: &mut ClientBuilder, | ||
client_settings: &mut hyper::client::conn::Builder, | ||
server: BoxServer, | ||
) -> (SendRequest<Body>, JoinSet<Result<(), Error>>) { | ||
) -> ( | ||
hyper::client::conn::SendRequest<hyper::Body>, | ||
JoinSet<Result<(), Error>>, | ||
) { | ||
tracing::info!(settings = ?client_settings, "connecting client with"); | ||
let (client_io, server_io) = io::duplex(4096); | ||
|
||
let (client, conn) = client_settings | ||
.handshake(client_io) | ||
.await | ||
.expect("Client must connect"); | ||
|
||
let mut bg = tokio::task::JoinSet::new(); | ||
bg.spawn( | ||
async move { | ||
server | ||
.oneshot(server_io) | ||
.await | ||
.map_err(ContextError::ctx("proxy background task failed"))?; | ||
tracing::info!("proxy serve task complete"); | ||
Ok(()) | ||
} | ||
.instrument(tracing::info_span!("proxy")), | ||
); | ||
bg.spawn( | ||
async move { | ||
conn.await | ||
.map_err(ContextError::ctx("client background task failed")) | ||
.map_err(Error::from)?; | ||
tracing::info!("client background complete"); | ||
Ok(()) | ||
} | ||
.instrument(tracing::info_span!("client_bg")), | ||
); | ||
|
||
(client, bg) | ||
} | ||
|
||
/// Connects a client and server, running a proxy between them. | ||
/// | ||
/// Returns a tuple containing (1) a [`SendRequest`] that can be used to transmit a request and | ||
Check warning on line 60 in linkerd/app/test/src/http_util.rs
|
||
/// await a response, and (2) a [`JoinSet<T>`] running background tasks. | ||
pub async fn connect_and_accept_http2<B>( | ||
client_settings: &mut hyper::client::conn::http2::Builder, | ||
server: BoxServer, | ||
) -> ( | ||
hyper::client::conn::http2::SendRequest<B>, | ||
JoinSet<Result<(), Error>>, | ||
) | ||
Comment on lines
+62
to
+68
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the diff presents this unfortunately, but the body of |
||
where | ||
B: Body + Send + 'static, | ||
B::Data: Send, | ||
B::Error: Into<Box<dyn std::error::Error + Send + Sync>>, | ||
{ | ||
tracing::info!(settings = ?client_settings, "connecting client with"); | ||
let (client_io, server_io) = io::duplex(4096); | ||
|
||
|
@@ -58,7 +108,7 @@ | |
/// Collects a request or response body, returning it as a [`String`]. | ||
pub async fn body_to_string<T>(body: T) -> Result<String, Error> | ||
where | ||
T: HttpBody, | ||
T: Body, | ||
T::Error: Into<Error>, | ||
{ | ||
let bytes = body | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the change we're applying to these inbound proxy tests.