Skip to content

Commit fed3041

Browse files
committed
chore(spanner): fix tests in SessionPoolLeakTest
1 parent b8de686 commit fed3041

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

google-cloud-spanner/src/main/java/com/google/cloud/spanner/MultiplexedSessionDatabaseClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ public void onSessionReady(SessionImpl session) {
262262
.getOptions()
263263
.getSessionPoolOptions()
264264
.getSkipVerifyBeginTransactionForMuxRW()) {
265-
265+
266266
verifyBeginTransactionWithRWOnMultiplexedSessionAsync(session.getName());
267267
}
268268
}

google-cloud-spanner/src/test/java/com/google/cloud/spanner/SessionPoolLeakTest.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ public void testIgnoreLeakedSession() {
171171

172172
@Test
173173
public void testReadWriteTransactionExceptionOnCreateSession() {
174+
assumeFalse(
175+
"Session Leaks do not occur with Multiplexed Sessions",
176+
isMultiplexedSessionsEnabledForRW());
174177
readWriteTransactionTest(
175178
() ->
176179
mockSpanner.setBatchCreateSessionsExecutionTime(
@@ -180,6 +183,9 @@ public void testReadWriteTransactionExceptionOnCreateSession() {
180183

181184
@Test
182185
public void testReadWriteTransactionExceptionOnBegin() {
186+
assumeFalse(
187+
"Session Leaks do not occur with Multiplexed Sessions",
188+
isMultiplexedSessionsEnabledForRW());
183189
readWriteTransactionTest(
184190
() ->
185191
mockSpanner.setBeginTransactionExecutionTime(
@@ -200,6 +206,9 @@ private void readWriteTransactionTest(
200206

201207
@Test
202208
public void testTransactionManagerExceptionOnCreateSession() {
209+
assumeFalse(
210+
"Session Leaks do not occur with Multiplexed Sessions",
211+
isMultiplexedSessionsEnabledForRW());
203212
transactionManagerTest(
204213
() ->
205214
mockSpanner.setBatchCreateSessionsExecutionTime(
@@ -209,6 +218,9 @@ public void testTransactionManagerExceptionOnCreateSession() {
209218

210219
@Test
211220
public void testTransactionManagerExceptionOnBegin() {
221+
assumeFalse(
222+
"Session Leaks do not occur with Multiplexed Sessions",
223+
isMultiplexedSessionsEnabledForRW());
212224
assertThat(pool.getNumberOfSessionsInPool(), is(equalTo(0)));
213225
mockSpanner.setBeginTransactionExecutionTime(
214226
SimulatedExecutionTime.ofException(FAILED_PRECONDITION));
@@ -229,4 +241,11 @@ private void transactionManagerTest(Runnable setup, int expectedNumberOfSessions
229241
}
230242
assertEquals(expectedNumberOfSessionsAfterExecution, pool.getNumberOfSessionsInPool());
231243
}
244+
245+
private boolean isMultiplexedSessionsEnabledForRW() {
246+
if (spanner.getOptions() == null || spanner.getOptions().getSessionPoolOptions() == null) {
247+
return false;
248+
}
249+
return spanner.getOptions().getSessionPoolOptions().getUseMultiplexedSessionForRW();
250+
}
232251
}

0 commit comments

Comments
 (0)