forked from redis-rs/redis-rs
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
33 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#![cfg(feature = "cluster-async")] | ||
mod support; | ||
|
||
#[cfg(test)] | ||
mod test_blocking_commands { | ||
use redis::{AsyncCommands, RedisResult, Value}; | ||
|
||
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: RedisResult<Value> = connection.set("foo", "bar").await; | ||
assert!(res.is_ok()); | ||
} | ||
} |