diff --git a/interop/src/bin/client.rs b/interop/src/bin/client.rs index 851fa0a3e..9e40972a5 100644 --- a/interop/src/bin/client.rs +++ b/interop/src/bin/client.rs @@ -83,6 +83,9 @@ async fn main() -> Result<(), Box> { Testcase::CustomMetadata => { client::custom_metadata(&mut client, &mut test_results).await } + Testcase::TimeoutOnSleepingServer => { + client::timeout_on_sleeping_server(&mut client, &mut test_results).await + } _ => unimplemented!(), } diff --git a/interop/src/client.rs b/interop/src/client.rs index aa5a9a93f..fa05c0cc6 100644 --- a/interop/src/client.rs +++ b/interop/src/client.rs @@ -399,6 +399,43 @@ pub async fn custom_metadata(client: &mut TestClient, assertions: &mut Vec, +) { + let request = StreamingOutputCallRequest { + payload: Some(crate::client_payload(27182)), + ..Default::default() + }; + let mut request = Request::new(tokio_stream::once(request).chain(tokio_stream::pending())); + request.set_timeout(std::time::Duration::from_millis(1)); + let result = client.full_duplex_call(request).await; + + match result { + Ok(res) => { + let result = res + .into_inner() + .next() + .await + .expect("stream should not close"); + + assertions.push(test_assert!( + "code must be DeadlineExceeded", + match &result { + Err(status) => status.code() == Code::DeadlineExceeded, + _ => false, + }, + format!("error={:?}", result) + )) + } + Err(e) => assertions.push(test_assert!( + "code must be DeadlineExceeded", + e.code() == Code::DeadlineExceeded, + format!("error={:?}", e) + )), + } +} + fn make_ping_pong_request(idx: usize) -> StreamingOutputCallRequest { let req_len = REQUEST_LENGTHS[idx]; let resp_len = RESPONSE_LENGTHS[idx]; diff --git a/interop/test.sh b/interop/test.sh index 1814b2df4..c0d4f17bc 100755 --- a/interop/test.sh +++ b/interop/test.sh @@ -17,6 +17,7 @@ TEST_CASES=( "custom_metadata" "unimplemented_method" "unimplemented_service" + "timeout_on_sleeping_server" ) # join all test cases in one comma separated string (dropping the first one)