Skip to content

Commit 74c1ec0

Browse files
committed
fix: test_consumer_group_action_mixed_results
1 parent 89ba998 commit 74c1ec0

File tree

2 files changed

+63
-25
lines changed

2 files changed

+63
-25
lines changed

tests/admin.rs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -638,28 +638,4 @@ async fn test_groups() {
638638
.await
639639
.expect("could not create admin client");
640640
let opts = AdminOptions::new();
641-
642-
// Verify that deleting a valid and invalid group results in a mixed result
643-
// set.
644-
{
645-
let group_name = rand_test_group();
646-
let unknown_group_name = rand_test_group();
647-
create_consumer_group(&group_name).await;
648-
let res = admin_client
649-
.delete_groups(
650-
&[&group_name, &unknown_group_name],
651-
&AdminOptions::default(),
652-
)
653-
.await;
654-
assert_eq!(
655-
res,
656-
Ok(vec![
657-
Ok(group_name.to_string()),
658-
Err((
659-
unknown_group_name.to_string(),
660-
RDKafkaErrorCode::GroupIdNotFound
661-
))
662-
])
663-
);
664-
}
665641
}

tests/consumer_groups.rs

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::utils::consumer;
12
use crate::utils::containers::KafkaContext;
23
use crate::utils::logging::init_test_logger;
34
use 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

Comments
 (0)