merlimat closed pull request #1592: Add properties alias for tenants in pulsar-admin URL: https://github.com/apache/incubator-pulsar/pull/1592
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdTenants.java b/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdTenants.java index 914bb74f2..98da636b7 100644 --- a/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdTenants.java +++ b/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdTenants.java @@ -112,4 +112,16 @@ public CmdTenants(PulsarAdmin admin) { jcommander.addCommand("delete", new Delete()); } + @Parameters(hidden = true) + static class CmdProperties extends CmdTenants { + public CmdProperties(PulsarAdmin admin) { + super(admin); + } + + @Override + public boolean run(String[] args) { + System.err.println("WARN: The properties subcommand is deprecated. Please use tenants instead"); + return super.run(args); + } + } } diff --git a/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/PulsarAdminTool.java b/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/PulsarAdminTool.java index 3abd39dd8..c7b0335e6 100644 --- a/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/PulsarAdminTool.java +++ b/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/PulsarAdminTool.java @@ -72,6 +72,7 @@ commandMap.put("brokers", CmdBrokers.class); commandMap.put("broker-stats", CmdBrokerStats.class); commandMap.put("tenants", CmdTenants.class); + commandMap.put("properties", CmdTenants.CmdProperties.class); // deprecated, doesn't show in usage() commandMap.put("namespaces", CmdNamespaces.class); commandMap.put("persistent", CmdPersistentTopics.class); commandMap.put("non-persistent", CmdNonPersistentTopics.class); @@ -132,7 +133,7 @@ boolean run(String[] args, Function<PulsarAdminBuilder, ? extends PulsarAdmin> a if (help) { setupCommands(adminFactory); jcommander.usage(); - return false; + return true; } if (cmdPos == args.length) { diff --git a/tests/integration/cli/pom.xml b/tests/integration/cli/pom.xml new file mode 100644 index 000000000..0d98bc317 --- /dev/null +++ b/tests/integration/cli/pom.xml @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation=" + http://maven.apache.org/POM/4.0.0 + http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.pulsar.tests</groupId> + <artifactId>integration-tests-base</artifactId> + <version>2.0.0-incubating-SNAPSHOT</version> + <relativePath>../../integration-tests-base</relativePath> + </parent> + + <groupId>org.apache.pulsar.tests.integration</groupId> + <artifactId>cli</artifactId> + <packaging>jar</packaging> + <name>Apache Pulsar :: Tests :: Integration Tests :: CLI</name> + + <dependencies> + <dependency> + <groupId>org.apache.pulsar</groupId> + <artifactId>pulsar-client</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> +</project> diff --git a/tests/integration/cli/src/test/java/org/apache/pulsar/tests/integration/TestCLI.java b/tests/integration/cli/src/test/java/org/apache/pulsar/tests/integration/TestCLI.java new file mode 100644 index 000000000..9d31654af --- /dev/null +++ b/tests/integration/cli/src/test/java/org/apache/pulsar/tests/integration/TestCLI.java @@ -0,0 +1,61 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.pulsar.tests.integration; + +import com.github.dockerjava.api.DockerClient; + +import java.util.concurrent.TimeUnit; + +import org.apache.pulsar.tests.DockerUtils; +import org.apache.pulsar.tests.PulsarClusterUtils; +import org.jboss.arquillian.test.api.ArquillianResource; +import org.jboss.arquillian.testng.Arquillian; +import org.testng.Assert; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +public class TestCLI extends Arquillian { + private static String clusterName = "test"; + + @ArquillianResource + DockerClient docker; + + @BeforeMethod + public void waitServicesUp() throws Exception { + Assert.assertTrue(PulsarClusterUtils.waitZooKeeperUp(docker, clusterName, 30, TimeUnit.SECONDS)); + Assert.assertTrue(PulsarClusterUtils.waitAllBrokersUp(docker, clusterName)); + } + + @Test + public void testDeprecatedCommands() throws Exception { + String broker = PulsarClusterUtils.brokerSet(docker, clusterName).stream().findAny().get(); + + Assert.assertFalse(DockerUtils.runCommand(docker, broker, "/pulsar/bin/pulsar-admin", "--help") + .contains("Usage: properties ")); + Assert.assertTrue(DockerUtils.runCommand(docker, broker, + "/pulsar/bin/pulsar-admin", "properties", + "create", "compaction-test-cli", "--allowed-clusters", clusterName, + "--admin-roles", "admin").contains("deprecated")); + Assert.assertTrue(DockerUtils.runCommand(docker, broker, "/pulsar/bin/pulsar-admin", "properties", "list") + .contains("compaction-test-cli")); + Assert.assertTrue(DockerUtils.runCommand(docker, broker, "/pulsar/bin/pulsar-admin", "tenants", "list") + .contains("compaction-test-cli")); + + } +} diff --git a/tests/integration/cli/src/test/resources/arquillian.xml b/tests/integration/cli/src/test/resources/arquillian.xml new file mode 100644 index 000000000..821d6e6e0 --- /dev/null +++ b/tests/integration/cli/src/test/resources/arquillian.xml @@ -0,0 +1,32 @@ +<?xml version="1.0"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +--> +<arquillian xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns="http://jboss.org/schema/arquillian" + xsi:schemaLocation="http://jboss.org/schema/arquillian + http://jboss.org/schema/arquillian/arquillian_1_0.xsd"> + + <extension qualifier="docker"> + <property name="definitionFormat">CUBE</property> + <property name="dockerContainersResource">cube-definitions/single-cluster-3-bookie-2-broker.yaml</property> + </extension> + +</arquillian> diff --git a/tests/integration/pom.xml b/tests/integration/pom.xml index 4b25ac417..b0b86fec7 100644 --- a/tests/integration/pom.xml +++ b/tests/integration/pom.xml @@ -35,5 +35,6 @@ <modules> <module>smoke</module> <module>compaction</module> + <module>cli</module> </modules> </project> ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services