Skip to content

Commit

Permalink
added blocking commands tests
Browse files Browse the repository at this point in the history
  • Loading branch information
avifenesh committed Jul 4, 2024
1 parent 4571c91 commit 36094fd
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ test:
@echo "===================================================================="
@echo "Testing Connection Type UNIX SOCKETS"
@echo "===================================================================="
@RUSTFLAGS="-D warnings" REDISRS_SERVER_TYPE=unix RUST_BACKTRACE=1 cargo test --locked -p redis --all-features -- --test-threads=1 --skip test_cluster --skip test_async_cluster --skip test_module --skip test_cluster_scan
@RUSTFLAGS="-D warnings" REDISRS_SERVER_TYPE=unix RUST_BACKTRACE=1 cargo test --locked -p redis --all-features -- --test-threads=1 --skip test_cluster --skip test_async_cluster --skip test_module --skip test_cluster_scan --skip test_blocking_commands

@echo "===================================================================="
@echo "Testing async-std with Rustls"
Expand Down
32 changes: 32 additions & 0 deletions redis/tests/test_blocking_commands.rs
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());
}
}

0 comments on commit 36094fd

Please sign in to comment.