@@ -102,7 +102,7 @@ public void createSpannerInstance() {
102102 }
103103
104104 @ Test
105- public void testCreateSessionDeadlineExceeded () throws Exception {
105+ public void testCreateSessionDeadlineExceededWithNoSessionCreateWaitTime () throws Exception {
106106 // Simulate a problem with the CreateSession RPC making it slow.
107107 mockSpanner .setCreateSessionExecutionTime (
108108 SimulatedExecutionTime .ofException (Status .DEADLINE_EXCEEDED .asRuntimeException ()));
@@ -113,9 +113,12 @@ public void testCreateSessionDeadlineExceeded() throws Exception {
113113 .setProjectId ("test-project" )
114114 .setChannelProvider (channelProvider )
115115 .setCredentials (NoCredentials .getInstance ())
116+ .setSessionPoolOption (
117+ SessionPoolOptions .newBuilder ().setFailOnSessionLeak ().build ())
116118 .build ()
117119 .getService ();
118- DatabaseClient client = testSpanner .getDatabaseClient (DatabaseId .of ("p" , "i" , "d" ));
120+ DatabaseClientImpl client =
121+ (DatabaseClientImpl ) testSpanner .getDatabaseClient (DatabaseId .of ("p" , "i" , "d" ));
119122
120123 // The first attempt should lead to a DEADLINE_EXCEEDED error being propagated from the
121124 // CreateSession attempt.
@@ -126,13 +129,20 @@ public void testCreateSessionDeadlineExceeded() throws Exception {
126129
127130 // The next attempt should then succeed.
128131 mockSpanner .unfreeze ();
129- DatabaseClientImpl clientImpl = (DatabaseClientImpl ) client ;
130- assertNotNull (clientImpl .multiplexedSessionDatabaseClient .getCurrentSessionReference ());
132+ assertNotNull (client .multiplexedSessionDatabaseClient .getCurrentSessionReference ());
131133
132134 try (ResultSet resultSet = client .singleUse ().executeQuery (STATEMENT )) {
133135 //noinspection StatementWithEmptyBody
134136 while (resultSet .next ()) {}
135137 }
138+
139+ List <CreateSessionRequest > createSessionRequests =
140+ mockSpanner .getRequestsOfType (CreateSessionRequest .class );
141+ assertEquals (2 , createSessionRequests .size ());
142+
143+ List <ExecuteSqlRequest > requests = mockSpanner .getRequestsOfType (ExecuteSqlRequest .class );
144+ assertEquals (1 , requests .size ());
145+
136146 testSpanner .close ();
137147 }
138148
@@ -338,67 +348,6 @@ public void testRetryWithTheDatabaseNotFoundExceptionWithSessionCreationWaitTime
338348 testSpanner .close ();
339349 }
340350
341- @ Test
342- public void testRetryWithNoSessionCreationWaitTime () {
343- mockSpanner .setCreateSessionExecutionTime (
344- SimulatedExecutionTime .ofExceptions (
345- Collections .singletonList (
346- Status .DEADLINE_EXCEEDED
347- .withDescription (
348- "CallOptions deadline exceeded after 22.986872393s. "
349- + "Name resolution delay 6.911918521 seconds. [closed=[], "
350- + "open=[[connecting_and_lb_delay=32445014148ns, was_still_waiting]]]" )
351- .asRuntimeException ())));
352-
353- Spanner testSpanner =
354- SpannerOptions .newBuilder ()
355- .setProjectId ("test-project" )
356- .setChannelProvider (channelProvider )
357- .setCredentials (NoCredentials .getInstance ())
358- .setSessionPoolOption (
359- SessionPoolOptions .newBuilder ()
360- .setUseMultiplexedSession (true )
361- .setUseMultiplexedSessionForRW (true )
362- .setUseMultiplexedSessionPartitionedOps (true )
363- .setFailOnSessionLeak ()
364- .build ())
365- .build ()
366- .getService ();
367-
368- DatabaseClientImpl client =
369- (DatabaseClientImpl ) testSpanner .getDatabaseClient (DatabaseId .of ("p" , "i" , "d" ));
370-
371- SpannerException spannerException =
372- assertThrows (
373- SpannerException .class ,
374- () -> {
375- try (ResultSet resultSet = client .singleUse ().executeQuery (STATEMENT )) {
376- //noinspection StatementWithEmptyBody
377- while (resultSet .next ()) {
378- // ignore
379- }
380- }
381- });
382- assertEquals (ErrorCode .DEADLINE_EXCEEDED , spannerException .getErrorCode ());
383-
384- // The CreateSession RPC will be retried, and as the exception is removed by the first call,
385- // the second attempt will succeed.
386- try (ResultSet resultSet = client .singleUse ().executeQuery (STATEMENT )) {
387- //noinspection StatementWithEmptyBody
388- while (resultSet .next ()) {
389- // ignore
390- }
391- }
392-
393- List <CreateSessionRequest > createSessionRequests =
394- mockSpanner .getRequestsOfType (CreateSessionRequest .class );
395- assertEquals (2 , createSessionRequests .size ());
396-
397- List <ExecuteSqlRequest > requests = mockSpanner .getRequestsOfType (ExecuteSqlRequest .class );
398- assertEquals (1 , requests .size ());
399-
400- testSpanner .close ();
401- }
402351
403352 @ Test
404353 public void testRetryWithDelayedInResponseExceedsSessionCreationWaitTime () {
0 commit comments