Skip to content

Commit 8bc9293

Browse files
authored
test: re-introduce parallel test execution (#1503)
* test: add timeout to it database admin test ops Adds timeout to admin operations in the ITDatabaseAdminTest (database, backup and restore ops) * test: decrease it test timeout We tried increasing the it test timeout to see if that could help with the intermittent failures. It did not help, so we are rolling it back to the original value. * test: re-introduce parallel it test execution We tried disabling parallel it test execution to see if it would help with the intermittent failures we were seeing. This did not decrease the failures, so we are rolling this back.
1 parent d5a37b8 commit 8bc9293

File tree

2 files changed

+32
-15
lines changed

2 files changed

+32
-15
lines changed

google-cloud-spanner/pom.xml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,27 @@
7474
<spanner.gce.config.project_id>gcloud-devel</spanner.gce.config.project_id>
7575
<spanner.testenv.kms_key.name>projects/gcloud-devel/locations/us-central1/keyRings/spanner-test-keyring/cryptoKeys/spanner-test-key</spanner.testenv.kms_key.name>
7676
</systemPropertyVariables>
77-
<forkedProcessTimeoutInSeconds>6000</forkedProcessTimeoutInSeconds>
77+
<forkedProcessTimeoutInSeconds>3000</forkedProcessTimeoutInSeconds>
7878
</configuration>
7979
<executions>
8080
<!-- Executes serial integration tests -->
8181
<execution>
8282
<id>default</id>
8383
<configuration>
84-
<groups>com.google.cloud.spanner.SerialIntegrationTest, com.google.cloud.spanner.ParallelIntegrationTest</groups>
84+
<groups>com.google.cloud.spanner.SerialIntegrationTest</groups>
85+
</configuration>
86+
</execution>
87+
<!-- Executes parallel integration tests -->
88+
<execution>
89+
<id>parallel-integration-test</id>
90+
<goals>
91+
<goal>integration-test</goal>
92+
</goals>
93+
<configuration>
94+
<groups>com.google.cloud.spanner.ParallelIntegrationTest</groups>
95+
<forkCount>8</forkCount>
96+
<reuseForks>true</reuseForks>
97+
<groups>com.google.cloud.spanner.ParallelIntegrationTest</groups>
8598
</configuration>
8699
</execution>
87100
</executions>
@@ -415,7 +428,7 @@
415428
<spanner.attempt_directpath>true</spanner.attempt_directpath>
416429
<spanner.directpath_test_scenario>ipv4</spanner.directpath_test_scenario>
417430
</systemPropertyVariables>
418-
<forkedProcessTimeoutInSeconds>6000</forkedProcessTimeoutInSeconds>
431+
<forkedProcessTimeoutInSeconds>3000</forkedProcessTimeoutInSeconds>
419432
</configuration>
420433
</plugin>
421434
</plugins>

google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITDatabaseAdminTest.java

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@
7272
@Category(ParallelIntegrationTest.class)
7373
@RunWith(JUnit4.class)
7474
public class ITDatabaseAdminTest {
75+
private static final long DATABASE_TIMEOUT_MINUTES = 5;
76+
private static final long BACKUP_TIMEOUT_MINUTES = 20;
77+
private static final long RESTORE_TIMEOUT_MINUTES = 10;
7578
@ClassRule public static IntegrationTestEnv env = new IntegrationTestEnv();
7679
private DatabaseAdminClient dbAdminClient;
7780
private RemoteSpannerHelper testHelper;
@@ -98,7 +101,7 @@ public void databaseOperations() throws Exception {
98101
String statement1 = "CREATE TABLE T (\n" + " K STRING(MAX),\n" + ") PRIMARY KEY(K)";
99102
OperationFuture<Database, CreateDatabaseMetadata> op =
100103
dbAdminClient.createDatabase(instanceId, dbId, ImmutableList.of(statement1));
101-
Database db = op.get();
104+
Database db = op.get(DATABASE_TIMEOUT_MINUTES, TimeUnit.MINUTES);
102105
dbs.add(db);
103106
assertThat(db.getId().getDatabase()).isEqualTo(dbId);
104107

@@ -119,7 +122,7 @@ public void databaseOperations() throws Exception {
119122
String statement2 = "CREATE TABLE T2 (\n" + " K2 STRING(MAX),\n" + ") PRIMARY KEY(K2)";
120123
OperationFuture<?, ?> op2 =
121124
dbAdminClient.updateDatabaseDdl(instanceId, dbId, ImmutableList.of(statement2), null);
122-
op2.get();
125+
op2.get(DATABASE_TIMEOUT_MINUTES, TimeUnit.MINUTES);
123126
List<String> statementsInDb = dbAdminClient.getDatabaseDdl(instanceId, dbId);
124127
assertThat(statementsInDb).containsExactly(statement1, statement2);
125128

@@ -140,15 +143,15 @@ public void updateDdlRetry() throws Exception {
140143
String statement1 = "CREATE TABLE T (\n" + " K STRING(MAX),\n" + ") PRIMARY KEY(K)";
141144
OperationFuture<Database, CreateDatabaseMetadata> op =
142145
dbAdminClient.createDatabase(instanceId, dbId, ImmutableList.of(statement1));
143-
Database db = op.get();
146+
Database db = op.get(DATABASE_TIMEOUT_MINUTES, TimeUnit.MINUTES);
144147
dbs.add(db);
145148
String statement2 = "CREATE TABLE T2 (\n" + " K2 STRING(MAX),\n" + ") PRIMARY KEY(K2)";
146149
OperationFuture<Void, UpdateDatabaseDdlMetadata> op1 =
147150
dbAdminClient.updateDatabaseDdl(instanceId, dbId, ImmutableList.of(statement2), "myop");
148151
OperationFuture<Void, UpdateDatabaseDdlMetadata> op2 =
149152
dbAdminClient.updateDatabaseDdl(instanceId, dbId, ImmutableList.of(statement2), "myop");
150-
op1.get();
151-
op2.get();
153+
op1.get(DATABASE_TIMEOUT_MINUTES, TimeUnit.MINUTES);
154+
op2.get(DATABASE_TIMEOUT_MINUTES, TimeUnit.MINUTES);
152155

153156
// Remove the progress list from the metadata before comparing, as there could be small
154157
// differences between the two in the reported progress depending on exactly when each
@@ -167,7 +170,7 @@ public void databaseOperationsViaEntity() throws Exception {
167170
String statement1 = "CREATE TABLE T (\n" + " K STRING(MAX),\n" + ") PRIMARY KEY(K)";
168171
OperationFuture<Database, CreateDatabaseMetadata> op =
169172
dbAdminClient.createDatabase(instanceId, dbId, ImmutableList.of(statement1));
170-
Database db = op.get();
173+
Database db = op.get(DATABASE_TIMEOUT_MINUTES, TimeUnit.MINUTES);
171174
dbs.add(db);
172175
assertThat(db.getId().getDatabase()).isEqualTo(dbId);
173176

@@ -176,7 +179,7 @@ public void databaseOperationsViaEntity() throws Exception {
176179

177180
String statement2 = "CREATE TABLE T2 (\n" + " K2 STRING(MAX),\n" + ") PRIMARY KEY(K2)";
178181
OperationFuture<?, ?> op2 = db.updateDdl(ImmutableList.of(statement2), null);
179-
op2.get();
182+
op2.get(DATABASE_TIMEOUT_MINUTES, TimeUnit.MINUTES);
180183
Iterable<String> statementsInDb = db.getDdl();
181184
assertThat(statementsInDb).containsExactly(statement1, statement2);
182185
db.drop();
@@ -308,12 +311,12 @@ public void testRetryNonIdempotentRpcsReturningLongRunningOperations() throws Ex
308311
testHelper.getInstanceId().getInstance(),
309312
initialDatabaseId,
310313
Collections.emptyList());
311-
databases.add(op.get());
314+
databases.add(op.get(DATABASE_TIMEOUT_MINUTES, TimeUnit.MINUTES));
312315
// Keep track of the original create time of this database, as we will drop this database
313316
// later and create another one with the exact same name. That means that the ListOperations
314317
// call will return at least two CreateDatabase operations. The retry logic should always
315318
// pick the last one.
316-
initialDbCreateTime = op.get().getCreateTime();
319+
initialDbCreateTime = op.get(DATABASE_TIMEOUT_MINUTES, TimeUnit.MINUTES).getCreateTime();
317320
// Assert that the CreateDatabase RPC was called only once, and that the operation tracking
318321
// was resumed through a GetOperation call.
319322
assertThat(createDbInterceptor.methodCount.get()).isEqualTo(1);
@@ -340,7 +343,7 @@ public void testRetryNonIdempotentRpcsReturningLongRunningOperations() throws Ex
340343
databaseId,
341344
Timestamp.ofTimeSecondsAndNanos(
342345
Timestamp.now().getSeconds() + TimeUnit.SECONDS.convert(7L, TimeUnit.DAYS), 0));
343-
backups.add(op.get());
346+
backups.add(op.get(BACKUP_TIMEOUT_MINUTES, TimeUnit.MINUTES));
344347
// Assert that the CreateBackup RPC was called only once, and that the operation tracking
345348
// was resumed through a GetOperation call.
346349
assertThat(createDbInterceptor.methodCount.get()).isEqualTo(1);
@@ -368,7 +371,7 @@ public void testRetryNonIdempotentRpcsReturningLongRunningOperations() throws Ex
368371
backupId,
369372
testHelper.getInstanceId().getInstance(),
370373
restoredDbId);
371-
databases.add(op.get());
374+
databases.add(op.get(RESTORE_TIMEOUT_MINUTES, TimeUnit.MINUTES));
372375
// Assert that the RestoreDatabase RPC was called only once, and that the operation
373376
// tracking was resumed through a GetOperation call.
374377
assertThat(createDbInterceptor.methodCount.get()).isEqualTo(1);
@@ -409,7 +412,8 @@ public void testRetryNonIdempotentRpcsReturningLongRunningOperations() throws Ex
409412
Collections.emptyList());
410413
// Check that the second database was created and has a greater creation time than the
411414
// first.
412-
Timestamp secondCreationTime = op.get().getCreateTime();
415+
Timestamp secondCreationTime =
416+
op.get(DATABASE_TIMEOUT_MINUTES, TimeUnit.MINUTES).getCreateTime();
413417
// TODO: Change this to greaterThan when the create time of a database is reported back by
414418
// the server.
415419
assertThat(secondCreationTime).isAtLeast(initialDbCreateTime);

0 commit comments

Comments
 (0)