Skip to content

Commit

Permalink
Fix redis_int_tests::passthrough_redis_down on macos (#1617)
Browse files Browse the repository at this point in the history
  • Loading branch information
rukai authored May 10, 2024
1 parent 383e67d commit 875d19d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
8 changes: 8 additions & 0 deletions shotover-proxy/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,11 @@ pub fn shotover_process(topology_path: &str) -> ShotoverProcessBuilder {
.with_bin(bin_path!("shotover-proxy"))
.with_config("tests/test-configs/shotover-config/config1.yaml")
}

#[cfg(target_os = "macos")]
#[cfg(feature = "redis")]
const CONNECTION_REFUSED_OS_ERROR: i32 = 61;

#[cfg(not(target_os = "macos"))]
#[cfg(feature = "redis")]
const CONNECTION_REFUSED_OS_ERROR: i32 = 111;
5 changes: 3 additions & 2 deletions shotover-proxy/tests/redis_int_tests/basic_driver_tests.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::redis_int_tests::assert::*;
use crate::CONNECTION_REFUSED_OS_ERROR;
use bytes::BytesMut;
use fred::clients::RedisClient;
use fred::interfaces::ClientLike;
Expand Down Expand Up @@ -1273,7 +1274,7 @@ pub async fn test_trigger_transform_failure_driver(client: &RedisClient) {
assert_eq!(
// fred sends a `CLIENT` command on startup to which shotover will reply with an error
client.wait_for_connect().await.unwrap_err().details(),
"ERR Internal shotover (or custom transform) bug: Chain failed to send and/or receive messages, the connection will now be closed. Caused by: 0: RedisSinkSingle transform failed 1: Failed to connect to destination 127.0.0.1:1111 2: Connection refused (os error 111)".to_string()
format!("ERR Internal shotover (or custom transform) bug: Chain failed to send and/or receive messages, the connection will now be closed. Caused by: 0: RedisSinkSingle transform failed 1: Failed to connect to destination 127.0.0.1:1111 2: Connection refused (os error {CONNECTION_REFUSED_OS_ERROR})")
);
}

Expand All @@ -1292,7 +1293,7 @@ pub async fn test_trigger_transform_failure_raw() {

assert_eq!(
read_redis_message(&mut connection).await,
RedisFrame::Error("ERR Internal shotover (or custom transform) bug: Chain failed to send and/or receive messages, the connection will now be closed. Caused by: 0: RedisSinkSingle transform failed 1: Failed to connect to destination 127.0.0.1:1111 2: Connection refused (os error 111)".into())
RedisFrame::Error(format!("ERR Internal shotover (or custom transform) bug: Chain failed to send and/or receive messages, the connection will now be closed. Caused by: 0: RedisSinkSingle transform failed 1: Failed to connect to destination 127.0.0.1:1111 2: Connection refused (os error {CONNECTION_REFUSED_OS_ERROR})").into())
);

// If the connection was closed by shotover then we will succesfully read 0 bytes.
Expand Down
14 changes: 7 additions & 7 deletions shotover-proxy/tests/redis_int_tests/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::shotover_process;
use crate::{shotover_process, CONNECTION_REFUSED_OS_ERROR};
use basic_driver_tests::*;
use fred::clients::RedisClient;
use fred::interfaces::ClientLike;
Expand Down Expand Up @@ -66,15 +66,15 @@ async fn passthrough_redis_down() {
EventMatcher::new()
.with_level(Level::Error)
.with_target("shotover::server")
.with_message(
.with_message(&format!(
r#"connection was unexpectedly terminated
Caused by:
0: Chain failed to send and/or receive messages, the connection will now be closed.
1: RedisSinkSingle transform failed
2: Failed to connect to destination 127.0.0.1:1111
3: Connection refused (os error 111)"#,
)
3: Connection refused (os error {CONNECTION_REFUSED_OS_ERROR})"#
))
.with_count(Count::Times(2)),
// This error occurs due to `test_invalid_frame`, it opens a connection, sends an invalid frame which
// fails at the codec stage and never reaches the transform.
Expand All @@ -83,14 +83,14 @@ Caused by:
EventMatcher::new()
.with_level(Level::Error)
.with_target("shotover::server")
.with_message(
.with_message(&format!(
r#"encountered an error when flushing the chain redis for shutdown
Caused by:
0: RedisSinkSingle transform failed
1: Failed to connect to destination 127.0.0.1:1111
2: Connection refused (os error 111)"#,
)
2: Connection refused (os error {CONNECTION_REFUSED_OS_ERROR})"#
))
.with_count(Count::Times(1)),
invalid_frame_event(),
])
Expand Down

0 comments on commit 875d19d

Please sign in to comment.