Search in sources :

Example 1 with ListClustersResponse

use of io.confluent.kafkarest.entities.v3.ListClustersResponse in project kafka-rest by confluentinc.

the class ClustersResourceIntegrationTest method listClusters_returnsArrayWithOwnCluster.

@Test
public void listClusters_returnsArrayWithOwnCluster() {
    String baseUrl = restConnect;
    String clusterId = getClusterId();
    int controllerId = getControllerID();
    ListClustersResponse expected = ListClustersResponse.create(ClusterDataList.builder().setMetadata(ResourceCollection.Metadata.builder().setSelf(baseUrl + "/v3/clusters").build()).setData(singletonList(ClusterData.builder().setMetadata(Resource.Metadata.builder().setSelf(baseUrl + "/v3/clusters/" + clusterId).setResourceName("crn:///kafka=" + clusterId).build()).setClusterId(clusterId).setController(Resource.Relationship.create(baseUrl + "/v3/clusters/" + clusterId + "/brokers/" + controllerId)).setAcls(Resource.Relationship.create(baseUrl + "/v3/clusters/" + clusterId + "/acls")).setBrokers(Resource.Relationship.create(baseUrl + "/v3/clusters/" + clusterId + "/brokers")).setBrokerConfigs(Resource.Relationship.create(baseUrl + "/v3/clusters/" + clusterId + "/broker-configs")).setConsumerGroups(Resource.Relationship.create(baseUrl + "/v3/clusters/" + clusterId + "/consumer-groups")).setTopics(Resource.Relationship.create(baseUrl + "/v3/clusters/" + clusterId + "/topics")).setPartitionReassignments(Resource.Relationship.create(baseUrl + "/v3/clusters/" + clusterId + "/topics/-/partitions/-/reassignment")).build())).build());
    Response response = request("/v3/clusters").accept(MediaType.APPLICATION_JSON).get();
    assertEquals(Status.OK.getStatusCode(), response.getStatus());
    ListClustersResponse actual = response.readEntity(ListClustersResponse.class);
    assertEquals(expected, actual);
}
Also used : GetClusterResponse(io.confluent.kafkarest.entities.v3.GetClusterResponse) ListClustersResponse(io.confluent.kafkarest.entities.v3.ListClustersResponse) Response(javax.ws.rs.core.Response) ListClustersResponse(io.confluent.kafkarest.entities.v3.ListClustersResponse) Test(org.junit.jupiter.api.Test)

Example 2 with ListClustersResponse

use of io.confluent.kafkarest.entities.v3.ListClustersResponse in project java-container by googleapis.

the class ITSystemTest method listClusterTest.

@Test
public void listClusterTest() {
    ListClustersResponse clustersResponse = client.listClusters(PROJECT_ID, ZONE);
    List<Cluster> clusters = clustersResponse.getClustersList();
    NodePool nodePool = client.getNodePool(PROJECT_ID, ZONE, CLUSTER_NAME, NODE_POOL_NAME);
    for (Cluster cluster : clusters) {
        if (CLUSTER_NAME.equals(cluster.getName())) {
            assertEquals(CLUSTER_NAME, cluster.getName());
            assertEquals(DETAIL, cluster.getDescription());
            assertEquals(ZONE, cluster.getLocation());
            assertEquals(SELF_LINK, cluster.getSelfLink());
            assertEquals(NETWORK, cluster.getNetwork());
            assertEquals(INITIAL_NODE_COUNT, nodePool.getInitialNodeCount());
        }
    }
}
Also used : NodePool(com.google.container.v1.NodePool) Cluster(com.google.container.v1.Cluster) ListClustersResponse(com.google.container.v1.ListClustersResponse) Test(org.junit.Test)

Example 3 with ListClustersResponse

use of io.confluent.kafkarest.entities.v3.ListClustersResponse in project java-container by googleapis.

the class Util method cleanUpExistingInstanceCluster.

/**
 * tear down any clusters that are older than 24 hours *
 */
public static void cleanUpExistingInstanceCluster(String projectId, String zone, ClusterManagerClient client) throws IOException, ExecutionException, InterruptedException {
    ListClustersResponse clustersResponse = client.listClusters(projectId, zone);
    List<Cluster> clusters = clustersResponse.getClustersList();
    for (Cluster cluster : clusters) {
        if (isCreatedBeforeThresholdTime(cluster.getCreateTime())) {
            client.deleteCluster(projectId, zone, cluster.getName());
        }
    }
}
Also used : Cluster(com.google.container.v1.Cluster) ListClustersResponse(com.google.container.v1.ListClustersResponse)

