Skip to content

Commit 81d143b

Browse files
committed
Update tests for createMultiplexedSession
1 parent 744706f commit 81d143b

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ Object value() {
117117
Option.REQUEST_ID, requestId);
118118
}
119119

120+
static Map<SpannerRpc.Option, ?> createRequestOptions(
121+
XGoogSpannerRequestId requestId) {
122+
return ImmutableMap.of(Option.REQUEST_ID, requestId);
123+
}
124+
120125
private final class BatchCreateSessionsRunnable implements Runnable {
121126
private final long channelHint;
122127
private final int sessionCount;
@@ -297,7 +302,7 @@ SessionImpl createMultiplexedSession() {
297302
db.getName(),
298303
spanner.getOptions().getDatabaseRole(),
299304
spanner.getOptions().getSessionLabels(),
300-
createRequestOptions(channelId, reqId),
305+
createRequestOptions(reqId),
301306
true);
302307
SessionImpl sessionImpl =
303308
new SessionImpl(

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import static com.google.common.truth.Truth.assertThat;
2020
import static org.junit.Assert.assertEquals;
2121
import static org.junit.Assert.assertNull;
22+
import static org.junit.Assert.assertNotNull;
2223
import static org.junit.Assert.assertTrue;
2324
import static org.mockito.ArgumentMatchers.any;
2425
import static org.mockito.Mockito.doNothing;
@@ -207,7 +208,9 @@ public void onSessionCreateFailure(Throwable t, int createFailureForSessionCount
207208
client.createMultiplexedSession(consumer);
208209
}
209210
// for multiplexed session there is no channel hint pass in the RPC options
210-
assertNull(options.getValue());
211+
assertNotNull(options.getValue());
212+
assertEquals(options.getValue().get(Option.CHANNEL_HINT), null);
213+
assertNotNull(options.getValue().get(Option.REQUEST_ID));
211214
assertEquals(1, returnedSessionCount.get());
212215
}
213216

@@ -239,7 +242,9 @@ public void onSessionCreateFailure(Throwable t, int createFailureForSessionCount
239242
client.createMultiplexedSession(consumer);
240243
}
241244
// for multiplexed session there is no channel hint pass in the RPC options
242-
assertNull(options.getValue());
245+
assertNotNull(options.getValue());
246+
assertEquals(options.getValue().get(Option.CHANNEL_HINT), null);
247+
assertNotNull(options.getValue().get(Option.REQUEST_ID));
243248
}
244249

245250
@SuppressWarnings("unchecked")

0 commit comments

Comments
 (0)