use of com.google.bigtable.admin.v2.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);
}
use of com.google.bigtable.admin.v2.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());
}
}
}
use of com.google.bigtable.admin.v2.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());
}
}
}
use of com.google.bigtable.admin.v2.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()));
}
use of com.google.bigtable.admin.v2.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());
}
Aggregations