Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix redis cluster test_recycled test #345

Merged
merged 5 commits into from
Aug 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
);
}
Loading