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

test(client): unflake client try_send_request unit test #3770

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions tests/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2044,22 +2044,20 @@ mod conn {
#[tokio::test]
async fn test_try_send_request() {
use std::future::Future;
let (listener, addr) = setup_tk_test_server().await;
let (done_tx, done_rx) = tokio::sync::oneshot::channel::<()>();
let (io_srv, io_cli) = tokio_test::io::Builder::new()
.write(b"GET / HTTP/1.1\r\n\r\n")
.read(b"HTTP/1.1 200 OK\r\ncontent-length: 0\r\n\r\n")
.build_with_handle();

tokio::spawn(async move {
let mut sock = listener.accept().await.unwrap().0;
let mut buf = [0u8; 8192];
sock.read(&mut buf).await.expect("read 1");
sock.write_all(b"HTTP/1.1 200 OK\r\ncontent-length: 0\r\n\r\n")
.await
.expect("write 1");
let _io = io_cli;
let _ = done_rx.await;
});

// make polling fair by putting both in spawns
tokio::spawn(async move {
let io = tcp_connect(&addr).await.expect("tcp connect");
let io = TokioIo::new(io_srv);
let (mut client, mut conn) = conn::http1::Builder::new()
.handshake::<_, Empty<Bytes>>(io)
.await
Expand Down