@@ -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,11 @@ public void testCreateSessionDeadlineExceeded() throws Exception {
113113 .setProjectId ("test-project" )
114114 .setChannelProvider (channelProvider )
115115 .setCredentials (NoCredentials .getInstance ())
116+ .setSessionPoolOption (SessionPoolOptions .newBuilder ().setFailOnSessionLeak ().build ())
116117 .build ()
117118 .getService ();
118- DatabaseClient client = testSpanner .getDatabaseClient (DatabaseId .of ("p" , "i" , "d" ));
119+ DatabaseClientImpl client =
120+ (DatabaseClientImpl ) testSpanner .getDatabaseClient (DatabaseId .of ("p" , "i" , "d" ));
119121
120122 // The first attempt should lead to a DEADLINE_EXCEEDED error being propagated from the
121123 // CreateSession attempt.
@@ -126,13 +128,20 @@ public void testCreateSessionDeadlineExceeded() throws Exception {
126128
127129 // The next attempt should then succeed.
128130 mockSpanner .unfreeze ();
129- DatabaseClientImpl clientImpl = (DatabaseClientImpl ) client ;
130- assertNotNull (clientImpl .multiplexedSessionDatabaseClient .getCurrentSessionReference ());
131+ assertNotNull (client .multiplexedSessionDatabaseClient .getCurrentSessionReference ());
131132
132133 try (ResultSet resultSet = client .singleUse ().executeQuery (STATEMENT )) {
133134 //noinspection StatementWithEmptyBody
134135 while (resultSet .next ()) {}
135136 }
137+
138+ List <CreateSessionRequest > createSessionRequests =
139+ mockSpanner .getRequestsOfType (CreateSessionRequest .class );
140+ assertEquals (2 , createSessionRequests .size ());
141+
142+ List <ExecuteSqlRequest > requests = mockSpanner .getRequestsOfType (ExecuteSqlRequest .class );
143+ assertEquals (1 , requests .size ());
144+
136145 testSpanner .close ();
137146 }
138147
@@ -338,68 +347,6 @@ public void testRetryWithTheDatabaseNotFoundExceptionWithSessionCreationWaitTime
338347 testSpanner .close ();
339348 }
340349
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- }
402-
403350 @ Test
404351 public void testRetryWithDelayedInResponseExceedsSessionCreationWaitTime () {
405352 mockSpanner .setCreateSessionExecutionTime (
0 commit comments