Skip to content

Commit

Permalink
Revert check for cmdstas_blpop
Browse files Browse the repository at this point in the history
  • Loading branch information
barshaul committed Apr 18, 2024
1 parent 9e6acd4 commit e44caf2
Showing 1 changed file with 2 additions and 39 deletions.
41 changes: 2 additions & 39 deletions glide-core/tests/test_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ pub(crate) mod shared_client_tests {
use glide_core::client::{Client, DEFAULT_RESPONSE_TIMEOUT};
use redis::{
cluster_routing::{MultipleNodeRoutingInfo, RoutingInfo},
cluster_topology::get_slot,
FromRedisValue, InfoDict, RedisConnectionInfo, Value,
};
use rstest::rstest;
Expand Down Expand Up @@ -399,7 +398,6 @@ pub(crate) mod shared_client_tests {
let result = test_basics.client.send_command(&cmd, None).await;
assert!(result.is_err());
let err = result.unwrap_err();
println!("{:?}", err);
assert_eq!(err.kind(), redis::ErrorKind::ResponseError);
assert!(err.to_string().contains("negative"));
});
Expand All @@ -410,8 +408,7 @@ pub(crate) mod shared_client_tests {
fn test_blocking_command_with_zero_timeout_blocks_indefinitely(
#[values(false, true)] use_cluster: bool,
) {
//"We test that when a blocking command is passed with a timeout duration of 0, it will block the client indefinitely
use redis::cluster_routing::{Route, SingleNodeRoutingInfo, SlotAddr};
// We test that when a blocking command is passed with a timeout duration of 0, it will block the client indefinitely
block_on_all(async {
let config = TestConfiguration {
request_timeout: Some(1), // millisecond
Expand All @@ -420,49 +417,15 @@ pub(crate) mod shared_client_tests {
};
let mut test_basics = setup_test_basics(use_cluster, config.clone()).await;
let key = generate_random_string(10);
// We're routing the request to specific node to verify later that BLPOP wasn't completed on that node
let routing = if use_cluster {
Some(RoutingInfo::SingleNode(
SingleNodeRoutingInfo::SpecificNode(Route::new(
get_slot(key.as_bytes()),
SlotAddr::Master,
)),
))
} else {
None
};
let get_blpop_cmdstats = |mut client: Client, routing: Option<RoutingInfo>| async move {
let mut cmd = redis::Cmd::new();
cmd.arg("INFO").arg("ALL");
let info_res: Value = client
.send_command(&cmd, routing)
.await
.expect("Failed to get INFO ALL");
let res_str = redis::from_owned_redis_value::<String>(info_res)
.expect("INFO ALL result isn't string");
res_str
.lines()
.filter(|line| line.contains("cmdstat_blpop"))
.collect::<String>()
};
let blpop_stats_before =
get_blpop_cmdstats(test_basics.client.clone(), routing.clone()).await;
let cloned_routing = routing.clone();
let future = async move {
let mut cmd = redis::Cmd::new();
cmd.arg("BLPOP").arg(key).arg(0); // `0` should block indefinitely
test_basics.client.send_command(&cmd, cloned_routing).await
test_basics.client.send_command(&cmd, None).await
};
// We execute the command with Tokio's timeout wrapper to prevent the test from hanging indefinitely.
let tokio_timeout_result =
tokio::time::timeout(DEFAULT_RESPONSE_TIMEOUT * 2, future).await;
assert!(tokio_timeout_result.is_err());
// Verify that BLPOP command wasn't completed.
// We create a new client since the connection in the existing client should be blocked
let new_client = create_client(&test_basics.server, config).await;
let blpop_stats_after = get_blpop_cmdstats(new_client, routing).await;
assert_eq!(blpop_stats_before, blpop_stats_after,
"BLPOP command statistiscs has been changed. Before: {blpop_stats_before}, After: {blpop_stats_after}");
});
}

Expand Down

0 comments on commit e44caf2

Please sign in to comment.