Skip to content

Commit

Permalink
include broker id in log string
Browse files Browse the repository at this point in the history
  • Loading branch information
rukai committed Nov 19, 2024
1 parent 39f99df commit 87f79e5
Show file tree
Hide file tree
Showing 3 changed files with 142 additions and 78 deletions.
7 changes: 6 additions & 1 deletion shotover-proxy/tests/kafka_int_tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,12 @@ async fn cluster_2_racks_multi_shotover(#[case] driver: KafkaDriver) {

let connection_builder = KafkaConnectionBuilder::new(driver, "127.0.0.1:9192");
test_cases::cluster_test_suite(&connection_builder).await;
test_cases::describe_log_dirs(&connection_builder).await;

#[allow(irrefutable_let_patterns)]
if let KafkaDriver::Java = driver {
// describeLogDirs is only on java driver
test_cases::describe_log_dirs(&connection_builder).await;
}

for shotover in shotovers {
tokio::time::timeout(
Expand Down
80 changes: 46 additions & 34 deletions shotover-proxy/tests/kafka_int_tests/test_cases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1853,40 +1853,52 @@ pub async fn describe_log_dirs(connection_builder: &KafkaConnectionBuilder) {
},
])
.await;
assert_eq!(
result,
HashMap::from([
(
TopicPartitionReplica {
topic_name: "describe_logs_test".to_owned(),
partition: 0,
broker_id: 0,
},
DescribeReplicaLogDirInfo {
path: Some("/bitnami/kafka/data".to_owned())
}
),
(
TopicPartitionReplica {
topic_name: "describe_logs_test".to_owned(),
partition: 0,
broker_id: 1,
},
DescribeReplicaLogDirInfo {
path: Some("/bitnami/kafka/data".to_owned())
}
),
(
TopicPartitionReplica {
topic_name: "describe_logs_test2".to_owned(),
partition: 0,
broker_id: 0,
},
DescribeReplicaLogDirInfo {
path: Some("/bitnami/kafka/data".to_owned())
}
)
])

/// Assert that the path in the DescribeLogsDir response matches the custom format used by shotover.
/// This format looks like: actual-kafka-broker-id3:/original/kafka/path/here
fn assert_valid_path(info: &DescribeReplicaLogDirInfo) {
let id = info
.path
.as_ref()
.unwrap()
.strip_prefix("actual-kafka-broker-id")
.unwrap()
.strip_suffix(":/bitnami/kafka/data")
.unwrap();
let id: i32 = id.parse().unwrap();
assert!(
id < 6,
"There are only 6 brokers so the broker id must be between 0-5 inclusive"
);
}

assert_eq!(result.len(), 3);
assert_valid_path(
result
.get(&TopicPartitionReplica {
topic_name: "describe_logs_test".to_owned(),
partition: 0,
broker_id: 0,
})
.unwrap(),
);
assert_valid_path(
result
.get(&TopicPartitionReplica {
topic_name: "describe_logs_test".to_owned(),
partition: 0,
broker_id: 1,
})
.unwrap(),
);
assert_valid_path(
result
.get(&TopicPartitionReplica {
topic_name: "describe_logs_test2".to_owned(),
partition: 0,
broker_id: 0,
})
.unwrap(),
);
}

Expand Down
Loading

0 comments on commit 87f79e5

Please sign in to comment.