@@ -376,6 +376,7 @@ public PickResult pickSubchannel(PickSubchannelArgs args) {
376
376
assertThat (fooBalancers ).hasSize (2 );
377
377
assertThat (fooHelpers ).hasSize (2 );
378
378
LoadBalancer balancer1 = Iterables .getLast (fooBalancers );
379
+ Helper helper1 = Iterables .getLast (fooHelpers );
379
380
380
381
// p1 timeout, and fails over to p2
381
382
fakeClock .forwardTime (10 , TimeUnit .SECONDS );
@@ -423,14 +424,20 @@ public PickResult pickSubchannel(PickSubchannelArgs args) {
423
424
LoadBalancer balancer3 = Iterables .getLast (fooBalancers );
424
425
Helper helper3 = Iterables .getLast (fooHelpers );
425
426
426
- // p3 timeout then the channel should go to TRANSIENT_FAILURE
427
+ // p3 timeout then the channel should stay in CONNECTING
427
428
fakeClock .forwardTime (10 , TimeUnit .SECONDS );
428
- assertCurrentPickerReturnsError ( Status . Code . UNAVAILABLE , "timeout" );
429
+ assertCurrentPicker ( CONNECTING , PickResult . withNoResult () );
429
430
430
- // p3 fails then the picker should have error status updated
431
+ // p3 fails then the picker should still be waiting on p1
431
432
helper3 .updateBalancingState (
432
433
TRANSIENT_FAILURE ,
433
434
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" ))));
434
441
assertCurrentPickerReturnsError (Status .Code .DATA_LOSS , "foo" );
435
442
436
443
// p2 gets back to READY
@@ -642,6 +649,7 @@ public void typicalPriorityFailOverFlowWithIdleUpdate() {
642
649
assertThat (fooBalancers ).hasSize (2 );
643
650
assertThat (fooHelpers ).hasSize (2 );
644
651
LoadBalancer balancer1 = Iterables .getLast (fooBalancers );
652
+ Helper helper1 = Iterables .getLast (fooHelpers );
645
653
646
654
// p1 timeout, and fails over to p2
647
655
fakeClock .forwardTime (10 , TimeUnit .SECONDS );
@@ -677,14 +685,20 @@ public void typicalPriorityFailOverFlowWithIdleUpdate() {
677
685
LoadBalancer balancer3 = Iterables .getLast (fooBalancers );
678
686
Helper helper3 = Iterables .getLast (fooHelpers );
679
687
680
- // p3 timeout then the channel should go to TRANSIENT_FAILURE
688
+ // p3 timeout then the channel should stay in CONNECTING
681
689
fakeClock .forwardTime (10 , TimeUnit .SECONDS );
682
- assertCurrentPickerReturnsError ( Status . Code . UNAVAILABLE , "timeout" );
690
+ assertCurrentPicker ( CONNECTING , PickResult . withNoResult () );
683
691
684
- // p3 fails then the picker should have error status updated
692
+ // p3 fails then the picker should still be waiting on p1
685
693
helper3 .updateBalancingState (
686
694
TRANSIENT_FAILURE ,
687
695
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" ))));
688
702
assertCurrentPickerReturnsError (Status .Code .DATA_LOSS , "foo" );
689
703
690
704
// p2 gets back to IDLE
@@ -863,15 +877,17 @@ private void assertCurrentPickerReturnsError(
863
877
}
864
878
865
879
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 ));
869
881
}
870
882
871
883
private void assertCurrentPickerIsBufferPicker () {
872
- assertLatestConnectivityState (IDLE );
884
+ assertCurrentPicker (IDLE , PickResult .withNoResult ());
885
+ }
886
+
887
+ private void assertCurrentPicker (ConnectivityState state , PickResult result ) {
888
+ assertLatestConnectivityState (state );
873
889
PickResult pickResult = pickerCaptor .getValue ().pickSubchannel (mock (PickSubchannelArgs .class ));
874
- assertThat (pickResult ).isEqualTo (PickResult . withNoResult () );
890
+ assertThat (pickResult ).isEqualTo (result );
875
891
}
876
892
877
893
private Object newChildConfig (LoadBalancerProvider provider , Object config ) {
0 commit comments