Skip to content

Commit

Permalink
tests: skip autocommit timeout test on emulator (#320)
Browse files Browse the repository at this point in the history
  • Loading branch information
olavloite committed Jul 7, 2020
1 parent 9665f3a commit a7378f8
Showing 1 changed file with 6 additions and 3 deletions.
Expand Up @@ -21,6 +21,7 @@
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeFalse;

import com.google.cloud.spanner.ErrorCode;
import com.google.cloud.spanner.Mutation;
Expand Down Expand Up @@ -73,6 +74,9 @@ public void test02_WriteMutation() {

@Test
public void test03_MultipleStatements_WithTimeouts() {
assumeFalse(
"Rolling back a transaction while an update statement is still in flight can cause the transaction to remain active on the emulator",
env.getTestHelper().isEmulator());
try (ITConnection connection = createConnection()) {
// do an insert that should succeed
assertThat(
Expand All @@ -91,10 +95,9 @@ public void test03_MultipleStatements_WithTimeouts() {
connection.setStatementTimeout(1L, TimeUnit.MILLISECONDS);
try {
connection.executeUpdate(Statement.of("UPDATE TEST SET NAME='test18' WHERE ID=1000"));
fail("missing expected exception");
} catch (SpannerException e) {
if (e.getErrorCode() != ErrorCode.DEADLINE_EXCEEDED) {
throw e;
}
assertThat(e.getErrorCode(), is(equalTo(ErrorCode.DEADLINE_EXCEEDED)));
}
// remove the timeout setting
connection.clearStatementTimeout();
Expand Down

0 comments on commit a7378f8

Please sign in to comment.