Skip to content

Commit ebd326b

Browse files
authored
test: enable more tests on the Emulator (googleapis#3535)
Multiple tests were skipped on the Emulator, because the features that are covered by these tests were originally not supported on the Emulator. These features are now available on the Emulator, and the tests can be enabled.
1 parent b060dfd commit ebd326b

11 files changed

+175
-282
lines changed

google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/it/ITAsyncTransactionRetryTest.java

-6
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@
1717
package com.google.cloud.spanner.connection.it;
1818

1919
import static com.google.cloud.spanner.SpannerApiFutures.get;
20-
import static com.google.cloud.spanner.testing.EmulatorSpannerHelper.isUsingEmulator;
2120
import static com.google.common.truth.Truth.assertThat;
2221
import static org.junit.Assert.fail;
23-
import static org.junit.Assume.assumeFalse;
2422

2523
import com.google.api.core.ApiFuture;
2624
import com.google.api.core.SettableApiFuture;
@@ -580,7 +578,6 @@ public void testAbortWithResultSetFullyConsumed() {
580578

581579
@Test
582580
public void testAbortWithConcurrentInsert() {
583-
assumeFalse("concurrent transactions are not supported on the emulator", isUsingEmulator());
584581
AbortInterceptor interceptor = new AbortInterceptor(0);
585582
try (ITConnection connection =
586583
createConnection(interceptor, new CountTransactionRetryListener())) {
@@ -632,7 +629,6 @@ public void testAbortWithConcurrentInsert() {
632629

633630
@Test
634631
public void testAbortWithConcurrentDelete() {
635-
assumeFalse("concurrent transactions are not supported on the emulator", isUsingEmulator());
636632
AbortInterceptor interceptor = new AbortInterceptor(0);
637633
// first insert two test records
638634
try (ITConnection connection = createConnection()) {
@@ -686,7 +682,6 @@ public void testAbortWithConcurrentDelete() {
686682

687683
@Test
688684
public void testAbortWithConcurrentUpdate() {
689-
assumeFalse("concurrent transactions are not supported on the emulator", isUsingEmulator());
690685
AbortInterceptor interceptor = new AbortInterceptor(0);
691686
// first insert two test records
692687
try (ITConnection connection = createConnection()) {
@@ -746,7 +741,6 @@ public void testAbortWithConcurrentUpdate() {
746741
*/
747742
@Test
748743
public void testAbortWithUnseenConcurrentInsert() throws InterruptedException {
749-
assumeFalse("concurrent transactions are not supported on the emulator", isUsingEmulator());
750744
AbortInterceptor interceptor = new AbortInterceptor(0);
751745
try (ITConnection connection =
752746
createConnection(interceptor, new CountTransactionRetryListener())) {

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

+23-39
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,9 @@
1919
import static com.google.cloud.spanner.connection.ITAbstractSpannerTest.extractConnectionUrl;
2020
import static com.google.cloud.spanner.connection.ITAbstractSpannerTest.getKeyFile;
2121
import static com.google.cloud.spanner.connection.ITAbstractSpannerTest.hasValidKeyFile;
22-
import static com.google.cloud.spanner.testing.EmulatorSpannerHelper.isUsingEmulator;
2322
import static com.google.common.truth.Truth.assertThat;
2423
import static org.junit.Assert.assertEquals;
2524
import static org.junit.Assert.assertTrue;
26-
import static org.junit.Assume.assumeFalse;
2725

2826
import com.google.cloud.ByteArray;
2927
import com.google.cloud.Timestamp;
@@ -96,10 +94,7 @@ public class ITBatchReadTest {
9694
public static List<DialectTestParameter> data() {
9795
List<DialectTestParameter> params = new ArrayList<>();
9896
params.add(new DialectTestParameter(Dialect.GOOGLE_STANDARD_SQL));
99-
// PG dialect tests are not supported by the emulator
100-
if (!isUsingEmulator()) {
101-
params.add(new DialectTestParameter(Dialect.POSTGRESQL));
102-
}
97+
params.add(new DialectTestParameter(Dialect.POSTGRESQL));
10398
return params;
10499
}
105100

@@ -135,30 +130,28 @@ public static void setUpDatabase() throws Exception {
135130
List<DatabaseClient> databaseClients = new ArrayList<>();
136131
databaseClients.add(env.getTestHelper().getDatabaseClient(googleStandardDatabase));
137132

138-
if (!isUsingEmulator()) {
139-
postgreSQLDatabase =
140-
env.getTestHelper().createTestDatabase(Dialect.POSTGRESQL, Collections.emptyList());
141-
env.getTestHelper()
142-
.getClient()
143-
.getDatabaseAdminClient()
144-
.updateDatabaseDdl(
145-
env.getTestHelper().getInstanceId().getInstance(),
146-
postgreSQLDatabase.getId().getDatabase(),
147-
ImmutableList.of(
148-
"CREATE TABLE "
149-
+ TABLE_NAME
150-
+ " ("
151-
+ " Key bigint not null primary key,"
152-
+ " Data bytea,"
153-
+ " Fingerprint bigint,"
154-
+ " Size bigint"
155-
+ ")",
156-
"CREATE INDEX " + INDEX_NAME + " ON " + TABLE_NAME + "(Fingerprint)"),
157-
null)
158-
.get();
159-
postgreSQLBatchClient = env.getTestHelper().getBatchClient(postgreSQLDatabase);
160-
databaseClients.add(env.getTestHelper().getDatabaseClient(postgreSQLDatabase));
161-
}
133+
postgreSQLDatabase =
134+
env.getTestHelper().createTestDatabase(Dialect.POSTGRESQL, Collections.emptyList());
135+
env.getTestHelper()
136+
.getClient()
137+
.getDatabaseAdminClient()
138+
.updateDatabaseDdl(
139+
env.getTestHelper().getInstanceId().getInstance(),
140+
postgreSQLDatabase.getId().getDatabase(),
141+
ImmutableList.of(
142+
"CREATE TABLE "
143+
+ TABLE_NAME
144+
+ " ("
145+
+ " Key bigint not null primary key,"
146+
+ " Data bytea,"
147+
+ " Fingerprint bigint,"
148+
+ " Size bigint"
149+
+ ")",
150+
"CREATE INDEX " + INDEX_NAME + " ON " + TABLE_NAME + "(Fingerprint)"),
151+
null)
152+
.get();
153+
postgreSQLBatchClient = env.getTestHelper().getBatchClient(postgreSQLDatabase);
154+
databaseClients.add(env.getTestHelper().getDatabaseClient(postgreSQLDatabase));
162155

163156
List<Integer> rows = manyRows();
164157
numRows = rows.size();
@@ -210,9 +203,6 @@ private Database getDatabase() {
210203

211204
@Test
212205
public void read() {
213-
assumeFalse(
214-
"PostgreSQL does not support the PartitionRead RPC", dialect.dialect == Dialect.POSTGRESQL);
215-
216206
BitSet seenRows = new BitSet(numRows);
217207
TimestampBound bound = getRandomBound();
218208
PartitionOptions partitionParams = getRandomPartitionOptions();
@@ -229,9 +219,6 @@ public void read() {
229219

230220
@Test
231221
public void readUsingIndex() {
232-
assumeFalse(
233-
"PostgreSQL does not support the PartitionRead RPC", dialect.dialect == Dialect.POSTGRESQL);
234-
235222
TimestampBound bound = getRandomBound();
236223
PartitionOptions partitionParams = getRandomPartitionOptions();
237224
batchTxn = getBatchClient().batchReadOnlyTransaction(bound);
@@ -258,8 +245,6 @@ public void readUsingIndex() {
258245

259246
@Test
260247
public void dataBoostRead() {
261-
assumeFalse("Emulator does not support data boost read", isUsingEmulator());
262-
263248
BitSet seenRows = new BitSet(numRows);
264249
TimestampBound bound = getRandomBound();
265250
PartitionOptions partitionParams = getRandomPartitionOptions();
@@ -312,7 +297,6 @@ private PartitionOptions getRandomPartitionOptions() {
312297

313298
@Test
314299
public void dataBoostQuery() {
315-
assumeFalse("Emulator does not support data boost query", isUsingEmulator());
316300
BitSet seenRows = new BitSet(numRows);
317301
TimestampBound bound = getRandomBound();
318302
PartitionOptions partitionParams = getRandomPartitionOptions();

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

+8-19
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,12 @@
1616

1717
package com.google.cloud.spanner.it;
1818

19-
import static com.google.cloud.spanner.testing.EmulatorSpannerHelper.isUsingEmulator;
2019
import static com.google.common.truth.Truth.assertThat;
2120
import static org.junit.Assert.assertEquals;
2221
import static org.junit.Assert.assertFalse;
2322
import static org.junit.Assert.assertNotNull;
2423
import static org.junit.Assert.assertTrue;
2524
import static org.junit.Assert.fail;
26-
import static org.junit.Assume.assumeFalse;
2725

2826
import com.google.cloud.spanner.AbortedException;
2927
import com.google.cloud.spanner.Database;
@@ -90,15 +88,13 @@ public static void setUpDatabase() {
9088
+ " V INT64,"
9189
+ ") PRIMARY KEY (K)");
9290
googleStandardSQLClient = env.getTestHelper().getDatabaseClient(googleStandardSQLDatabase);
93-
if (!isUsingEmulator()) {
94-
Database postgreSQLDatabase =
95-
env.getTestHelper()
96-
.createTestDatabase(
97-
Dialect.POSTGRESQL,
98-
Arrays.asList(
99-
"CREATE TABLE T (" + " K VARCHAR PRIMARY KEY," + " V BIGINT" + ")"));
100-
postgreSQLClient = env.getTestHelper().getDatabaseClient(postgreSQLDatabase);
101-
}
91+
Database postgreSQLDatabase =
92+
env.getTestHelper()
93+
.createTestDatabase(
94+
Dialect.POSTGRESQL,
95+
Arrays.asList(
96+
"CREATE TABLE T (" + " K VARCHAR PRIMARY KEY," + " V BIGINT" + ")"));
97+
postgreSQLClient = env.getTestHelper().getDatabaseClient(postgreSQLDatabase);
10298
}
10399

104100
@AfterClass
@@ -122,10 +118,7 @@ public void increaseTestIdAndDeleteTestData() {
122118
public static List<DialectTestParameter> data() {
123119
List<DialectTestParameter> params = new ArrayList<>();
124120
params.add(new DialectTestParameter(Dialect.GOOGLE_STANDARD_SQL));
125-
// "PG dialect tests are not supported by the emulator"
126-
if (!isUsingEmulator()) {
127-
params.add(new DialectTestParameter(Dialect.POSTGRESQL));
128-
}
121+
params.add(new DialectTestParameter(Dialect.POSTGRESQL));
129122
return params;
130123
}
131124

@@ -389,10 +382,6 @@ public void standardDMLWithExecuteSQL() {
389382

390383
@Test
391384
public void testUntypedNullValues() {
392-
assumeFalse(
393-
"Spanner PostgreSQL does not yet support untyped null values",
394-
dialect.dialect == Dialect.POSTGRESQL);
395-
396385
DatabaseClient client = getClient(dialect.dialect);
397386
String sql;
398387
if (dialect.dialect == Dialect.POSTGRESQL) {

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

-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import static com.google.common.truth.Truth.assertThat;
2121
import static org.junit.Assert.assertEquals;
2222
import static org.junit.Assert.fail;
23-
import static org.junit.Assume.assumeFalse;
2423

2524
import com.google.api.client.util.ExponentialBackOff;
2625
import com.google.api.gax.longrunning.OperationFuture;
@@ -182,8 +181,6 @@ public void instanceNotFound() {
182181

183182
@Test
184183
public void testNumericPrimaryKey() {
185-
assumeFalse("Emulator does not support numeric primary keys", isUsingEmulator());
186-
187184
final String table = "NumericTable";
188185

189186
// Creates table with numeric primary key

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

+13-15
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
import com.google.cloud.spanner.TransactionRunner;
4343
import com.google.cloud.spanner.TransactionRunner.TransactionCallable;
4444
import com.google.cloud.spanner.connection.ConnectionOptions;
45-
import com.google.cloud.spanner.testing.EmulatorSpannerHelper;
4645
import java.util.ArrayList;
4746
import java.util.Arrays;
4847
import java.util.Collections;
@@ -75,8 +74,6 @@ public final class ITDmlReturningTest {
7574

7675
@BeforeClass
7776
public static void setUpDatabase() {
78-
assumeFalse(
79-
"DML Returning is not supported in the emulator", EmulatorSpannerHelper.isUsingEmulator());
8077
Database googleStandardSQLDatabase =
8178
env.getTestHelper()
8279
.createTestDatabase(
@@ -85,18 +82,16 @@ public static void setUpDatabase() {
8582
+ " V INT64,"
8683
+ ") PRIMARY KEY (K)");
8784
googleStandardSQLClient = env.getTestHelper().getDatabaseClient(googleStandardSQLDatabase);
88-
if (!isUsingEmulator()) {
89-
Database postgreSQLDatabase =
90-
env.getTestHelper()
91-
.createTestDatabase(
92-
Dialect.POSTGRESQL,
93-
Collections.singletonList(
94-
"CREATE TABLE T ("
95-
+ " \"K\" VARCHAR PRIMARY KEY,"
96-
+ " \"V\" BIGINT"
97-
+ ")"));
98-
postgreSQLClient = env.getTestHelper().getDatabaseClient(postgreSQLDatabase);
99-
}
85+
Database postgreSQLDatabase =
86+
env.getTestHelper()
87+
.createTestDatabase(
88+
Dialect.POSTGRESQL,
89+
Collections.singletonList(
90+
"CREATE TABLE T ("
91+
+ " \"K\" VARCHAR PRIMARY KEY,"
92+
+ " \"V\" BIGINT"
93+
+ ")"));
94+
postgreSQLClient = env.getTestHelper().getDatabaseClient(postgreSQLDatabase);
10095
}
10196

10297
@AfterClass
@@ -222,6 +217,9 @@ private void executeUpdateAsync(long expectedCount, final String... stmts) {
222217

223218
@Test
224219
public void dmlReturningWithExecutePartitionedUpdate() {
220+
assumeFalse(
221+
"The emulator does not dis-allow THEN RETURN statements for PDML", isUsingEmulator());
222+
225223
SpannerException e =
226224
assertThrows(
227225
SpannerException.class,

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

-4
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,11 @@
1616

1717
package com.google.cloud.spanner.it;
1818

19-
import static com.google.cloud.spanner.testing.EmulatorSpannerHelper.isUsingEmulator;
2019
import static org.junit.Assert.assertArrayEquals;
2120
import static org.junit.Assert.assertEquals;
2221
import static org.junit.Assert.assertFalse;
2322
import static org.junit.Assert.assertThrows;
2423
import static org.junit.Assert.assertTrue;
25-
import static org.junit.Assume.assumeFalse;
2624

2725
import com.google.cloud.Timestamp;
2826
import com.google.cloud.spanner.Database;
@@ -93,8 +91,6 @@ public static List<DialectTestParameter> data() {
9391
@BeforeClass
9492
public static void setUpDatabase()
9593
throws ExecutionException, InterruptedException, TimeoutException {
96-
assumeFalse("Emulator does not support FLOAT32 yet", isUsingEmulator());
97-
9894
Database googleStandardSQLDatabase =
9995
env.getTestHelper().createTestDatabase(GOOGLE_STANDARD_SQL_SCHEMA);
10096

0 commit comments

Comments
 (0)