Search in sources :

Example 21 with Cluster

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()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) Instance(com.google.bigtable.admin.v2.Instance) ProjectName(com.google.bigtable.admin.v2.ProjectName) HashMap(java.util.HashMap) Cluster(com.google.bigtable.admin.v2.Cluster) ByteString(com.google.protobuf.ByteString) Operation(com.google.longrunning.Operation) CreateInstanceRequest(com.google.bigtable.admin.v2.CreateInstanceRequest) Test(org.junit.Test)

Example 22 with Cluster

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());
}
Also used : NodePool(com.google.container.v1.NodePool) Cluster(com.google.container.v1.Cluster) Test(org.junit.Test)

Example 23 with Cluster

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));
}
Also used : NodePool(com.google.container.v1.NodePool) Cluster(com.google.container.v1.Cluster) BeforeClass(org.junit.BeforeClass)

Example 24 with Cluster

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());
        }
    }
}
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 25 with Cluster

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());
        }
    }
}
Also used : Cluster(com.google.container.v1.Cluster) ListClustersResponse(com.google.container.v1.ListClustersResponse)

Aggregations

Test (org.junit.Test)40 AbstractMessage (com.google.protobuf.AbstractMessage)19 ClusterOperationMetadata (com.google.cloud.dataproc.v1.ClusterOperationMetadata)18 ExecutionException (java.util.concurrent.ExecutionException)18 HashMap (java.util.HashMap)17 Cluster (com.google.bigtable.admin.v2.Cluster)16 Cluster (com.google.cloud.dataproc.v1.Cluster)15 ArrayList (java.util.ArrayList)14 ClusterControllerSettings (com.google.cloud.dataproc.v1.ClusterControllerSettings)12 Cluster (com.google.container.v1.Cluster)12 ClusterConfig (com.google.cloud.dataproc.v1.ClusterConfig)10 ClusterControllerClient (com.google.cloud.dataproc.v1.ClusterControllerClient)10 Operation (com.google.longrunning.Operation)10 Cluster (io.envoyproxy.envoy.config.cluster.v3.Cluster)10 RetryableProvisionException (io.cdap.cdap.runtime.spi.provisioner.RetryableProvisionException)8 IOException (java.io.IOException)8 GeneralSecurityException (java.security.GeneralSecurityException)8 Optional (java.util.Optional)8 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)7 GceClusterConfig (com.google.cloud.dataproc.v1.GceClusterConfig)7