Skip to content

Commit

Permalink
Port Tee to MessageId
Browse files Browse the repository at this point in the history
  • Loading branch information
rukai committed Feb 28, 2024
1 parent 81ddc61 commit c70040f
Show file tree
Hide file tree
Showing 3 changed files with 254 additions and 81 deletions.
2 changes: 1 addition & 1 deletion shotover-proxy/tests/test-configs/tee/switch_chain.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ sources:
- DebugReturner:
Redis: "a"
- Redis:
name: "redis-3"
name: "redis-2"
listen_addr: "127.0.0.1:6372"
connection_limit:
chain:
Expand Down
56 changes: 33 additions & 23 deletions shotover-proxy/tests/transforms/tee.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::shotover_process;
use test_helpers::connection::redis_connection;
use test_helpers::docker_compose::docker_compose;
use test_helpers::shotover_process::{EventMatcher, Level};
use test_helpers::shotover_process::{Count, EventMatcher, Level};

#[tokio::test(flavor = "multi_thread")]
async fn test_ignore_matches() {
Expand Down Expand Up @@ -77,24 +77,15 @@ async fn test_log_with_mismatch() {

assert_eq!("42", result);
shotover
.shutdown_and_then_consume_events(&[
EventMatcher::new()
.with_level(Level::Warn)
.with_target("shotover::transforms::tee")
.with_message(
r#"Tee mismatch:
chain response: ["Redis BulkString(b\"42\")", "Redis BulkString(b\"42\")"]
tee response: ["Redis BulkString(b\"41\")", "Redis BulkString(b\"41\")"]"#,
),
EventMatcher::new()
.with_level(Level::Warn)
.with_target("shotover::transforms::tee")
.with_message(
r#"Tee mismatch:
chain response: ["Redis BulkString(b\"42\")"]
tee response: ["Redis BulkString(b\"41\")"]"#,
),
])
.shutdown_and_then_consume_events(&[EventMatcher::new()
.with_level(Level::Warn)
.with_count(Count::Times(3))
.with_target("shotover::transforms::tee")
.with_message(
r#"Tee mismatch:
result-source response: Redis BulkString(b"42")
other response: Redis BulkString(b"41")"#,
)])
.await;
}

Expand Down Expand Up @@ -211,6 +202,7 @@ async fn test_switch_main_chain() {
.await;

for i in 1..=3 {
println!("{i}");
let redis_port = 6370 + i;
let switch_port = 1230 + i;

Expand Down Expand Up @@ -254,9 +246,27 @@ async fn test_switch_main_chain() {
}

shotover
.shutdown_and_then_consume_events(&[EventMatcher::new()
.with_level(Level::Warn)
// 1 warning per loop above + 1 warning from the redis-rs driver connection handshake
.with_count(tokio_bin_process::event_matcher::Count::Times(4))])
.shutdown_and_then_consume_events(&[
EventMatcher::new()
.with_level(Level::Warn)
// generated by the final loop above, 2 by the requests + 2 by the redis-rs driver connection handshake
.with_count(Count::Times(4))
.with_target("shotover::transforms::tee")
.with_message(
r#"Tee mismatch:
result-source response: Redis BulkString(b"a")
other response: Redis BulkString(b"b")"#,
),
EventMatcher::new()
.with_level(Level::Warn)
// generated by the final loop above, while the result-source is flipped.
.with_count(Count::Times(1))
.with_target("shotover::transforms::tee")
.with_message(
r#"Tee mismatch:
result-source response: Redis BulkString(b"b")
other response: Redis BulkString(b"a")"#,
),
])
.await;
}
Loading

0 comments on commit c70040f

Please sign in to comment.