Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

support delete topics using the kafka client #348

Merged
merged 2 commits into from
Jan 27, 2021

Conversation

dockerzhang
Copy link
Contributor

fixes #347

@BewareMyPower
Copy link
Collaborator

Add a test to verify deleting an empty topic throws an UnknownTopicOrPartitionException. Here's an example:

diff --git a/tests/src/test/java/io/streamnative/pulsar/handlers/kop/KafkaRequestHandlerTest.java b/tests/src/test/java/io/streamnative/pulsar/handlers/kop/KafkaRequestHandlerTest.java
index 21cf192..1b393ca 100644
--- a/tests/src/test/java/io/streamnative/pulsar/handlers/kop/KafkaRequestHandlerTest.java
+++ b/tests/src/test/java/io/streamnative/pulsar/handlers/kop/KafkaRequestHandlerTest.java
@@ -376,6 +376,23 @@ public class KafkaRequestHandlerTest extends KopProtocolHandlerTestBase {
         verifyTopicsDeletedByPulsarAdmin(topicToNumPartitions);
     }
 
+    @Test(timeOut = 10000)
+    public void testDeleteNotExistedTopics() throws Exception {
+        Properties props = new Properties();
+        props.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:" + getKafkaBrokerPort());
+
+        @Cleanup
+        AdminClient kafkaAdmin = AdminClient.create(props);
+        Set<String> topics = new HashSet<>();
+        topics.add("testDeleteNotExistedTopics");
+        try {
+            deleteTopicsByKafkaAdmin(kafkaAdmin, topics);
+            fail();
+        } catch (ExecutionException e) {
+            assertTrue(e.getCause() instanceof UnknownTopicOrPartitionException);
+        }
+    }
+
     @Test(timeOut = 10000)
     public void testCreateInvalidTopics() {
         Properties props = new Properties();

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type/feature Indicates new functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] support delete topics using the kafka client
2 participants