I've been using yup-hyper-mock a fair bit in a restrained docker environment (thanks for the library!). Unfortunately, I've discovered that sometimes hyper will not flush its buffer before a write is triggered in yup_hyper_mock
, causing the mock library to never process the server headers when they are flushed, thereby hanging the process.
$ cargo test -- --test-threads 1 --test container::tests::test_kill_container 2>&1 | less
test container::tests::test_kill_container ... [2018-12-04T11:33:23Z DEBUG bollard::uri] Parsing uri: unix://5f/containers/postgres/kill?signal=SIGKILL, client_type: Unix, socket: _
[2018-12-04T11:33:23Z TRACE hyper::client::pool] checkout waiting for idle connection: "unix://5f"
[2018-12-04T11:33:23Z DEBUG yup_hyper_mock] HostToReplyConnector::connect(Destination { uri: unix://5f/containers/postgres/kill?signal=SIGKILL })
[2018-12-04T11:33:23Z TRACE hyper::client::conn] client handshake HTTP/1
[2018-12-04T11:33:23Z TRACE hyper::proto::h1::conn] read_keep_alive; is_mid_message=false
[2018-12-04T11:33:23Z TRACE hyper::proto::h1::conn] read_keep_alive; is_mid_message=false
[2018-12-04T11:33:23Z TRACE hyper::proto::h1::role] Client::encode method=POST, body=None
[2018-12-04T11:33:23Z TRACE hyper::proto::h1::io] detected no usage of vectored write, flattening
[2018-12-04T11:33:23Z TRACE hyper::proto::h1::conn] Conn::read_head
[2018-12-04T11:33:23Z TRACE yup_hyper_mock::streams] Not ready for read yet
[2018-12-04T11:33:23Z TRACE hyper::proto::h1::conn] Conn::read_head
[2018-12-04T11:33:23Z TRACE yup_hyper_mock::streams] Not ready for read yet
[2018-12-04T11:33:23Z TRACE hyper::proto::h1::conn] Conn::read_head
[2018-12-04T11:33:23Z TRACE yup_hyper_mock::streams] Not ready for read yet
[2018-12-04T11:33:23Z TRACE hyper::proto::h1::conn] Conn::read_head
[2018-12-04T11:33:23Z TRACE yup_hyper_mock::streams] Not ready for read yet
[2018-12-04T11:33:23Z TRACE hyper::proto::h1::conn] Conn::read_head
[2018-12-04T11:33:23Z TRACE yup_hyper_mock::streams] Not ready for read yet
[2018-12-04T11:33:23Z TRACE hyper::proto::h1::conn] Conn::read_head
...
This goes on until my self-imposed tokio deadline is triggered.
test container::tests::test_kill_container ... [2018-12-04T11:45:32Z DEBUG bollard::uri] Parsing uri: unix://5f/containers/postgres/kill?signal=SIGKILL, client_type: Unix, socket: _
[2018-12-04T11:45:32Z TRACE hyper::client::pool] checkout waiting for idle connection: "unix://5f"
[2018-12-04T11:45:32Z DEBUG yup_hyper_mock] HostToReplyConnector::connect(Destination { uri: unix://5f/containers/postgres/kill?signal=SIGKILL })
[2018-12-04T11:45:32Z TRACE hyper::client::conn] client handshake HTTP/1
[2018-12-04T11:45:32Z TRACE hyper::proto::h1::conn] read_keep_alive; is_mid_message=false
[2018-12-04T11:45:32Z TRACE hyper::proto::h1::conn] read_keep_alive; is_mid_message=false
[2018-12-04T11:45:32Z TRACE yup_hyper_mock::streams] Not ready for read yet
[2018-12-04T11:45:32Z TRACE hyper::proto::h1::role] Client::encode method=POST, body=None
[2018-12-04T11:45:32Z TRACE yup_hyper_mock::streams] Request data: POST /containers/postgres/kill?signal=SIGKILL HTTP/1.1
content-type: application/json
host: 5f
[2018-12-04T11:45:32Z TRACE hyper::proto::h1::io] detected no usage of vectored write, flattening
[2018-12-04T11:45:32Z DEBUG hyper::proto::h1::io] flushed 100 bytes
[2018-12-04T11:45:32Z TRACE hyper::proto::h1::conn] flushed({role=client}): State { reading: Init, writing: KeepAlive, keep_alive: Busy, error: None }
[2018-12-04T11:45:32Z TRACE hyper::proto::h1::conn] Conn::read_head
[2018-12-04T11:45:32Z TRACE hyper::proto::h1::conn] flushed({role=client}): State { reading: Init, writing: KeepAlive, keep_alive: Busy, error: None }
[2018-12-04T11:45:32Z TRACE hyper::proto::h1::conn] Conn::read_head
[2018-12-04T11:45:32Z TRACE yup_hyper_mock::streams] Buffer size: 8192, Data size: 85, Pos: 0
[2018-12-04T11:45:32Z TRACE yup_hyper_mock::streams] Read 85 bytes: 'HTTP/1.1 200 OK
Server: mock1
Content-Type: application/json
Content-Length: 0
'
[2018-12-04T11:45:32Z DEBUG hyper::proto::h1::io] read 85 bytes
[2018-12-04T11:45:32Z TRACE hyper::proto::h1::role] Response.parse([Header; 100], [u8; 85])
[2018-12-04T11:45:32Z TRACE hyper::proto::h1::role] Response.parse Complete(85)
[2018-12-04T11:45:32Z DEBUG hyper::proto::h1::io] parsed 3 headers
[2018-12-04T11:45:32Z DEBUG hyper::proto::h1::conn] incoming body is empty
[2018-12-04T11:45:32Z TRACE yup_hyper_mock::streams] Buffer size: 8192, Data size: 85, Pos: 85
[2018-12-04T11:45:32Z TRACE yup_hyper_mock::streams] Read 0 bytes: ''
[2018-12-04T11:45:32Z DEBUG hyper::proto::h1::io] read 0 bytes
[2018-12-04T11:45:32Z TRACE hyper::proto::h1::conn] read_keep_alive; is_mid_message=false
[2018-12-04T11:45:32Z TRACE yup_hyper_mock::streams] Buffer size: 8192, Data size: 85, Pos: 85
[2018-12-04T11:45:32Z TRACE yup_hyper_mock::streams] Read 0 bytes: ''
[2018-12-04T11:45:32Z DEBUG hyper::proto::h1::io] read 0 bytes
[2018-12-04T11:45:32Z TRACE hyper::proto::h1::conn] try_io_read; found EOF on connection: State { reading: Init, writing: Init, keep_alive: Idle, error: None }
[2018-12-04T11:45:32Z TRACE hyper::proto::h1::conn] State::close_read()
[2018-12-04T11:45:32Z TRACE hyper::proto::h1::conn] flushed({role=client}): State { reading: Closed, writing: Init, keep_alive: Disabled, error: None }
[2018-12-04T11:45:32Z TRACE hyper::proto::h1::conn] read_keep_alive; is_mid_message=true
[2018-12-04T11:45:32Z TRACE hyper::proto::h1::conn] flushed({role=client}): State { reading: Closed, writing: Init, keep_alive: Disabled, error: None }
[2018-12-04T11:45:32Z TRACE hyper::proto::h1::conn] shut down IO complete