Skip to content

Commit

Permalink
not rely on client_id. checking if connections are being reused
Browse files Browse the repository at this point in the history
  • Loading branch information
rgrfoss committed Aug 5, 2024
1 parent f250230 commit cf4c8b8
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions redis/tests/redis_cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,38 +98,27 @@ async fn test_recycled() {

let connection_reused = Arc::new(Mutex::new(false));

let client_id_1 = {
{
let mut conn = pool.get().await.unwrap();
let client_id: i64 = cmd("CLIENT")
let _client_id: i64 = cmd("CLIENT")
.arg("ID")
.query_async(&mut conn)
.await
.unwrap();

let mut reused = connection_reused.lock().await;
*reused = true;
}

client_id
};

drop(client_id_1);

let client_id_2 = {
{
let mut conn = pool.get().await.unwrap();
let client_id: i64 = cmd("CLIENT")
let _client_id: i64 = cmd("CLIENT")
.arg("ID")
.query_async(&mut conn)
.await
.unwrap();

let reused = connection_reused.lock().await;
assert!(*reused, "Connection was not reused");

client_id
};

assert_eq!(
client_id_1, client_id_2,
"The Redis connection was not recycled"
);
}
}

0 comments on commit cf4c8b8

Please sign in to comment.