You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by ch...@apache.org on 2026/10/25 04:50:04 UTC
(kafka) branch trunk updated: MINOR: Propagate ClusterInstance#createTopic errors and clean up callers (#23699)
This is an automated email from the ASF dual-hosted git repository.
chia7712 pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/trunk by this push:
new c9da36e2707 MINOR: Propagate ClusterInstance#createTopic errors and clean up callers (#23699)
c9da36e2707 is described below
commit c9da36e27076da3acb51bf75beed30d46b9f0583
Author: Yen-Ting Li <yt...@gmail.com>
AuthorDate: Sun Oct 25 12:49:57 2026 +0800
MINOR: Propagate ClusterInstance#createTopic errors and clean up callers (#23699)
ClusterInstance#createTopic and #createTopicWithAssignment did not wait
for the CreateTopics result, so a failed creation was hidden behind the
60s waitTopicCreation timeout, or ignored if the topic already existed.
They now call get() and wrap the cause in a RuntimeException.
InterruptedException is rethrown as InterruptException, so callers no
longer need to declare checked exceptions.
Also removes the now redundant throws clauses, assertDoesNotThrow
wrappers and pass-through helpers, and a duplicate createTopic call in
PlaintextConsumerTest#testSeek.
Follow-up to #23513.
Reviewers: Chia-Ping Tsai <ch...@gmail.com>, Ken Huang
<s7...@gmail.com>
---------
Co-authored-by: Claude Opus 5.5 <no...@anthropic.com>
---
.../clients/CreateTopicsRequestWithPolicyTest.java | 2 +-
.../kafka/clients/admin/AddPartitionsTest.java | 4 +-
.../kafka/clients/admin/AdminMetadataTest.java | 2 +-
.../admin/DescribeProducersWithBrokerIdTest.java | 2 +-
.../clients/admin/ListOffsetsIntegrationTest.java | 12 ++--
.../kafka/clients/consumer/ConsumerBounceTest.java | 4 +-
...umerWithLegacyMessageFormatIntegrationTest.java | 2 +-
.../consumer/PlaintextConsumerAssignTest.java | 2 +-
.../consumer/PlaintextConsumerCommitTest.java | 4 +-
.../consumer/PlaintextConsumerFetchTest.java | 2 +-
.../consumer/PlaintextConsumerPollTest.java | 2 +-
.../PlaintextConsumerSubscriptionTest.java | 2 +-
.../clients/consumer/PlaintextConsumerTest.java | 31 +++++-----
.../consumer/SaslPlainPlaintextConsumerTest.java | 2 +-
.../consumer/SaslPlaintextConsumerTest.java | 2 +-
.../clients/consumer/ShareConsumerDLQTest.java | 8 +--
.../producer/ProducerFailureHandlingTest.java | 12 ++--
.../clients/producer/ProducerIntegrationTest.java | 2 +-
.../apache/kafka/api/EndToEndClusterIdTest.java | 2 +-
.../server/CordonedLogDirsIntegrationTest.java | 12 ++--
.../apache/kafka/server/MetadataRequestTest.java | 15 +++--
.../apache/kafka/admin/RemoteTopicCrudTest.java | 13 ++---
...ogMetadataManagerMultipleSubscriptionsTest.java | 11 +---
.../tiered/storage/TieredStorageTestContext.java | 2 +-
.../tiered/storage/actions/CreateTopicAction.java | 3 +-
.../storage/integration/TransactionsTest.java | 10 ++--
.../integration/TransactionsTestHelper.java | 12 ++--
.../TransactionsWithTieredStoreTest.java | 12 ++--
.../apache/kafka/common/test/ClusterInstance.java | 27 +++++----
.../kafka/tools/ConfigCommandIntegrationTest.java | 4 +-
.../org/apache/kafka/tools/LogDirsCommandTest.java | 12 ++--
.../apache/kafka/tools/ResetIntegrationTest.java | 10 ++--
.../org/apache/kafka/tools/TopicCommandTest.java | 66 +++++++---------------
...OffsetsConsumerGroupCommandIntegrationTest.java | 12 ++--
.../consumer/group/DescribeConsumerGroupTest.java | 62 +++++++++-----------
.../group/ResetConsumerGroupOffsetTest.java | 2 +-
.../reassign/ReassignPartitionsCommandTest.java | 6 +-
37 files changed, 167 insertions(+), 223 deletions(-)
diff --git a/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/CreateTopicsRequestWithPolicyTest.java b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/CreateTopicsRequestWithPolicyTest.java
index da1d7f60535..8d8fe4c8501 100644
--- a/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/CreateTopicsRequestWithPolicyTest.java
+++ b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/CreateTopicsRequestWithPolicyTest.java
@@ -160,7 +160,7 @@ public class CreateTopicsRequestWithPolicyTest {
}
@ClusterTest
- public void testErrorCreateTopicsRequests(ClusterInstance cluster) throws Exception {
+ public void testErrorCreateTopicsRequests(ClusterInstance cluster) {
try (Admin admin = cluster.admin()) {
String existingTopic = "existing-topic";
cluster.createTopic(existingTopic, 5, (short) 1);
diff --git a/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/admin/AddPartitionsTest.java b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/admin/AddPartitionsTest.java
index 97c2b9becea..3ef132579f8 100644
--- a/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/admin/AddPartitionsTest.java
+++ b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/admin/AddPartitionsTest.java
@@ -47,7 +47,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class AddPartitionsTest {
@ClusterTest
- public void testWrongReplicaCount(ClusterInstance cluster) throws Exception {
+ public void testWrongReplicaCount(ClusterInstance cluster) {
try (Admin admin = cluster.admin()) {
cluster.createTopicWithAssignment("topic1", Map.of(0, List.of(0, 1)));
@@ -87,7 +87,7 @@ public class AddPartitionsTest {
}
@ClusterTest
- public void testMissingPartitionsInCreatePartitions(ClusterInstance cluster) throws Exception {
+ public void testMissingPartitionsInCreatePartitions(ClusterInstance cluster) {
try (Admin admin = cluster.admin()) {
cluster.createTopicWithAssignment("topic1", Map.of(0, List.of(0, 1)));
diff --git a/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/admin/AdminMetadataTest.java b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/admin/AdminMetadataTest.java
index df5df5d3da5..c88f67bd9da 100644
--- a/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/admin/AdminMetadataTest.java
+++ b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/admin/AdminMetadataTest.java
@@ -162,7 +162,7 @@ public class AdminMetadataTest {
}
@ClusterTest
- public void testCreateExistingTopicsThrowTopicExistsException() throws Exception {
+ public void testCreateExistingTopicsThrowTopicExistsException() {
String topic = "mytopic";
clusterInstance.createTopic(topic, 1, (short) 1);
try (Admin admin = clusterInstance.admin()) {
diff --git a/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/admin/DescribeProducersWithBrokerIdTest.java b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/admin/DescribeProducersWithBrokerIdTest.java
index 3ac09d4a6ab..9bdf8fb584b 100644
--- a/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/admin/DescribeProducersWithBrokerIdTest.java
+++ b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/admin/DescribeProducersWithBrokerIdTest.java
@@ -57,7 +57,7 @@ public class DescribeProducersWithBrokerIdTest {
}
@BeforeEach
- void setUp() throws InterruptedException {
+ void setUp() {
clusterInstance.createTopic(TOPIC_NAME, NUM_PARTITIONS, REPLICATION_FACTOR);
}
diff --git a/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/admin/ListOffsetsIntegrationTest.java b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/admin/ListOffsetsIntegrationTest.java
index d2f67c76fc7..e6de6cf5eb2 100644
--- a/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/admin/ListOffsetsIntegrationTest.java
+++ b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/admin/ListOffsetsIntegrationTest.java
@@ -130,14 +130,14 @@ public class ListOffsetsIntegrationTest {
@ClusterTest
public void testThreeRecordsInOneBatchHavingDifferentCompressionTypeWithServer() throws InterruptedException, ExecutionException {
- createTopicWithConfig(CUSTOM_CONFIG_TOPIC, Map.of(TopicConfig.COMPRESSION_TYPE_CONFIG, CompressionType.LZ4.name));
+ clusterInstance.createTopic(CUSTOM_CONFIG_TOPIC, PARTITION, REPLICAS, Map.of(TopicConfig.COMPRESSION_TYPE_CONFIG, CompressionType.LZ4.name));
produceMessagesInOneBatch(CompressionType.NONE.name, CUSTOM_CONFIG_TOPIC);
verifyListOffsets(CUSTOM_CONFIG_TOPIC, 1);
}
@ClusterTest
public void testThreeRecordsInSeparateBatchHavingDifferentCompressionTypeWithServer() throws InterruptedException, ExecutionException {
- createTopicWithConfig(CUSTOM_CONFIG_TOPIC, Map.of(TopicConfig.COMPRESSION_TYPE_CONFIG, CompressionType.LZ4.name));
+ clusterInstance.createTopic(CUSTOM_CONFIG_TOPIC, PARTITION, REPLICAS, Map.of(TopicConfig.COMPRESSION_TYPE_CONFIG, CompressionType.LZ4.name));
produceMessagesInOneBatch(CompressionType.NONE.name, CUSTOM_CONFIG_TOPIC);
verifyListOffsets(CUSTOM_CONFIG_TOPIC, 1);
}
@@ -287,11 +287,7 @@ public class ListOffsetsIntegrationTest {
return adminClient.listOffsets(Map.of(tp, offsetSpec), new ListOffsetsOptions()).all().get().get(tp);
}
- private void setUpForLogAppendTimeCase() throws InterruptedException {
- createTopicWithConfig(CUSTOM_CONFIG_TOPIC, Map.of(TopicConfig.MESSAGE_TIMESTAMP_TYPE_CONFIG, "LogAppendTime"));
- }
-
- private void createTopicWithConfig(String topic, Map<String, String> props) throws InterruptedException {
- clusterInstance.createTopic(topic, PARTITION, REPLICAS, props);
+ private void setUpForLogAppendTimeCase() {
+ clusterInstance.createTopic(CUSTOM_CONFIG_TOPIC, PARTITION, REPLICAS, Map.of(TopicConfig.MESSAGE_TIMESTAMP_TYPE_CONFIG, "LogAppendTime"));
}
}
diff --git a/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/ConsumerBounceTest.java b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/ConsumerBounceTest.java
index bd1d01ac8ce..b36d91b7650 100644
--- a/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/ConsumerBounceTest.java
+++ b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/ConsumerBounceTest.java
@@ -127,7 +127,7 @@ public class ConsumerBounceTest {
}
@BeforeEach
- void setUp() throws InterruptedException {
+ void setUp() {
clusterInstance.createTopic(topic, numPartitions, numReplica);
}
@@ -272,7 +272,7 @@ public class ConsumerBounceTest {
consumer.subscribe(List.of(newTopic));
consumer.poll(Duration.ZERO);
// Schedule topic creation after 2 seconds
- executor.schedule(() -> assertDoesNotThrow(() -> clusterInstance.createTopic(newTopic, numPartitions, numReplica)),
+ executor.schedule(() -> clusterInstance.createTopic(newTopic, numPartitions, numReplica),
2, TimeUnit.SECONDS);
// Start first poller
diff --git a/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/ConsumerWithLegacyMessageFormatIntegrationTest.java b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/ConsumerWithLegacyMessageFormatIntegrationTest.java
index 6c413e97883..6c416066c9e 100644
--- a/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/ConsumerWithLegacyMessageFormatIntegrationTest.java
+++ b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/ConsumerWithLegacyMessageFormatIntegrationTest.java
@@ -107,7 +107,7 @@ public class ConsumerWithLegacyMessageFormatIntegrationTest {
}
@BeforeEach
- public void setupTopics() throws InterruptedException {
+ public void setupTopics() {
cluster.createTopic(topic1, 2, (short) 1);
cluster.createTopicWithAssignment(topic2, Map.of(0, List.of(0), 1, List.of(1)));
cluster.createTopicWithAssignment(topic3, Map.of(0, List.of(0), 1, List.of(1)));
diff --git a/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/PlaintextConsumerAssignTest.java b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/PlaintextConsumerAssignTest.java
index b1699851a18..cd7267d028b 100644
--- a/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/PlaintextConsumerAssignTest.java
+++ b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/PlaintextConsumerAssignTest.java
@@ -72,7 +72,7 @@ public class PlaintextConsumerAssignTest {
}
@BeforeEach
- public void setup() throws InterruptedException {
+ public void setup() {
clusterInstance.createTopic(topic, 2, (short) BROKER_COUNT);
}
diff --git a/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/PlaintextConsumerCommitTest.java b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/PlaintextConsumerCommitTest.java
index c770fc2c52c..14a48a5b63a 100644
--- a/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/PlaintextConsumerCommitTest.java
+++ b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/PlaintextConsumerCommitTest.java
@@ -83,7 +83,7 @@ public class PlaintextConsumerCommitTest {
}
@BeforeEach
- public void setup() throws InterruptedException {
+ public void setup() {
cluster.createTopic(topic, 2, (short) BROKER_COUNT);
}
@@ -582,7 +582,7 @@ public class PlaintextConsumerCommitTest {
// TODO: This only works in the new consumer, but should be fixed for the old consumer as well
@ClusterTest
- public void testCommitAsyncCompletedBeforeConsumerCloses() throws InterruptedException {
+ public void testCommitAsyncCompletedBeforeConsumerCloses() {
// This is testing the contract that asynchronous offset commit are completed before the consumer
// is closed, even when no commit sync is performed as part of the close (due to auto-commit
// disabled, or simply because there are no consumed offsets).
diff --git a/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/PlaintextConsumerFetchTest.java b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/PlaintextConsumerFetchTest.java
index 97e5f93d34c..ef71279cf2d 100644
--- a/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/PlaintextConsumerFetchTest.java
+++ b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/PlaintextConsumerFetchTest.java
@@ -79,7 +79,7 @@ public class PlaintextConsumerFetchTest {
}
@BeforeEach
- public void setup() throws InterruptedException {
+ public void setup() {
cluster.createTopic(topic, 2, (short) BROKER_COUNT);
}
diff --git a/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/PlaintextConsumerPollTest.java b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/PlaintextConsumerPollTest.java
index ed900ceec28..1e9f6421a2c 100644
--- a/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/PlaintextConsumerPollTest.java
+++ b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/PlaintextConsumerPollTest.java
@@ -95,7 +95,7 @@ public class PlaintextConsumerPollTest {
}
@BeforeEach
- public void setup() throws InterruptedException {
+ public void setup() {
cluster.createTopic(topic, 2, (short) BROKER_COUNT);
}
diff --git a/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/PlaintextConsumerSubscriptionTest.java b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/PlaintextConsumerSubscriptionTest.java
index 51b68478e4f..dcd0e545c37 100644
--- a/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/PlaintextConsumerSubscriptionTest.java
+++ b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/PlaintextConsumerSubscriptionTest.java
@@ -81,7 +81,7 @@ public class PlaintextConsumerSubscriptionTest {
}
@BeforeEach
- public void setup() throws InterruptedException {
+ public void setup() {
cluster.createTopic(topic, 2, (short) BROKER_COUNT);
}
diff --git a/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/PlaintextConsumerTest.java b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/PlaintextConsumerTest.java
index 33a08b65a93..014a4f0a66c 100644
--- a/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/PlaintextConsumerTest.java
+++ b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/PlaintextConsumerTest.java
@@ -449,20 +449,20 @@ public class PlaintextConsumerTest {
}
@ClusterTest
- public void testClassicConsumerPartitionsFor() throws Exception {
+ public void testClassicConsumerPartitionsFor() {
testPartitionsFor(Map.of(
GROUP_PROTOCOL_CONFIG, GroupProtocol.CLASSIC.name().toLowerCase(Locale.ROOT)
));
}
@ClusterTest
- public void testAsyncConsumerPartitionsFor() throws Exception {
+ public void testAsyncConsumerPartitionsFor() {
testPartitionsFor(Map.of(
GROUP_PROTOCOL_CONFIG, GroupProtocol.CONSUMER.name().toLowerCase(Locale.ROOT)
));
}
- private void testPartitionsFor(Map<String, Object> consumerConfig) throws Exception {
+ private void testPartitionsFor(Map<String, Object> consumerConfig) {
var numParts = 2;
cluster.createTopic(TOPIC, 2, (short) BROKER_COUNT);
cluster.createTopic("part-test", numParts, (short) 1);
@@ -560,7 +560,6 @@ public class PlaintextConsumerTest {
// Test seek compressed message
var tp2 = new TopicPartition(TOPIC, 1);
- cluster.createTopic(TOPIC, 2, (short) BROKER_COUNT);
sendCompressedMessages(totalRecords, tp2);
consumer.assign(List.of(tp2));
@@ -1257,20 +1256,20 @@ public class PlaintextConsumerTest {
}
@ClusterTest
- public void testClassicConsumerSeekThrowsIllegalStateIfPartitionsNotAssigned() throws Exception {
+ public void testClassicConsumerSeekThrowsIllegalStateIfPartitionsNotAssigned() {
testSeekThrowsIllegalStateIfPartitionsNotAssigned(Map.of(
GROUP_PROTOCOL_CONFIG, GroupProtocol.CLASSIC.name().toLowerCase(Locale.ROOT)
));
}
@ClusterTest
- public void testAsyncConsumerSeekThrowsIllegalStateIfPartitionsNotAssigned() throws Exception {
+ public void testAsyncConsumerSeekThrowsIllegalStateIfPartitionsNotAssigned() {
testSeekThrowsIllegalStateIfPartitionsNotAssigned(Map.of(
GROUP_PROTOCOL_CONFIG, GroupProtocol.CONSUMER.name().toLowerCase(Locale.ROOT)
));
}
- private void testSeekThrowsIllegalStateIfPartitionsNotAssigned(Map<String, Object> consumerConfig) throws Exception {
+ private void testSeekThrowsIllegalStateIfPartitionsNotAssigned(Map<String, Object> consumerConfig) {
cluster.createTopic(TOPIC, 2, (short) BROKER_COUNT);
try (var consumer = cluster.consumer(consumerConfig)) {
var e = assertThrows(IllegalStateException.class, () -> consumer.seekToEnd(List.of(TP)));
@@ -1356,7 +1355,7 @@ public class PlaintextConsumerTest {
}
@ClusterTest
- public void testClassicConsumerNullGroupIdNotSupportedIfCommitting() throws Exception {
+ public void testClassicConsumerNullGroupIdNotSupportedIfCommitting() {
testNullGroupIdNotSupportedIfCommitting(Map.of(
GROUP_PROTOCOL_CONFIG, GroupProtocol.CLASSIC.name().toLowerCase(Locale.ROOT),
KEY_DESERIALIZER_CLASS_CONFIG, ByteArrayDeserializer.class.getName(),
@@ -1368,7 +1367,7 @@ public class PlaintextConsumerTest {
}
@ClusterTest
- public void testAsyncConsumerNullGroupIdNotSupportedIfCommitting() throws Exception {
+ public void testAsyncConsumerNullGroupIdNotSupportedIfCommitting() {
testNullGroupIdNotSupportedIfCommitting(Map.of(
GROUP_PROTOCOL_CONFIG, GroupProtocol.CONSUMER.name().toLowerCase(Locale.ROOT),
KEY_DESERIALIZER_CLASS_CONFIG, ByteArrayDeserializer.class.getName(),
@@ -1379,7 +1378,7 @@ public class PlaintextConsumerTest {
));
}
- private void testNullGroupIdNotSupportedIfCommitting(Map<String, Object> consumerConfig) throws Exception {
+ private void testNullGroupIdNotSupportedIfCommitting(Map<String, Object> consumerConfig) {
cluster.createTopic(TOPIC, 2, (short) BROKER_COUNT);
try (var consumer = new KafkaConsumer<>(consumerConfig)) {
consumer.assign(List.of(TP));
@@ -1487,20 +1486,20 @@ public class PlaintextConsumerTest {
}
@ClusterTest
- public void testClassicConsumerFetchOffsetsForTime() throws Exception {
+ public void testClassicConsumerFetchOffsetsForTime() {
testFetchOffsetsForTime(Map.of(
GROUP_PROTOCOL_CONFIG, GroupProtocol.CLASSIC.name().toLowerCase(Locale.ROOT)
));
}
@ClusterTest
- public void testAsyncConsumerFetchOffsetsForTime() throws Exception {
+ public void testAsyncConsumerFetchOffsetsForTime() {
testFetchOffsetsForTime(Map.of(
GROUP_PROTOCOL_CONFIG, GroupProtocol.CONSUMER.name().toLowerCase(Locale.ROOT)
));
}
- private void testFetchOffsetsForTime(Map<String, Object> consumerConfig) throws Exception {
+ private void testFetchOffsetsForTime(Map<String, Object> consumerConfig) {
var numPartitions = 2;
var tp2 = new TopicPartition(TOPIC, 1);
cluster.createTopic(TOPIC, 2, (short) BROKER_COUNT);
@@ -1620,20 +1619,20 @@ public class PlaintextConsumerTest {
}
@ClusterTest
- public void testClassicConsumerOffsetRelatedWhenTimeoutZero() throws Exception {
+ public void testClassicConsumerOffsetRelatedWhenTimeoutZero() {
testOffsetRelatedWhenTimeoutZero(Map.of(
GROUP_PROTOCOL_CONFIG, GroupProtocol.CLASSIC.name().toLowerCase(Locale.ROOT)
));
}
@ClusterTest
- public void testAsyncConsumerOffsetRelatedWhenTimeoutZero() throws Exception {
+ public void testAsyncConsumerOffsetRelatedWhenTimeoutZero() {
testOffsetRelatedWhenTimeoutZero(Map.of(
GROUP_PROTOCOL_CONFIG, GroupProtocol.CONSUMER.name().toLowerCase(Locale.ROOT)
));
}
- private void testOffsetRelatedWhenTimeoutZero(Map<String, Object> consumerConfig) throws Exception {
+ private void testOffsetRelatedWhenTimeoutZero(Map<String, Object> consumerConfig) {
cluster.createTopic(TOPIC, 2, (short) BROKER_COUNT);
try (var consumer = cluster.consumer(consumerConfig)) {
var result1 = consumer.beginningOffsets(List.of(TP), Duration.ZERO);
diff --git a/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/SaslPlainPlaintextConsumerTest.java b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/SaslPlainPlaintextConsumerTest.java
index dcd9d3a27b8..739ed2e28a8 100644
--- a/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/SaslPlainPlaintextConsumerTest.java
+++ b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/SaslPlainPlaintextConsumerTest.java
@@ -70,7 +70,7 @@ public class SaslPlainPlaintextConsumerTest {
}
@BeforeEach
- public void setUp() throws InterruptedException {
+ public void setUp() {
cluster.createTopic(ClientsTestUtils.BaseConsumerTestcase.TOPIC, 2, (short) ClientsTestUtils.BaseConsumerTestcase.BROKER_COUNT);
}
diff --git a/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/SaslPlaintextConsumerTest.java b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/SaslPlaintextConsumerTest.java
index a0747ec0a1e..c8c30319c58 100644
--- a/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/SaslPlaintextConsumerTest.java
+++ b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/SaslPlaintextConsumerTest.java
@@ -115,7 +115,7 @@ public class SaslPlaintextConsumerTest {
}
@BeforeEach
- public void beforeEach() throws InterruptedException {
+ public void beforeEach() {
cluster.createTopic(ClientsTestUtils.BaseConsumerTestcase.TOPIC, 2, (short) ClientsTestUtils.BaseConsumerTestcase.BROKER_COUNT);
}
diff --git a/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/ShareConsumerDLQTest.java b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/ShareConsumerDLQTest.java
index 1ab4cc350de..e36ffcc5dbf 100644
--- a/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/ShareConsumerDLQTest.java
+++ b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/ShareConsumerDLQTest.java
@@ -53,7 +53,6 @@ import java.util.Set;
import static org.apache.kafka.test.TestUtils.DEFAULT_MAX_WAIT_MS;
import static org.apache.kafka.test.TestUtils.waitForCondition;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
-import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
@@ -1045,8 +1044,8 @@ public class ShareConsumerDLQTest extends ShareConsumerTestBase {
}
private void createDlqTopic(String topicName, int numPartitions) {
- assertDoesNotThrow(() -> cluster.createTopic(topicName, numPartitions, (short) 1,
- Map.of(TopicConfig.ERRORS_DEADLETTERQUEUE_GROUP_ENABLE_CONFIG, "true")), "Failed to create DLQ topic");
+ cluster.createTopic(topicName, numPartitions, (short) 1,
+ Map.of(TopicConfig.ERRORS_DEADLETTERQUEUE_GROUP_ENABLE_CONFIG, "true"));
}
// Creates a single-partition source topic with tiered storage enabled and one log segment per record (via
@@ -1062,8 +1061,7 @@ public class ShareConsumerDLQTest extends ShareConsumerTestBase {
// Roll a segment for every record so each inactive segment can be offloaded then deleted locally.
TopicConfig.INDEX_INTERVAL_BYTES_CONFIG, "1",
TopicConfig.SEGMENT_INDEX_BYTES_CONFIG, "12");
- assertDoesNotThrow(() -> cluster.createTopic(topic, 1, (short) 1, configs),
- "Failed to create remote-storage source topic");
+ cluster.createTopic(topic, 1, (short) 1, configs);
}
// The earliest offset still held in local storage. Offsets below this have been removed locally (e.g. after
diff --git a/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/producer/ProducerFailureHandlingTest.java b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/producer/ProducerFailureHandlingTest.java
index 33034e50e88..45542566aaa 100644
--- a/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/producer/ProducerFailureHandlingTest.java
+++ b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/producer/ProducerFailureHandlingTest.java
@@ -107,7 +107,7 @@ public class ProducerFailureHandlingTest {
* With ack == 1 the future metadata will throw ExecutionException caused by RecordTooLargeException
*/
@ClusterTest
- public void testTooLargeRecordWithAckOne(ClusterInstance clusterInstance) throws InterruptedException {
+ public void testTooLargeRecordWithAckOne(ClusterInstance clusterInstance) {
clusterInstance.createTopic(topic1, 1, (short) clusterInstance.brokers().size());
try (Producer<byte[], byte[]> producer = clusterInstance.producer(producerConfig(1))) {
@@ -156,7 +156,7 @@ public class ProducerFailureHandlingTest {
* With incorrect broker-list the future metadata should return ExecutionException caused by TimeoutException
*/
@ClusterTest
- public void testWrongBrokerList(ClusterInstance clusterInstance) throws InterruptedException {
+ public void testWrongBrokerList(ClusterInstance clusterInstance) {
clusterInstance.createTopic(topic1, 1, (short) 1);
// producer with incorrect broker list
Map<String, Object> producerConfig = new HashMap<>(producerConfig(1));
@@ -174,7 +174,7 @@ public class ProducerFailureHandlingTest {
* when partition is higher than the upper bound of partitions.
*/
@ClusterTest
- public void testInvalidPartition(ClusterInstance clusterInstance) throws InterruptedException {
+ public void testInvalidPartition(ClusterInstance clusterInstance) {
// create topic with a single partition
clusterInstance.createTopic(topic1, 1, (short) clusterInstance.brokers().size());
@@ -222,7 +222,7 @@ public class ProducerFailureHandlingTest {
@ClusterTest(serverProperties = {
@ClusterConfigProperty(key = AUTO_CREATE_TOPICS_ENABLE_CONFIG, value = "true")
})
- public void testCannotSendToInternalTopicWhenAutoCreateTrueAndTopicExists(ClusterInstance clusterInstance) throws Exception {
+ public void testCannotSendToInternalTopicWhenAutoCreateTrueAndTopicExists(ClusterInstance clusterInstance) {
createInternalTopic(clusterInstance);
assertSendToInternalTopicFails(clusterInstance, InvalidTopicException.class);
}
@@ -232,7 +232,7 @@ public class ProducerFailureHandlingTest {
* when auto.create.topics.enable=false and the internal topic already exists.
*/
@ClusterTest
- public void testCannotSendToInternalTopicWhenAutoCreateFalseAndTopicExists(ClusterInstance clusterInstance) throws Exception {
+ public void testCannotSendToInternalTopicWhenAutoCreateFalseAndTopicExists(ClusterInstance clusterInstance) {
createInternalTopic(clusterInstance);
assertSendToInternalTopicFails(clusterInstance, InvalidTopicException.class);
}
@@ -329,7 +329,7 @@ public class ProducerFailureHandlingTest {
BUFFER_MEMORY_CONFIG, producerBufferSize);
}
- private void createInternalTopic(ClusterInstance clusterInstance) throws Exception {
+ private void createInternalTopic(ClusterInstance clusterInstance) {
clusterInstance.createTopic(Topic.GROUP_METADATA_TOPIC_NAME, 1, (short) 1, clusterInstance.brokers().get(0)
.groupCoordinator()
.groupMetadataTopicConfigs());
diff --git a/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/producer/ProducerIntegrationTest.java b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/producer/ProducerIntegrationTest.java
index 273169dd04c..1df44ad5a09 100644
--- a/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/producer/ProducerIntegrationTest.java
+++ b/clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/producer/ProducerIntegrationTest.java
@@ -120,7 +120,7 @@ public class ProducerIntegrationTest {
@ClusterTest(features = {
@ClusterFeature(feature = Feature.TRANSACTION_VERSION, version = 2)}),
})
- public void testTransactionWithInvalidSendAndEndTxnRequestSent(ClusterInstance cluster) throws InterruptedException {
+ public void testTransactionWithInvalidSendAndEndTxnRequestSent(ClusterInstance cluster) {
var topic = "foobar";
cluster.createTopic(topic, 1, (short) 1, Map.of(TopicConfig.MAX_MESSAGE_BYTES_CONFIG, "100"));
String txnId = "test-txn";
diff --git a/server/src/test/java/org/apache/kafka/api/EndToEndClusterIdTest.java b/server/src/test/java/org/apache/kafka/api/EndToEndClusterIdTest.java
index beb2bca8205..3ceee5afd91 100644
--- a/server/src/test/java/org/apache/kafka/api/EndToEndClusterIdTest.java
+++ b/server/src/test/java/org/apache/kafka/api/EndToEndClusterIdTest.java
@@ -83,7 +83,7 @@ public class EndToEndClusterIdTest {
}
@BeforeEach
- public void setup() throws InterruptedException {
+ public void setup() {
this.clusterInstance.createTopic(TOPIC, 2, (short) 1);
clusterBrokerId = String.valueOf(clusterInstance.brokerIds().iterator().next());
controllerId = String.valueOf(clusterInstance.controllerIds().iterator().next());
diff --git a/server/src/test/java/org/apache/kafka/server/CordonedLogDirsIntegrationTest.java b/server/src/test/java/org/apache/kafka/server/CordonedLogDirsIntegrationTest.java
index c4b7e5931df..3a3384ed231 100644
--- a/server/src/test/java/org/apache/kafka/server/CordonedLogDirsIntegrationTest.java
+++ b/server/src/test/java/org/apache/kafka/server/CordonedLogDirsIntegrationTest.java
@@ -348,7 +348,7 @@ public class CordonedLogDirsIntegrationTest {
try (Admin admin = clusterInstance.admin()) {
// Create 10 topics
for (int i = 0; i < 10; i++) {
- createTopic("topic" + i, (short) 1);
+ clusterInstance.createTopic("topic" + i, 1, (short) 1);
}
// Check the 10 topics have been created and find the partitions on brokerId
@@ -377,7 +377,7 @@ public class CordonedLogDirsIntegrationTest {
// Create another 10 topics
for (int i = 10; i < 20; i++) {
- createTopic("topic" + i, (short) 1);
+ clusterInstance.createTopic("topic" + i, 1, (short) 1);
}
// Check only the other broker has replicas
@@ -494,12 +494,8 @@ public class CordonedLogDirsIntegrationTest {
}, 10_000, "Unable to set the " + CORDONED_LOG_DIRS_CONFIG + " configuration on " + cr + ".");
}
- private void createTopic(String name) throws InterruptedException {
- createTopic(name, (short) clusterInstance.brokers().size());
- }
-
- private void createTopic(String name, short replicationFactor) throws InterruptedException {
- clusterInstance.createTopic(name, 1, replicationFactor);
+ private void createTopic(String name) {
+ clusterInstance.createTopic(name, 1, (short) clusterInstance.brokers().size());
}
private Set<NewTopic> newTopic(String name) {
diff --git a/server/src/test/java/org/apache/kafka/server/MetadataRequestTest.java b/server/src/test/java/org/apache/kafka/server/MetadataRequestTest.java
index d14a6560322..853cd3eb1e7 100644
--- a/server/src/test/java/org/apache/kafka/server/MetadataRequestTest.java
+++ b/server/src/test/java/org/apache/kafka/server/MetadataRequestTest.java
@@ -48,7 +48,6 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
-import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -156,7 +155,7 @@ public class MetadataRequestTest {
}
@ClusterTest
- public void testIsInternal() throws InterruptedException, IOException {
+ public void testIsInternal() throws IOException {
String internalTopic = Topic.GROUP_METADATA_TOPIC_NAME;
String notInternalTopic = "notInternal";
// create the topics
@@ -177,7 +176,7 @@ public class MetadataRequestTest {
}
@ClusterTest
- public void testNoTopicsRequest() throws InterruptedException, IOException {
+ public void testNoTopicsRequest() throws IOException {
// create some topics
clusterInstance.createTopic("t1", 3, (short) 2);
clusterInstance.createTopic("t2", 3, (short) 2);
@@ -233,7 +232,7 @@ public class MetadataRequestTest {
}
@ClusterTest
- public void testAllTopicsRequest() throws InterruptedException, IOException {
+ public void testAllTopicsRequest() throws IOException {
// create some topics
clusterInstance.createTopic("t1", 3, (short) 2);
clusterInstance.createTopic("t2", 3, (short) 2);
@@ -250,7 +249,7 @@ public class MetadataRequestTest {
}
@ClusterTest
- public void testTopicIdsInResponse() throws ExecutionException, InterruptedException, IOException {
+ public void testTopicIdsInResponse() throws IOException {
Map<Integer, List<Integer>> replicaAssignment = Map.of(0, List.of(1, 2, 0), 1, List.of(2, 0, 1));
String topic1 = "topic1";
String topic2 = "topic2";
@@ -279,7 +278,7 @@ public class MetadataRequestTest {
* Preferred replica should be the first item in the replicas list
*/
@ClusterTest
- public void testPreferredReplica() throws ExecutionException, InterruptedException, IOException {
+ public void testPreferredReplica() throws IOException {
Map<Integer, List<Integer>> replicaAssignment = Map.of(0, List.of(1, 2, 0), 1, List.of(2, 0, 1));
clusterInstance.createTopicWithAssignment("t1", replicaAssignment);
// Test metadata on two different brokers to ensure that metadata propagation works correctly
@@ -303,7 +302,7 @@ public class MetadataRequestTest {
}
@ClusterTest
- public void testPartitionInfoPreferredReplica() throws ExecutionException, InterruptedException, IOException {
+ public void testPartitionInfoPreferredReplica() throws IOException {
Map<Integer, List<Integer>> replicaAssignment = Map.of(0, List.of(1, 2, 0));
String topic = "testPartitionInfoPreferredReplicaTopic";
clusterInstance.createTopicWithAssignment(topic, replicaAssignment);
@@ -384,7 +383,7 @@ public class MetadataRequestTest {
}
@ClusterTest
- public void testIsrAfterBrokerShutDownAndJoinsBack() throws InterruptedException {
+ public void testIsrAfterBrokerShutDownAndJoinsBack() {
String topic = "isr-after-broker-shutdown";
short replicaCount = 3;
clusterInstance.createTopic(topic, 1, replicaCount);
diff --git a/storage/src/test/java/org/apache/kafka/admin/RemoteTopicCrudTest.java b/storage/src/test/java/org/apache/kafka/admin/RemoteTopicCrudTest.java
index 0dc2e6e0ebe..aca8a04f4a0 100644
--- a/storage/src/test/java/org/apache/kafka/admin/RemoteTopicCrudTest.java
+++ b/storage/src/test/java/org/apache/kafka/admin/RemoteTopicCrudTest.java
@@ -55,7 +55,6 @@ import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
-import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicInteger;
import static org.apache.kafka.test.TestUtils.assertFutureThrows;
@@ -95,7 +94,7 @@ class RemoteTopicCrudTest {
}
@ClusterTest
- void testCreateRemoteTopicWithValidRetentionTime() throws InterruptedException {
+ void testCreateRemoteTopicWithValidRetentionTime() {
var topicConfig = Map.of(
TopicConfig.REMOTE_LOG_STORAGE_ENABLE_CONFIG, "true",
TopicConfig.RETENTION_MS_CONFIG, "60000",
@@ -329,7 +328,7 @@ class RemoteTopicCrudTest {
@ClusterTest
void testEnableRemoteLogOnExistingTopic() throws Exception {
try (var admin = cluster.admin()) {
- cluster.createTopic(testTopicName, numPartitions, numReplicationFactor, Map.of());
+ cluster.createTopic(testTopicName, numPartitions, numReplicationFactor);
var configs = new HashMap<ConfigResource, Collection<AlterConfigOp>>();
configs.put(new ConfigResource(ConfigResource.Type.TOPIC, testTopicName),
@@ -343,7 +342,7 @@ class RemoteTopicCrudTest {
@ClusterTest(serverProperties = {
@ClusterConfigProperty(key = RemoteLogManagerConfig.REMOTE_LOG_STORAGE_SYSTEM_ENABLE_PROP, value = "false")
})
- void testEnableRemoteLogWhenSystemRemoteStorageIsDisabled() throws ExecutionException, InterruptedException {
+ void testEnableRemoteLogWhenSystemRemoteStorageIsDisabled() {
try (var admin = cluster.admin()) {
var topicConfig = Map.of(
TopicConfig.REMOTE_LOG_STORAGE_ENABLE_CONFIG, "true"
@@ -408,7 +407,7 @@ class RemoteTopicCrudTest {
}
@ClusterTest
- void testUpdateTopicConfigWithInheritedLocalRetentionTime() throws Exception {
+ void testUpdateTopicConfigWithInheritedLocalRetentionTime() {
try (var admin = cluster.admin()) {
var topicConfig = Map.of(
TopicConfig.REMOTE_LOG_STORAGE_ENABLE_CONFIG, "true"
@@ -429,7 +428,7 @@ class RemoteTopicCrudTest {
}
@ClusterTest
- void testUpdateTopicConfigWithInheritedLocalRetentionSize() throws Exception {
+ void testUpdateTopicConfigWithInheritedLocalRetentionSize() {
try (var admin = cluster.admin()) {
var topicConfig = Map.of(
TopicConfig.REMOTE_LOG_STORAGE_ENABLE_CONFIG, "true"
@@ -450,7 +449,7 @@ class RemoteTopicCrudTest {
}
@ClusterTest
- void testUpdateTopicConfigWithDisablingRemoteStorage() throws Exception {
+ void testUpdateTopicConfigWithDisablingRemoteStorage() {
try (var admin = cluster.admin()) {
var topicConfig = Map.of(
TopicConfig.REMOTE_LOG_STORAGE_ENABLE_CONFIG, "true"
diff --git a/storage/src/test/java/org/apache/kafka/server/log/remote/metadata/storage/TopicBasedRemoteLogMetadataManagerMultipleSubscriptionsTest.java b/storage/src/test/java/org/apache/kafka/server/log/remote/metadata/storage/TopicBasedRemoteLogMetadataManagerMultipleSubscriptionsTest.java
index c4288bdfa70..1f97ed233cb 100644
--- a/storage/src/test/java/org/apache/kafka/server/log/remote/metadata/storage/TopicBasedRemoteLogMetadataManagerMultipleSubscriptionsTest.java
+++ b/storage/src/test/java/org/apache/kafka/server/log/remote/metadata/storage/TopicBasedRemoteLogMetadataManagerMultipleSubscriptionsTest.java
@@ -35,7 +35,6 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.Phaser;
import java.util.concurrent.TimeUnit;
-import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -59,15 +58,15 @@ public class TopicBasedRemoteLogMetadataManagerMultipleSubscriptionsTest {
// Create topics.
String leaderTopic = "leader";
// Set broker id 0 as the first entry which is taken as the leader.
- createTopic(leaderTopic, Map.of(0, List.of(0, 1, 2)));
+ clusterInstance.createTopicWithAssignment(leaderTopic, Map.of(0, List.of(0, 1, 2)));
String followerTopic = "follower";
// Set broker id 1 as the first entry which is taken as the leader.
- createTopic(followerTopic, Map.of(0, List.of(1, 2, 0)));
+ clusterInstance.createTopicWithAssignment(followerTopic, Map.of(0, List.of(1, 2, 0)));
String topicWithNoMessages = "no-messages-topic";
// Set broker id 1 as the first entry which is taken as the leader.
- createTopic(topicWithNoMessages, Map.of(0, List.of(1, 2, 0)));
+ clusterInstance.createTopicWithAssignment(topicWithNoMessages, Map.of(0, List.of(1, 2, 0)));
final TopicIdPartition leaderTopicIdPartition = new TopicIdPartition(Uuid.randomUuid(), new TopicPartition(leaderTopic, 0));
final TopicIdPartition followerTopicIdPartition = new TopicIdPartition(Uuid.randomUuid(), new TopicPartition(followerTopic, 0));
@@ -166,8 +165,4 @@ public class TopicBasedRemoteLogMetadataManagerMultipleSubscriptionsTest {
assertTrue(remoteLogMetadataManager.listRemoteLogSegments(followerTopicIdPartition).hasNext(), "No segments found");
}
}
-
- private void createTopic(String topic, Map<Integer, List<Integer>> replicasAssignments) {
- assertDoesNotThrow(() -> clusterInstance.createTopicWithAssignment(topic, replicasAssignments));
- }
}
diff --git a/storage/src/test/java/org/apache/kafka/tiered/storage/TieredStorageTestContext.java b/storage/src/test/java/org/apache/kafka/tiered/storage/TieredStorageTestContext.java
index d80309c7f7f..d10d5804483 100644
--- a/storage/src/test/java/org/apache/kafka/tiered/storage/TieredStorageTestContext.java
+++ b/storage/src/test/java/org/apache/kafka/tiered/storage/TieredStorageTestContext.java
@@ -142,7 +142,7 @@ public final class TieredStorageTestContext implements AutoCloseable {
.toList();
}
- public void createTopic(TopicSpec spec) throws InterruptedException {
+ public void createTopic(TopicSpec spec) {
if (spec.assignment() == null || spec.assignment().isEmpty()) {
cluster.createTopic(spec.topicName(), spec.partitionCount(), (short) spec.replicationFactor(), spec.properties());
} else {
diff --git a/storage/src/test/java/org/apache/kafka/tiered/storage/actions/CreateTopicAction.java b/storage/src/test/java/org/apache/kafka/tiered/storage/actions/CreateTopicAction.java
index e523d094b6f..0c7b0ff0f73 100644
--- a/storage/src/test/java/org/apache/kafka/tiered/storage/actions/CreateTopicAction.java
+++ b/storage/src/test/java/org/apache/kafka/tiered/storage/actions/CreateTopicAction.java
@@ -22,7 +22,6 @@ import org.apache.kafka.tiered.storage.specs.TopicSpec;
import java.io.PrintStream;
import java.util.Map;
-import java.util.concurrent.ExecutionException;
import static org.apache.kafka.tiered.storage.utils.TieredStorageTestUtils.createTopicConfigForRemoteStorage;
@@ -35,7 +34,7 @@ public final class CreateTopicAction implements TieredStorageTestAction {
}
@Override
- public void doExecute(TieredStorageTestContext context) throws ExecutionException, InterruptedException {
+ public void doExecute(TieredStorageTestContext context) {
boolean enableRemoteStorage = true;
Map<String, String> topicConfigs = createTopicConfigForRemoteStorage(
enableRemoteStorage, spec.maxBatchCountPerSegment());
diff --git a/storage/src/test/java/org/apache/kafka/tiered/storage/integration/TransactionsTest.java b/storage/src/test/java/org/apache/kafka/tiered/storage/integration/TransactionsTest.java
index d0c285caecd..ce6fd5bdb45 100644
--- a/storage/src/test/java/org/apache/kafka/tiered/storage/integration/TransactionsTest.java
+++ b/storage/src/test/java/org/apache/kafka/tiered/storage/integration/TransactionsTest.java
@@ -113,22 +113,22 @@ public class TransactionsTest {
}
@ClusterTest
- public void testInitTransactionsTimeout() throws Exception {
+ public void testInitTransactionsTimeout() {
TransactionsTestHelper.testInitTransactionsTimeout(clusterInstance, TOPIC_CONFIG);
}
@ClusterTest
- public void testSendOffsetsToTransactionTimeout() throws Exception {
+ public void testSendOffsetsToTransactionTimeout() {
TransactionsTestHelper.testSendOffsetsToTransactionTimeout(clusterInstance, TOPIC_CONFIG);
}
@ClusterTest
- public void testCommitTransactionTimeout() throws Exception {
+ public void testCommitTransactionTimeout() {
TransactionsTestHelper.testCommitTransactionTimeout(clusterInstance, TOPIC_CONFIG);
}
@ClusterTest
- public void testAbortTransactionTimeout() throws Exception {
+ public void testAbortTransactionTimeout() {
TransactionsTestHelper.testAbortTransactionTimeout(clusterInstance, TOPIC_CONFIG);
}
@@ -185,7 +185,7 @@ public class TransactionsTest {
}
@ClusterTest(features = {@ClusterFeature(feature = Feature.TRANSACTION_VERSION, version = 2)})
- public void testEmptyAbortAfterCommit() throws Exception {
+ public void testEmptyAbortAfterCommit() {
TransactionsTestHelper.testEmptyAbortAfterCommit(clusterInstance, TOPIC_CONFIG);
}
}
diff --git a/storage/src/test/java/org/apache/kafka/tiered/storage/integration/TransactionsTestHelper.java b/storage/src/test/java/org/apache/kafka/tiered/storage/integration/TransactionsTestHelper.java
index 985a115f4a8..9f12ad8adde 100644
--- a/storage/src/test/java/org/apache/kafka/tiered/storage/integration/TransactionsTestHelper.java
+++ b/storage/src/test/java/org/apache/kafka/tiered/storage/integration/TransactionsTestHelper.java
@@ -462,7 +462,7 @@ public class TransactionsTestHelper {
public static void testInitTransactionsTimeout(
ClusterInstance clusterInstance,
Map<String, String> topicConfig
- ) throws Exception {
+ ) {
createTopicsWithConfig(clusterInstance, topicConfig);
testTimeout(clusterInstance, false, Producer::initTransactions);
}
@@ -471,7 +471,7 @@ public class TransactionsTestHelper {
public static void testSendOffsetsToTransactionTimeout(
ClusterInstance clusterInstance,
Map<String, String> topicConfig
- ) throws Exception {
+ ) {
createTopicsWithConfig(clusterInstance, topicConfig);
testTimeout(clusterInstance, true, producer ->
producer.sendOffsetsToTransaction(
@@ -482,7 +482,7 @@ public class TransactionsTestHelper {
public static void testCommitTransactionTimeout(
ClusterInstance clusterInstance,
Map<String, String> topicConfig
- ) throws Exception {
+ ) {
createTopicsWithConfig(clusterInstance, topicConfig);
testTimeout(clusterInstance, true, Producer::commitTransaction);
}
@@ -490,7 +490,7 @@ public class TransactionsTestHelper {
public static void testAbortTransactionTimeout(
ClusterInstance clusterInstance,
Map<String, String> topicConfig
- ) throws Exception {
+ ) {
createTopicsWithConfig(clusterInstance, topicConfig);
testTimeout(clusterInstance, true, Producer::abortTransaction);
}
@@ -981,7 +981,7 @@ public class TransactionsTestHelper {
public static void testEmptyAbortAfterCommit(
ClusterInstance clusterInstance,
Map<String, String> topicConfig
- ) throws Exception {
+ ) {
createTopicsWithConfig(clusterInstance, topicConfig);
try (var producer = createTransactionalProducer(clusterInstance, "transactional-producer")) {
@@ -1184,7 +1184,7 @@ public class TransactionsTestHelper {
public static void createTopicsWithConfig(
ClusterInstance clusterInstance,
Map<String, String> topicConfig
- ) throws InterruptedException {
+ ) {
clusterInstance.createTopic(TOPIC1, NUM_PARTITIONS, BROKER_COUNT, topicConfig);
clusterInstance.createTopic(TOPIC2, NUM_PARTITIONS, BROKER_COUNT, topicConfig);
}
diff --git a/storage/src/test/java/org/apache/kafka/tiered/storage/integration/TransactionsWithTieredStoreTest.java b/storage/src/test/java/org/apache/kafka/tiered/storage/integration/TransactionsWithTieredStoreTest.java
index dff3347248a..d8c6a960e94 100644
--- a/storage/src/test/java/org/apache/kafka/tiered/storage/integration/TransactionsWithTieredStoreTest.java
+++ b/storage/src/test/java/org/apache/kafka/tiered/storage/integration/TransactionsWithTieredStoreTest.java
@@ -181,22 +181,22 @@ public class TransactionsWithTieredStoreTest {
}
@ClusterTemplate("tieredStorageClusterConfig")
- public void testInitTransactionsTimeout(ClusterInstance clusterInstance) throws Exception {
+ public void testInitTransactionsTimeout(ClusterInstance clusterInstance) {
TransactionsTestHelper.testInitTransactionsTimeout(clusterInstance, topicConfig());
}
@ClusterTemplate("tieredStorageClusterConfig")
- public void testSendOffsetsToTransactionTimeout(ClusterInstance clusterInstance) throws Exception {
+ public void testSendOffsetsToTransactionTimeout(ClusterInstance clusterInstance) {
TransactionsTestHelper.testSendOffsetsToTransactionTimeout(clusterInstance, topicConfig());
}
@ClusterTemplate("tieredStorageClusterConfig")
- public void testCommitTransactionTimeout(ClusterInstance clusterInstance) throws Exception {
+ public void testCommitTransactionTimeout(ClusterInstance clusterInstance) {
TransactionsTestHelper.testCommitTransactionTimeout(clusterInstance, topicConfig());
}
@ClusterTemplate("tieredStorageClusterConfig")
- public void testAbortTransactionTimeout(ClusterInstance clusterInstance) throws Exception {
+ public void testAbortTransactionTimeout(ClusterInstance clusterInstance) {
TransactionsTestHelper.testAbortTransactionTimeout(clusterInstance, topicConfig());
}
@@ -285,12 +285,12 @@ public class TransactionsWithTieredStoreTest {
}
@ClusterTemplate("tieredStorageClusterConfigTV1")
- public void testEmptyAbortAfterCommitWithTV1(ClusterInstance clusterInstance) throws Exception {
+ public void testEmptyAbortAfterCommitWithTV1(ClusterInstance clusterInstance) {
TransactionsTestHelper.testEmptyAbortAfterCommit(clusterInstance, topicConfig());
}
@ClusterTemplate("tieredStorageClusterConfigTV2")
- public void testEmptyAbortAfterCommitWithTV2(ClusterInstance clusterInstance) throws Exception {
+ public void testEmptyAbortAfterCommitWithTV2(ClusterInstance clusterInstance) {
TransactionsTestHelper.testEmptyAbortAfterCommit(clusterInstance, topicConfig());
}
diff --git a/test-common/test-common-runtime/src/main/java/org/apache/kafka/common/test/ClusterInstance.java b/test-common/test-common-runtime/src/main/java/org/apache/kafka/common/test/ClusterInstance.java
index 296de2af121..44af589dc13 100644
--- a/test-common/test-common-runtime/src/main/java/org/apache/kafka/common/test/ClusterInstance.java
+++ b/test-common/test-common-runtime/src/main/java/org/apache/kafka/common/test/ClusterInstance.java
@@ -40,6 +40,7 @@ import org.apache.kafka.common.acl.AccessControlEntry;
import org.apache.kafka.common.acl.AclBindingFilter;
import org.apache.kafka.common.config.SaslConfigs;
import org.apache.kafka.common.config.internals.BrokerSecurityConfigs;
+import org.apache.kafka.common.errors.InterruptException;
import org.apache.kafka.common.network.ListenerName;
import org.apache.kafka.common.security.auth.SecurityProtocol;
import org.apache.kafka.common.serialization.ByteArrayDeserializer;
@@ -329,26 +330,30 @@ public interface ClusterInstance {
), "Failed to soft-delete the data to a delete directory");
}
- default void createTopic(String topicName, int partitions, short replicas) throws InterruptedException {
+ default void createTopic(String topicName, int partitions, short replicas) {
createTopic(topicName, partitions, replicas, Map.of());
}
- default void createTopic(String topicName, int partitions, short replicas, Map<String, String> props) throws InterruptedException {
- try (Admin admin = admin()) {
- admin.createTopics(List.of(new NewTopic(topicName, partitions, replicas).configs(props)));
- waitTopicCreation(topicName, partitions);
- }
+ default void createTopic(String topicName, int partitions, short replicas, Map<String, String> props) {
+ createTopicAndWait(new NewTopic(topicName, partitions, replicas).configs(props), partitions);
}
- default void createTopicWithAssignment(String topicName, Map<Integer, List<Integer>> replicaAssignment) throws InterruptedException {
+ default void createTopicWithAssignment(String topicName, Map<Integer, List<Integer>> replicaAssignment) {
createTopicWithAssignment(topicName, replicaAssignment, Map.of());
}
- default void createTopicWithAssignment(String topicName, Map<Integer, List<Integer>> replicaAssignment, Map<String, String> props) throws InterruptedException {
+ default void createTopicWithAssignment(String topicName, Map<Integer, List<Integer>> replicaAssignment, Map<String, String> props) {
+ createTopicAndWait(new NewTopic(topicName, replicaAssignment).configs(props), replicaAssignment.size());
+ }
+
+ private void createTopicAndWait(NewTopic newTopic, int partitions) {
try (Admin admin = admin()) {
- admin.createTopics(List.of(new NewTopic(topicName, replicaAssignment).configs(props)));
- int partitions = replicaAssignment.size();
- waitTopicCreation(topicName, partitions);
+ admin.createTopics(List.of(newTopic)).all().get();
+ waitTopicCreation(newTopic.name(), partitions);
+ } catch (InterruptedException e) {
+ throw new InterruptException(e);
+ } catch (ExecutionException e) {
+ throw new RuntimeException("Failed to create topic " + newTopic.name(), e.getCause());
}
}
diff --git a/tools/src/test/java/org/apache/kafka/tools/ConfigCommandIntegrationTest.java b/tools/src/test/java/org/apache/kafka/tools/ConfigCommandIntegrationTest.java
index 9cb11db0687..97e52fd1632 100644
--- a/tools/src/test/java/org/apache/kafka/tools/ConfigCommandIntegrationTest.java
+++ b/tools/src/test/java/org/apache/kafka/tools/ConfigCommandIntegrationTest.java
@@ -215,7 +215,7 @@ public class ConfigCommandIntegrationTest {
}
@ClusterTest
- public void testAddConfigKeyValuesUsingCommand() throws Exception {
+ public void testAddConfigKeyValuesUsingCommand() {
cluster.createTopic("topic", 1, (short) 1);
Stream<String> command = Stream.concat(quorumArgs(), Stream.of(
"--entity-type", "topics",
@@ -637,7 +637,7 @@ public class ConfigCommandIntegrationTest {
}
@ClusterTest
- public void testUpdateInvalidTopicConfigs() throws ExecutionException, InterruptedException {
+ public void testUpdateInvalidTopicConfigs() {
List<String> alterOpts = List.of("--bootstrap-server", cluster.bootstrapServers(), "--entity-type", "topics", "--alter");
try (Admin client = cluster.admin()) {
cluster.createTopic("test-config-topic", 1, (short) 1);
diff --git a/tools/src/test/java/org/apache/kafka/tools/LogDirsCommandTest.java b/tools/src/test/java/org/apache/kafka/tools/LogDirsCommandTest.java
index 37b8ca83554..68fede18661 100644
--- a/tools/src/test/java/org/apache/kafka/tools/LogDirsCommandTest.java
+++ b/tools/src/test/java/org/apache/kafka/tools/LogDirsCommandTest.java
@@ -49,7 +49,7 @@ public class LogDirsCommandTest {
@ClusterTest(brokers = 3)
public void testLogDirsWithoutBrokers(ClusterInstance clusterInstance) {
- createTopic(clusterInstance, TOPIC);
+ clusterInstance.createTopicWithAssignment(TOPIC, Map.of(0, List.of(0)));
try (Admin admin = Admin.create(Map.of(CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG, clusterInstance.bootstrapServers()))) {
String output = assertDoesNotThrow(() -> execute(fromArgsToOptions("--bootstrap-server", clusterInstance.bootstrapServers(), "--describe"), admin));
@@ -69,7 +69,7 @@ public class LogDirsCommandTest {
@ClusterTest(brokers = 3)
public void testLogDirsWithBrokers(ClusterInstance clusterInstance) {
- createTopic(clusterInstance, TOPIC);
+ clusterInstance.createTopicWithAssignment(TOPIC, Map.of(0, List.of(0)));
try (Admin admin = Admin.create(Map.of(CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG, clusterInstance.bootstrapServers()))) {
int brokerId = 0;
String output = assertDoesNotThrow(() -> execute(fromArgsToOptions("--bootstrap-server", clusterInstance.bootstrapServers(), "--broker-list", String.valueOf(brokerId), "--describe"), admin));
@@ -115,8 +115,8 @@ public class LogDirsCommandTest {
@ClusterTest
public void testLogDirsWithSpecificTopic(ClusterInstance clusterInstance) {
- createTopic(clusterInstance, TOPIC);
- createTopic(clusterInstance, "other-topic");
+ clusterInstance.createTopicWithAssignment(TOPIC, Map.of(0, List.of(0)));
+ clusterInstance.createTopicWithAssignment("other-topic", Map.of(0, List.of(0)));
try (Admin admin = Admin.create(Map.of(CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG, clusterInstance.bootstrapServers()))) {
String output = assertDoesNotThrow(() -> execute(fromArgsToOptions("--bootstrap-server", clusterInstance.bootstrapServers(), "--topic-list", TOPIC, "--describe"), admin));
// check all brokers are present
@@ -215,8 +215,4 @@ public class LogDirsCommandTest {
};
return ToolsTestUtils.captureStandardOut(runnable);
}
-
- private void createTopic(ClusterInstance clusterInstance, String topic) {
- assertDoesNotThrow(() -> clusterInstance.createTopicWithAssignment(topic, Map.of(0, List.of(0))));
- }
}
diff --git a/tools/src/test/java/org/apache/kafka/tools/ResetIntegrationTest.java b/tools/src/test/java/org/apache/kafka/tools/ResetIntegrationTest.java
index 44523c2b582..ccc267159bd 100644
--- a/tools/src/test/java/org/apache/kafka/tools/ResetIntegrationTest.java
+++ b/tools/src/test/java/org/apache/kafka/tools/ResetIntegrationTest.java
@@ -208,7 +208,7 @@ public class ResetIntegrationTest {
}
@ClusterTest
- public void shouldDefaultToClassicGroupProtocol(ClusterInstance cluster) throws Exception {
+ public void shouldDefaultToClassicGroupProtocol(ClusterInstance cluster) {
final String appId = generateAppId();
cluster.createTopic(INPUT_TOPIC, 1, (short) 1);
final String[] parameters = new String[] {
@@ -226,7 +226,7 @@ public class ResetIntegrationTest {
}
@ClusterTest
- public void shouldAllowGroupProtocolClassic(ClusterInstance cluster) throws Exception {
+ public void shouldAllowGroupProtocolClassic(ClusterInstance cluster) {
final String appId = generateAppId();
cluster.createTopic(INPUT_TOPIC, 1, (short) 1);
final String[] parameters = new String[] {
@@ -245,7 +245,7 @@ public class ResetIntegrationTest {
}
@ClusterTest
- public void shouldOverwriteGroupProtocolOtherThanClassic(ClusterInstance cluster) throws Exception {
+ public void shouldOverwriteGroupProtocolOtherThanClassic(ClusterInstance cluster) {
final String appId = generateAppId();
cluster.createTopic(INPUT_TOPIC, 1, (short) 1);
final String[] parameters = new String[] {
@@ -296,7 +296,7 @@ public class ResetIntegrationTest {
}
@ClusterTest
- public void shouldNotAllowToResetWhenSpecifiedInternalTopicIsNotInternal(ClusterInstance cluster) throws Exception {
+ public void shouldNotAllowToResetWhenSpecifiedInternalTopicIsNotInternal(ClusterInstance cluster) {
final String appId = generateAppId();
cluster.createTopic(INPUT_TOPIC, 1, (short) 1);
final String[] parameters = new String[] {
@@ -560,7 +560,7 @@ public class ResetIntegrationTest {
return APP_ID_PREFIX + "-" + TestUtils.randomString(10);
}
- private void prepare(final ClusterInstance cluster, final Map<String, Object> sslConfig, final String appId) throws Exception {
+ private void prepare(final ClusterInstance cluster, final Map<String, Object> sslConfig, final String appId) {
prepareConfigs(cluster, sslConfig, appId);
// align time to seconds to get clean window boundaries and thus ensure the same result for each run
recordTimestamp = (System.currentTimeMillis() / 1000 + 1) * 1000;
diff --git a/tools/src/test/java/org/apache/kafka/tools/TopicCommandTest.java b/tools/src/test/java/org/apache/kafka/tools/TopicCommandTest.java
index 99e8b1f0b97..c3328b9890e 100644
--- a/tools/src/test/java/org/apache/kafka/tools/TopicCommandTest.java
+++ b/tools/src/test/java/org/apache/kafka/tools/TopicCommandTest.java
@@ -571,7 +571,7 @@ public class TopicCommandTest {
}
@ClusterTest
- public void testListTopics(ClusterInstance clusterInstance) throws InterruptedException {
+ public void testListTopics(ClusterInstance clusterInstance) {
String testTopicName = TestUtils.randomString(10);
clusterInstance.createTopic(testTopicName, defaultNumPartitions, defaultReplicationFactor);
@@ -580,7 +580,7 @@ public class TopicCommandTest {
}
@ClusterTest(brokers = 3)
- public void testListTopicsWithIncludeList(ClusterInstance clusterInstance) throws InterruptedException {
+ public void testListTopicsWithIncludeList(ClusterInstance clusterInstance) {
String topic1 = "kafka.testTopic1";
String topic2 = "kafka.testTopic2";
String topic3 = "oooof.testTopic1";
@@ -597,12 +597,10 @@ public class TopicCommandTest {
}
@ClusterTest(brokers = 3)
- public void testListTopicsWithExcludeInternal(ClusterInstance clusterInstance) throws InterruptedException {
+ public void testListTopicsWithExcludeInternal(ClusterInstance clusterInstance) {
String topic1 = "kafka.testTopic1";
String hiddenConsumerTopic = Topic.GROUP_METADATA_TOPIC_NAME;
- int partition = 2;
- short replicationFactor = 2;
- clusterInstance.createTopic(topic1, partition, replicationFactor);
+ clusterInstance.createTopic(topic1, 2, (short) 2);
String output = captureListTopicStandardOut(clusterInstance, buildTopicCommandOptionsWithBootstrap(clusterInstance, "--list", "--exclude-internal"));
assertTrue(output.contains(topic1), "Expected topic name " + topic1 + " to be present in output: " + output);
@@ -612,9 +610,7 @@ public class TopicCommandTest {
@ClusterTest(brokers = 3)
public void testAlterPartitionCount(ClusterInstance clusterInstance) throws Exception {
String testTopicName = TestUtils.randomString(10);
- int partition = 2;
- short replicationFactor = 2;
- clusterInstance.createTopic(testTopicName, partition, replicationFactor);
+ clusterInstance.createTopic(testTopicName, 2, (short) 2);
try (Admin adminClient = clusterInstance.admin();
TopicCommand.TopicService topicService = new TopicCommand.TopicService(adminClient)) {
topicService.alterTopic(buildTopicCommandOptionsWithBootstrap(clusterInstance, "--alter", "--topic", testTopicName, "--partitions", "3"));
@@ -636,9 +632,7 @@ public class TopicCommandTest {
@ClusterTemplate("generate")
public void testAlterAssignment(ClusterInstance clusterInstance) throws Exception {
String testTopicName = TestUtils.randomString(10);
- int partition = 2;
- short replicationFactor = 2;
- clusterInstance.createTopic(testTopicName, partition, replicationFactor);
+ clusterInstance.createTopic(testTopicName, 2, (short) 2);
try (Admin adminClient = clusterInstance.admin();
TopicCommand.TopicService topicService = new TopicCommand.TopicService(adminClient)) {
topicService.alterTopic(buildTopicCommandOptionsWithBootstrap(clusterInstance, "--alter",
@@ -665,9 +659,7 @@ public class TopicCommandTest {
@ClusterTest(brokers = 3)
public void testAlterAssignmentWithMoreAssignmentThanPartitions(ClusterInstance clusterInstance) throws Exception {
String testTopicName = TestUtils.randomString(10);
- int partition = 2;
- short replicationFactor = 2;
- clusterInstance.createTopic(testTopicName, partition, replicationFactor);
+ clusterInstance.createTopic(testTopicName, 2, (short) 2);
try (Admin adminClient = clusterInstance.admin();
TopicCommand.TopicService topicService = new TopicCommand.TopicService(adminClient)) {
assertThrows(ExecutionException.class,
@@ -681,9 +673,7 @@ public class TopicCommandTest {
@ClusterTemplate("generate")
public void testAlterAssignmentWithMorePartitionsThanAssignment(ClusterInstance clusterInstance) throws Exception {
String testTopicName = TestUtils.randomString(10);
- int partition = 2;
- short replicationFactor = 2;
- clusterInstance.createTopic(testTopicName, partition, replicationFactor);
+ clusterInstance.createTopic(testTopicName, 2, (short) 2);
try (Admin adminClient = clusterInstance.admin();
TopicCommand.TopicService topicService = new TopicCommand.TopicService(adminClient)) {
assertThrows(ExecutionException.class,
@@ -895,11 +885,9 @@ public class TopicCommandTest {
}
@ClusterTemplate("generate")
- public void testDescribe(ClusterInstance clusterInstance) throws InterruptedException {
+ public void testDescribe(ClusterInstance clusterInstance) {
String testTopicName = TestUtils.randomString(10);
- int partition = 2;
- short replicationFactor = 2;
- clusterInstance.createTopic(testTopicName, partition, replicationFactor);
+ clusterInstance.createTopic(testTopicName, 2, (short) 2);
String output = captureDescribeTopicStandardOut(clusterInstance, buildTopicCommandOptionsWithBootstrap(clusterInstance, "--describe", "--topic", testTopicName));
String[] rows = output.split(System.lineSeparator());
@@ -908,7 +896,7 @@ public class TopicCommandTest {
}
@ClusterTemplate("generate")
- public void testDescribeWithDescribeTopicPartitionsApi(ClusterInstance clusterInstance) throws InterruptedException {
+ public void testDescribeWithDescribeTopicPartitionsApi(ClusterInstance clusterInstance) {
String testTopicName = TestUtils.randomString(10);
clusterInstance.createTopic(testTopicName, 20, (short) 2);
@@ -954,10 +942,8 @@ public class TopicCommandTest {
@ClusterTest(brokers = 3)
public void testDescribeUnavailablePartitions(ClusterInstance clusterInstance) throws InterruptedException {
String testTopicName = TestUtils.randomString(10);
- int partitions = 3;
- short replicationFactor = 1;
- clusterInstance.createTopic(testTopicName, partitions, replicationFactor);
+ clusterInstance.createTopic(testTopicName, 3, (short) 1);
// check which partition is on broker 0 which we'll kill
clusterInstance.shutdownBroker(0);
@@ -978,9 +964,7 @@ public class TopicCommandTest {
@ClusterTest(brokers = 3)
public void testDescribeUnderReplicatedPartitions(ClusterInstance clusterInstance) throws InterruptedException {
String testTopicName = TestUtils.randomString(10);
- int partitions = 1;
- short replicationFactor = 3;
- clusterInstance.createTopic(testTopicName, partitions, replicationFactor);
+ clusterInstance.createTopic(testTopicName, 1, (short) 3);
clusterInstance.shutdownBroker(0);
Assertions.assertEquals(2, clusterInstance.aliveBrokers().size());
@@ -1005,9 +989,7 @@ public class TopicCommandTest {
String testTopicName = TestUtils.randomString(10);
Map<String, String> topicConfig = new HashMap<>();
topicConfig.put(TopicConfig.MIN_IN_SYNC_REPLICAS_CONFIG, "3");
- int partitions = 1;
- short replicationFactor = 3;
- clusterInstance.createTopic(testTopicName, partitions, replicationFactor, topicConfig);
+ clusterInstance.createTopic(testTopicName, 1, (short) 3, topicConfig);
clusterInstance.shutdownBroker(0);
assertEquals(2, clusterInstance.aliveBrokers().size());
@@ -1101,10 +1083,7 @@ public class TopicCommandTest {
Map<String, String> topicConfig = new HashMap<>();
topicConfig.put(TopicConfig.MIN_IN_SYNC_REPLICAS_CONFIG, "4");
- int partitions = 1;
- short replicationFactor = 6;
-
- clusterInstance.createTopic(testTopicName, partitions, replicationFactor, topicConfig);
+ clusterInstance.createTopic(testTopicName, 1, (short) 6, topicConfig);
clusterInstance.shutdownBroker(0);
clusterInstance.shutdownBroker(1);
@@ -1183,23 +1162,20 @@ public class TopicCommandTest {
}
@ClusterTest(brokers = 3)
- public void testDescribeReportOverriddenConfigs(ClusterInstance clusterInstance) throws InterruptedException {
+ public void testDescribeReportOverriddenConfigs(ClusterInstance clusterInstance) {
String testTopicName = TestUtils.randomString(10);
String config = "file.delete.delay.ms=1000";
Map<String, String> topicConfig = new HashMap<>();
topicConfig.put(TopicConfig.FILE_DELETE_DELAY_MS_CONFIG, "1000");
- int partitions = 2;
- short replicationFactor = 2;
-
- clusterInstance.createTopic(testTopicName, partitions, replicationFactor, topicConfig);
+ clusterInstance.createTopic(testTopicName, 2, (short) 2, topicConfig);
String output = captureDescribeTopicStandardOut(clusterInstance, buildTopicCommandOptionsWithBootstrap(clusterInstance, "--describe"));
assertTrue(output.contains(config), String.format("Describe output should have contained %s", config));
}
@ClusterTest
- public void testDescribeAndListTopicsWithoutInternalTopics(ClusterInstance clusterInstance) throws InterruptedException {
+ public void testDescribeAndListTopicsWithoutInternalTopics(ClusterInstance clusterInstance) {
String testTopicName = TestUtils.randomString(10);
clusterInstance.createTopic(testTopicName, defaultNumPartitions, defaultReplicationFactor);
@@ -1218,7 +1194,7 @@ public class TopicCommandTest {
}
@ClusterTest
- public void testDescribeDoesNotFailWhenListingReassignmentIsUnauthorized(ClusterInstance clusterInstance) throws Exception {
+ public void testDescribeDoesNotFailWhenListingReassignmentIsUnauthorized(ClusterInstance clusterInstance) {
String testTopicName = TestUtils.randomString(10);
clusterInstance.createTopic(testTopicName, defaultNumPartitions, defaultReplicationFactor);
@@ -1244,9 +1220,7 @@ public class TopicCommandTest {
@ClusterTest(brokers = 3)
public void testCreateWithTopicNameCollision(ClusterInstance clusterInstance) throws Exception {
String topic = "foo_bar";
- int partitions = 1;
- short replicationFactor = 3;
- clusterInstance.createTopic(topic, partitions, replicationFactor);
+ clusterInstance.createTopic(topic, 1, (short) 3);
try (Admin adminClient = clusterInstance.admin();
TopicCommand.TopicService topicService = new TopicCommand.TopicService(adminClient)) {
diff --git a/tools/src/test/java/org/apache/kafka/tools/consumer/group/DeleteOffsetsConsumerGroupCommandIntegrationTest.java b/tools/src/test/java/org/apache/kafka/tools/consumer/group/DeleteOffsetsConsumerGroupCommandIntegrationTest.java
index a1c8e6755df..a09ea8a8637 100644
--- a/tools/src/test/java/org/apache/kafka/tools/consumer/group/DeleteOffsetsConsumerGroupCommandIntegrationTest.java
+++ b/tools/src/test/java/org/apache/kafka/tools/consumer/group/DeleteOffsetsConsumerGroupCommandIntegrationTest.java
@@ -89,7 +89,7 @@ public class DeleteOffsetsConsumerGroupCommandIntegrationTest {
for (GroupProtocol groupProtocol : clusterInstance.supportedGroupProtocols()) {
String topic = TOPIC_PREFIX + groupProtocol.name();
String group = GROUP_PREFIX + groupProtocol.name();
- createTopic(topic);
+ clusterInstance.createTopic(topic, 1, (short) 1);
Runnable validateRunnable = getValidateRunnable(topic, group, 0, 0, Errors.GROUP_SUBSCRIBED_TO_TOPIC);
testWithConsumerGroup(topic, group, groupProtocol, true, validateRunnable);
removeTopic(topic);
@@ -101,7 +101,7 @@ public class DeleteOffsetsConsumerGroupCommandIntegrationTest {
for (GroupProtocol groupProtocol : clusterInstance.supportedGroupProtocols()) {
String topic = TOPIC_PREFIX + groupProtocol.name();
String group = GROUP_PREFIX + groupProtocol.name();
- createTopic(topic);
+ clusterInstance.createTopic(topic, 1, (short) 1);
Runnable validateRunnable = getValidateRunnable(topic, group, -1, 0, Errors.GROUP_SUBSCRIBED_TO_TOPIC);
testWithConsumerGroup(topic, group, groupProtocol, true, validateRunnable);
removeTopic(topic);
@@ -133,7 +133,7 @@ public class DeleteOffsetsConsumerGroupCommandIntegrationTest {
for (GroupProtocol groupProtocol : clusterInstance.supportedGroupProtocols()) {
String topic = TOPIC_PREFIX + groupProtocol.name();
String group = GROUP_PREFIX + groupProtocol.name();
- createTopic(topic);
+ clusterInstance.createTopic(topic, 1, (short) 1);
Runnable validateRunnable = getValidateRunnable(topic, group, 0, 0, Errors.NONE);
testWithConsumerGroup(topic, group, groupProtocol, false, validateRunnable);
removeTopic(topic);
@@ -145,7 +145,7 @@ public class DeleteOffsetsConsumerGroupCommandIntegrationTest {
for (GroupProtocol groupProtocol : clusterInstance.supportedGroupProtocols()) {
String topic = TOPIC_PREFIX + groupProtocol.name();
String group = GROUP_PREFIX + groupProtocol.name();
- createTopic(topic);
+ clusterInstance.createTopic(topic, 1, (short) 1);
Runnable validateRunnable = getValidateRunnable(topic, group, -1, 0, Errors.NONE);
testWithConsumerGroup(topic, group, groupProtocol, false, validateRunnable);
removeTopic(topic);
@@ -258,10 +258,6 @@ public class DeleteOffsetsConsumerGroupCommandIntegrationTest {
return new KafkaConsumer<>(consumerConfig);
}
- private void createTopic(String topic) {
- Assertions.assertDoesNotThrow(() -> clusterInstance.createTopic(topic, 1, (short) 1));
- }
-
private void removeTopic(String topic) {
try (Admin admin = Admin.create(Map.of(CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG, clusterInstance.bootstrapServers()))) {
Assertions.assertDoesNotThrow(() -> admin.deleteTopics(List.of(topic)).all());
diff --git a/tools/src/test/java/org/apache/kafka/tools/consumer/group/DescribeConsumerGroupTest.java b/tools/src/test/java/org/apache/kafka/tools/consumer/group/DescribeConsumerGroupTest.java
index dc275fed0d2..84079a3bd98 100644
--- a/tools/src/test/java/org/apache/kafka/tools/consumer/group/DescribeConsumerGroupTest.java
+++ b/tools/src/test/java/org/apache/kafka/tools/consumer/group/DescribeConsumerGroupTest.java
@@ -124,7 +124,7 @@ public class DescribeConsumerGroupTest {
for (GroupProtocol groupProtocol: clusterInstance.supportedGroupProtocols()) {
String topic = TOPIC_PREFIX + groupProtocol.name();
String group = GROUP_PREFIX + groupProtocol.name();
- createTopic(topic);
+ clusterInstance.createTopic(topic, 1, (short) 1);
// run one consumer in the group consuming from a single-partition topic
try (AutoCloseable protocolConsumerGroupExecutor = consumerGroupClosable(groupProtocol, group, topic, Map.of());
@@ -147,7 +147,7 @@ public class DescribeConsumerGroupTest {
for (GroupProtocol groupProtocol: clusterInstance.supportedGroupProtocols()) {
String topic = TOPIC_PREFIX + groupProtocol.name();
String group = GROUP_PREFIX + groupProtocol.name();
- createTopic(topic);
+ clusterInstance.createTopic(topic, 1, (short) 1);
try (AutoCloseable protocolConsumerGroupExecutor = consumerGroupClosable(groupProtocol, group, topic, Map.of());
// note the group to be queried is a different (non-existing) group
ConsumerGroupCommand.ConsumerGroupService service = consumerGroupService(new String[]{"--bootstrap-server", clusterInstance.bootstrapServers(), "--describe", "--group", missingGroup})
@@ -168,7 +168,7 @@ public class DescribeConsumerGroupTest {
for (GroupProtocol groupProtocol: clusterInstance.supportedGroupProtocols()) {
String topic = TOPIC_PREFIX + groupProtocol.name();
String group = GROUP_PREFIX + groupProtocol.name();
- createTopic(topic);
+ clusterInstance.createTopic(topic, 1, (short) 1);
try (AutoCloseable protocolConsumerGroupExecutor = consumerGroupClosable(groupProtocol, group, topic, Map.of());
// note the group to be queried is a different (non-existing) group
ConsumerGroupCommand.ConsumerGroupService service = consumerGroupService(new String[]{"--bootstrap-server", clusterInstance.bootstrapServers(), "--describe", "--group", missingGroup})
@@ -367,7 +367,7 @@ public class DescribeConsumerGroupTest {
this.clusterInstance = clusterInstance;
for (GroupProtocol groupProtocol: clusterInstance.supportedGroupProtocols()) {
String topic = TOPIC_PREFIX + groupProtocol.name();
- createTopic(topic);
+ clusterInstance.createTopic(topic, 1, (short) 1);
// Create N single-threaded consumer groups from a single-partition topic
List<AutoCloseable> protocolConsumerGroupExecutors = new ArrayList<>();
@@ -408,7 +408,7 @@ public class DescribeConsumerGroupTest {
this.clusterInstance = clusterInstance;
for (GroupProtocol groupProtocol: clusterInstance.supportedGroupProtocols()) {
String topic = TOPIC_PREFIX + groupProtocol.name();
- createTopic(topic);
+ clusterInstance.createTopic(topic, 1, (short) 1);
// Create N single-threaded consumer groups from a single-partition topic
List<AutoCloseable> protocolConsumerGroupExecutors = new ArrayList<>();
@@ -450,7 +450,7 @@ public class DescribeConsumerGroupTest {
for (GroupProtocol groupProtocol: clusterInstance.supportedGroupProtocols()) {
String topic = TOPIC_PREFIX + groupProtocol.name();
String group = GROUP_PREFIX + groupProtocol.name();
- createTopic(topic);
+ clusterInstance.createTopic(topic, 1, (short) 1);
// run one consumer in the group consuming from a single-partition topic
try (AutoCloseable protocolConsumerGroupExecutor = consumerGroupClosable(groupProtocol, group, topic, Map.of());
@@ -490,7 +490,7 @@ public class DescribeConsumerGroupTest {
for (GroupProtocol groupProtocol: clusterInstance.supportedGroupProtocols()) {
String topic = TOPIC_PREFIX + groupProtocol.name();
String group = GROUP_PREFIX + groupProtocol.name();
- createTopic(topic);
+ clusterInstance.createTopic(topic, 1, (short) 1);
// run one consumer in the group consuming from a single-partition topic
try (AutoCloseable protocolConsumerGroupExecutor = consumerGroupClosable(groupProtocol, group, topic, Map.of());
@@ -517,7 +517,7 @@ public class DescribeConsumerGroupTest {
for (GroupProtocol groupProtocol: clusterInstance.supportedGroupProtocols()) {
String topic = TOPIC_PREFIX + groupProtocol.name();
String group = GROUP_PREFIX + groupProtocol.name();
- createTopic(topic);
+ clusterInstance.createTopic(topic, 1, (short) 1);
// run one consumer in the group consuming from a single-partition topic
try (AutoCloseable protocolConsumerGroupExecutor = consumerGroupClosable(groupProtocol, group, topic, Map.of(ConsumerConfig.GROUP_REMOTE_ASSIGNOR_CONFIG, groupProtocol == GroupProtocol.CONSUMER ? "range" : ""));
@@ -540,7 +540,7 @@ public class DescribeConsumerGroupTest {
for (GroupProtocol groupProtocol: clusterInstance.supportedGroupProtocols()) {
String topic = TOPIC_PREFIX + groupProtocol.name();
String group = GROUP_PREFIX + groupProtocol.name();
- createTopic(topic);
+ clusterInstance.createTopic(topic, 1, (short) 1);
// run one consumer in the group consuming from a single-partition topic
AutoCloseable protocolConsumerGroupExecutor = null;
@@ -577,7 +577,7 @@ public class DescribeConsumerGroupTest {
this.clusterInstance = clusterInstance;
for (GroupProtocol groupProtocol: clusterInstance.supportedGroupProtocols()) {
String topic = TOPIC_PREFIX + groupProtocol.name();
- createTopic(topic);
+ clusterInstance.createTopic(topic, 1, (short) 1);
for (List<String> describeType : DESCRIBE_TYPES) {
String group = GROUP_PREFIX + groupProtocol.name() + String.join("", describeType);
@@ -609,7 +609,7 @@ public class DescribeConsumerGroupTest {
for (GroupProtocol groupProtocol: clusterInstance.supportedGroupProtocols()) {
String topic = TOPIC_PREFIX + groupProtocol.name();
String group = GROUP_PREFIX + groupProtocol.name();
- createTopic(topic);
+ clusterInstance.createTopic(topic, 1, (short) 1);
// run one consumer in the group consuming from a single-partition topic
try (AutoCloseable protocolConsumerGroupExecutor = consumerGroupClosable(groupProtocol, group, topic, Map.of());
@@ -646,7 +646,7 @@ public class DescribeConsumerGroupTest {
for (GroupProtocol groupProtocol: clusterInstance.supportedGroupProtocols()) {
String topic = TOPIC_PREFIX + groupProtocol.name();
String group = GROUP_PREFIX + groupProtocol.name();
- createTopic(topic);
+ clusterInstance.createTopic(topic, 1, (short) 1);
// run one consumer in the group consuming from a single-partition topic
try (AutoCloseable protocolConsumerGroupExecutor = consumerGroupClosable(groupProtocol, group, topic, Map.of());
@@ -675,7 +675,7 @@ public class DescribeConsumerGroupTest {
for (GroupProtocol groupProtocol: clusterInstance.supportedGroupProtocols()) {
String topic = TOPIC_PREFIX + groupProtocol.name();
String group = GROUP_PREFIX + groupProtocol.name();
- createTopic(topic);
+ clusterInstance.createTopic(topic, 1, (short) 1);
// run one consumer in the group consuming from a single-partition topic
try (AutoCloseable protocolConsumerGroupExecutor = consumerGroupClosable(groupProtocol, group, topic, Map.of());
@@ -705,7 +705,7 @@ public class DescribeConsumerGroupTest {
this.clusterInstance = clusterInstance;
for (GroupProtocol groupProtocol: clusterInstance.supportedGroupProtocols()) {
String topic = TOPIC_PREFIX + groupProtocol.name();
- createTopic(topic);
+ clusterInstance.createTopic(topic, 1, (short) 1);
for (List<String> describeType : DESCRIBE_TYPES) {
String group = GROUP_PREFIX + groupProtocol.name() + String.join("", describeType);
@@ -733,7 +733,7 @@ public class DescribeConsumerGroupTest {
for (GroupProtocol groupProtocol: clusterInstance.supportedGroupProtocols()) {
String topic = TOPIC_PREFIX + groupProtocol.name();
String group = GROUP_PREFIX + groupProtocol.name();
- createTopic(topic);
+ clusterInstance.createTopic(topic, 1, (short) 1);
// run two consumers in the group consuming from a single-partition topic
try (AutoCloseable protocolConsumerGroupExecutor = consumerGroupClosable(groupProtocol, group, topic, Map.of(), 2);
@@ -756,7 +756,7 @@ public class DescribeConsumerGroupTest {
for (GroupProtocol groupProtocol: clusterInstance.supportedGroupProtocols()) {
String topic = TOPIC_PREFIX + groupProtocol.name();
String group = GROUP_PREFIX + groupProtocol.name();
- createTopic(topic);
+ clusterInstance.createTopic(topic, 1, (short) 1);
// run two consumers in the group consuming from a single-partition topic
try (AutoCloseable protocolConsumerGroupExecutor = consumerGroupClosable(groupProtocol, group, topic, Map.of(), 2);
@@ -786,7 +786,7 @@ public class DescribeConsumerGroupTest {
for (GroupProtocol groupProtocol: clusterInstance.supportedGroupProtocols()) {
String topic = TOPIC_PREFIX + groupProtocol.name();
String group = GROUP_PREFIX + groupProtocol.name();
- createTopic(topic);
+ clusterInstance.createTopic(topic, 1, (short) 1);
// run two consumers in the group consuming from a single-partition topic
try (AutoCloseable protocolConsumerGroupExecutor = consumerGroupClosable(groupProtocol, group, topic, Map.of(), 2);
@@ -805,7 +805,7 @@ public class DescribeConsumerGroupTest {
this.clusterInstance = clusterInstance;
for (GroupProtocol groupProtocol: clusterInstance.supportedGroupProtocols()) {
String topic = TOPIC_PREFIX + groupProtocol.name();
- createTopic(topic, 2);
+ clusterInstance.createTopic(topic, 2, (short) 1);
for (List<String> describeType : DESCRIBE_TYPES) {
String group = GROUP_PREFIX + groupProtocol.name() + String.join("", describeType);
@@ -833,7 +833,7 @@ public class DescribeConsumerGroupTest {
for (GroupProtocol groupProtocol: clusterInstance.supportedGroupProtocols()) {
String topic = TOPIC_PREFIX + groupProtocol.name();
String group = GROUP_PREFIX + groupProtocol.name();
- createTopic(topic, 2);
+ clusterInstance.createTopic(topic, 2, (short) 1);
// run two consumers in the group consuming from a two-partition topic
try (AutoCloseable protocolConsumerGroupExecutor = consumerGroupClosable(groupProtocol, group, topic, Map.of(), 2);
@@ -857,7 +857,7 @@ public class DescribeConsumerGroupTest {
for (GroupProtocol groupProtocol: clusterInstance.supportedGroupProtocols()) {
String topic = TOPIC_PREFIX + groupProtocol.name();
String group = GROUP_PREFIX + groupProtocol.name();
- createTopic(topic, 2);
+ clusterInstance.createTopic(topic, 2, (short) 1);
// run two consumers in the group consuming from a two-partition topic
try (AutoCloseable protocolConsumerGroupExecutor = consumerGroupClosable(groupProtocol, group, topic, Map.of(), 2);
@@ -885,7 +885,7 @@ public class DescribeConsumerGroupTest {
for (GroupProtocol groupProtocol: clusterInstance.supportedGroupProtocols()) {
String topic = TOPIC_PREFIX + groupProtocol.name();
String group = GROUP_PREFIX + groupProtocol.name();
- createTopic(topic, 2);
+ clusterInstance.createTopic(topic, 2, (short) 1);
// run two consumers in the group consuming from a two-partition topic
try (AutoCloseable protocolConsumerGroupExecutor = consumerGroupClosable(groupProtocol, group, topic, Map.of(), 2);
@@ -905,7 +905,7 @@ public class DescribeConsumerGroupTest {
GroupProtocol groupProtocol = GroupProtocol.CLASSIC;
String topic = TOPIC_PREFIX + groupProtocol.name();
String group = GROUP_PREFIX + groupProtocol.name();
- createTopic(topic, 2);
+ clusterInstance.createTopic(topic, 2, (short) 1);
try (AutoCloseable protocolConsumerGroupExecutor = consumerGroupClosable(groupProtocol, group, Set.of(new TopicPartition(topic, 0), new TopicPartition(topic, 1)), Map.of());
ConsumerGroupCommand.ConsumerGroupService service = consumerGroupService(new String[]{"--bootstrap-server", clusterInstance.bootstrapServers(), "--describe", "--group", group})
@@ -923,7 +923,7 @@ public class DescribeConsumerGroupTest {
this.clusterInstance = clusterInstance;
GroupProtocol groupProtocol = GroupProtocol.CONSUMER;
String topic = TOPIC_PREFIX + groupProtocol.name();
- createTopic(topic);
+ clusterInstance.createTopic(topic, 1, (short) 1);
// Let creation of the offsets topic happen during group initialization to ensure that initialization doesn't
// complete before the timeout expires
@@ -949,7 +949,7 @@ public class DescribeConsumerGroupTest {
GroupProtocol groupProtocol = GroupProtocol.CONSUMER;
String topic = TOPIC_PREFIX + groupProtocol.name();
String group = GROUP_PREFIX + groupProtocol.name();
- createTopic(topic);
+ clusterInstance.createTopic(topic, 1, (short) 1);
// Let creation of the offsets topic happen during group initialization to ensure that initialization doesn't
// complete before the timeout expires
@@ -970,7 +970,7 @@ public class DescribeConsumerGroupTest {
GroupProtocol groupProtocol = GroupProtocol.CONSUMER;
String topic = TOPIC_PREFIX + groupProtocol.name();
String group = GROUP_PREFIX + groupProtocol.name();
- createTopic(topic);
+ clusterInstance.createTopic(topic, 1, (short) 1);
// Let creation of the offsets topic happen during group initialization to ensure that initialization doesn't
// complete before the timeout expires
@@ -991,7 +991,7 @@ public class DescribeConsumerGroupTest {
GroupProtocol groupProtocol = GroupProtocol.CONSUMER;
String topic = TOPIC_PREFIX + groupProtocol.name();
String group = GROUP_PREFIX + groupProtocol.name();
- createTopic(topic);
+ clusterInstance.createTopic(topic, 1, (short) 1);
// Let creation of the offsets topic happen during group initialization to ensure that initialization doesn't
// complete before the timeout expires
@@ -1012,7 +1012,7 @@ public class DescribeConsumerGroupTest {
for (GroupProtocol groupProtocol: clusterInstance.supportedGroupProtocols()) {
String topic = TOPIC_PREFIX + groupProtocol.name();
String group = GROUP_PREFIX + groupProtocol.name();
- createTopic(topic);
+ clusterInstance.createTopic(topic, 1, (short) 1);
// run one consumer in the group consuming from a single-partition topic
try (AutoCloseable protocolConsumerGroupExecutor = consumerGroupClosable(groupProtocol, group, topic, Map.of(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, "false"));
@@ -1168,14 +1168,6 @@ public class DescribeConsumerGroupTest {
);
}
- private void createTopic(String topic) {
- createTopic(topic, 1);
- }
-
- private void createTopic(String topic, int numPartitions) {
- Assertions.assertDoesNotThrow(() -> clusterInstance.createTopic(topic, numPartitions, (short) 1));
- }
-
private void deleteConsumerGroups(Collection<String> groupIds) {
try (Admin admin = Admin.create(Map.of(CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG, clusterInstance.bootstrapServers()))) {
Assertions.assertDoesNotThrow(() -> admin.deleteConsumerGroups(groupIds).all().get());
diff --git a/tools/src/test/java/org/apache/kafka/tools/consumer/group/ResetConsumerGroupOffsetTest.java b/tools/src/test/java/org/apache/kafka/tools/consumer/group/ResetConsumerGroupOffsetTest.java
index 0c888e7dcec..110c6df6c9b 100644
--- a/tools/src/test/java/org/apache/kafka/tools/consumer/group/ResetConsumerGroupOffsetTest.java
+++ b/tools/src/test/java/org/apache/kafka/tools/consumer/group/ResetConsumerGroupOffsetTest.java
@@ -154,7 +154,7 @@ public class ResetConsumerGroupOffsetTest {
@ClusterConfigProperty(key = OFFSETS_TOPIC_REPLICATION_FACTOR_CONFIG, value = "2"),
}
)
- public void testResetOffsetsWithOfflinePartitionNotInResetTarget(ClusterInstance cluster) throws Exception {
+ public void testResetOffsetsWithOfflinePartitionNotInResetTarget(ClusterInstance cluster) {
String topic = generateRandomTopic();
String group = "new.group";
String[] args = buildArgsForGroup(cluster, group, "--to-earliest", "--execute", "--topic", topic + ":0");
diff --git a/tools/src/test/java/org/apache/kafka/tools/reassign/ReassignPartitionsCommandTest.java b/tools/src/test/java/org/apache/kafka/tools/reassign/ReassignPartitionsCommandTest.java
index b14c4ed7125..d61869c8057 100644
--- a/tools/src/test/java/org/apache/kafka/tools/reassign/ReassignPartitionsCommandTest.java
+++ b/tools/src/test/java/org/apache/kafka/tools/reassign/ReassignPartitionsCommandTest.java
@@ -548,17 +548,17 @@ public class ReassignPartitionsCommandTest {
Map<Integer, List<Integer>> fooReplicasAssignments = new HashMap<>();
fooReplicasAssignments.put(0, List.of(0, 1, 2));
fooReplicasAssignments.put(1, List.of(1, 2, 3));
- Assertions.assertDoesNotThrow(() -> clusterInstance.createTopicWithAssignment("foo", fooReplicasAssignments));
+ clusterInstance.createTopicWithAssignment("foo", fooReplicasAssignments);
Map<Integer, List<Integer>> barReplicasAssignments = new HashMap<>();
barReplicasAssignments.put(0, List.of(3, 2, 1));
- Assertions.assertDoesNotThrow(() -> clusterInstance.createTopicWithAssignment("bar", barReplicasAssignments));
+ clusterInstance.createTopicWithAssignment("bar", barReplicasAssignments);
Map<Integer, List<Integer>> bazReplicasAssignments = new HashMap<>();
bazReplicasAssignments.put(0, List.of(1, 0, 2));
bazReplicasAssignments.put(1, List.of(2, 0, 1));
bazReplicasAssignments.put(2, List.of(0, 2, 1));
- Assertions.assertDoesNotThrow(() -> clusterInstance.createTopicWithAssignment("baz", bazReplicasAssignments));
+ clusterInstance.createTopicWithAssignment("baz", bazReplicasAssignments);
}
private void produceMessages(String topic, int partition, int numMessages) {