xds: Do RLS fallback policy eagar start (#12211) · grpc/grpc-java@42e1829
@@ -201,7 +201,13 @@ public void tearDown() {
201201202202@Test
203203public void lb_serverStatusCodeConversion() throws Exception {
204-deliverResolvedAddresses();
204+helper.getSynchronizationContext().execute(() -> {
205+try {
206+deliverResolvedAddresses();
207+ } catch (Exception e) {
208+throw new RuntimeException(e);
209+ }
210+ });
205211InOrder inOrder = inOrder(helper);
206212inOrder.verify(helper)
207213 .updateBalancingState(eq(ConnectivityState.CONNECTING), pickerCaptor.capture());
@@ -236,7 +242,13 @@ public void lb_serverStatusCodeConversion() throws Exception {
236242237243@Test
238244public void lb_working_withDefaultTarget_rlsResponding() throws Exception {
239-deliverResolvedAddresses();
245+helper.getSynchronizationContext().execute(() -> {
246+try {
247+deliverResolvedAddresses();
248+ } catch (Exception e) {
249+throw new RuntimeException(e);
250+ }
251+ });
240252InOrder inOrder = inOrder(helper);
241253inOrder.verify(helper)
242254 .updateBalancingState(eq(ConnectivityState.CONNECTING), pickerCaptor.capture());
@@ -257,7 +269,7 @@ public void lb_working_withDefaultTarget_rlsResponding() throws Exception {
257269inOrder.verifyNoMoreInteractions();
258270259271assertThat(res.getStatus().isOk()).isTrue();
260-assertThat(subchannels).hasSize(1);
272+assertThat(subchannels).hasSize(2); // includes fallback sub-channel
261273FakeSubchannel searchSubchannel = subchannels.getLast();
262274assertThat(subchannelIsReady(searchSubchannel)).isFalse();
263275@@ -277,7 +289,7 @@ public void lb_working_withDefaultTarget_rlsResponding() throws Exception {
277289// other rls picker itself is ready due to first channel.
278290assertThat(res.getStatus().isOk()).isTrue();
279291assertThat(subchannelIsReady(res.getSubchannel())).isFalse();
280-assertThat(subchannels).hasSize(2);
292+assertThat(subchannels).hasSize(3); // includes fallback sub-channel
281293FakeSubchannel rescueSubchannel = subchannels.getLast();
282294283295// search subchannel is down, rescue subchannel is connecting
@@ -393,7 +405,13 @@ public void lb_working_withoutDefaultTarget_noRlsResponse() throws Exception {
393405public void lb_working_withDefaultTarget_noRlsResponse() throws Exception {
394406fakeThrottler.nextResult = true;
395407396-deliverResolvedAddresses();
408+helper.getSynchronizationContext().execute(() -> {
409+try {
410+deliverResolvedAddresses();
411+ } catch (Exception e) {
412+throw new RuntimeException(e);
413+ }
414+ });
397415InOrder inOrder = inOrder(helper);
398416inOrder.verify(helper)
399417 .updateBalancingState(eq(ConnectivityState.CONNECTING), pickerCaptor.capture());
@@ -535,7 +553,13 @@ public void lb_working_withoutDefaultTarget() throws Exception {
535553536554@Test
537555public void lb_nameResolutionFailed() throws Exception {
538-deliverResolvedAddresses();
556+helper.getSynchronizationContext().execute(() -> {
557+try {
558+deliverResolvedAddresses();
559+ } catch (Exception e) {
560+throw new RuntimeException(e);
561+ }
562+ });
539563InOrder inOrder = inOrder(helper);
540564inOrder.verify(helper)
541565 .updateBalancingState(eq(ConnectivityState.CONNECTING), pickerCaptor.capture());
@@ -545,7 +569,7 @@ public void lb_nameResolutionFailed() throws Exception {
545569assertThat(subchannelIsReady(res.getSubchannel())).isFalse();
546570547571inOrder.verify(helper).createSubchannel(any(CreateSubchannelArgs.class));
548-assertThat(subchannels).hasSize(1);
572+assertThat(subchannels).hasSize(2); // includes fallback sub-channel
549573550574FakeSubchannel searchSubchannel = subchannels.getLast();
551575searchSubchannel.updateState(ConnectivityStateInfo.forNonError(ConnectivityState.READY));