use of com.google.cloud.dataproc.v1.Cluster in project java-bigtable by googleapis.
the class BaseBigtableInstanceAdminClientTest method createInstanceTest.
@Test
public void createInstanceTest() throws Exception {
Instance expectedResponse = Instance.newBuilder().setName(InstanceName.of("[PROJECT]", "[INSTANCE]").toString()).setDisplayName("displayName1714148973").putAllLabels(new HashMap<String, String>()).setCreateTime(Timestamp.newBuilder().build()).build();
Operation resultOperation = Operation.newBuilder().setName("createInstanceTest").setDone(true).setResponse(Any.pack(expectedResponse)).build();
mockBigtableInstanceAdmin.addResponse(resultOperation);
ProjectName parent = ProjectName.of("[PROJECT]");
String instanceId = "instanceId902024336";
Instance instance = Instance.newBuilder().build();
Map<String, Cluster> clusters = new HashMap<>();
Instance actualResponse = client.createInstanceAsync(parent, instanceId, instance, clusters).get();
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockBigtableInstanceAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateInstanceRequest actualRequest = ((CreateInstanceRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertEquals(instanceId, actualRequest.getInstanceId());
Assert.assertEquals(instance, actualRequest.getInstance());
Assert.assertEquals(clusters, actualRequest.getClustersMap());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.dataproc.v1.Cluster in project java-container by googleapis.
the class ITSystemTest method getClusterTest.
@Test
public void getClusterTest() {
Cluster cluster = client.getCluster(PROJECT_ID, ZONE, CLUSTER_NAME);
NodePool nodePool = client.getNodePool(PROJECT_ID, ZONE, CLUSTER_NAME, NODE_POOL_NAME);
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.cloud.dataproc.v1.Cluster in project java-container by googleapis.
the class ITSystemTest method beforeClass.
@BeforeClass
public static void beforeClass() throws Exception {
client = ClusterManagerClient.create();
Util.cleanUpExistingInstanceCluster(PROJECT_ID, ZONE, client);
/**
* create node pool*
*/
NodePool nodePool = NodePool.newBuilder().setInitialNodeCount(INITIAL_NODE_COUNT).setName(NODE_POOL_NAME).setSelfLink(NODE_POOL_SEL_LINK).setStatusMessage(STATUS_MESSAGE).build();
/**
* create cluster
*/
Cluster cluster = Cluster.newBuilder().setName(CLUSTER_NAME).setLocation("us-central1").setDescription(DETAIL).setSelfLink(SELF_LINK).addNodePools(nodePool).setStatusMessage(STATUS_MESSAGE).setNetwork(NETWORK).build();
operation = client.createCluster(PROJECT_ID, ZONE, cluster);
LOG.info(String.format("%s cluster created successfully.", CLUSTER_NAME));
LOG.info(String.format("%s node pool created successfully.", NODE_POOL_NAME));
}
use of com.google.cloud.dataproc.v1.Cluster 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.cloud.dataproc.v1.Cluster 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());
}
}
}
Aggregations