Search in sources :

Example 56 with Cluster

use of com.google.bigtable.admin.v2.Cluster in project java-container by googleapis.

the class ClusterManagerClientTest method createClusterExceptionTest.

@Test
public void createClusterExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockClusterManager.addException(exception);
    try {
        String parent = "parent-995424086";
        Cluster cluster = Cluster.newBuilder().build();
        client.createCluster(parent, cluster);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) Cluster(com.google.container.v1.Cluster) Test(org.junit.Test)

Example 57 with Cluster

use of com.google.bigtable.admin.v2.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 58 with Cluster

use of com.google.bigtable.admin.v2.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 59 with Cluster

use of com.google.bigtable.admin.v2.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 60 with Cluster

use of com.google.bigtable.admin.v2.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)93 AbstractMessage (com.google.protobuf.AbstractMessage)38 ByteString (com.google.protobuf.ByteString)32 Cluster (io.envoyproxy.envoy.config.cluster.v3.Cluster)25 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)24 StatusRuntimeException (io.grpc.StatusRuntimeException)24 ExecutionException (java.util.concurrent.ExecutionException)22 Cluster (com.google.cloud.dataproc.v1.Cluster)18 Operation (com.google.longrunning.Operation)18 Cluster (com.google.bigtable.admin.v2.Cluster)16 ClusterName (com.google.bigtable.admin.v2.ClusterName)16 ArrayList (java.util.ArrayList)16 ClusterOperationMetadata (com.google.cloud.dataproc.v1.ClusterOperationMetadata)13 HashMap (java.util.HashMap)13 Cluster (com.google.container.v1.Cluster)12 ClusterControllerClient (com.google.cloud.dataproc.v1.ClusterControllerClient)11 ClusterControllerSettings (com.google.cloud.dataproc.v1.ClusterControllerSettings)11 SoftwareConfig (com.google.cloud.dataproc.v1.SoftwareConfig)9 SnapshotName (com.google.bigtable.admin.v2.SnapshotName)8 ClusterConfig (com.google.cloud.dataproc.v1.ClusterConfig)8