test(server): fix flaky pipeline disabled test
This commit is contained in:
@@ -438,7 +438,7 @@ fn expect_continue() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn pipline_disabled() {
|
fn pipeline_disabled() {
|
||||||
let server = serve();
|
let server = serve();
|
||||||
let mut req = connect(server.addr());
|
let mut req = connect(server.addr());
|
||||||
server.reply().status(hyper::Ok);
|
server.reply().status(hyper::Ok);
|
||||||
@@ -456,8 +456,23 @@ fn pipline_disabled() {
|
|||||||
let mut buf = vec![0; 4096];
|
let mut buf = vec![0; 4096];
|
||||||
let n = req.read(&mut buf).expect("read 1");
|
let n = req.read(&mut buf).expect("read 1");
|
||||||
assert_ne!(n, 0);
|
assert_ne!(n, 0);
|
||||||
let n = req.read(&mut buf).expect("read 2");
|
// Woah there. What?
|
||||||
assert_ne!(n, 0);
|
//
|
||||||
|
// This test is wishy-washy because of race conditions in access of the
|
||||||
|
// socket. The test is still useful, since it allows for the responses
|
||||||
|
// to be received in 2 reads. But it might sometimes come in 1 read.
|
||||||
|
//
|
||||||
|
// TODO: add in a delay to the `ServeReply` interface, to allow this
|
||||||
|
// delay to prevent the 2 writes from happening before this test thread
|
||||||
|
// can read from the socket.
|
||||||
|
match req.read(&mut buf) {
|
||||||
|
Ok(n) => {
|
||||||
|
// won't be 0, because we didn't say to close, and so socket
|
||||||
|
// will be open until `server` drops
|
||||||
|
assert_ne!(n, 0);
|
||||||
|
}
|
||||||
|
Err(_) => (),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -579,8 +594,6 @@ impl NewService for TestService {
|
|||||||
fn new_service(&self) -> std::io::Result<TestService> {
|
fn new_service(&self) -> std::io::Result<TestService> {
|
||||||
Ok(self.clone())
|
Ok(self.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Service for TestService {
|
impl Service for TestService {
|
||||||
|
|||||||
Reference in New Issue
Block a user