Skip to content

Commit c49c8cc

Browse files
committed
Fix all the tests except the sentinel one
1 parent ffb67e3 commit c49c8cc

File tree

3 files changed

+37
-7
lines changed

3 files changed

+37
-7
lines changed

nativelink-redis-tester/src/fake_redis.rs

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,37 @@ pub fn add_to_response_raw<B: BuildHasher>(
9595
}
9696

9797
fn setinfo(responses: &mut HashMap<String, String>) {
98-
// Library sends both lib-name and lib-ver in one go, so we respond to both
99-
add_to_response(
100-
responses,
98+
// We do raw inserts of command here, because the library sends 3/4 commands in one go
99+
// They always start with HELLO, then optionally SELECT, so we use this to differentiate
100+
let hello = cmd_as_string(redis::cmd("HELLO").arg("3"));
101+
let setinfo = cmd_as_string(
101102
redis::cmd("CLIENT")
102103
.arg("SETINFO")
103104
.arg("LIB-NAME")
104105
.arg("redis-rs"),
105-
vec![Value::Okay, Value::Okay],
106+
);
107+
responses.insert(
108+
vec![hello.clone(), setinfo.clone()].join(""),
109+
args_as_string(vec![
110+
Value::Map(vec![(
111+
Value::SimpleString("server".into()),
112+
Value::SimpleString("redis".into()),
113+
)]),
114+
Value::Okay,
115+
Value::Okay,
116+
]),
117+
);
118+
responses.insert(
119+
vec![hello, cmd_as_string(redis::cmd("SELECT").arg(3)), setinfo].join(""),
120+
args_as_string(vec![
121+
Value::Map(vec![(
122+
Value::SimpleString("server".into()),
123+
Value::SimpleString("redis".into()),
124+
)]),
125+
Value::Okay,
126+
Value::Okay,
127+
Value::Okay,
128+
]),
106129
);
107130
}
108131

nativelink-store/src/redis_store.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,13 @@ impl RedisStore<ConnectionManager, StandardRedisManager<ConnectionManager>> {
601601
let mut parsed_addr = local_addr
602602
.replace("redis+sentinel://", "redis://")
603603
.into_connection_info()?;
604+
605+
let redis_settings = parsed_addr
606+
.redis_settings()
607+
.clone()
608+
// We need RESP3 here because we want to do set_push_sender
609+
.set_protocol(redis::ProtocolVersion::RESP3);
610+
parsed_addr = parsed_addr.set_redis_settings(redis_settings);
604611
debug!(?parsed_addr, "Parsed redis addr");
605612

606613
let client = timeout(

nativelink-store/tests/redis_store_test.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ fn test_connection_errors() {
641641
Error {
642642
code: Code::DeadlineExceeded,
643643
messages: vec![
644-
"deadline has elapsed".into(),
644+
"Io: timed out".into(),
645645
format!("While connecting to redis with url: redis://nativelink.com:6379/")
646646
]
647647
},
@@ -671,7 +671,7 @@ async fn test_health() {
671671
} => {
672672
assert_eq!(
673673
struct_name,
674-
"nativelink_store::redis_store::RedisStore<redis::aio::connection_manager::ConnectionManager, redis::aio::pubsub::PubSub>"
674+
"nativelink_store::redis_store::RedisStore<redis::aio::connection_manager::ConnectionManager, nativelink_store::redis_store::StandardRedisManager<redis::aio::connection_manager::ConnectionManager>>"
675675
);
676676
assert!(
677677
message.starts_with("Store.update_oneshot() failed: Error { code: DeadlineExceeded, messages: [\"Io: timed out\", \"While appending to temp key ("),
@@ -814,7 +814,7 @@ async fn test_redis_connect_timeout() {
814814
Error {
815815
code: Code::DeadlineExceeded,
816816
messages: vec![
817-
"deadline has elapsed".into(),
817+
"Io: timed out".into(),
818818
format!("While connecting to redis with url: redis://127.0.0.1:{port}/")
819819
]
820820
},

0 commit comments

Comments
 (0)