Skip to content

Commit f14f7c9

Browse files
authored
test: fix ITTransactionManagerAsyncTest (#706)
* test: fix test that would not run on both emulator and real Spanner * fix: add category to test to ensure it's executed
1 parent fa19940 commit f14f7c9

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

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

+10-10
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import com.google.cloud.spanner.Key;
3737
import com.google.cloud.spanner.KeySet;
3838
import com.google.cloud.spanner.Mutation;
39+
import com.google.cloud.spanner.ParallelIntegrationTest;
3940
import com.google.cloud.spanner.Spanner;
4041
import com.google.cloud.spanner.SpannerException;
4142
import com.google.cloud.spanner.Struct;
@@ -48,17 +49,19 @@
4849
import java.util.concurrent.ExecutionException;
4950
import java.util.concurrent.Executor;
5051
import java.util.concurrent.Executors;
51-
import org.junit.After;
5252
import org.junit.Before;
5353
import org.junit.BeforeClass;
5454
import org.junit.ClassRule;
55+
import org.junit.Ignore;
5556
import org.junit.Test;
57+
import org.junit.experimental.categories.Category;
5658
import org.junit.runner.RunWith;
5759
import org.junit.runners.Parameterized;
5860
import org.junit.runners.Parameterized.Parameter;
5961
import org.junit.runners.Parameterized.Parameters;
6062

6163
@RunWith(Parameterized.class)
64+
@Category(ParallelIntegrationTest.class)
6265
public class ITTransactionManagerAsyncTest {
6366

6467
@Parameter(0)
@@ -76,8 +79,8 @@ public static Collection<Object[]> data() {
7679

7780
@ClassRule public static IntegrationTestEnv env = new IntegrationTestEnv();
7881
private static Database db;
79-
private Spanner spanner;
80-
private DatabaseClient client;
82+
private static Spanner spanner;
83+
private static DatabaseClient client;
8184

8285
@BeforeClass
8386
public static void setUpDatabase() {
@@ -89,20 +92,15 @@ public static void setUpDatabase() {
8992
+ " K STRING(MAX) NOT NULL,"
9093
+ " BoolValue BOOL,"
9194
+ ") PRIMARY KEY (K)");
95+
spanner = env.getTestHelper().getClient();
96+
client = spanner.getDatabaseClient(db.getId());
9297
}
9398

9499
@Before
95100
public void clearTable() {
96-
spanner = env.getTestHelper().getClient();
97-
client = spanner.getDatabaseClient(db.getId());
98101
client.write(ImmutableList.of(Mutation.delete("T", KeySet.all())));
99102
}
100103

101-
@After
102-
public void closeSpanner() {
103-
spanner.close();
104-
}
105-
106104
@Test
107105
public void testSimpleInsert() throws ExecutionException, InterruptedException {
108106
try (AsyncTransactionManager manager = client.transactionManagerAsync()) {
@@ -224,6 +222,8 @@ public ApiFuture<Void> apply(TransactionContext txn, Void input) throws Exceptio
224222
}
225223
}
226224

225+
@Ignore(
226+
"Cloud Spanner now seems to return CANCELLED instead of ABORTED when a transaction is invalidated by a later transaction in the same session")
227227
@Test
228228
public void testAbortAndRetry() throws InterruptedException, ExecutionException {
229229
assumeFalse(

0 commit comments

Comments
 (0)