1+ use crate :: utils:: consumer;
12use crate :: utils:: containers:: KafkaContext ;
23use crate :: utils:: logging:: init_test_logger;
34use crate :: utils:: rand:: { rand_test_group, rand_test_topic} ;
@@ -57,7 +58,7 @@ pub async fn test_consumer_groups_deletion() {
5758/// Verify that attempting to delete an unknown group returns a "group not
5859/// found" error.
5960#[ tokio:: test]
60- pub async fn delete_unknown_group ( ) {
61+ pub async fn test_delete_unknown_group ( ) {
6162 init_test_logger ( ) ;
6263
6364 // Get Kafka container context.
@@ -77,3 +78,64 @@ pub async fn delete_unknown_group() {
7778 let expected: GroupResult = Err ( ( unknown_group_name, RDKafkaErrorCode :: NotCoordinator ) ) ;
7879 assert_eq ! ( res, Ok ( vec![ expected] ) ) ;
7980}
81+
82+ /// Verify that deleting a valid and invalid group results in a mixed result
83+ /// set.
84+ #[ tokio:: test]
85+ pub async fn test_consumer_group_action_mixed_results ( ) {
86+ init_test_logger ( ) ;
87+
88+ // Get Kafka container context.
89+ let kafka_context = KafkaContext :: shared ( )
90+ . await
91+ . expect ( "could not create kafka context" ) ;
92+
93+ // Create admin client
94+ let admin_client = utils:: admin:: create_admin_client ( & kafka_context. bootstrap_servers )
95+ . await
96+ . expect ( "could not create admin client" ) ;
97+
98+ // Create consumer_client
99+ let group_name = rand_test_group ( ) ;
100+ let topic_name = rand_test_topic ( "test_topic" ) ;
101+ let consumer_client = utils:: consumer:: create_unsubscribed_base_consumer (
102+ & kafka_context. bootstrap_servers ,
103+ Some ( & group_name) ,
104+ )
105+ . await
106+ . expect ( "could not create subscribed base consumer" ) ;
107+
108+ admin_client
109+ . create_topics (
110+ & [ NewTopic {
111+ name : & topic_name,
112+ num_partitions : 1 ,
113+ replication : TopicReplication :: Fixed ( 1 ) ,
114+ config : vec ! [ ] ,
115+ } ] ,
116+ & AdminOptions :: default ( ) ,
117+ )
118+ . await
119+ . expect ( "topic creation failed" ) ;
120+
121+ let unknown_group_name = rand_test_group ( ) ;
122+ consumer:: create_consumer_group_on_topic ( & consumer_client, & topic_name)
123+ . await
124+ . expect ( "could not create group" ) ;
125+ let res = admin_client
126+ . delete_groups (
127+ & [ & group_name, & unknown_group_name] ,
128+ & AdminOptions :: default ( ) ,
129+ )
130+ . await ;
131+ assert_eq ! (
132+ res,
133+ Ok ( vec![
134+ Ok ( group_name. to_string( ) ) ,
135+ Err ( (
136+ unknown_group_name. to_string( ) ,
137+ RDKafkaErrorCode :: GroupIdNotFound
138+ ) )
139+ ] )
140+ ) ;
141+ }
0 commit comments