diff --git a/redis/tests/test_blocking_commands.rs b/redis/tests/test_blocking_commands.rs new file mode 100644 index 0000000000..9aa1e31c8b --- /dev/null +++ b/redis/tests/test_blocking_commands.rs @@ -0,0 +1,32 @@ +#![cfg(feature = "cluster-async")] +mod support; + +#[cfg(test)] +mod test_blocking_commands { + use redis::AsyncCommands; + + use crate::support::*; + #[tokio::test] + async fn test_blocking_command_when_cluster_drops() { + let mut cluster = TestClusterContext::new(3, 0); + let mut connection = cluster.async_connection(None).await; + let time_now = std::time::SystemTime::now(); + futures::future::join( + async { + let res = connection.blpop::<&str, f64>("foo", 0.0).await; + assert!(res.is_err()); + println!("blpop returned error {:?}", res.map_err(|e| e.to_string())); + println!("time elapsed: {:?}", time_now.elapsed().unwrap()); + }, + async { + tokio::time::sleep(tokio::time::Duration::from_secs(10)).await; + drop(cluster); + }, + ) + .await; + cluster = TestClusterContext::new(3, 0); + connection = cluster.async_connection(None).await; + let res: () = connection.set("foo", "bar").await.unwrap(); + assert!(res == ()); + } +}