Search in sources :

Example 1 with Clusters

use of org.apache.pulsar.client.admin.Clusters in project incubator-pulsar by apache.

the class PulsarAdminToolTest method clusters.

@Test
void clusters() throws Exception {
    PulsarAdmin admin = Mockito.mock(PulsarAdmin.class);
    Clusters mockClusters = mock(Clusters.class);
    when(admin.clusters()).thenReturn(mockClusters);
    CmdClusters clusters = new CmdClusters(admin);
    clusters.run(split("list"));
    verify(mockClusters).getClusters();
    clusters.run(split("get use"));
    verify(mockClusters).getCluster("use");
    clusters.run(split("create use --url http://my-service.url:8080"));
    verify(mockClusters).createCluster("use", new ClusterData("http://my-service.url:8080", null));
    clusters.run(split("update use --url http://my-service.url:8080"));
    verify(mockClusters).updateCluster("use", new ClusterData("http://my-service.url:8080", null));
    clusters.run(split("delete use"));
    verify(mockClusters).deleteCluster("use");
    clusters.run(split("list-failure-domains use"));
    verify(mockClusters).getFailureDomains("use");
    clusters.run(split("get-failure-domain use --domain-name domain"));
    verify(mockClusters).getFailureDomain("use", "domain");
    clusters.run(split("create-failure-domain use --domain-name domain --broker-list b1"));
    FailureDomain domain = new FailureDomain();
    domain.setBrokers(Sets.newHashSet("b1"));
    verify(mockClusters).createFailureDomain("use", "domain", domain);
    clusters.run(split("update-failure-domain use --domain-name domain --broker-list b1"));
    verify(mockClusters).updateFailureDomain("use", "domain", domain);
    clusters.run(split("delete-failure-domain use --domain-name domain"));
    verify(mockClusters).deleteFailureDomain("use", "domain");
    // Re-create CmdClusters to avoid a issue.
    // See https://github.com/cbeust/jcommander/issues/271
    clusters = new CmdClusters(admin);
    clusters.run(split("create my-cluster --url http://my-service.url:8080 --url-secure https://my-service.url:4443"));
    verify(mockClusters).createCluster("my-cluster", new ClusterData("http://my-service.url:8080", "https://my-service.url:4443"));
    clusters.run(split("update my-cluster --url http://my-service.url:8080 --url-secure https://my-service.url:4443"));
    verify(mockClusters).updateCluster("my-cluster", new ClusterData("http://my-service.url:8080", "https://my-service.url:4443"));
    clusters.run(split("delete my-cluster"));
    verify(mockClusters).deleteCluster("my-cluster");
    clusters.run(split("update-peer-clusters my-cluster --peer-clusters c1,c2"));
    verify(mockClusters).updatePeerClusterNames("my-cluster", Sets.newLinkedHashSet(Lists.newArrayList("c1", "c2")));
    clusters.run(split("get-peer-clusters my-cluster"));
    verify(mockClusters).getPeerClusterNames("my-cluster");
}
Also used : ClusterData(org.apache.pulsar.common.policies.data.ClusterData) PulsarAdmin(org.apache.pulsar.client.admin.PulsarAdmin) Clusters(org.apache.pulsar.client.admin.Clusters) FailureDomain(org.apache.pulsar.common.policies.data.FailureDomain) Test(org.testng.annotations.Test)

Aggregations

Clusters (org.apache.pulsar.client.admin.Clusters)1 PulsarAdmin (org.apache.pulsar.client.admin.PulsarAdmin)1 ClusterData (org.apache.pulsar.common.policies.data.ClusterData)1 FailureDomain (org.apache.pulsar.common.policies.data.FailureDomain)1 Test (org.testng.annotations.Test)1