poorbarcode commented on code in PR #21664:
URL: https://github.com/apache/pulsar/pull/21664#discussion_r1419875489
##########
pulsar-client-tools/src/test/java/org/apache/pulsar/admin/cli/TestCmdTopics.java:
##########
@@ -160,4 +168,59 @@ public void testPartitionedLookupSortByBroker() throws
Exception {
partitionedLookup.sortByBroker = true;
verify(mockLookup).lookupPartitionedTopic(eq(topic.toString()));
}
+ @Test
+ public void testRunDeleteSingleTopic() throws PulsarAdminException,
IOException {
Review Comment:
Could you also add a test that some topics could not be deleted successfully?
##########
pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdTopics.java:
##########
@@ -726,10 +734,38 @@ private class DeleteCmd extends CliCommand {
+ "but the parameter is invalid and the schema is always
deleted", hidden = true)
private boolean deleteSchema = false;
+ @Parameter(names = {"-r", "regex"},
+ description = "Use a regex expression to match multiple topics
for deletion.")
+ boolean regex = false;
+
+ @Parameter(names = {"--from-file"}, description = "Read a list of
topics from a file for deletion.")
+ boolean readFromFile;
+
+
@Override
- void run() throws PulsarAdminException {
- String topic = validateTopicName(params);
- getTopics().delete(topic, force);
+ void run() throws PulsarAdminException, IOException {
+ if (readFromFile && regex) {
+ throw new ParameterException("Could not apply regex when read
topics from file.");
+ }
+ if (readFromFile) {
+ String path = checkArgument(params);
+ List<String> topicsFromFile =
Files.readAllLines(Path.of(path));
+ for (String t : topicsFromFile) {
+ getTopics().delete(t, force);
Review Comment:
If one topic has been deleted before, what will happen here?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]