From 251aa11fca697719df2d6ab29be413f3db942c9c Mon Sep 17 00:00:00 2001 From: rgrfoss Date: Mon, 5 Aug 2024 21:46:25 +0200 Subject: [PATCH] fix redis cluster test_recycled test This closes #344 --- redis/tests/redis_cluster.rs | 41 +++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/redis/tests/redis_cluster.rs b/redis/tests/redis_cluster.rs index 8f1c656..b20b7e3 100644 --- a/redis/tests/redis_cluster.rs +++ b/redis/tests/redis_cluster.rs @@ -94,28 +94,39 @@ async fn test_aborted_command() { async fn test_recycled() { let pool = create_pool(); - let client_id = { - let mut conn = pool.get().await.unwrap(); + let connection_name = "unique_connection_name"; + let connection_details_1 = { + let mut conn = pool.get().await.unwrap(); cmd("CLIENT") - .arg("ID") - .query_async::(&mut conn) + .arg("SETNAME") + .arg(connection_name) + .query_async::<()>(&mut conn) .await - .unwrap() + .unwrap(); + + let current_name: Option = cmd("CLIENT") + .arg("GETNAME") + .query_async(&mut conn) + .await + .unwrap(); + + current_name }; - { + let connection_details_2 = { let mut conn = pool.get().await.unwrap(); - - let new_client_id = cmd("CLIENT") - .arg("ID") - .query_async::(&mut conn) + let current_name: Option = cmd("CLIENT") + .arg("GETNAME") + .query_async(&mut conn) .await .unwrap(); - assert_eq!( - client_id, new_client_id, - "the redis connection was not recycled" - ); - } + current_name + }; + + assert_eq!( + connection_details_1, connection_details_2, + "The Redis connection was not recycled: different connection name" + ); }