Skip to content

Commit 251aa11

Browse files
authored
fix redis cluster test_recycled test
This closes deadpool-rs#344
1 parent 1a3b68d commit 251aa11

File tree

1 file changed

+26
-15
lines changed

1 file changed

+26
-15
lines changed

redis/tests/redis_cluster.rs

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -94,28 +94,39 @@ async fn test_aborted_command() {
9494
async fn test_recycled() {
9595
let pool = create_pool();
9696

97-
let client_id = {
98-
let mut conn = pool.get().await.unwrap();
97+
let connection_name = "unique_connection_name";
9998

99+
let connection_details_1 = {
100+
let mut conn = pool.get().await.unwrap();
100101
cmd("CLIENT")
101-
.arg("ID")
102-
.query_async::<i64>(&mut conn)
102+
.arg("SETNAME")
103+
.arg(connection_name)
104+
.query_async::<()>(&mut conn)
103105
.await
104-
.unwrap()
106+
.unwrap();
107+
108+
let current_name: Option<String> = cmd("CLIENT")
109+
.arg("GETNAME")
110+
.query_async(&mut conn)
111+
.await
112+
.unwrap();
113+
114+
current_name
105115
};
106116

107-
{
117+
let connection_details_2 = {
108118
let mut conn = pool.get().await.unwrap();
109-
110-
let new_client_id = cmd("CLIENT")
111-
.arg("ID")
112-
.query_async::<i64>(&mut conn)
119+
let current_name: Option<String> = cmd("CLIENT")
120+
.arg("GETNAME")
121+
.query_async(&mut conn)
113122
.await
114123
.unwrap();
115124

116-
assert_eq!(
117-
client_id, new_client_id,
118-
"the redis connection was not recycled"
119-
);
120-
}
125+
current_name
126+
};
127+
128+
assert_eq!(
129+
connection_details_1, connection_details_2,
130+
"The Redis connection was not recycled: different connection name"
131+
);
121132
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy