Search in sources :

Example 1 with MetadataCacheImpl

use of org.apache.pulsar.metadata.cache.impl.MetadataCacheImpl in project pulsar by apache.

the class NamespacesTest method testGetNamespaces.

@Test
public void testGetNamespaces() throws Exception {
    List<String> expectedList = Lists.newArrayList(this.testLocalNamespaces.get(0).toString(), this.testLocalNamespaces.get(1).toString());
    expectedList.sort(null);
    assertEquals(namespaces.getNamespacesForCluster(this.testTenant, this.testLocalCluster), expectedList);
    expectedList = Lists.newArrayList(this.testLocalNamespaces.get(0).toString(), this.testLocalNamespaces.get(1).toString(), this.testLocalNamespaces.get(2).toString(), this.testGlobalNamespaces.get(0).toString());
    expectedList.sort(null);
    assertEquals(namespaces.getTenantNamespaces(this.testTenant), expectedList);
    try {
        // check the tenant name is valid
        namespaces.getTenantNamespaces(this.testTenant + "/default");
        fail("should have failed");
    } catch (RestException e) {
        assertEquals(e.getResponse().getStatus(), Status.PRECONDITION_FAILED.getStatusCode());
    }
    try {
        namespaces.getTenantNamespaces("non-existing-tenant");
        fail("should have failed");
    } catch (RestException e) {
    // Ok, does not exist
    }
    try {
        namespaces.getNamespacesForCluster(this.testTenant, "other-cluster");
        fail("should have failed");
    } catch (RestException e) {
    // Ok, does not exist
    }
    // ZK Errors
    mockZooKeeperGlobal.failConditional(Code.SESSIONEXPIRED, (op, path) -> {
        return op == MockZooKeeper.Op.GET_CHILDREN && path.equals("/admin/policies/my-tenant");
    });
    // clear caches to load data from metadata-store again
    MetadataCacheImpl<TenantInfo> tenantCache = (MetadataCacheImpl<TenantInfo>) pulsar.getPulsarResources().getTenantResources().getCache();
    AbstractMetadataStore store = (AbstractMetadataStore) tenantCache.getStore();
    tenantCache.invalidateAll();
    store.invalidateAll();
    try {
        namespaces.getTenantNamespaces(this.testTenant);
        fail("should have failed");
    } catch (RestException e) {
    // Ok
    }
    mockZooKeeperGlobal.failConditional(Code.SESSIONEXPIRED, (op, path) -> {
        return op == MockZooKeeper.Op.GET_CHILDREN && path.equals("/admin/policies/my-tenant/use");
    });
    try {
        namespaces.getNamespacesForCluster(this.testTenant, this.testLocalCluster);
        fail("should have failed");
    } catch (RestException e) {
    // Ok
    }
}
Also used : AbstractMetadataStore(org.apache.pulsar.metadata.impl.AbstractMetadataStore) RestException(org.apache.pulsar.broker.web.RestException) TenantInfo(org.apache.pulsar.common.policies.data.TenantInfo) MetadataCacheImpl(org.apache.pulsar.metadata.cache.impl.MetadataCacheImpl) Test(org.testng.annotations.Test) MockedPulsarServiceBaseTest(org.apache.pulsar.broker.auth.MockedPulsarServiceBaseTest)

Example 2 with MetadataCacheImpl

use of org.apache.pulsar.metadata.cache.impl.MetadataCacheImpl in project pulsar by apache.

the class AdminTest method clusters.

@Test
public void clusters() throws Exception {
    assertEquals(clusters.getClusters(), Lists.newArrayList());
    verify(clusters, never()).validateSuperUserAccess();
    clusters.createCluster("use", ClusterDataImpl.builder().serviceUrl("http://broker.messaging.use.example.com:8080").build());
    verify(clusters, times(1)).validateSuperUserAccess();
    // ensure to read from ZooKeeper directly
    // clusters.clustersListCache().clear();
    assertEquals(clusters.getClusters(), Lists.newArrayList("use"));
    // Check creating existing cluster
    try {
        clusters.createCluster("use", ClusterDataImpl.builder().serviceUrl("http://broker.messaging.use.example.com:8080").build());
        fail("should have failed");
    } catch (RestException e) {
        assertEquals(e.getResponse().getStatus(), Status.CONFLICT.getStatusCode());
    }
    // Check deleting non-existing cluster
    try {
        clusters.deleteCluster("usc");
        fail("should have failed");
    } catch (RestException e) {
        assertEquals(e.getResponse().getStatus(), Status.NOT_FOUND.getStatusCode());
    }
    assertEquals(clusters.getCluster("use"), ClusterDataImpl.builder().serviceUrl("http://broker.messaging.use.example.com:8080").build());
    verify(clusters, times(4)).validateSuperUserAccess();
    clusters.updateCluster("use", ClusterDataImpl.builder().serviceUrl("http://new-broker.messaging.use.example.com:8080").build());
    verify(clusters, times(5)).validateSuperUserAccess();
    assertEquals(clusters.getCluster("use"), ClusterData.builder().serviceUrl("http://new-broker.messaging.use.example.com:8080").build());
    verify(clusters, times(6)).validateSuperUserAccess();
    try {
        clusters.getNamespaceIsolationPolicies("use");
        fail("should have failed");
    } catch (RestException e) {
        assertEquals(e.getResponse().getStatus(), 404);
    }
    Map<String, String> parameters1 = new HashMap<>();
    parameters1.put("min_limit", "1");
    parameters1.put("usage_threshold", "90");
    NamespaceIsolationDataImpl policyData = NamespaceIsolationDataImpl.builder().namespaces(Collections.singletonList("dummy/colo/ns")).primary(Collections.singletonList("localhost" + ":" + pulsar.getListenPortHTTP())).autoFailoverPolicy(AutoFailoverPolicyData.builder().policyType(AutoFailoverPolicyType.min_available).parameters(parameters1).build()).build();
    AsyncResponse response = mock(AsyncResponse.class);
    clusters.setNamespaceIsolationPolicy(response, "use", "policy1", policyData);
    clusters.getNamespaceIsolationPolicies("use");
    try {
        clusters.deleteCluster("use");
        fail("should have failed");
    } catch (RestException e) {
        assertEquals(e.getResponse().getStatus(), 412);
    }
    clusters.deleteNamespaceIsolationPolicy("use", "policy1");
    assertTrue(clusters.getNamespaceIsolationPolicies("use").isEmpty());
    clusters.deleteCluster("use");
    verify(clusters, times(13)).validateSuperUserAccess();
    assertEquals(clusters.getClusters(), Lists.newArrayList());
    try {
        clusters.getCluster("use");
        fail("should have failed");
    } catch (RestException e) {
        assertEquals(e.getResponse().getStatus(), 404);
    }
    try {
        clusters.updateCluster("use", ClusterDataImpl.builder().build());
        fail("should have failed");
    } catch (RestException e) {
        assertEquals(e.getResponse().getStatus(), 404);
    }
    try {
        clusters.getNamespaceIsolationPolicies("use");
        fail("should have failed");
    } catch (RestException e) {
        assertEquals(e.getResponse().getStatus(), 404);
    }
    // Test zk failures
    mockZooKeeperGlobal.failConditional(Code.SESSIONEXPIRED, (op, path) -> {
        return op == MockZooKeeper.Op.GET_CHILDREN && path.equals("/admin/clusters");
    });
    // clear caches to load data from metadata-store again
    MetadataCacheImpl<ClusterData> clusterCache = (MetadataCacheImpl<ClusterData>) pulsar.getPulsarResources().getClusterResources().getCache();
    MetadataCacheImpl isolationPolicyCache = (MetadataCacheImpl) pulsar.getPulsarResources().getNamespaceResources().getIsolationPolicies().getCache();
    AbstractMetadataStore store = (AbstractMetadataStore) clusterCache.getStore();
    clusterCache.invalidateAll();
    store.invalidateAll();
    try {
        clusters.getClusters();
        fail("should have failed");
    } catch (RestException e) {
        assertEquals(e.getResponse().getStatus(), Status.INTERNAL_SERVER_ERROR.getStatusCode());
    }
    mockZooKeeperGlobal.failConditional(Code.SESSIONEXPIRED, (op, path) -> {
        return op == MockZooKeeper.Op.CREATE && path.equals("/admin/clusters/test");
    });
    try {
        clusters.createCluster("test", ClusterDataImpl.builder().serviceUrl("http://broker.messaging.test.example.com:8080").build());
        fail("should have failed");
    } catch (RestException e) {
        assertEquals(e.getResponse().getStatus(), Status.INTERNAL_SERVER_ERROR.getStatusCode());
    }
    mockZooKeeperGlobal.failConditional(Code.SESSIONEXPIRED, (op, path) -> {
        return op == MockZooKeeper.Op.GET && path.equals("/admin/clusters/test");
    });
    clusterCache.invalidateAll();
    store.invalidateAll();
    try {
        clusters.updateCluster("test", ClusterDataImpl.builder().serviceUrl("http://broker.messaging.test.example.com").build());
        fail("should have failed");
    } catch (RestException e) {
        assertEquals(e.getResponse().getStatus(), Status.INTERNAL_SERVER_ERROR.getStatusCode());
    }
    mockZooKeeperGlobal.failConditional(Code.SESSIONEXPIRED, (op, path) -> {
        return op == MockZooKeeper.Op.GET && path.equals("/admin/clusters/test");
    });
    try {
        clusters.getCluster("test");
        fail("should have failed");
    } catch (RestException e) {
        assertEquals(e.getResponse().getStatus(), Status.INTERNAL_SERVER_ERROR.getStatusCode());
    }
    mockZooKeeperGlobal.failConditional(Code.SESSIONEXPIRED, (op, path) -> {
        return op == MockZooKeeper.Op.GET_CHILDREN && path.equals("/admin/policies");
    });
    try {
        clusters.deleteCluster("use");
        fail("should have failed");
    } catch (RestException e) {
        assertEquals(e.getResponse().getStatus(), Status.INTERNAL_SERVER_ERROR.getStatusCode());
    }
    mockZooKeeperGlobal.failConditional(Code.SESSIONEXPIRED, (op, path) -> {
        return op == MockZooKeeper.Op.GET && path.equals("/admin/clusters/use/namespaceIsolationPolicies");
    });
    clusterCache.invalidateAll();
    isolationPolicyCache.invalidateAll();
    store.invalidateAll();
    try {
        clusters.deleteCluster("use");
        fail("should have failed");
    } catch (RestException e) {
        assertEquals(e.getResponse().getStatus(), Status.INTERNAL_SERVER_ERROR.getStatusCode());
    }
    // Check name validations
    try {
        clusters.createCluster("bf@", ClusterDataImpl.builder().serviceUrl("http://dummy.messaging.example.com").build());
        fail("should have filed");
    } catch (RestException e) {
        assertEquals(e.getResponse().getStatus(), Status.PRECONDITION_FAILED.getStatusCode());
    }
    // Check authentication and listener name
    try {
        clusters.createCluster("auth", ClusterDataImpl.builder().serviceUrl("http://dummy.web.example.com").serviceUrlTls("").brokerServiceUrl("http://dummy.messaging.example.com").brokerServiceUrlTls("").authenticationPlugin("authenticationPlugin").authenticationParameters("authenticationParameters").listenerName("listenerName").build());
        ClusterData cluster = clusters.getCluster("auth");
        assertEquals(cluster.getAuthenticationPlugin(), "authenticationPlugin");
        assertEquals(cluster.getAuthenticationParameters(), "authenticationParameters");
        assertEquals(cluster.getListenerName(), "listenerName");
    } catch (RestException e) {
        assertEquals(e.getResponse().getStatus(), Status.PRECONDITION_FAILED.getStatusCode());
    }
}
Also used : ClusterData(org.apache.pulsar.common.policies.data.ClusterData) AbstractMetadataStore(org.apache.pulsar.metadata.impl.AbstractMetadataStore) HashMap(java.util.HashMap) RestException(org.apache.pulsar.broker.web.RestException) MetadataCacheImpl(org.apache.pulsar.metadata.cache.impl.MetadataCacheImpl) NamespaceIsolationDataImpl(org.apache.pulsar.common.policies.data.NamespaceIsolationDataImpl) AsyncResponse(javax.ws.rs.container.AsyncResponse) Test(org.testng.annotations.Test) MockedPulsarServiceBaseTest(org.apache.pulsar.broker.auth.MockedPulsarServiceBaseTest)

Example 3 with MetadataCacheImpl

use of org.apache.pulsar.metadata.cache.impl.MetadataCacheImpl in project pulsar by apache.

the class MetadataCacheTest method crossStoreUpdates.

@Test(dataProvider = "zk")
public void crossStoreUpdates(String provider, Supplier<String> urlSupplier) throws Exception {
    String testName = "cross store updates";
    @Cleanup MetadataStore store1 = MetadataStoreFactory.create(urlSupplier.get(), MetadataStoreConfig.builder().build());
    @Cleanup MetadataStore store2 = MetadataStoreFactory.create(urlSupplier.get(), MetadataStoreConfig.builder().build());
    MetadataCacheImpl<MyClass> objCache1 = (MetadataCacheImpl<MyClass>) store1.getMetadataCache(MyClass.class);
    MetadataCacheImpl<MyClass> objCache2 = (MetadataCacheImpl<MyClass>) store2.getMetadataCache(MyClass.class);
    AtomicReference<MyClass> storeObj = new AtomicReference<MyClass>();
    store2.registerListener(n -> {
        if (n.getType() == NotificationType.Modified) {
            CompletableFuture.runAsync(() -> {
                try {
                    MyClass obj = objCache2.get(n.getPath()).get().get();
                    storeObj.set(obj);
                } catch (Exception e) {
                    log.error("Got exception {}", e.getMessage());
                }
            });
        }
    });
    String key1 = "/test-key1";
    assertEquals(objCache1.getIfCached(key1), Optional.empty());
    assertEquals(objCache2.getIfCached(key1), Optional.empty());
    MyClass value1 = new MyClass(testName, 1);
    objCache1.create(key1, value1).join();
    Awaitility.await().ignoreNoExceptions().untilAsserted(() -> {
        assertEquals(objCache1.getIfCached(key1), Optional.of(value1));
        assertEquals(objCache2.get(key1).join(), Optional.of(value1));
        assertEquals(objCache2.getIfCached(key1), Optional.of(value1));
    });
    MyClass value2 = new MyClass(testName, 2);
    objCache1.readModifyUpdate(key1, (oldData) -> value2).join();
    Awaitility.await().ignoreNoExceptions().untilAsserted(() -> assertEquals(storeObj.get(), value2));
}
Also used : MetadataStore(org.apache.pulsar.metadata.api.MetadataStore) DataProvider(org.testng.annotations.DataProvider) ObjectMapperFactory(org.apache.pulsar.common.util.ObjectMapperFactory) Assert.assertEquals(org.testng.Assert.assertEquals) Cleanup(lombok.Cleanup) MetadataStore(org.apache.pulsar.metadata.api.MetadataStore) CompletableFuture(java.util.concurrent.CompletableFuture) Test(org.testng.annotations.Test) CacheGetResult(org.apache.pulsar.metadata.api.CacheGetResult) MetadataCacheImpl(org.apache.pulsar.metadata.cache.impl.MetadataCacheImpl) AtomicReference(java.util.concurrent.atomic.AtomicReference) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) MetadataCache(org.apache.pulsar.metadata.api.MetadataCache) Assert.assertNotSame(org.testng.Assert.assertNotSame) MetadataSerde(org.apache.pulsar.metadata.api.MetadataSerde) Map(java.util.Map) JsonIgnore(com.fasterxml.jackson.annotation.JsonIgnore) TypeReference(com.fasterxml.jackson.core.type.TypeReference) Assert.assertSame(org.testng.Assert.assertSame) Stat(org.apache.pulsar.metadata.api.Stat) Assert.assertNotEquals(org.testng.Assert.assertNotEquals) AlreadyExistsException(org.apache.pulsar.metadata.api.MetadataStoreException.AlreadyExistsException) Predicate(java.util.function.Predicate) Assert.fail(org.testng.Assert.fail) IOException(java.io.IOException) CompletionException(java.util.concurrent.CompletionException) MetadataStoreConfig(org.apache.pulsar.metadata.api.MetadataStoreConfig) StandardCharsets(java.nio.charset.StandardCharsets) ContentDeserializationException(org.apache.pulsar.metadata.api.MetadataStoreException.ContentDeserializationException) Policies(org.apache.pulsar.common.policies.data.Policies) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) TreeMap(java.util.TreeMap) NotFoundException(org.apache.pulsar.metadata.api.MetadataStoreException.NotFoundException) NotificationType(org.apache.pulsar.metadata.api.NotificationType) Data(lombok.Data) Assert.assertTrue(org.testng.Assert.assertTrue) Optional(java.util.Optional) AllArgsConstructor(lombok.AllArgsConstructor) Awaitility(org.awaitility.Awaitility) NoArgsConstructor(lombok.NoArgsConstructor) MetadataStoreFactory(org.apache.pulsar.metadata.api.MetadataStoreFactory) MetadataCacheImpl(org.apache.pulsar.metadata.cache.impl.MetadataCacheImpl) AtomicReference(java.util.concurrent.atomic.AtomicReference) Cleanup(lombok.Cleanup) AlreadyExistsException(org.apache.pulsar.metadata.api.MetadataStoreException.AlreadyExistsException) IOException(java.io.IOException) CompletionException(java.util.concurrent.CompletionException) ContentDeserializationException(org.apache.pulsar.metadata.api.MetadataStoreException.ContentDeserializationException) NotFoundException(org.apache.pulsar.metadata.api.MetadataStoreException.NotFoundException) Test(org.testng.annotations.Test)

Example 4 with MetadataCacheImpl

use of org.apache.pulsar.metadata.cache.impl.MetadataCacheImpl in project pulsar by yahoo.

the class AdminTest method clusters.

@Test
@SuppressWarnings("unchecked")
public void clusters() throws Exception {
    assertEquals(asyncRequests(ctx -> clusters.getClusters(ctx)), Sets.newHashSet());
    verify(clusters, never()).validateSuperUserAccessAsync();
    asyncRequests(ctx -> clusters.createCluster(ctx, "use", ClusterDataImpl.builder().serviceUrl("http://broker.messaging.use.example.com:8080").build()));
    // ensure to read from ZooKeeper directly
    // clusters.clustersListCache().clear();
    assertEquals(asyncRequests(ctx -> clusters.getClusters(ctx)), Sets.newHashSet("use"));
    // Check creating existing cluster
    try {
        asyncRequests(ctx -> clusters.createCluster(ctx, "use", ClusterDataImpl.builder().serviceUrl("http://broker.messaging.use.example.com:8080").build()));
        fail("should have failed");
    } catch (RestException e) {
        assertEquals(e.getResponse().getStatus(), Status.CONFLICT.getStatusCode());
    }
    // Check deleting non-existing cluster
    try {
        asyncRequests(ctx -> clusters.deleteCluster(ctx, "usc"));
        fail("should have failed");
    } catch (RestException e) {
        assertEquals(e.getResponse().getStatus(), Status.NOT_FOUND.getStatusCode());
    }
    assertEquals(asyncRequests(ctx -> clusters.getCluster(ctx, "use")), ClusterDataImpl.builder().serviceUrl("http://broker.messaging.use.example.com:8080").build());
    asyncRequests(ctx -> clusters.updateCluster(ctx, "use", ClusterDataImpl.builder().serviceUrl("http://new-broker.messaging.use.example.com:8080").build()));
    assertEquals(asyncRequests(ctx -> clusters.getCluster(ctx, "use")), ClusterData.builder().serviceUrl("http://new-broker.messaging.use.example.com:8080").build());
    try {
        asyncRequests(ctx -> clusters.getNamespaceIsolationPolicies(ctx, "use"));
        fail("should have failed");
    } catch (RestException e) {
        assertEquals(e.getResponse().getStatus(), 404);
    }
    Map<String, String> parameters1 = new HashMap<>();
    parameters1.put("min_limit", "1");
    parameters1.put("usage_threshold", "90");
    NamespaceIsolationDataImpl policyData = NamespaceIsolationDataImpl.builder().namespaces(Collections.singletonList("dummy/colo/ns")).primary(Collections.singletonList("localhost" + ":" + pulsar.getListenPortHTTP())).autoFailoverPolicy(AutoFailoverPolicyData.builder().policyType(AutoFailoverPolicyType.min_available).parameters(parameters1).build()).build();
    asyncRequests(ctx -> clusters.setNamespaceIsolationPolicy(ctx, "use", "policy1", policyData));
    asyncRequests(ctx -> clusters.getNamespaceIsolationPolicies(ctx, "use"));
    try {
        asyncRequests(ctx -> clusters.deleteCluster(ctx, "use"));
        fail("should have failed");
    } catch (RestException e) {
        assertEquals(e.getResponse().getStatus(), 412);
    }
    asyncRequests(ctx -> clusters.deleteNamespaceIsolationPolicy(ctx, "use", "policy1"));
    assertTrue(((Map<String, NamespaceIsolationDataImpl>) asyncRequests(ctx -> clusters.getNamespaceIsolationPolicies(ctx, "use"))).isEmpty());
    asyncRequests(ctx -> clusters.deleteCluster(ctx, "use"));
    assertEquals(asyncRequests(ctx -> clusters.getClusters(ctx)), Sets.newHashSet());
    try {
        asyncRequests(ctx -> clusters.getCluster(ctx, "use"));
        fail("should have failed");
    } catch (RestException e) {
        assertEquals(e.getResponse().getStatus(), 404);
    }
    try {
        asyncRequests(ctx -> clusters.updateCluster(ctx, "use", ClusterDataImpl.builder().build()));
        fail("should have failed");
    } catch (RestException e) {
        assertEquals(e.getResponse().getStatus(), 404);
    }
    try {
        asyncRequests(ctx -> clusters.getNamespaceIsolationPolicies(ctx, "use"));
        fail("should have failed");
    } catch (RestException e) {
        assertEquals(e.getResponse().getStatus(), 404);
    }
    // Test zk failures
    mockZooKeeperGlobal.failConditional(Code.SESSIONEXPIRED, (op, path) -> {
        return op == MockZooKeeper.Op.GET_CHILDREN && path.equals("/admin/clusters");
    });
    // clear caches to load data from metadata-store again
    MetadataCacheImpl<ClusterData> clusterCache = (MetadataCacheImpl<ClusterData>) pulsar.getPulsarResources().getClusterResources().getCache();
    MetadataCacheImpl isolationPolicyCache = (MetadataCacheImpl) pulsar.getPulsarResources().getNamespaceResources().getIsolationPolicies().getCache();
    AbstractMetadataStore store = (AbstractMetadataStore) clusterCache.getStore();
    clusterCache.invalidateAll();
    store.invalidateAll();
    try {
        asyncRequests(ctx -> clusters.getClusters(ctx));
        fail("should have failed");
    } catch (RestException e) {
        assertEquals(e.getResponse().getStatus(), Status.INTERNAL_SERVER_ERROR.getStatusCode());
    }
    mockZooKeeperGlobal.failConditional(Code.SESSIONEXPIRED, (op, path) -> {
        return op == MockZooKeeper.Op.CREATE && path.equals("/admin/clusters/test");
    });
    try {
        asyncRequests(ctx -> clusters.createCluster(ctx, "test", ClusterDataImpl.builder().serviceUrl("http://broker.messaging.test.example.com:8080").build()));
        fail("should have failed");
    } catch (RestException e) {
        assertEquals(e.getResponse().getStatus(), Status.INTERNAL_SERVER_ERROR.getStatusCode());
    }
    mockZooKeeperGlobal.failConditional(Code.SESSIONEXPIRED, (op, path) -> {
        return op == MockZooKeeper.Op.GET && path.equals("/admin/clusters/test");
    });
    clusterCache.invalidateAll();
    store.invalidateAll();
    try {
        asyncRequests(ctx -> clusters.updateCluster(ctx, "test", ClusterDataImpl.builder().serviceUrl("http://broker.messaging.test.example.com").build()));
        fail("should have failed");
    } catch (RestException e) {
        assertEquals(e.getResponse().getStatus(), Status.INTERNAL_SERVER_ERROR.getStatusCode());
    }
    mockZooKeeperGlobal.failConditional(Code.SESSIONEXPIRED, (op, path) -> {
        return op == MockZooKeeper.Op.GET && path.equals("/admin/clusters/test");
    });
    try {
        asyncRequests(ctx -> clusters.getCluster(ctx, "test"));
        fail("should have failed");
    } catch (RestException e) {
        assertEquals(e.getResponse().getStatus(), Status.INTERNAL_SERVER_ERROR.getStatusCode());
    }
    mockZooKeeperGlobal.failConditional(Code.SESSIONEXPIRED, (op, path) -> {
        return op == MockZooKeeper.Op.GET_CHILDREN && path.equals("/admin/policies");
    });
    try {
        asyncRequests(ctx -> clusters.deleteCluster(ctx, "use"));
        fail("should have failed");
    } catch (RestException e) {
        assertEquals(e.getResponse().getStatus(), Status.INTERNAL_SERVER_ERROR.getStatusCode());
    }
    mockZooKeeperGlobal.failConditional(Code.SESSIONEXPIRED, (op, path) -> {
        return op == MockZooKeeper.Op.GET && path.equals("/admin/clusters/use/namespaceIsolationPolicies");
    });
    clusterCache.invalidateAll();
    isolationPolicyCache.invalidateAll();
    store.invalidateAll();
    try {
        asyncRequests(ctx -> clusters.deleteCluster(ctx, "use"));
        fail("should have failed");
    } catch (RestException e) {
        assertEquals(e.getResponse().getStatus(), Status.INTERNAL_SERVER_ERROR.getStatusCode());
    }
    // Check name validations
    try {
        asyncRequests(ctx -> clusters.createCluster(ctx, "bf@", ClusterDataImpl.builder().serviceUrl("http://dummy.messaging.example.com").build()));
        fail("should have filed");
    } catch (RestException e) {
        assertEquals(e.getResponse().getStatus(), Status.PRECONDITION_FAILED.getStatusCode());
    }
    // Check authentication and listener name
    try {
        asyncRequests(ctx -> clusters.createCluster(ctx, "auth", ClusterDataImpl.builder().serviceUrl("http://dummy.web.example.com").serviceUrlTls("").brokerServiceUrl("http://dummy.messaging.example.com").brokerServiceUrlTls("").authenticationPlugin("authenticationPlugin").authenticationParameters("authenticationParameters").listenerName("listenerName").build()));
        ClusterData cluster = (ClusterData) asyncRequests(ctx -> clusters.getCluster(ctx, "auth"));
        assertEquals(cluster.getAuthenticationPlugin(), "authenticationPlugin");
        assertEquals(cluster.getAuthenticationParameters(), "authenticationParameters");
        assertEquals(cluster.getListenerName(), "listenerName");
    } catch (RestException e) {
        assertEquals(e.getResponse().getStatus(), Status.PRECONDITION_FAILED.getStatusCode());
    }
    verify(clusters, times(24)).validateSuperUserAccessAsync();
}
Also used : ClusterDataImpl(org.apache.pulsar.common.policies.data.ClusterDataImpl) Metrics(org.apache.pulsar.common.stats.Metrics) AbstractMetadataStore(org.apache.pulsar.metadata.impl.AbstractMetadataStore) Test(org.testng.annotations.Test) ClusterData(org.apache.pulsar.common.policies.data.ClusterData) MetadataCacheImpl(org.apache.pulsar.metadata.cache.impl.MetadataCacheImpl) BrokerStats(org.apache.pulsar.broker.admin.v1.BrokerStats) AfterMethod(org.testng.annotations.AfterMethod) Namespaces(org.apache.pulsar.broker.admin.v1.Namespaces) AuthenticationDataHttps(org.apache.pulsar.broker.authentication.AuthenticationDataHttps) AuthAction(org.apache.pulsar.common.policies.data.AuthAction) Map(java.util.Map) RestException(org.apache.pulsar.broker.web.RestException) NamespaceName(org.apache.pulsar.common.naming.NamespaceName) URI(java.net.URI) Mockito.doReturn(org.mockito.Mockito.doReturn) Assert.assertFalse(org.testng.Assert.assertFalse) Brokers(org.apache.pulsar.broker.admin.v1.Brokers) PendingBookieOpsStats(org.apache.bookkeeper.mledger.proto.PendingBookieOpsStats) Collection(java.util.Collection) AsyncResponse(javax.ws.rs.container.AsyncResponse) BrokerInfo(org.apache.pulsar.common.policies.data.BrokerInfo) BeforeMethod(org.testng.annotations.BeforeMethod) Set(java.util.Set) PersistentTopics(org.apache.pulsar.broker.admin.v1.PersistentTopics) StreamingOutput(javax.ws.rs.core.StreamingOutput) MockZooKeeper(org.apache.zookeeper.MockZooKeeper) Mockito.doNothing(org.mockito.Mockito.doNothing) Assert.assertNotNull(org.testng.Assert.assertNotNull) WorkerConfig(org.apache.pulsar.functions.worker.WorkerConfig) Sets(com.google.common.collect.Sets) MockedPulsarServiceBaseTest(org.apache.pulsar.broker.auth.MockedPulsarServiceBaseTest) List(java.util.List) SchemasResource(org.apache.pulsar.broker.admin.v2.SchemasResource) Response(javax.ws.rs.core.Response) UriInfo(javax.ws.rs.core.UriInfo) TenantInfoImpl(org.apache.pulsar.common.policies.data.TenantInfoImpl) LeaderBroker(org.apache.pulsar.broker.loadbalance.LeaderBroker) Awaitility(org.awaitility.Awaitility) Mockito.mock(org.mockito.Mockito.mock) Code(org.apache.zookeeper.KeeperException.Code) TopicName(org.apache.pulsar.common.naming.TopicName) NamespaceIsolationDataImpl(org.apache.pulsar.common.policies.data.NamespaceIsolationDataImpl) Properties(org.apache.pulsar.broker.admin.v1.Properties) CommandGetTopicsOfNamespace(org.apache.pulsar.common.api.proto.CommandGetTopicsOfNamespace) Assert.assertEquals(org.testng.Assert.assertEquals) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) NamespaceService(org.apache.pulsar.broker.namespace.NamespaceService) Mockito.spy(org.mockito.Mockito.spy) Mockito.timeout(org.mockito.Mockito.timeout) Lists(com.google.common.collect.Lists) ArgumentCaptor(org.mockito.ArgumentCaptor) Assert.assertNotSame(org.testng.Assert.assertNotSame) Assert(org.testng.Assert) BundlesData(org.apache.pulsar.common.policies.data.BundlesData) Clusters(org.apache.pulsar.broker.admin.v1.Clusters) TenantInfo(org.apache.pulsar.common.policies.data.TenantInfo) Status(javax.ws.rs.core.Response.Status) AllocatorStats(org.apache.pulsar.common.stats.AllocatorStats) ResourceQuota(org.apache.pulsar.common.policies.data.ResourceQuota) PulsarWebResource(org.apache.pulsar.broker.web.PulsarWebResource) AutoFailoverPolicyType(org.apache.pulsar.common.policies.data.AutoFailoverPolicyType) ErrorData(org.apache.pulsar.common.policies.data.ErrorData) ServiceConfiguration(org.apache.pulsar.broker.ServiceConfiguration) LocalBrokerData(org.apache.pulsar.policies.data.loadbalancer.LocalBrokerData) Assert.fail(org.testng.Assert.fail) Mockito.times(org.mockito.Mockito.times) Field(java.lang.reflect.Field) ResourceQuotas(org.apache.pulsar.broker.admin.v1.ResourceQuotas) Mockito.verify(org.mockito.Mockito.verify) Policies(org.apache.pulsar.common.policies.data.Policies) Mockito.never(org.mockito.Mockito.never) ClientConfiguration(org.apache.bookkeeper.conf.ClientConfiguration) InternalConfigurationData(org.apache.pulsar.common.conf.InternalConfigurationData) Assert.assertTrue(org.testng.Assert.assertTrue) Collections(java.util.Collections) AutoFailoverPolicyData(org.apache.pulsar.common.policies.data.AutoFailoverPolicyData) ClusterData(org.apache.pulsar.common.policies.data.ClusterData) AbstractMetadataStore(org.apache.pulsar.metadata.impl.AbstractMetadataStore) HashMap(java.util.HashMap) RestException(org.apache.pulsar.broker.web.RestException) MetadataCacheImpl(org.apache.pulsar.metadata.cache.impl.MetadataCacheImpl) NamespaceIsolationDataImpl(org.apache.pulsar.common.policies.data.NamespaceIsolationDataImpl) Test(org.testng.annotations.Test) MockedPulsarServiceBaseTest(org.apache.pulsar.broker.auth.MockedPulsarServiceBaseTest)

