11#![ allow( dead_code) ]
22
3+ pub mod logging;
4+ pub mod rand;
5+
36use std:: collections:: HashMap ;
47use std:: env:: { self , VarError } ;
5- use std:: sync:: Once ;
68use std:: time:: Duration ;
79
8- use rand:: distr:: { Alphanumeric , SampleString } ;
910use regex:: Regex ;
1011
1112use rdkafka:: admin:: { AdminClient , AdminOptions , NewTopic , TopicReplication } ;
@@ -18,21 +19,6 @@ use rdkafka::producer::{FutureProducer, FutureRecord};
1819use rdkafka:: statistics:: Statistics ;
1920use rdkafka:: TopicPartitionList ;
2021
21- pub fn rand_test_topic ( test_name : & str ) -> String {
22- let id = Alphanumeric . sample_string ( & mut rand:: rng ( ) , 10 ) ;
23- format ! ( "__{}_{}" , test_name, id)
24- }
25-
26- pub fn rand_test_group ( ) -> String {
27- let id = Alphanumeric . sample_string ( & mut rand:: rng ( ) , 10 ) ;
28- format ! ( "__test_{}" , id)
29- }
30-
31- pub fn rand_test_transactional_id ( ) -> String {
32- let id = Alphanumeric . sample_string ( & mut rand:: rng ( ) , 10 ) ;
33- format ! ( "__test_{}" , id)
34- }
35-
3622pub fn get_bootstrap_server ( ) -> String {
3723 env:: var ( "KAFKA_HOST" ) . unwrap_or_else ( |_| "localhost:9092" . to_owned ( ) )
3824}
@@ -195,21 +181,13 @@ pub fn consumer_config(
195181 config
196182}
197183
198- static INIT : Once = Once :: new ( ) ;
199-
200- pub fn configure_logging_for_tests ( ) {
201- INIT . call_once ( || {
202- env_logger:: try_init ( ) . expect ( "Failed to initialize env_logger" ) ;
203- } ) ;
204- }
205-
206184#[ cfg( test) ]
207185mod tests {
208186 use super :: * ;
209187
210188 #[ tokio:: test]
211189 async fn test_populate_topic ( ) {
212- let topic_name = rand_test_topic ( "test_populate_topic" ) ;
190+ let topic_name = rand :: rand_test_topic ( "test_populate_topic" ) ;
213191 let message_map = populate_topic ( & topic_name, 100 , & value_fn, & key_fn, Some ( 0 ) , None ) . await ;
214192
215193 let total_messages = message_map
0 commit comments