chore: setup kafka standalone in coverage test (#2984)

* chore: setup kafka standalone in coverage test

* test: add a naive test for topic manager
This commit is contained in:
Weny Xu
2023-12-25 20:18:54 +09:00
committed by GitHub
parent 48cd22d459
commit 89129c99c8
3 changed files with 53 additions and 1 deletions

View File

@@ -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]
@@ -201,4 +206,27 @@ 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 config = KafkaConfig {
replication_factor: 1,
broker_endpoints: endpoints
.split(',')
.map(|s| s.to_string())
.collect::<Vec<_>>(),
..Default::default()
};
let manager = TopicManager::new(config, kv_backend);
manager.start().await.unwrap();
}
}