diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/TenantsBase.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/TenantsBase.java index a6e1d35ee85bc..b7b64ddd91a08 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/TenantsBase.java +++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/TenantsBase.java @@ -18,7 +18,6 @@ */ package org.apache.pulsar.broker.admin.impl; -import io.swagger.annotations.ApiParam; import java.util.List; import java.util.Set; import java.util.stream.Collectors; @@ -31,6 +30,7 @@ import javax.ws.rs.PathParam; import javax.ws.rs.core.Response.Status; +import org.apache.commons.lang3.StringUtils; import org.apache.pulsar.broker.admin.AdminResource; import org.apache.pulsar.broker.web.RestException; import org.apache.pulsar.common.naming.Constants; @@ -42,7 +42,9 @@ import org.slf4j.LoggerFactory; import com.google.common.collect.Lists; +import com.google.common.collect.Sets; import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; import static org.apache.pulsar.broker.cache.ConfigurationCacheService.POLICIES; @@ -91,6 +93,7 @@ public TenantInfo getTenantAdmin( @ApiResponses(value = { @ApiResponse(code = 403, message = "The requester doesn't have admin permissions"), @ApiResponse(code = 409, message = "Tenant already exists"), @ApiResponse(code = 412, message = "Tenant name is not valid"), + @ApiResponse(code = 412, message = "Clusters can not be empty"), @ApiResponse(code = 412, message = "Clusters do not exist") }) public void createTenant( @ApiParam(value = "The tenant name") @@ -102,9 +105,6 @@ public void createTenant( try { NamedEntity.checkName(tenant); - if (config == null) { - config = new TenantInfo(); - } zkCreate(path(POLICIES, tenant), jsonMapper().writeValueAsBytes(config)); log.info("[{}] Created tenant {}", clientAppId(), tenant); } catch (KeeperException.NodeExistsException e) { @@ -125,6 +125,7 @@ public void createTenant( @ApiResponses(value = { @ApiResponse(code = 403, message = "The requester doesn't have admin permissions"), @ApiResponse(code = 404, message = "Tenant does not exist"), @ApiResponse(code = 409, message = "Tenant already exists"), + @ApiResponse(code = 412, message = "Clusters can not be empty"), @ApiResponse(code = 412, message = "Clusters do not exist") }) public void updateTenant( @ApiParam(value = "The tenant name") @@ -225,11 +226,15 @@ public void deleteTenant( } private void validateClusters(TenantInfo info) { + // empty cluster shouldn't be allowed + if (info == null || info.getAllowedClusters().stream().filter(c -> !StringUtils.isBlank(c)).collect(Collectors.toSet()).isEmpty() + || info.getAllowedClusters().stream().anyMatch(ac -> StringUtils.isBlank(ac))) { + log.warn("[{}] Failed to validate due to clusters are empty", clientAppId()); + throw new RestException(Status.PRECONDITION_FAILED, "Clusters can not be empty"); + } + List nonexistentClusters; try { - if (info == null) { - info = new TenantInfo(); - } Set availableClusters = clustersListCache().get(); Set allowedClusters = info.getAllowedClusters(); nonexistentClusters = allowedClusters.stream() diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminTest.java index 06ec02ae000b7..00d1a31b1ef53 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminTest.java @@ -381,7 +381,11 @@ void properties() throws Exception { assertEquals(properties.getTenants(), Lists.newArrayList()); verify(properties, times(1)).validateSuperUserAccess(); + // create local cluster + clusters.createCluster(configClusterName, new ClusterData()); + Set allowedClusters = Sets.newHashSet(); + allowedClusters.add(configClusterName); TenantInfo tenantInfo = new TenantInfo(Sets.newHashSet("role1", "role2"), allowedClusters); properties.createTenant("test-property", tenantInfo); verify(properties, times(2)).validateSuperUserAccess(); @@ -489,7 +493,6 @@ void properties() throws Exception { assertEquals(properties.getTenants(), Lists.newArrayList()); // Create a namespace to test deleting a non-empty property - clusters.createCluster("use", new ClusterData()); newPropertyAdmin = new TenantInfo(Sets.newHashSet("role1", "other-role"), Sets.newHashSet("use")); properties.createTenant("my-tenant", newPropertyAdmin); @@ -511,9 +514,34 @@ void properties() throws Exception { } // Check tenantInfo is null - TenantInfo nullTenantInfo = new TenantInfo(); - properties.createTenant("tenant-config-is-null", null); - assertEquals(properties.getTenantAdmin("tenant-config-is-null"), nullTenantInfo); + try { + properties.createTenant("tenant-config-is-null", null); + fail("should have failed"); + } catch (RestException e) { + assertEquals(e.getResponse().getStatus(), Status.PRECONDITION_FAILED.getStatusCode()); + } + + // Check tenantInfo with empty cluster + String blankCluster = ""; + Set blankClusters = Sets.newHashSet(blankCluster); + TenantInfo tenantWithEmptyCluster = new TenantInfo(Sets.newHashSet("role1", "role2"), blankClusters); + try { + properties.createTenant("tenant-config-is-empty", tenantWithEmptyCluster); + fail("should have failed"); + } catch (RestException e) { + assertEquals(e.getResponse().getStatus(), Status.PRECONDITION_FAILED.getStatusCode()); + } + + // Check tenantInfo contains empty cluster + Set containBlankClusters = Sets.newHashSet(blankCluster); + containBlankClusters.add(configClusterName); + TenantInfo tenantContainEmptyCluster = new TenantInfo(Sets.newHashSet(), containBlankClusters); + try { + properties.createTenant("tenant-config-contain-empty", tenantContainEmptyCluster); + fail("should have failed"); + } catch (RestException e) { + assertEquals(e.getResponse().getStatus(), Status.PRECONDITION_FAILED.getStatusCode()); + } AsyncResponse response = mock(AsyncResponse.class); namespaces.deleteNamespace(response, "my-tenant", "use", "my-namespace", false); @@ -521,7 +549,6 @@ void properties() throws Exception { verify(response, timeout(5000).times(1)).resume(captor.capture()); assertEquals(captor.getValue().getStatus(), Status.NO_CONTENT.getStatusCode()); properties.deleteTenant("my-tenant"); - properties.deleteTenant("tenant-config-is-null"); } @Test diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/auth/MockedPulsarServiceBaseTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/auth/MockedPulsarServiceBaseTest.java index a47e3ebc3dea4..7b3b04061e55d 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/auth/MockedPulsarServiceBaseTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/auth/MockedPulsarServiceBaseTest.java @@ -21,6 +21,7 @@ import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.spy; +import com.google.common.collect.Sets; import com.google.common.util.concurrent.MoreExecutors; import com.google.common.util.concurrent.ThreadFactoryBuilder; @@ -31,6 +32,7 @@ import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -48,8 +50,11 @@ import org.apache.pulsar.broker.ServiceConfiguration; import org.apache.pulsar.broker.namespace.NamespaceService; import org.apache.pulsar.client.admin.PulsarAdmin; +import org.apache.pulsar.client.admin.PulsarAdminException; import org.apache.pulsar.client.api.PulsarClient; import org.apache.pulsar.client.api.PulsarClientException; +import org.apache.pulsar.common.policies.data.ClusterData; +import org.apache.pulsar.common.policies.data.TenantInfo; import org.apache.pulsar.compaction.Compactor; import org.apache.pulsar.zookeeper.ZooKeeperClientFactory; import org.apache.pulsar.zookeeper.ZookeeperClientFactoryImpl; @@ -231,6 +236,17 @@ protected void setupBrokerMocks(PulsarService pulsar) throws Exception { doReturn(sameThreadOrderedSafeExecutor).when(pulsar).getOrderedExecutor(); } + public TenantInfo createDefaultTenantInfo() throws PulsarAdminException { + // create local cluster if not exist + if (!admin.clusters().getClusters().contains(configClusterName)) { + admin.clusters().createCluster(configClusterName, new ClusterData()); + } + Set allowedClusters = Sets.newHashSet(); + allowedClusters.add(configClusterName); + TenantInfo tenantInfo = new TenantInfo(Sets.newHashSet(), allowedClusters); + return tenantInfo; + } + public static MockZooKeeper createMockZooKeeper() throws Exception { MockZooKeeper zk = MockZooKeeper.newInstance(MoreExecutors.newDirectExecutorService()); List dummyAclList = new ArrayList<>(0); diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/ResendRequestTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/ResendRequestTest.java index e6bdd71ad4de5..f9147250346b8 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/ResendRequestTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/ResendRequestTest.java @@ -421,7 +421,8 @@ public void testExclusiveSingleAckedPartitionedTopic() throws Exception { final String messagePredicate = "my-message-" + key + "-"; final int totalMessages = 10; final int numberOfPartitions = 4; - admin.tenants().createTenant("prop", new TenantInfo()); + TenantInfo tenantInfo = createDefaultTenantInfo(); + admin.tenants().createTenant("prop", tenantInfo); admin.topics().createPartitionedTopic(topicName, numberOfPartitions); // Special step to create partitioned topic @@ -476,7 +477,8 @@ public void testSharedSingleAckedPartitionedTopic() throws Exception { final String messagePredicate = "my-message-" + key + "-"; final int totalMessages = 10; final int numberOfPartitions = 3; - admin.tenants().createTenant("prop", new TenantInfo()); + TenantInfo tenantInfo = createDefaultTenantInfo(); + admin.tenants().createTenant("prop", tenantInfo); admin.topics().createPartitionedTopic(topicName, numberOfPartitions); Random rn = new Random(); // Special step to create partitioned topic @@ -576,7 +578,8 @@ public void testFailoverSingleAckedPartitionedTopic() throws Exception { final String messagePredicate = "my-message-" + key + "-"; final int totalMessages = 10; final int numberOfPartitions = 3; - admin.tenants().createTenant("prop", new TenantInfo()); + TenantInfo tenantInfo = createDefaultTenantInfo(); + admin.tenants().createTenant("prop", tenantInfo); admin.topics().createPartitionedTopic(topicName, numberOfPartitions); Random rn = new Random(); // Special step to create partitioned topic diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/web/WebServiceTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/web/WebServiceTest.java index 591176dd544fa..fb427473ea3e2 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/web/WebServiceTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/web/WebServiceTest.java @@ -22,6 +22,7 @@ import static org.mockito.Mockito.spy; import static org.testng.Assert.assertEquals; +import com.google.common.collect.Sets; import com.google.common.io.CharStreams; import com.google.common.io.Closeables; @@ -70,6 +71,7 @@ import org.apache.pulsar.common.util.SecurityUtility; import org.apache.pulsar.zookeeper.MockedZooKeeperClientFactoryImpl; import org.apache.zookeeper.CreateMode; +import org.apache.zookeeper.ZooDefs; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.Assert; @@ -228,8 +230,14 @@ public void testMaxRequestSize() throws Exception { // This should have failed assertEquals(response.getStatusLine().getStatusCode(), 400); + // Create local cluster + String localCluster = "test"; + String clusterPath = PulsarWebResource.path("clusters", localCluster); + byte[] content = ObjectMapperFactory.getThreadLocal().writeValueAsBytes(new ClusterData()); + pulsar.getGlobalZkCache().getZooKeeper().create(clusterPath, content, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT); TenantInfo info2 = new TenantInfo(); info2.setAdminRoles(Collections.singleton(StringUtils.repeat("*", 1 * 1024))); + info2.setAllowedClusters(Sets.newHashSet(localCluster)); httpPut.setEntity(new ByteArrayEntity(ObjectMapperFactory.getThreadLocal().writeValueAsBytes(info2))); response = client.execute(httpPut); diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/PatternTopicsConsumerImplTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/PatternTopicsConsumerImplTest.java index ff51d74cef7b3..b14c1cd466090 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/PatternTopicsConsumerImplTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/PatternTopicsConsumerImplTest.java @@ -84,7 +84,8 @@ public void testPatternTopicsSubscribeWithBuilderFail() throws Exception { final String patternString = "persistent://my-property/my-ns/pattern-topic.*"; Pattern pattern = Pattern.compile(patternString); - admin.tenants().createTenant("prop", new TenantInfo()); + TenantInfo tenantInfo = createDefaultTenantInfo(); + admin.tenants().createTenant("prop", tenantInfo); admin.topics().createPartitionedTopic(topicName2, 2); admin.topics().createPartitionedTopic(topicName3, 3); @@ -143,7 +144,8 @@ public void testBinaryProtoToGetTopicsOfNamespacePersistent() throws Exception { Pattern pattern = Pattern.compile("my-property/my-ns/pattern-topic.*"); // 1. create partition - admin.tenants().createTenant("prop", new TenantInfo()); + TenantInfo tenantInfo = createDefaultTenantInfo(); + admin.tenants().createTenant("prop", tenantInfo); admin.topics().createPartitionedTopic(topicName2, 2); admin.topics().createPartitionedTopic(topicName3, 3); @@ -234,7 +236,8 @@ public void testBinaryProtoToGetTopicsOfNamespaceNonPersistent() throws Exceptio Pattern pattern = Pattern.compile("my-property/my-ns/np-pattern-topic.*"); // 1. create partition - admin.tenants().createTenant("prop", new TenantInfo()); + TenantInfo tenantInfo = createDefaultTenantInfo(); + admin.tenants().createTenant("prop", tenantInfo); admin.topics().createPartitionedTopic(topicName2, 2); admin.topics().createPartitionedTopic(topicName3, 3); @@ -324,7 +327,8 @@ public void testBinaryProtoToGetTopicsOfNamespaceAll() throws Exception { Pattern pattern = Pattern.compile("my-property/my-ns/pattern-topic.*"); // 1. create partition - admin.tenants().createTenant("prop", new TenantInfo()); + TenantInfo tenantInfo = createDefaultTenantInfo(); + admin.tenants().createTenant("prop", tenantInfo); admin.topics().createPartitionedTopic(topicName2, 2); admin.topics().createPartitionedTopic(topicName3, 3); @@ -473,7 +477,8 @@ public void testStartEmptyPatternConsumer() throws Exception { Pattern pattern = Pattern.compile("persistent://my-property/my-ns/pattern-topic.*"); // 1. create partition - admin.tenants().createTenant("prop", new TenantInfo()); + TenantInfo tenantInfo = createDefaultTenantInfo(); + admin.tenants().createTenant("prop", tenantInfo); admin.topics().createPartitionedTopic(topicName2, 2); admin.topics().createPartitionedTopic(topicName3, 3); @@ -560,7 +565,8 @@ public void testAutoSubscribePatternConsumer() throws Exception { Pattern pattern = Pattern.compile("persistent://my-property/my-ns/pattern-topic.*"); // 1. create partition - admin.tenants().createTenant("prop", new TenantInfo()); + TenantInfo tenantInfo = createDefaultTenantInfo(); + admin.tenants().createTenant("prop", tenantInfo); admin.topics().createPartitionedTopic(topicName2, 2); admin.topics().createPartitionedTopic(topicName3, 3); @@ -668,7 +674,8 @@ public void testAutoUnbubscribePatternConsumer() throws Exception { Pattern pattern = Pattern.compile("persistent://my-property/my-ns/pattern-topic.*"); // 1. create partition - admin.tenants().createTenant("prop", new TenantInfo()); + TenantInfo tenantInfo = createDefaultTenantInfo(); + admin.tenants().createTenant("prop", tenantInfo); admin.topics().createPartitionedTopic(topicName2, 2); admin.topics().createPartitionedTopic(topicName3, 3); diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/PerMessageUnAcknowledgedRedeliveryTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/PerMessageUnAcknowledgedRedeliveryTest.java index 508de46482db0..8b91af6f87fd7 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/PerMessageUnAcknowledgedRedeliveryTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/PerMessageUnAcknowledgedRedeliveryTest.java @@ -403,7 +403,8 @@ public void testSharedAckedPartitionedTopic() throws Exception { final String messagePredicate = "my-message-" + key + "-"; final int totalMessages = 15; final int numberOfPartitions = 3; - admin.tenants().createTenant("prop", new TenantInfo()); + TenantInfo tenantInfo = createDefaultTenantInfo(); + admin.tenants().createTenant("prop", tenantInfo); admin.topics().createPartitionedTopic(topicName, numberOfPartitions); // 1. producer connect diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/TopicsConsumerImplTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/TopicsConsumerImplTest.java index 0d693663b76fc..c823e608dbe7d 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/TopicsConsumerImplTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/TopicsConsumerImplTest.java @@ -88,7 +88,8 @@ public void testDifferentTopicsNameSubscribe() throws Exception { final String topicName3 = "persistent://prop/use/ns-abc3/topic-3-" + key; List topicNames = Lists.newArrayList(topicName1, topicName2, topicName3); - admin.tenants().createTenant("prop", new TenantInfo()); + TenantInfo tenantInfo = createDefaultTenantInfo(); + admin.tenants().createTenant("prop", tenantInfo); admin.topics().createPartitionedTopic(topicName2, 2); admin.topics().createPartitionedTopic(topicName3, 3); @@ -116,7 +117,8 @@ public void testGetConsumersAndGetTopics() throws Exception { final String topicName3 = "persistent://prop/use/ns-abc/topic-3-" + key; List topicNames = Lists.newArrayList(topicName1, topicName2); - admin.tenants().createTenant("prop", new TenantInfo()); + TenantInfo tenantInfo = createDefaultTenantInfo(); + admin.tenants().createTenant("prop", tenantInfo); admin.topics().createPartitionedTopic(topicName2, 2); admin.topics().createPartitionedTopic(topicName3, 3); @@ -159,7 +161,8 @@ public void testSyncProducerAndConsumer() throws Exception { final String topicName3 = "persistent://prop/use/ns-abc/topic-3-" + key; List topicNames = Lists.newArrayList(topicName1, topicName2, topicName3); - admin.tenants().createTenant("prop", new TenantInfo()); + TenantInfo tenantInfo = createDefaultTenantInfo(); + admin.tenants().createTenant("prop", tenantInfo); admin.topics().createPartitionedTopic(topicName2, 2); admin.topics().createPartitionedTopic(topicName3, 3); @@ -224,7 +227,8 @@ public void testAsyncConsumer() throws Exception { final String topicName3 = "persistent://prop/use/ns-abc/topic-3-" + key; List topicNames = Lists.newArrayList(topicName1, topicName2, topicName3); - admin.tenants().createTenant("prop", new TenantInfo()); + TenantInfo tenantInfo = createDefaultTenantInfo(); + admin.tenants().createTenant("prop", tenantInfo); admin.topics().createPartitionedTopic(topicName2, 2); admin.topics().createPartitionedTopic(topicName3, 3); @@ -308,7 +312,8 @@ public void testConsumerUnackedRedelivery() throws Exception { final String topicName3 = "persistent://prop/use/ns-abc/topic-3-" + key; List topicNames = Lists.newArrayList(topicName1, topicName2, topicName3); - admin.tenants().createTenant("prop", new TenantInfo()); + TenantInfo tenantInfo = createDefaultTenantInfo(); + admin.tenants().createTenant("prop", tenantInfo); admin.topics().createPartitionedTopic(topicName2, 2); admin.topics().createPartitionedTopic(topicName3, 3); @@ -451,7 +456,8 @@ public void testSubscribeUnsubscribeSingleTopic() throws Exception { final String topicName3 = "persistent://prop/use/ns-abc/topic-3-" + key; List topicNames = Lists.newArrayList(topicName1, topicName2, topicName3); - admin.tenants().createTenant("prop", new TenantInfo()); + TenantInfo tenantInfo = createDefaultTenantInfo(); + admin.tenants().createTenant("prop", tenantInfo); admin.topics().createPartitionedTopic(topicName2, 2); admin.topics().createPartitionedTopic(topicName3, 3); @@ -575,7 +581,8 @@ public void testTopicsNameSubscribeWithBuilderFail() throws Exception { final String topicName2 = "persistent://prop/use/ns-abc/topic-2-" + key; final String topicName3 = "persistent://prop/use/ns-abc/topic-3-" + key; - admin.tenants().createTenant("prop", new TenantInfo()); + TenantInfo tenantInfo = createDefaultTenantInfo(); + admin.tenants().createTenant("prop", tenantInfo); admin.topics().createPartitionedTopic(topicName2, 2); admin.topics().createPartitionedTopic(topicName3, 3); @@ -644,7 +651,8 @@ public void testMultiTopicsMessageListener() throws Exception { final String topicName1 = "persistent://prop/use/ns-abc/topic-1-" + key; List topicNames = Lists.newArrayList(topicName1); - admin.tenants().createTenant("prop", new TenantInfo()); + TenantInfo tenantInfo = createDefaultTenantInfo(); + admin.tenants().createTenant("prop", tenantInfo); admin.topics().createPartitionedTopic(topicName1, 2); // 1. producer connect @@ -707,7 +715,8 @@ public void testTopicAutoUpdatePartitions() throws Exception { final String topicName2 = "persistent://prop/use/ns-abc/topic-2-" + key; List topicNames = Lists.newArrayList(topicName1, topicName2); - admin.tenants().createTenant("prop", new TenantInfo()); + TenantInfo tenantInfo = createDefaultTenantInfo(); + admin.tenants().createTenant("prop", tenantInfo); admin.topics().createPartitionedTopic(topicName1, 2); admin.topics().createPartitionedTopic(topicName2, 2); @@ -811,7 +820,8 @@ public void testGetLastMessageId() throws Exception { final String topicName3 = "persistent://prop/use/ns-abc/topic-3-" + key; List topicNames = Lists.newArrayList(topicName1, topicName2, topicName3); - admin.tenants().createTenant("prop", new TenantInfo()); + TenantInfo tenantInfo = createDefaultTenantInfo(); + admin.tenants().createTenant("prop", tenantInfo); admin.topics().createPartitionedTopic(topicName2, 2); admin.topics().createPartitionedTopic(topicName3, 3); diff --git a/pulsar-client-tools-test/src/test/java/org/apache/pulsar/client/cli/PulsarClientToolTest.java b/pulsar-client-tools-test/src/test/java/org/apache/pulsar/client/cli/PulsarClientToolTest.java index bac300aebcf74..21b71eb042755 100644 --- a/pulsar-client-tools-test/src/test/java/org/apache/pulsar/client/cli/PulsarClientToolTest.java +++ b/pulsar-client-tools-test/src/test/java/org/apache/pulsar/client/cli/PulsarClientToolTest.java @@ -29,7 +29,6 @@ import org.apache.pulsar.broker.service.BrokerTestBase; import org.apache.pulsar.client.admin.PulsarAdminException; -import org.apache.pulsar.client.cli.PulsarClientTool; import org.apache.pulsar.common.policies.data.TenantInfo; import org.testng.Assert; import org.testng.annotations.AfterClass; @@ -60,7 +59,8 @@ public void testInitialzation() throws MalformedURLException, InterruptedExcepti String tenantName = UUID.randomUUID().toString(); - admin.tenants().createTenant(tenantName, new TenantInfo()); + TenantInfo tenantInfo = createDefaultTenantInfo(); + admin.tenants().createTenant(tenantName, tenantInfo); String topicName = String.format("persistent://%s/ns/topic-scale-ns-0/topic", tenantName); diff --git a/pulsar-proxy/src/test/java/org/apache/pulsar/proxy/server/ProxyParserTest.java b/pulsar-proxy/src/test/java/org/apache/pulsar/proxy/server/ProxyParserTest.java index 7ae6cc03a00c5..3557441d80612 100644 --- a/pulsar-proxy/src/test/java/org/apache/pulsar/proxy/server/ProxyParserTest.java +++ b/pulsar-proxy/src/test/java/org/apache/pulsar/proxy/server/ProxyParserTest.java @@ -141,7 +141,8 @@ public void testProducerConsumer() throws Exception { @Test public void testPartitions() throws Exception { - admin.tenants().createTenant("sample", new TenantInfo()); + TenantInfo tenantInfo = createDefaultTenantInfo(); + admin.tenants().createTenant("sample", tenantInfo); PulsarClient client = PulsarClient.builder().serviceUrl(proxyService.getServiceUrl()) .build(); admin.topics().createPartitionedTopic("persistent://sample/test/local/partitioned-topic", 2); diff --git a/pulsar-proxy/src/test/java/org/apache/pulsar/proxy/server/ProxyTest.java b/pulsar-proxy/src/test/java/org/apache/pulsar/proxy/server/ProxyTest.java index eb5a32e32720e..7b308d198e401 100644 --- a/pulsar-proxy/src/test/java/org/apache/pulsar/proxy/server/ProxyTest.java +++ b/pulsar-proxy/src/test/java/org/apache/pulsar/proxy/server/ProxyTest.java @@ -161,7 +161,8 @@ public void testProducerConsumer() throws Exception { @Test public void testPartitions() throws Exception { - admin.tenants().createTenant("sample", new TenantInfo()); + TenantInfo tenantInfo = createDefaultTenantInfo(); + admin.tenants().createTenant("sample", tenantInfo); @Cleanup PulsarClient client = PulsarClient.builder().serviceUrl(proxyService.getServiceUrl()) .build(); diff --git a/pulsar-proxy/src/test/java/org/apache/pulsar/proxy/server/ProxyTlsTest.java b/pulsar-proxy/src/test/java/org/apache/pulsar/proxy/server/ProxyTlsTest.java index 7fdd9fd95bf87..847e6a569ca6e 100644 --- a/pulsar-proxy/src/test/java/org/apache/pulsar/proxy/server/ProxyTlsTest.java +++ b/pulsar-proxy/src/test/java/org/apache/pulsar/proxy/server/ProxyTlsTest.java @@ -98,7 +98,8 @@ public void testPartitions() throws Exception { PulsarClient client = PulsarClient.builder() .serviceUrl(proxyService.getServiceUrlTls()) .allowTlsInsecureConnection(false).tlsTrustCertsFilePath(TLS_TRUST_CERT_FILE_PATH).build(); - admin.tenants().createTenant("sample", new TenantInfo()); + TenantInfo tenantInfo = createDefaultTenantInfo(); + admin.tenants().createTenant("sample", tenantInfo); admin.topics().createPartitionedTopic("persistent://sample/test/local/partitioned-topic", 2); Producer producer = client.newProducer(Schema.BYTES).topic("persistent://sample/test/local/partitioned-topic")