Skip to content

Commit

Permalink
fix redis cluster test_recycled test
Browse files Browse the repository at this point in the history
This closes #344
  • Loading branch information
rgrfoss authored Aug 5, 2024
1 parent 1a3b68d commit 251aa11
Showing 1 changed file with 26 additions and 15 deletions.
41 changes: 26 additions & 15 deletions redis/tests/redis_cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<i64>(&mut conn)
.arg("SETNAME")
.arg(connection_name)
.query_async::<()>(&mut conn)
.await
.unwrap()
.unwrap();

let current_name: Option<String> = 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::<i64>(&mut conn)
let current_name: Option<String> = 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"
);
}

0 comments on commit 251aa11

Please sign in to comment.