@@ -376,6 +376,7 @@ public PickResult pickSubchannel(PickSubchannelArgs args) {
376376 assertThat (fooBalancers ).hasSize (2 );
377377 assertThat (fooHelpers ).hasSize (2 );
378378 LoadBalancer balancer1 = Iterables .getLast (fooBalancers );
379+ Helper helper1 = Iterables .getLast (fooHelpers );
379380
380381 // p1 timeout, and fails over to p2
381382 fakeClock .forwardTime (10 , TimeUnit .SECONDS );
@@ -423,14 +424,20 @@ public PickResult pickSubchannel(PickSubchannelArgs args) {
423424 LoadBalancer balancer3 = Iterables .getLast (fooBalancers );
424425 Helper helper3 = Iterables .getLast (fooHelpers );
425426
426- // p3 timeout then the channel should go to TRANSIENT_FAILURE
427+ // p3 timeout then the channel should stay in CONNECTING
427428 fakeClock .forwardTime (10 , TimeUnit .SECONDS );
428- assertCurrentPickerReturnsError ( Status . Code . UNAVAILABLE , "timeout" );
429+ assertCurrentPicker ( CONNECTING , PickResult . withNoResult () );
429430
430- // p3 fails then the picker should have error status updated
431+ // p3 fails then the picker should still be waiting on p1
431432 helper3 .updateBalancingState (
432433 TRANSIENT_FAILURE ,
433434 new FixedResultPicker (PickResult .withError (Status .DATA_LOSS .withDescription ("foo" ))));
435+ assertCurrentPicker (CONNECTING , PickResult .withNoResult ());
436+
437+ // p1 fails then the picker should have error status updated to p3
438+ helper1 .updateBalancingState (
439+ TRANSIENT_FAILURE ,
440+ new FixedResultPicker (PickResult .withError (Status .DATA_LOSS .withDescription ("bar" ))));
434441 assertCurrentPickerReturnsError (Status .Code .DATA_LOSS , "foo" );
435442
436443 // p2 gets back to READY
@@ -642,6 +649,7 @@ public void typicalPriorityFailOverFlowWithIdleUpdate() {
642649 assertThat (fooBalancers ).hasSize (2 );
643650 assertThat (fooHelpers ).hasSize (2 );
644651 LoadBalancer balancer1 = Iterables .getLast (fooBalancers );
652+ Helper helper1 = Iterables .getLast (fooHelpers );
645653
646654 // p1 timeout, and fails over to p2
647655 fakeClock .forwardTime (10 , TimeUnit .SECONDS );
@@ -677,14 +685,20 @@ public void typicalPriorityFailOverFlowWithIdleUpdate() {
677685 LoadBalancer balancer3 = Iterables .getLast (fooBalancers );
678686 Helper helper3 = Iterables .getLast (fooHelpers );
679687
680- // p3 timeout then the channel should go to TRANSIENT_FAILURE
688+ // p3 timeout then the channel should stay in CONNECTING
681689 fakeClock .forwardTime (10 , TimeUnit .SECONDS );
682- assertCurrentPickerReturnsError ( Status . Code . UNAVAILABLE , "timeout" );
690+ assertCurrentPicker ( CONNECTING , PickResult . withNoResult () );
683691
684- // p3 fails then the picker should have error status updated
692+ // p3 fails then the picker should still be waiting on p1
685693 helper3 .updateBalancingState (
686694 TRANSIENT_FAILURE ,
687695 new FixedResultPicker (PickResult .withError (Status .DATA_LOSS .withDescription ("foo" ))));
696+ assertCurrentPicker (CONNECTING , PickResult .withNoResult ());
697+
698+ // p1 fails then the picker should have error status updated to p3
699+ helper1 .updateBalancingState (
700+ TRANSIENT_FAILURE ,
701+ new FixedResultPicker (PickResult .withError (Status .DATA_LOSS .withDescription ("bar" ))));
688702 assertCurrentPickerReturnsError (Status .Code .DATA_LOSS , "foo" );
689703
690704 // p2 gets back to IDLE
@@ -863,15 +877,17 @@ private void assertCurrentPickerReturnsError(
863877 }
864878
865879 private void assertCurrentPickerPicksSubchannel (Subchannel expectedSubchannelToPick ) {
866- assertLatestConnectivityState (READY );
867- PickResult pickResult = pickerCaptor .getValue ().pickSubchannel (mock (PickSubchannelArgs .class ));
868- assertThat (pickResult .getSubchannel ()).isEqualTo (expectedSubchannelToPick );
880+ assertCurrentPicker (READY , PickResult .withSubchannel (expectedSubchannelToPick ));
869881 }
870882
871883 private void assertCurrentPickerIsBufferPicker () {
872- assertLatestConnectivityState (IDLE );
884+ assertCurrentPicker (IDLE , PickResult .withNoResult ());
885+ }
886+
887+ private void assertCurrentPicker (ConnectivityState state , PickResult result ) {
888+ assertLatestConnectivityState (state );
873889 PickResult pickResult = pickerCaptor .getValue ().pickSubchannel (mock (PickSubchannelArgs .class ));
874- assertThat (pickResult ).isEqualTo (PickResult . withNoResult () );
890+ assertThat (pickResult ).isEqualTo (result );
875891 }
876892
877893 private Object newChildConfig (LoadBalancerProvider provider , Object config ) {
0 commit comments