Skip to content

Commit f5f70e0

Browse files
chore: fix tests (#83)
* chore: fix tests * Fix bug in the instance admin IT. This was unnoticed because our presubmits target a development instance (I just changed that) * Move auto-value back as a provided dep in the main dependency list. This caused issues in intellij when annotation processing was disabled * deflake cluster creation test * disable parallel unit tests until autogen tests use googleapis/gapic-generator#3028
1 parent a21bf1c commit f5f70e0

File tree

3 files changed

+28
-29
lines changed

3 files changed

+28
-29
lines changed

google-cloud-bigtable/pom.xml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@
6262
<groupId>com.google.api.grpc</groupId>
6363
<artifactId>proto-google-iam-v1</artifactId>
6464
</dependency>
65+
<dependency>
66+
<groupId>com.google.auto.value</groupId>
67+
<artifactId>auto-value</artifactId>
68+
<scope>provided</scope>
69+
</dependency>
6570
<dependency>
6671
<groupId>com.google.auto.value</groupId>
6772
<artifactId>auto-value-annotations</artifactId>
@@ -338,7 +343,7 @@
338343
grpc-grpclb is used at runtime using reflection
339344
grpc-auth is not directly used transitively, but is pulled to align with other grpc parts
340345
-->
341-
<usedDependencies>io.grpc:grpc-auth,io.grpc:grpc-grpclb</usedDependencies>
346+
<usedDependencies>io.grpc:grpc-auth,io.grpc:grpc-grpclb,com.google.auto.value:auto-value</usedDependencies>
342347
</configuration>
343348
</plugin>
344349

@@ -357,10 +362,6 @@
357362
<artifactId>maven-surefire-plugin</artifactId>
358363

359364
<configuration>
360-
<parallel>classes</parallel>
361-
<forkCount>2C</forkCount>
362-
<reuseForks>true</reuseForks>
363-
364365
<!-- enable the ability to skip unit tests, while running integration tests -->
365366
<skipTests>${skipUnitTests}</skipTests>
366367
<trimStackTrace>false</trimStackTrace>

google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/it/BigtableInstanceAdminClientIT.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import com.google.cloud.bigtable.admin.v2.models.CreateClusterRequest;
2828
import com.google.cloud.bigtable.admin.v2.models.CreateInstanceRequest;
2929
import com.google.cloud.bigtable.admin.v2.models.Instance;
30+
import com.google.cloud.bigtable.admin.v2.models.Instance.Type;
3031
import com.google.cloud.bigtable.admin.v2.models.StorageType;
3132
import com.google.cloud.bigtable.admin.v2.models.UpdateAppProfileRequest;
3233
import com.google.cloud.bigtable.admin.v2.models.UpdateInstanceRequest;
@@ -110,18 +111,18 @@ public void iamUpdateTest() {
110111
assertThat(permissions).hasSize(2);
111112
}
112113

114+
/** To optimize test run time, instance & cluster creation is tested at the same time */
113115
@Test
114-
public void instanceCreationDeletionTest() {
116+
public void instanceAndClusterCreationDeletionTest() {
115117
String newInstanceId = AbstractTestEnv.TEST_INSTANCE_PREFIX + Instant.now().getEpochSecond();
116118
String newClusterId = newInstanceId + "-c1";
117119

118120
client.createInstance(
119121
CreateInstanceRequest.of(newInstanceId)
120-
.addDevelopmentCluster(
121-
newClusterId, testEnvRule.env().getPrimaryZone(), StorageType.SSD)
122+
.addCluster(newClusterId, testEnvRule.env().getPrimaryZone(), 3, StorageType.SSD)
122123
.setDisplayName("Fresh-Instance-Name")
123124
.addLabel("state", "readytodelete")
124-
.setType(Instance.Type.DEVELOPMENT));
125+
.setType(Type.PRODUCTION));
125126

126127
try {
127128
assertThat(client.exists(newInstanceId)).isTrue();
@@ -134,6 +135,8 @@ public void instanceCreationDeletionTest() {
134135

135136
assertThat(client.listInstances()).contains(instance);
136137

138+
clusterCreationDeletionTestHelper(newInstanceId);
139+
137140
client.deleteInstance(newInstanceId);
138141
assertThat(client.exists(newInstanceId)).isFalse();
139142
} finally {
@@ -143,29 +146,25 @@ public void instanceCreationDeletionTest() {
143146
}
144147
}
145148

146-
@Test
147-
public void clusterCreationDeletionTest() {
148-
Instance currentInstance = client.getInstance(instanceId);
149-
assume()
150-
.withMessage("cluster replication test can only run on PRODUCTION instance")
151-
.that(currentInstance.getType())
152-
.isEqualTo(Instance.Type.PRODUCTION);
153-
149+
// To improve test runtime, piggyback off the instance creation/deletion test's fresh instance.
150+
// This will avoid the need to copy any existing tables and will also reduce flakiness in case a
151+
// previous run failed to clean up a cluster in the secondary zone.
152+
public void clusterCreationDeletionTestHelper(String newInstanceId) {
154153
String newClusterId = AbstractTestEnv.TEST_CLUSTER_PREFIX + Instant.now().getEpochSecond();
155154
boolean isClusterDeleted = false;
156155
client.createCluster(
157-
CreateClusterRequest.of(instanceId, newClusterId)
156+
CreateClusterRequest.of(newInstanceId, newClusterId)
158157
.setZone(testEnvRule.env().getSecondaryZone())
159158
.setStorageType(StorageType.SSD)
160159
.setServeNodes(3));
161160
try {
162-
assertThat(client.getCluster(instanceId, newClusterId)).isNotNull();
161+
assertThat(client.getCluster(newInstanceId, newClusterId)).isNotNull();
163162

164-
client.deleteCluster(instanceId, newClusterId);
163+
client.deleteCluster(newInstanceId, newClusterId);
165164
isClusterDeleted = true;
166165
} finally {
167166
if (!isClusterDeleted) {
168-
client.deleteCluster(instanceId, newClusterId);
167+
client.deleteCluster(newInstanceId, newClusterId);
169168
}
170169
}
171170
}
@@ -203,7 +202,8 @@ public void basicClusterOperationTest() {
203202
Cluster resizeCluster = client.resizeCluster(instanceId, clusterId, freshNumOfNodes);
204203
assertThat(resizeCluster.getServeNodes()).isEqualTo(freshNumOfNodes);
205204

206-
assertThat(client.resizeCluster(instanceId, clusterId, existingClusterNodeSize))
205+
assertThat(
206+
client.resizeCluster(instanceId, clusterId, existingClusterNodeSize).getServeNodes())
207207
.isEqualTo(existingClusterNodeSize);
208208
}
209209
}

pom.xml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,11 @@
234234
<artifactId>proto-google-iam-v1</artifactId>
235235
<version>0.13.0</version>
236236
</dependency>
237+
<dependency>
238+
<groupId>com.google.auto.value</groupId>
239+
<artifactId>auto-value</artifactId>
240+
<version>${autovalue.version}</version>
241+
</dependency>
237242
<dependency>
238243
<groupId>com.google.auto.value</groupId>
239244
<artifactId>auto-value-annotations</artifactId>
@@ -345,13 +350,6 @@
345350
<target>1.7</target>
346351
<encoding>UTF-8</encoding>
347352
<compilerArgument>-Xlint:unchecked</compilerArgument>
348-
<annotationProcessorPaths>
349-
<path>
350-
<groupId>com.google.auto.value</groupId>
351-
<artifactId>auto-value</artifactId>
352-
<version>${autovalue.version}</version>
353-
</path>
354-
</annotationProcessorPaths>
355353
</configuration>
356354
</plugin>
357355

0 commit comments

Comments
 (0)