Skip to content
Merged
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 @@ -36,6 +36,7 @@
import com.google.cloud.spanner.Key;
import com.google.cloud.spanner.KeySet;
import com.google.cloud.spanner.Mutation;
import com.google.cloud.spanner.ParallelIntegrationTest;
import com.google.cloud.spanner.Spanner;
import com.google.cloud.spanner.SpannerException;
import com.google.cloud.spanner.Struct;
Expand All @@ -48,17 +49,19 @@
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameter;
import org.junit.runners.Parameterized.Parameters;

@RunWith(Parameterized.class)
@Category(ParallelIntegrationTest.class)
public class ITTransactionManagerAsyncTest {

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

@ClassRule public static IntegrationTestEnv env = new IntegrationTestEnv();
private static Database db;
private Spanner spanner;
private DatabaseClient client;
private static Spanner spanner;
private static DatabaseClient client;

@BeforeClass
public static void setUpDatabase() {
Expand All @@ -89,20 +92,15 @@ public static void setUpDatabase() {
+ " K STRING(MAX) NOT NULL,"
+ " BoolValue BOOL,"
+ ") PRIMARY KEY (K)");
spanner = env.getTestHelper().getClient();
client = spanner.getDatabaseClient(db.getId());
}

@Before
public void clearTable() {
spanner = env.getTestHelper().getClient();
client = spanner.getDatabaseClient(db.getId());
client.write(ImmutableList.of(Mutation.delete("T", KeySet.all())));
}

@After
public void closeSpanner() {
spanner.close();
}

@Test
public void testSimpleInsert() throws ExecutionException, InterruptedException {
try (AsyncTransactionManager manager = client.transactionManagerAsync()) {
Expand Down Expand Up @@ -224,6 +222,8 @@ public ApiFuture<Void> apply(TransactionContext txn, Void input) throws Exceptio
}
}

@Ignore(
"Cloud Spanner now seems to return CANCELLED instead of ABORTED when a transaction is invalidated by a later transaction in the same session")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be a slight behavioral change in Cloud Spanner: Starting a new read/write transaction on a session that already has a read/write transaction will invalidate the first transaction. As far as I can tell, that would previously return an ABORTED error. That seems to have been changed to a CANCELLED error, which does make sense as it is an indication of an application error rather than a transient server error.

@Test
public void testAbortAndRetry() throws InterruptedException, ExecutionException {
assumeFalse(
Expand Down