|
47 | 47 | import io.grpc.LoadBalancer.Subchannel;
|
48 | 48 | import io.grpc.LoadBalancer.SubchannelPicker;
|
49 | 49 | import io.grpc.LoadBalancer.SubchannelStateListener;
|
| 50 | +import io.grpc.Status; |
50 | 51 | import io.grpc.SynchronizationContext;
|
51 | 52 | import io.grpc.internal.FakeClock;
|
52 | 53 | import io.grpc.internal.TestUtils;
|
@@ -162,6 +163,22 @@ public ClientCall<OrcaLoadReportRequest, OrcaLoadReport> answer(
|
162 | 163 | verify(helper, times(3)).createSubchannel(any(CreateSubchannelArgs.class));
|
163 | 164 | }
|
164 | 165 |
|
| 166 | + @Test |
| 167 | + public void pickChildLbTF() throws Exception { |
| 168 | + syncContext.execute(() -> wrr.acceptResolvedAddresses(ResolvedAddresses.newBuilder() |
| 169 | + .setAddresses(servers.subList(0, 1)).setLoadBalancingPolicyConfig(weightedConfig) |
| 170 | + .setAttributes(affinity).build())); |
| 171 | + Iterator<Subchannel> it = subchannels.values().iterator(); |
| 172 | + Subchannel readySubchannel1 = it.next(); |
| 173 | + getSubchannelStateListener(readySubchannel1).onSubchannelState(ConnectivityStateInfo |
| 174 | + .forTransientFailure(Status.UNAVAILABLE)); |
| 175 | + verify(helper).updateBalancingState( |
| 176 | + eq(ConnectivityState.TRANSIENT_FAILURE), pickerCaptor.capture()); |
| 177 | + final WeightedRoundRobinPicker weightedPicker = |
| 178 | + (WeightedRoundRobinPicker) pickerCaptor.getValue(); |
| 179 | + weightedPicker.pickSubchannel(mockArgs); |
| 180 | + } |
| 181 | + |
165 | 182 | @Test
|
166 | 183 | public void wrrLifeCycle() {
|
167 | 184 | syncContext.execute(() -> wrr.acceptResolvedAddresses(ResolvedAddresses.newBuilder()
|
|
0 commit comments