Skip to content

Commit 74bcc51

Browse files
authored
chore(spanner): test fixes for mux rw (#3649)
1 parent 20a3d0d commit 74bcc51

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,6 +1521,10 @@ public void testRetryLargeResultSet() {
15211521
/** Test the successful retry of a transaction with a high chance of multiple aborts */
15221522
@Test
15231523
public void testRetryHighAbortRate() {
1524+
// TODO(sriharshach): Remove this skip once backend support empty transactions to commit.
1525+
assumeFalse(
1526+
"Skipping for multiplexed sessions since it does not allow empty transactions to commit",
1527+
env.getTestHelper().getOptions().getSessionPoolOptions().getUseMultiplexedSessionForRW());
15241528
final int NUMBER_OF_TEST_RECORDS = 10000;
15251529
final long UPDATED_RECORDS = 1000L;
15261530
// abort on 25% of all statements

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,16 @@ public void testInvalidInsert() throws InterruptedException {
161161
} catch (ExecutionException e) {
162162
assertThat(e.getCause()).isInstanceOf(SpannerException.class);
163163
SpannerException se = (SpannerException) e.getCause();
164-
assertThat(se.getErrorCode()).isEqualTo(ErrorCode.NOT_FOUND);
164+
if (env.getTestHelper()
165+
.getOptions()
166+
.getSessionPoolOptions()
167+
.getUseMultiplexedSessionForRW()) {
168+
// Backend currently returns INVALID_ARGUMENT, however this will be changed to NOT_FOUND
169+
// in future.
170+
assertThat(se.getErrorCode()).isAnyOf(ErrorCode.NOT_FOUND, ErrorCode.INVALID_ARGUMENT);
171+
} else {
172+
assertThat(se.getErrorCode()).isEqualTo(ErrorCode.NOT_FOUND);
173+
}
165174
// expected
166175
break;
167176
}

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

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,16 @@ public void tableNotFound() {
10431043
.build());
10441044
fail("Expected exception");
10451045
} catch (SpannerException ex) {
1046-
assertThat(ex.getErrorCode()).isEqualTo(ErrorCode.NOT_FOUND);
1046+
if (env.getTestHelper()
1047+
.getOptions()
1048+
.getSessionPoolOptions()
1049+
.getUseMultiplexedSessionForRW()) {
1050+
// Backend currently returns INVALID_ARGUMENT, however this will be changed to NOT_FOUND in
1051+
// future.
1052+
assertThat(ex.getErrorCode()).isAnyOf(ErrorCode.NOT_FOUND, ErrorCode.INVALID_ARGUMENT);
1053+
} else {
1054+
assertThat(ex.getErrorCode()).isEqualTo(ErrorCode.NOT_FOUND);
1055+
}
10471056
}
10481057
}
10491058

@@ -1053,7 +1062,16 @@ public void columnNotFound() {
10531062
write(baseInsert().set("ColumnThatDoesNotExist").to("V1").build());
10541063
fail("Expected exception");
10551064
} catch (SpannerException ex) {
1056-
assertThat(ex.getErrorCode()).isEqualTo(ErrorCode.NOT_FOUND);
1065+
if (env.getTestHelper()
1066+
.getOptions()
1067+
.getSessionPoolOptions()
1068+
.getUseMultiplexedSessionForRW()) {
1069+
// Backend currently returns INVALID_ARGUMENT, however this will be changed to NOT_FOUND in
1070+
// future.
1071+
assertThat(ex.getErrorCode()).isAnyOf(ErrorCode.NOT_FOUND, ErrorCode.INVALID_ARGUMENT);
1072+
} else {
1073+
assertThat(ex.getErrorCode()).isEqualTo(ErrorCode.NOT_FOUND);
1074+
}
10571075
}
10581076
}
10591077

0 commit comments

Comments
 (0)