From 527a3c9ac8b7d308dcf0dac1a3b30238692ba419 Mon Sep 17 00:00:00 2001 From: lxl66566 Date: Fri, 26 Jul 2024 09:50:34 +0800 Subject: [PATCH] fix: shutdown cluster test timeout Signed-off-by: lxl66566 --- crates/curp/tests/it/server.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/crates/curp/tests/it/server.rs b/crates/curp/tests/it/server.rs index 9eeb5878a..09ff3879c 100644 --- a/crates/curp/tests/it/server.rs +++ b/crates/curp/tests/it/server.rs @@ -299,8 +299,23 @@ async fn shutdown_rpc_should_shutdown_the_cluster() { for i in 0..10 { let cmd = TestCommand::new_put(vec![i], i); let res = req_client.propose(&cmd, None, true).await; - if res.is_ok() && res.unwrap().is_ok() { - collection.push(i); + match res { + Ok(res) => { + if res.is_ok() { + collection.push(i); + } + } + Err(err) => { + // retry 3 times after 10.5s, the cluster has been shutted down + if err.code() == tonic::Code::DeadlineExceeded + || matches!( + err.into(), + CurpError::ShuttingDown(_) | CurpError::RpcTransport(()) + ) + { + return collection; + } + } } } collection