Example 4 with ListClustersResponse

use of io.confluent.kafkarest.entities.v3.ListClustersResponse in project java-container by googleapis.

the class ClusterManagerClientTest method listClustersTest.

@Test
public void listClustersTest() throws Exception {
    ListClustersResponse expectedResponse = ListClustersResponse.newBuilder().addAllClusters(new ArrayList<Cluster>()).addAllMissingZones(new ArrayList<String>()).build();
    mockClusterManager.addResponse(expectedResponse);
    String projectId = "projectId-894832108";
    String zone = "zone3744684";
    ListClustersResponse actualResponse = client.listClusters(projectId, zone);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockClusterManager.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListClustersRequest actualRequest = ((ListClustersRequest) actualRequests.get(0));
    Assert.assertEquals(projectId, actualRequest.getProjectId());
    Assert.assertEquals(zone, actualRequest.getZone());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ArrayList(java.util.ArrayList) Cluster(com.google.container.v1beta1.Cluster) ListClustersRequest(com.google.container.v1beta1.ListClustersRequest) ListClustersResponse(com.google.container.v1beta1.ListClustersResponse) Test(org.junit.Test)

Example 5 with ListClustersResponse

use of io.confluent.kafkarest.entities.v3.ListClustersResponse in project kafka-rest by confluentinc.

the class ClustersResourceTest method listClusters_returnsArrayWithOwnClusters.

@Test
public void listClusters_returnsArrayWithOwnClusters() {
    expect(clusterManager.listClusters()).andReturn(CompletableFuture.completedFuture(singletonList(CLUSTER_1)));
    replay(clusterManager);
    FakeAsyncResponse response = new FakeAsyncResponse();
    clustersResource.listClusters(response);
    ListClustersResponse expected = ListClustersResponse.create(ClusterDataList.builder().setMetadata(ResourceCollection.Metadata.builder().setSelf("/v3/clusters").build()).setData(singletonList(ClusterData.builder().setMetadata(Resource.Metadata.builder().setSelf("/v3/clusters/cluster-1").setResourceName("crn:///kafka=cluster-1").build()).setClusterId("cluster-1").setController(Resource.Relationship.create("/v3/clusters/cluster-1/brokers/1")).setAcls(Resource.Relationship.create("/v3/clusters/cluster-1/acls")).setBrokers(Resource.Relationship.create("/v3/clusters/cluster-1/brokers")).setBrokerConfigs(Resource.Relationship.create("/v3/clusters/cluster-1/broker-configs")).setConsumerGroups(Resource.Relationship.create("/v3/clusters/cluster-1/consumer-groups")).setTopics(Resource.Relationship.create("/v3/clusters/cluster-1/topics")).setPartitionReassignments(Resource.Relationship.create("/v3/clusters/cluster-1/topics/-/partitions/-/reassignment")).build())).build());
    assertEquals(expected, response.getValue());
}
Also used : FakeAsyncResponse(io.confluent.kafkarest.response.FakeAsyncResponse) ListClustersResponse(io.confluent.kafkarest.entities.v3.ListClustersResponse) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.Test)6 AbstractMessage (com.google.protobuf.AbstractMessage)5 ArrayList (java.util.ArrayList)5 Cluster (com.google.container.v1.Cluster)4 ListClustersResponse (com.google.container.v1.ListClustersResponse)4 ListClustersRequest (com.google.bigtable.admin.v2.ListClustersRequest)2 ListClustersResponse (com.google.bigtable.admin.v2.ListClustersResponse)2 ListClustersRequest (com.google.container.v1.ListClustersRequest)2 ByteString (com.google.protobuf.ByteString)2 ListClustersResponse (io.confluent.kafkarest.entities.v3.ListClustersResponse)2 Test (org.junit.jupiter.api.Test)2 InstanceName (com.google.bigtable.admin.v2.InstanceName)1 NodePool (com.google.container.v1.NodePool)1 Cluster (com.google.container.v1beta1.Cluster)1 ListClustersRequest (com.google.container.v1beta1.ListClustersRequest)1 ListClustersResponse (com.google.container.v1beta1.ListClustersResponse)1 GetClusterResponse (io.confluent.kafkarest.entities.v3.GetClusterResponse)1 FakeAsyncResponse (io.confluent.kafkarest.response.FakeAsyncResponse)1 Response (javax.ws.rs.core.Response)1