Skip to content

Commit

Permalink
debug hanging test
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmonstar committed Jun 25, 2024
1 parent c6157d4 commit 3b1929c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:
- uses: Swatinem/rust-cache@v2

- name: Test
run: cargo test ${{ matrix.features }}
run: cargo test ${{ matrix.features }} -- --nocapture

- name: Test all benches
if: matrix.benches
Expand Down
13 changes: 12 additions & 1 deletion tests/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2055,16 +2055,19 @@ mod conn {
.await
.expect("write 1");
let _ = done_rx.await;
eprintln!("bye server");
});

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

eprintln!("client connected");
let mut conn = std::pin::pin!(conn);

// get the conn ready
Expand All @@ -2073,6 +2076,7 @@ mod conn {
.is_pending());
assert!(client.is_ready());

eprintln!("client send1");
// use the connection once
let mut fut1 = std::pin::pin!(client.send_request(http::Request::new(Empty::new())));
let _res1 = future::poll_fn(|cx| loop {
Expand All @@ -2089,32 +2093,39 @@ mod conn {

assert!(client.is_ready());

eprintln!("client trigger server end");
// simulate the server dropping the conn
let _ = done_tx.send(());
// let the server task die
// a full sleep might needed to make Windows happy
tokio::time::sleep(Duration::from_millis(10)).await;
eprintln!("client slept");

let mut fut2 =
std::pin::pin!(client.try_send_request(http::Request::new(Empty::new())));
let poll1 = future::poll_fn(|cx| Poll::Ready(fut2.as_mut().poll(cx))).await;
assert!(poll1.is_pending(), "not already known to error");
eprintln!("client try_send 2");

// wasn't a known error, req is in queue, and now the next poll, the
// conn will be noticed as errored
let mut err = future::poll_fn(|cx| {
loop {
eprintln!("client try_send poll loop");
if let Poll::Ready(res) = fut2.as_mut().poll(cx) {
return Poll::Ready(res);
}
match conn.as_mut().poll(cx) {
Poll::Ready(_) => continue, // ok
Poll::Ready(c) => {
eprintln!("conn result: {:?}", c);
} // ok
Poll::Pending => return Poll::Pending,
};
}
})
.await
.expect_err("resp 2");
eprintln!("client error 2");

assert!(err.take_message().is_some(), "request was returned");
})
Expand Down

0 comments on commit 3b1929c

Please sign in to comment.