Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add timeout_on_sleeping_server interop test #1568

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading