-
Notifications
You must be signed in to change notification settings - Fork 15.4k
MINOR: add test for kafka-consumer-groups.sh should not fail when partition offline
#20235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 16 commits
13c821c
a0fdb86
f7a4b03
a18d896
c2a24c9
b0e292f
391326a
e1cfa54
e13bc80
05b504b
ca27cea
7cd0703
cbe8138
3406b22
b843e4e
ae74eb4
5d1c22d
1a9e642
cda748f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,6 +27,7 @@ | |
| import org.apache.kafka.clients.producer.ProducerRecord; | ||
| import org.apache.kafka.common.GroupState; | ||
| import org.apache.kafka.common.TopicPartition; | ||
| import org.apache.kafka.common.config.TopicConfig; | ||
| import org.apache.kafka.common.errors.LeaderNotAvailableException; | ||
| import org.apache.kafka.common.errors.UnknownTopicOrPartitionException; | ||
| import org.apache.kafka.common.serialization.ByteArraySerializer; | ||
|
|
@@ -52,6 +53,7 @@ | |
| import java.util.Map; | ||
| import java.util.Objects; | ||
| import java.util.Properties; | ||
| import java.util.Set; | ||
| import java.util.concurrent.ExecutionException; | ||
| import java.util.function.Function; | ||
| import java.util.function.Supplier; | ||
|
|
@@ -153,6 +155,29 @@ public void testResetOffsetsNotExistingGroup(ClusterInstance cluster) throws Exc | |
| } | ||
| } | ||
|
|
||
| @ClusterTest( | ||
| brokers = 2, | ||
| serverProperties = { | ||
| @ClusterConfigProperty(key = OFFSETS_TOPIC_REPLICATION_FACTOR_CONFIG, value = "2"), | ||
| @ClusterConfigProperty(key = TopicConfig.MIN_IN_SYNC_REPLICAS_CONFIG, value = "1") | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we really need to set these properties? We can reproduce the failure without setting them.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These settings can avoid flaky.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The min.insync.replicas default value is 1, so we don't need to configure it explicitly? |
||
| } | ||
| ) | ||
| public void testResetOffsetsWithOfflinePartitionNotInResetTarget(ClusterInstance cluster) throws Exception { | ||
| String topic = generateRandomTopic(); | ||
| String group = "new.group"; | ||
| String[] args = buildArgsForGroup(cluster, group, "--to-earliest", "--execute", "--topic", topic + ":0"); | ||
|
|
||
| try (Admin admin = cluster.admin(); ConsumerGroupCommand.ConsumerGroupService service = getConsumerGroupService(args)) { | ||
| admin.createTopics(List.of(new NewTopic(topic, Map.of(0, List.of(0), 1, List.of(1))))); | ||
| cluster.waitTopicCreation(topic, 2); | ||
|
|
||
| cluster.shutdownBroker(1); | ||
|
|
||
| Map<TopicPartition, OffsetAndMetadata> resetOffsets = service.resetOffsets().get(group); | ||
| assertEquals(Set.of(new TopicPartition(topic, 0)), resetOffsets.keySet()); | ||
| } | ||
| } | ||
|
|
||
| @ClusterTest | ||
| public void testResetOffsetsExistingTopic(ClusterInstance cluster) { | ||
| String topic = generateRandomTopic(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add the filter after
mapto avoid creating extraTopicPartitionobject.