Skip to content

Commit e7fbecc

Browse files
committed
chore(spanner): fix DatabaseClientImpl test
1 parent 3a473ac commit e7fbecc

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

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

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3142,15 +3142,20 @@ public void testDatabaseOrInstanceDoesNotExistOnCreate() {
31423142
.readWriteTransaction()
31433143
.run(transaction -> transaction.executeUpdate(UPDATE_STATEMENT)));
31443144
// No additional requests should have been sent by the client.
3145-
// Note that in case of the use of multiplexed sessions, then we have 2 requests:
3146-
// Note that in case of the use of regular sessions, then we have 1 request:
3147-
// 1. BatchCreateSessions for the session pool.
3148-
// 2. CreateSession for the multiplexed session.
3149-
assertThat(mockSpanner.getRequests())
3150-
.hasSize(
3151-
spanner.getOptions().getSessionPoolOptions().getUseMultiplexedSession()
3152-
? 2
3153-
: 1);
3145+
if (spanner.getOptions().getSessionPoolOptions().getUseMultiplexedSession()
3146+
&& !spanner.getOptions().getSessionPoolOptions().getUseMultiplexedSessionForRW()) {
3147+
// Note that in case of the use of multiplexed sessions for read-only alone, then we
3148+
// have 2 requests:
3149+
// 1. BatchCreateSessions for the session pool.
3150+
// 2. CreateSession for the multiplexed session.
3151+
assertThat(mockSpanner.getRequests()).hasSize(2);
3152+
} else {
3153+
// Note that in case of the use of regular sessions, then we have 1 request:
3154+
// BatchCreateSessions for the session pool.
3155+
// Note that in case of the use of multiplexed sessions for read-write, then we have 1
3156+
// request: CreateSession for the multiplexed session.
3157+
assertThat(mockSpanner.getRequests()).hasSize(1);
3158+
}
31543159
}
31553160
}
31563161
mockSpanner.reset();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import static org.junit.Assert.assertNotEquals;
2323
import static org.junit.Assert.assertThrows;
2424
import static org.junit.Assert.assertTrue;
25+
import static org.junit.Assume.assumeFalse;
2526

2627
import com.google.cloud.NoCredentials;
2728
import com.google.cloud.spanner.MockSpannerServiceImpl.SimulatedExecutionTime;
@@ -59,7 +60,6 @@
5960
import org.junit.Test;
6061
import org.junit.runner.RunWith;
6162
import org.junit.runners.JUnit4;
62-
import static org.junit.Assume.assumeFalse;
6363

6464
@RunWith(JUnit4.class)
6565
public class RetryOnDifferentGrpcChannelMockServerTest extends AbstractMockServerTest {

0 commit comments

Comments
 (0)