@@ -56,25 +56,34 @@ public void testTranslateInternalException() {
5656              Status .INTERNAL 
5757                  .withDescription ("Authentication backend internal server error. Please retry." )
5858                  .asRuntimeException ()));
59-       mockSpanner .setExecuteSqlExecutionTime (
60-           SimulatedExecutionTime .ofException (
61-               Status .INTERNAL 
62-                   .withDescription ("Authentication backend internal server error. Please retry." )
63-                   .asRuntimeException ()));
6459
60+       // Execute a query. This will block until a BatchCreateSessions call has finished and then 
61+       // invoke ExecuteStreamingSql. Both of these RPCs should be retried. 
6562      try  (ResultSet  resultSet  = client .singleUse ().executeQuery (SELECT1_STATEMENT )) {
6663        assertTrue (resultSet .next ());
6764        assertFalse (resultSet .next ());
6865      }
66+       // Verify that both the BatchCreateSessions call and the ExecuteStreamingSql call were 
67+       // retried. 
68+       assertEquals (2 , mockSpanner .countRequestsOfType (BatchCreateSessionsRequest .class ));
69+       assertEquals (2 , mockSpanner .countRequestsOfType (ExecuteSqlRequest .class ));
70+       // Clear the requests before the next test. 
71+       mockSpanner .clearRequests ();
72+ 
73+       // Execute a DML statement. This uses the ExecuteSql RPC. 
74+       assertEquals (0 , mockSpanner .countRequestsOfType (ExecuteSqlRequest .class ));
75+       mockSpanner .setExecuteSqlExecutionTime (
76+           SimulatedExecutionTime .ofException (
77+               Status .INTERNAL 
78+                   .withDescription ("Authentication backend internal server error. Please retry." )
79+                   .asRuntimeException ()));
6980      assertEquals (
7081          Long .valueOf (1L ),
7182          client 
7283              .readWriteTransaction ()
7384              .run (transaction  -> transaction .executeUpdate (INSERT_STATEMENT )));
74- 
75-       // Verify that all the RPCs were retried. 
76-       assertEquals (2 , mockSpanner .countRequestsOfType (BatchCreateSessionsRequest .class ));
77-       assertEquals (4 , mockSpanner .countRequestsOfType (ExecuteSqlRequest .class ));
85+       // Verify that also this request was retried. 
86+       assertEquals (2 , mockSpanner .countRequestsOfType (ExecuteSqlRequest .class ));
7887    }
7988  }
8089}
0 commit comments