xds: Align PriorityLB child selection with A56 · grpc/grpc-java@c4256ad
@@ -376,6 +376,7 @@ public PickResult pickSubchannel(PickSubchannelArgs args) {
376376assertThat(fooBalancers).hasSize(2);
377377assertThat(fooHelpers).hasSize(2);
378378LoadBalancer balancer1 = Iterables.getLast(fooBalancers);
379+Helper helper1 = Iterables.getLast(fooHelpers);
379380380381// p1 timeout, and fails over to p2
381382fakeClock.forwardTime(10, TimeUnit.SECONDS);
@@ -423,14 +424,20 @@ public PickResult pickSubchannel(PickSubchannelArgs args) {
423424LoadBalancer balancer3 = Iterables.getLast(fooBalancers);
424425Helper helper3 = Iterables.getLast(fooHelpers);
425426426-// p3 timeout then the channel should go to TRANSIENT_FAILURE
427+// p3 timeout then the channel should stay in CONNECTING
427428fakeClock.forwardTime(10, TimeUnit.SECONDS);
428-assertCurrentPickerReturnsError(Status.Code.UNAVAILABLE, "timeout");
429+assertCurrentPicker(CONNECTING, PickResult.withNoResult());
429430430-// p3 fails then the picker should have error status updated
431+// p3 fails then the picker should still be waiting on p1
431432helper3.updateBalancingState(
432433TRANSIENT_FAILURE,
433434new 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"))));
434441assertCurrentPickerReturnsError(Status.Code.DATA_LOSS, "foo");
435442436443// p2 gets back to READY
@@ -642,6 +649,7 @@ public void typicalPriorityFailOverFlowWithIdleUpdate() {
642649assertThat(fooBalancers).hasSize(2);
643650assertThat(fooHelpers).hasSize(2);
644651LoadBalancer balancer1 = Iterables.getLast(fooBalancers);
652+Helper helper1 = Iterables.getLast(fooHelpers);
645653646654// p1 timeout, and fails over to p2
647655fakeClock.forwardTime(10, TimeUnit.SECONDS);
@@ -677,14 +685,20 @@ public void typicalPriorityFailOverFlowWithIdleUpdate() {
677685LoadBalancer balancer3 = Iterables.getLast(fooBalancers);
678686Helper helper3 = Iterables.getLast(fooHelpers);
679687680-// p3 timeout then the channel should go to TRANSIENT_FAILURE
688+// p3 timeout then the channel should stay in CONNECTING
681689fakeClock.forwardTime(10, TimeUnit.SECONDS);
682-assertCurrentPickerReturnsError(Status.Code.UNAVAILABLE, "timeout");
690+assertCurrentPicker(CONNECTING, PickResult.withNoResult());
683691684-// p3 fails then the picker should have error status updated
692+// p3 fails then the picker should still be waiting on p1
685693helper3.updateBalancingState(
686694TRANSIENT_FAILURE,
687695new 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"))));
688702assertCurrentPickerReturnsError(Status.Code.DATA_LOSS, "foo");
689703690704// p2 gets back to IDLE
@@ -863,15 +877,17 @@ private void assertCurrentPickerReturnsError(
863877 }
864878865879private 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 }
870882871883private void assertCurrentPickerIsBufferPicker() {
872-assertLatestConnectivityState(IDLE);
884+assertCurrentPicker(IDLE, PickResult.withNoResult());
885+ }
886+887+private void assertCurrentPicker(ConnectivityState state, PickResult result) {
888+assertLatestConnectivityState(state);
873889PickResult pickResult = pickerCaptor.getValue().pickSubchannel(mock(PickSubchannelArgs.class));
874-assertThat(pickResult).isEqualTo(PickResult.withNoResult());
890+assertThat(pickResult).isEqualTo(result);
875891 }
876892877893private Object newChildConfig(LoadBalancerProvider provider, Object config) {