Skip to content

Commit

Permalink
test: add timeout_on_sleeping_server interop test
Browse files Browse the repository at this point in the history
  • Loading branch information
plaflamme committed Nov 9, 2023
1 parent b3fca19 commit 107beb0
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
3 changes: 3 additions & 0 deletions interop/src/bin/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
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!(),
}

Expand Down
37 changes: 37 additions & 0 deletions interop/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,43 @@ pub async fn custom_metadata(client: &mut TestClient, assertions: &mut Vec<TestA
));
}

pub async fn timeout_on_sleeping_server(
client: &mut TestClient,
assertions: &mut Vec<TestAssertion>,
) {
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];
Expand Down
1 change: 1 addition & 0 deletions interop/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 107beb0

Please sign in to comment.