Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import static com.google.cloud.bigtable.test_helpers.env.AbstractTestEnv.TEST_APP_PREFIX;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static com.google.common.truth.TruthJUnit.assume;

import com.google.cloud.Policy;
Expand Down Expand Up @@ -136,6 +137,7 @@ public void instanceAndClusterCreationDeletionTest() {
assertThat(client.listInstances()).contains(instance);

clusterCreationDeletionTestHelper(newInstanceId);
basicClusterOperationTestHelper(newInstanceId, newClusterId);

client.deleteInstance(newInstanceId);
assertThat(client.exists(newInstanceId)).isFalse();
Expand All @@ -149,7 +151,7 @@ public void instanceAndClusterCreationDeletionTest() {
// To improve test runtime, piggyback off the instance creation/deletion test's fresh instance.
// This will avoid the need to copy any existing tables and will also reduce flakiness in case a
// previous run failed to clean up a cluster in the secondary zone.
public void clusterCreationDeletionTestHelper(String newInstanceId) {
private void clusterCreationDeletionTestHelper(String newInstanceId) {
String newClusterId = AbstractTestEnv.TEST_CLUSTER_PREFIX + Instant.now().getEpochSecond();
boolean isClusterDeleted = false;
client.createCluster(
Expand Down Expand Up @@ -184,27 +186,26 @@ public void basicInstanceOperationTest() {
assertThat(client.listInstances()).contains(instance);
}

/* As cluster creation is very expensive operation, so reusing existing clusters to verify rest
of the operation.*/
@Test
public void basicClusterOperationTest() {
List<Cluster> clusters = client.listClusters(instanceId);
assertThat(clusters).isNotEmpty();
// To improve test runtime, piggyback off the instance creation/deletion test's fresh instance.
private void basicClusterOperationTestHelper(String targetInstanceId, String targetClusterId) {
List<Cluster> clusters = client.listClusters(targetInstanceId);

Cluster existingCluster = clusters.get(0);
String clusterId = existingCluster.getId();
assertThat(client.getCluster(instanceId, clusterId)).isEqualTo(existingCluster);
Cluster targetCluster = null;
for (Cluster cluster : clusters) {
if (cluster.getId().equals(targetClusterId)) {
targetCluster = cluster;
}
}
assertWithMessage("Failed to find target cluster id in listClusters")
.that(targetCluster)
.isNotNull();

if (Instance.Type.PRODUCTION.equals(client.getInstance(instanceId).getType())) {
int existingClusterNodeSize = existingCluster.getServeNodes();
int freshNumOfNodes = existingClusterNodeSize + 1;
assertThat(client.getCluster(targetInstanceId, targetClusterId)).isEqualTo(targetCluster);

Cluster resizeCluster = client.resizeCluster(instanceId, clusterId, freshNumOfNodes);
assertThat(resizeCluster.getServeNodes()).isEqualTo(freshNumOfNodes);
int freshNumOfNodes = targetCluster.getServeNodes() + 1;

assertThat(
client.resizeCluster(instanceId, clusterId, existingClusterNodeSize).getServeNodes())
.isEqualTo(existingClusterNodeSize);
}
Cluster resizeCluster =
client.resizeCluster(targetInstanceId, targetClusterId, freshNumOfNodes);
assertThat(resizeCluster.getServeNodes()).isEqualTo(freshNumOfNodes);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,17 @@
import java.util.Random;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

@RunWith(JUnit4.class)
public class LargeRowIT {
@ClassRule public static TestEnvRule testEnvRule = new TestEnvRule();
private static final Logger logger = Logger.getLogger(LargeRowIT.class.getName());

@ClassRule public static final TestEnvRule testEnvRule = new TestEnvRule();

@Test
public void testWriteRead() throws Exception {
Expand All @@ -45,6 +48,7 @@ public void testWriteRead() throws Exception {
ByteString largeValue = ByteString.copyFrom(largeValueBytes);

// Create a 200 MB row
logger.info("Sending large row, this will take awhile");
for (int i = 0; i < 2; i++) {
testEnvRule
.env()
Expand All @@ -55,6 +59,7 @@ public void testWriteRead() throws Exception {
.get(10, TimeUnit.MINUTES);
}

logger.info("Reading large row, this will take awhile");
// Read it back
Row row =
testEnvRule
Expand Down