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.
}
}
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));
}
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());
}
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());
}
}
}
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());
}
}
}
Aggregations