Example 5 with MetadataCacheImpl

use of org.apache.pulsar.metadata.cache.impl.MetadataCacheImpl in project pulsar by yahoo.

the class AdminTest method properties.

@Test
public void properties() throws Throwable {
    Object response = asyncRequests(ctx -> properties.getTenants(ctx));
    assertEquals(response, Lists.newArrayList());
    verify(properties, times(1)).validateSuperUserAccessAsync();
    // create local cluster
    asyncRequests(ctx -> clusters.createCluster(ctx, configClusterName, ClusterDataImpl.builder().build()));
    Set<String> allowedClusters = Sets.newHashSet();
    allowedClusters.add(configClusterName);
    TenantInfoImpl tenantInfo = TenantInfoImpl.builder().adminRoles(Sets.newHashSet("role1", "role2")).allowedClusters(allowedClusters).build();
    response = asyncRequests(ctx -> properties.createTenant(ctx, "test-property", tenantInfo));
    verify(properties, times(2)).validateSuperUserAccessAsync();
    response = asyncRequests(ctx -> properties.getTenants(ctx));
    assertEquals(response, Lists.newArrayList("test-property"));
    verify(properties, times(3)).validateSuperUserAccessAsync();
    response = asyncRequests(ctx -> properties.getTenantAdmin(ctx, "test-property"));
    assertEquals(response, tenantInfo);
    verify(properties, times(4)).validateSuperUserAccessAsync();
    final TenantInfoImpl newPropertyAdmin = TenantInfoImpl.builder().adminRoles(Sets.newHashSet("role1", "other-role")).allowedClusters(allowedClusters).build();
    response = asyncRequests(ctx -> properties.updateTenant(ctx, "test-property", newPropertyAdmin));
    verify(properties, times(5)).validateSuperUserAccessAsync();
    // Wait for updateTenant to take effect
    Thread.sleep(100);
    response = asyncRequests(ctx -> properties.getTenantAdmin(ctx, "test-property"));
    assertEquals(response, newPropertyAdmin);
    response = asyncRequests(ctx -> properties.getTenantAdmin(ctx, "test-property"));
    assertNotSame(response, tenantInfo);
    verify(properties, times(7)).validateSuperUserAccessAsync();
    // Check creating existing property
    try {
        response = asyncRequests(ctx -> properties.createTenant(ctx, "test-property", tenantInfo));
        fail("should have failed");
    } catch (RestException e) {
        assertEquals(e.getResponse().getStatus(), Status.CONFLICT.getStatusCode());
    }
    // Check non-existing property
    try {
        response = asyncRequests(ctx -> properties.getTenantAdmin(ctx, "non-existing"));
        fail("should have failed");
    } catch (RestException e) {
        assertEquals(e.getResponse().getStatus(), Status.NOT_FOUND.getStatusCode());
    }
    try {
        response = asyncRequests(ctx -> properties.updateTenant(ctx, "xxx-non-existing", newPropertyAdmin));
        fail("should have failed");
    } catch (RestException e) {
        assertEquals(e.getResponse().getStatus(), Status.NOT_FOUND.getStatusCode());
    }
    // Check deleting non-existing property
    try {
        response = asyncRequests(ctx -> properties.deleteTenant(ctx, "non-existing", false));
        fail("should have failed");
    } catch (RestException e) {
        assertEquals(e.getResponse().getStatus(), Status.NOT_FOUND.getStatusCode());
    }
    // clear caches to load data from metadata-store again
    MetadataCacheImpl<TenantInfo> cache = (MetadataCacheImpl<TenantInfo>) pulsar.getPulsarResources().getTenantResources().getCache();
    AbstractMetadataStore store = (AbstractMetadataStore) cache.getStore();
    cache.invalidateAll();
    store.invalidateAll();
    // Test zk failures
    mockZooKeeperGlobal.failConditional(Code.SESSIONEXPIRED, (op, path) -> {
        return op == MockZooKeeper.Op.GET_CHILDREN && path.equals("/admin/policies");
    });
    try {
        response = asyncRequests(ctx -> properties.getTenants(ctx));
        fail("should have failed");
    } catch (RestException e) {
        assertEquals(e.getResponse().getStatus(), Status.INTERNAL_SERVER_ERROR.getStatusCode());
    }
    mockZooKeeperGlobal.failConditional(Code.SESSIONEXPIRED, (op, path) -> {
        return op == MockZooKeeper.Op.GET && path.equals("/admin/policies/my-tenant");
    });
    try {
        response = asyncRequests(ctx -> properties.getTenantAdmin(ctx, "my-tenant"));
        fail("should have failed");
    } catch (RestException e) {
        assertEquals(e.getResponse().getStatus(), Status.INTERNAL_SERVER_ERROR.getStatusCode());
    }
    mockZooKeeperGlobal.failConditional(Code.SESSIONEXPIRED, (op, path) -> {
        return op == MockZooKeeper.Op.GET && path.equals("/admin/policies/my-tenant");
    });
    try {
        response = asyncRequests(ctx -> properties.updateTenant(ctx, "my-tenant", newPropertyAdmin));
        fail("should have failed");
    } catch (RestException e) {
        assertEquals(e.getResponse().getStatus(), Status.INTERNAL_SERVER_ERROR.getStatusCode());
    }
    mockZooKeeperGlobal.failConditional(Code.SESSIONEXPIRED, (op, path) -> {
        return op == MockZooKeeper.Op.CREATE && path.equals("/admin/policies/test");
    });
    try {
        response = asyncRequests(ctx -> properties.createTenant(ctx, "test", tenantInfo));
        fail("should have failed");
    } catch (RestException e) {
        assertEquals(e.getResponse().getStatus(), Status.INTERNAL_SERVER_ERROR.getStatusCode());
    }
    mockZooKeeperGlobal.failConditional(Code.SESSIONEXPIRED, (op, path) -> {
        return op == MockZooKeeper.Op.GET_CHILDREN && path.equals("/admin/policies/test-property");
    });
    try {
        cache.invalidateAll();
        store.invalidateAll();
        response = asyncRequests(ctx -> properties.deleteTenant(ctx, "test-property", false));
        fail("should have failed");
    } catch (RestException e) {
        assertEquals(e.getResponse().getStatus(), Status.INTERNAL_SERVER_ERROR.getStatusCode());
    }
    response = asyncRequests(ctx -> properties.createTenant(ctx, "error-property", tenantInfo));
    mockZooKeeperGlobal.failConditional(Code.SESSIONEXPIRED, (op, path) -> {
        return op == MockZooKeeper.Op.DELETE && path.equals("/admin/policies/error-property");
    });
    try {
        response = asyncRequests(ctx -> properties.deleteTenant(ctx, "error-property", false));
        fail("should have failed");
    } catch (RestException e) {
        assertEquals(e.getResponse().getStatus(), Status.INTERNAL_SERVER_ERROR.getStatusCode());
    }
    response = asyncRequests(ctx -> properties.deleteTenant(ctx, "test-property", false));
    response = asyncRequests(ctx -> properties.deleteTenant(ctx, "error-property", false));
    response = Lists.newArrayList();
    response = asyncRequests(ctx -> properties.getTenants(ctx));
    assertEquals(response, Lists.newArrayList());
    // Create a namespace to test deleting a non-empty property
    TenantInfoImpl newPropertyAdmin2 = TenantInfoImpl.builder().adminRoles(Sets.newHashSet("role1", "other-role")).allowedClusters(Sets.newHashSet("use")).build();
    response = asyncRequests(ctx -> properties.createTenant(ctx, "my-tenant", newPropertyAdmin2));
    response = asyncRequests(ctx -> namespaces.createNamespace(ctx, "my-tenant", "use", "my-namespace", BundlesData.builder().build()));
    try {
        response = asyncRequests(ctx -> properties.deleteTenant(ctx, "my-tenant", false));
        fail("should have failed");
    } catch (RestException e) {
    // Ok
    }
    // Check name validation
    try {
        response = asyncRequests(ctx -> properties.createTenant(ctx, "test&", tenantInfo));
        fail("should have failed");
    } catch (RestException e) {
        assertEquals(e.getResponse().getStatus(), Status.PRECONDITION_FAILED.getStatusCode());
    }
    // Check tenantInfo is null
    try {
        response = asyncRequests(ctx -> properties.createTenant(ctx, "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<String> blankClusters = Sets.newHashSet(blankCluster);
    TenantInfoImpl tenantWithEmptyCluster = TenantInfoImpl.builder().adminRoles(Sets.newHashSet("role1", "role2")).allowedClusters(blankClusters).build();
    try {
        response = asyncRequests(ctx -> properties.createTenant(ctx, "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<String> containBlankClusters = Sets.newHashSet(blankCluster);
    containBlankClusters.add(configClusterName);
    TenantInfoImpl tenantContainEmptyCluster = TenantInfoImpl.builder().adminRoles(Sets.newHashSet()).allowedClusters(containBlankClusters).build();
    try {
        response = asyncRequests(ctx -> properties.createTenant(ctx, "tenant-config-contain-empty", tenantContainEmptyCluster));
        fail("should have failed");
    } catch (RestException e) {
        assertEquals(e.getResponse().getStatus(), Status.PRECONDITION_FAILED.getStatusCode());
    }
    AsyncResponse response2 = mock(AsyncResponse.class);
    namespaces.deleteNamespace(response2, "my-tenant", "use", "my-namespace", false, false);
    ArgumentCaptor<Response> captor = ArgumentCaptor.forClass(Response.class);
    verify(response2, timeout(5000).times(1)).resume(captor.capture());
    assertEquals(captor.getValue().getStatus(), Status.NO_CONTENT.getStatusCode());
    response = asyncRequests(ctx -> properties.deleteTenant(ctx, "my-tenant", false));
}
Also used : ClusterDataImpl(org.apache.pulsar.common.policies.data.ClusterDataImpl) Metrics(org.apache.pulsar.common.stats.Metrics) AbstractMetadataStore(org.apache.pulsar.metadata.impl.AbstractMetadataStore) Test(org.testng.annotations.Test) ClusterData(org.apache.pulsar.common.policies.data.ClusterData) MetadataCacheImpl(org.apache.pulsar.metadata.cache.impl.MetadataCacheImpl) BrokerStats(org.apache.pulsar.broker.admin.v1.BrokerStats) AfterMethod(org.testng.annotations.AfterMethod) Namespaces(org.apache.pulsar.broker.admin.v1.Namespaces) AuthenticationDataHttps(org.apache.pulsar.broker.authentication.AuthenticationDataHttps) AuthAction(org.apache.pulsar.common.policies.data.AuthAction) Map(java.util.Map) RestException(org.apache.pulsar.broker.web.RestException) NamespaceName(org.apache.pulsar.common.naming.NamespaceName) URI(java.net.URI) Mockito.doReturn(org.mockito.Mockito.doReturn) Assert.assertFalse(org.testng.Assert.assertFalse) Brokers(org.apache.pulsar.broker.admin.v1.Brokers) PendingBookieOpsStats(org.apache.bookkeeper.mledger.proto.PendingBookieOpsStats) Collection(java.util.Collection) AsyncResponse(javax.ws.rs.container.AsyncResponse) BrokerInfo(org.apache.pulsar.common.policies.data.BrokerInfo) BeforeMethod(org.testng.annotations.BeforeMethod) Set(java.util.Set) PersistentTopics(org.apache.pulsar.broker.admin.v1.PersistentTopics) StreamingOutput(javax.ws.rs.core.StreamingOutput) MockZooKeeper(org.apache.zookeeper.MockZooKeeper) Mockito.doNothing(org.mockito.Mockito.doNothing) Assert.assertNotNull(org.testng.Assert.assertNotNull) WorkerConfig(org.apache.pulsar.functions.worker.WorkerConfig) Sets(com.google.common.collect.Sets) MockedPulsarServiceBaseTest(org.apache.pulsar.broker.auth.MockedPulsarServiceBaseTest) List(java.util.List) SchemasResource(org.apache.pulsar.broker.admin.v2.SchemasResource) Response(javax.ws.rs.core.Response) UriInfo(javax.ws.rs.core.UriInfo) TenantInfoImpl(org.apache.pulsar.common.policies.data.TenantInfoImpl) LeaderBroker(org.apache.pulsar.broker.loadbalance.LeaderBroker) Awaitility(org.awaitility.Awaitility) Mockito.mock(org.mockito.Mockito.mock) Code(org.apache.zookeeper.KeeperException.Code) TopicName(org.apache.pulsar.common.naming.TopicName) NamespaceIsolationDataImpl(org.apache.pulsar.common.policies.data.NamespaceIsolationDataImpl) Properties(org.apache.pulsar.broker.admin.v1.Properties) CommandGetTopicsOfNamespace(org.apache.pulsar.common.api.proto.CommandGetTopicsOfNamespace) Assert.assertEquals(org.testng.Assert.assertEquals) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) NamespaceService(org.apache.pulsar.broker.namespace.NamespaceService) Mockito.spy(org.mockito.Mockito.spy) Mockito.timeout(org.mockito.Mockito.timeout) Lists(com.google.common.collect.Lists) ArgumentCaptor(org.mockito.ArgumentCaptor) Assert.assertNotSame(org.testng.Assert.assertNotSame) Assert(org.testng.Assert) BundlesData(org.apache.pulsar.common.policies.data.BundlesData) Clusters(org.apache.pulsar.broker.admin.v1.Clusters) TenantInfo(org.apache.pulsar.common.policies.data.TenantInfo) Status(javax.ws.rs.core.Response.Status) AllocatorStats(org.apache.pulsar.common.stats.AllocatorStats) ResourceQuota(org.apache.pulsar.common.policies.data.ResourceQuota) PulsarWebResource(org.apache.pulsar.broker.web.PulsarWebResource) AutoFailoverPolicyType(org.apache.pulsar.common.policies.data.AutoFailoverPolicyType) ErrorData(org.apache.pulsar.common.policies.data.ErrorData) ServiceConfiguration(org.apache.pulsar.broker.ServiceConfiguration) LocalBrokerData(org.apache.pulsar.policies.data.loadbalancer.LocalBrokerData) Assert.fail(org.testng.Assert.fail) Mockito.times(org.mockito.Mockito.times) Field(java.lang.reflect.Field) ResourceQuotas(org.apache.pulsar.broker.admin.v1.ResourceQuotas) Mockito.verify(org.mockito.Mockito.verify) Policies(org.apache.pulsar.common.policies.data.Policies) Mockito.never(org.mockito.Mockito.never) ClientConfiguration(org.apache.bookkeeper.conf.ClientConfiguration) InternalConfigurationData(org.apache.pulsar.common.conf.InternalConfigurationData) Assert.assertTrue(org.testng.Assert.assertTrue) Collections(java.util.Collections) AutoFailoverPolicyData(org.apache.pulsar.common.policies.data.AutoFailoverPolicyData) AbstractMetadataStore(org.apache.pulsar.metadata.impl.AbstractMetadataStore) RestException(org.apache.pulsar.broker.web.RestException) TenantInfo(org.apache.pulsar.common.policies.data.TenantInfo) MetadataCacheImpl(org.apache.pulsar.metadata.cache.impl.MetadataCacheImpl) TenantInfoImpl(org.apache.pulsar.common.policies.data.TenantInfoImpl) AsyncResponse(javax.ws.rs.container.AsyncResponse) Response(javax.ws.rs.core.Response) AsyncResponse(javax.ws.rs.container.AsyncResponse) Test(org.testng.annotations.Test) MockedPulsarServiceBaseTest(org.apache.pulsar.broker.auth.MockedPulsarServiceBaseTest)

Aggregations

MetadataCacheImpl (org.apache.pulsar.metadata.cache.impl.MetadataCacheImpl)15 Test (org.testng.annotations.Test)15 MockedPulsarServiceBaseTest (org.apache.pulsar.broker.auth.MockedPulsarServiceBaseTest)12 RestException (org.apache.pulsar.broker.web.RestException)12 AbstractMetadataStore (org.apache.pulsar.metadata.impl.AbstractMetadataStore)12 Policies (org.apache.pulsar.common.policies.data.Policies)11 List (java.util.List)10 Map (java.util.Map)9 AsyncResponse (javax.ws.rs.container.AsyncResponse)9 TenantInfo (org.apache.pulsar.common.policies.data.TenantInfo)9 Awaitility (org.awaitility.Awaitility)9 Assert.assertEquals (org.testng.Assert.assertEquals)9 Assert.assertTrue (org.testng.Assert.assertTrue)9 Assert.fail (org.testng.Assert.fail)9 CompletableFuture (java.util.concurrent.CompletableFuture)8 Response (javax.ws.rs.core.Response)8 TenantInfoImpl (org.apache.pulsar.common.policies.data.TenantInfoImpl)8 ClusterData (org.apache.pulsar.common.policies.data.ClusterData)6 Lists (com.google.common.collect.Lists)5 Sets (com.google.common.collect.Sets)5