From df69c0455a9c7015bd5b40115551f7dc2d6f191c Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Mon, 18 Jun 2018 11:20:18 -0700 Subject: [PATCH] Fix spurrious test failure (#288) There was a race condition in the test where the server connection sometimes closed before the final client opereation. This triggered an unwrap in the test. This patch updates the test to ensuree that the mock server connection stays open until the client test is complete. --- tests/h2-tests/tests/client_request.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/h2-tests/tests/client_request.rs b/tests/h2-tests/tests/client_request.rs index 26a9ed4..2c7d8e7 100644 --- a/tests/h2-tests/tests/client_request.rs +++ b/tests/h2-tests/tests/client_request.rs @@ -850,8 +850,9 @@ fn notify_on_send_capacity() { use std::sync::mpsc; let _ = ::env_logger::try_init(); + let (io, srv) = mock::new(); - let (done_tx, done_rx) = mpsc::channel(); + let (done_tx, done_rx) = futures::sync::oneshot::channel(); let (tx, rx) = mpsc::channel(); let mut settings = frame::Settings::default(); @@ -884,6 +885,9 @@ fn notify_on_send_capacity() { .eos(), ) .send_frame(frames::headers(5).response(200).eos()) + // Don't close the connection until the client is done doing its + // checks. + .wait_for(done_rx) .close() ; @@ -922,10 +926,11 @@ fn notify_on_send_capacity() { }); conn.expect("h2") - }); + }) + .expect("client"); + client.join(srv).wait().unwrap(); - done_rx.recv().unwrap(); } #[test]