test(server): fix flaky pipeline disabled test
This commit is contained in:
@@ -438,7 +438,7 @@ fn expect_continue() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pipline_disabled() {
|
||||
fn pipeline_disabled() {
|
||||
let server = serve();
|
||||
let mut req = connect(server.addr());
|
||||
server.reply().status(hyper::Ok);
|
||||
@@ -456,9 +456,24 @@ fn pipline_disabled() {
|
||||
let mut buf = vec![0; 4096];
|
||||
let n = req.read(&mut buf).expect("read 1");
|
||||
assert_ne!(n, 0);
|
||||
let n = req.read(&mut buf).expect("read 2");
|
||||
// Woah there. What?
|
||||
//
|
||||
// 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]
|
||||
fn pipeline_enabled() {
|
||||
@@ -579,8 +594,6 @@ impl NewService for TestService {
|
||||
fn new_service(&self) -> std::io::Result<TestService> {
|
||||
Ok(self.clone())
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
impl Service for TestService {
|
||||
|
||||
Reference in New Issue
Block a user