1919import static com .google .cloud .bigtable .data .v2 .internal .test_helpers .StatusSubject .assertThat ;
2020import static com .google .cloud .bigtable .data .v2 .internal .test_helpers .VRpcResultSubject .assertThat ;
2121import static com .google .common .truth .Truth .assertThat ;
22+ import static com .google .common .truth .Truth .assertWithMessage ;
2223import static org .junit .jupiter .api .Assertions .assertThrows ;
2324
2425import com .google .bigtable .v2 .CloseSessionRequest ;
@@ -201,6 +202,8 @@ void sessionGoAwayTest() throws Exception {
201202
202203 // Send vRPCs until after a goaway time
203204 Stopwatch stopwatch = Stopwatch .createStarted ();
205+ int numUncommittedErrors = 0 ;
206+ int numOk = 0 ;
204207 while (stopwatch .elapsed (TimeUnit .MILLISECONDS ) < goAwayDelay .toMillis ()) {
205208 VRpc <SessionFakeScriptedRequest , SessionFakeScriptedResponse > rpc =
206209 session .newCall (FakeDescriptor .SCRIPTED );
@@ -209,9 +212,24 @@ void sessionGoAwayTest() throws Exception {
209212 SessionFakeScriptedRequest .newBuilder ().setTag (0 ).build (),
210213 VRpcCallContext .create (Deadline .after (1 , TimeUnit .MINUTES ), true , tracer ),
211214 f );
212- f .get ();
215+ try {
216+ f .get ();
217+ numOk ++;
218+ } catch (VRpcException e ) {
219+ if (e .getResult ().getState () == State .UNCOMMITED ) {
220+ numUncommittedErrors ++;
221+ }
222+ }
213223 }
214224
225+ assertWithMessage ("Sanity check that some vRpcs succeeded prior to the goaway" )
226+ .that (numOk )
227+ .isGreaterThan (0 );
228+ assertWithMessage (
229+ "Sanity check possibly only the last vRpc was rejected with an uncommited error" )
230+ .that (numUncommittedErrors )
231+ .isAtMost (1 );
232+
215233 assertThat (sessionListener .popUntil (GoAwayResponse .class )).isInstanceOf (GoAwayResponse .class );
216234
217235 // Make sure we can't send vrpc after receiving goaway
0 commit comments