Skip to content

Commit

Permalink
test: add a naive test for topic manager
Browse files Browse the repository at this point in the history
  • Loading branch information
WenyXu committed Dec 23, 2023
1 parent e7c717d commit f217991
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/common/meta/src/wal/kafka/topic_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,13 @@ impl TopicManager {

#[cfg(test)]
mod tests {
use std::env;

use common_telemetry::info;

use super::*;
use crate::kv_backend::memory::MemoryKvBackend;
use crate::kv_backend::{self};

// Tests that topics can be successfully persisted into the kv backend and can be successfully restored from the kv backend.
#[tokio::test]
Expand All @@ -201,4 +206,25 @@ mod tests {

assert_eq!(topics, restored_topics);
}

#[tokio::test]
async fn test_topic_manager() {
let endpoints = env::var("GT_KAFKA_ENDPOINTS").unwrap_or_default();
common_telemetry::init_default_ut_logging();

if endpoints.is_empty() {
info!("The endpoints is empty, skipping the test.");
return;
}
// TODO: supports topic prefix
let kv_backend = Arc::new(MemoryKvBackend::new());
let mut config = KafkaConfig::default();
config.replication_factor = 1;
config.broker_endpoints = endpoints
.split(",")
.map(|s| s.to_string())
.collect::<Vec<_>>();
let manager = TopicManager::new(config, kv_backend);
manager.start().await.unwrap();
}
}

0 comments on commit f217991

Please sign in to comment.