@@ -200,11 +200,14 @@ void sessionGoAwayTest() throws Exception {
200200 assertThat (sessionListener .popUntil (OpenSessionResponse .class ))
201201 .isInstanceOf (OpenSessionResponse .class );
202202
203- // Send vRPCs until after a goaway time
204203 Stopwatch stopwatch = Stopwatch .createStarted ();
204+ int numOkBeforeError = 0 ;
205+ int numOkAfterError = 0 ;
205206 int numUncommittedErrors = 0 ;
206- int numOk = 0 ;
207- while (stopwatch .elapsed (TimeUnit .MILLISECONDS ) < goAwayDelay .toMillis ()) {
207+ int otherErrors = 0 ;
208+ boolean encounteredError = false ;
209+
210+ while (stopwatch .elapsed (TimeUnit .MILLISECONDS ) < goAwayDelay .toMillis () + 200 ) {
208211 VRpc <SessionFakeScriptedRequest , SessionFakeScriptedResponse > rpc =
209212 session .newCall (FakeDescriptor .SCRIPTED );
210213 UnaryResponseFuture <SessionFakeScriptedResponse > f = new UnaryResponseFuture <>();
@@ -214,25 +217,38 @@ void sessionGoAwayTest() throws Exception {
214217 f );
215218 try {
216219 f .get ();
217- numOk ++;
220+ if (!encounteredError ) {
221+ numOkBeforeError ++;
222+ } else {
223+ numOkAfterError ++;
224+ }
218225 } catch (ExecutionException e ) {
226+ encounteredError = true ;
219227 if (e .getCause () instanceof VRpcException ) {
220228 VRpcException vrpcException = (VRpcException ) e .getCause ();
221229 if (vrpcException .getResult ().getState () == State .UNCOMMITED ) {
222230 numUncommittedErrors ++;
231+ } else {
232+ otherErrors ++;
223233 }
224234 } else {
225- throw e ;
235+ otherErrors ++ ;
226236 }
227237 }
228238 }
229239
230240 assertWithMessage ("Ensure that some vRpcs succeeded prior to the goaway" )
231- .that (numOk )
241+ .that (numOkBeforeError )
232242 .isGreaterThan (0 );
233- assertWithMessage ("Ensure that only the last vRpc could be rejected with an uncommited error" )
243+ assertWithMessage ("Ensure that no vRpcs succeeded after the first error" )
244+ .that (numOkAfterError )
245+ .isEqualTo (0 );
246+ assertWithMessage ("Ensure that we received uncommitted errors after goaway" )
234247 .that (numUncommittedErrors )
235- .isAtMost (1 );
248+ .isGreaterThan (0 );
249+ assertWithMessage ("Ensure that we received no other types of errors" )
250+ .that (otherErrors )
251+ .isEqualTo (0 );
236252
237253 assertThat (sessionListener .popUntil (GoAwayResponse .class )).isInstanceOf (GoAwayResponse .class );
238254
0 commit comments