Skip to content

Commit

Permalink
Set expected requestConnection count based on whether happy eyeballs …
Browse files Browse the repository at this point in the history
…is enabled or not
  • Loading branch information
larry-safran committed Apr 22, 2024
1 parent 0365541 commit dd6d125
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions xds/src/test/java/io/grpc/xds/RingHashLoadBalancerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ public void subchannelLazyConnectUntilPicked() {
assertThat(result.getStatus().isOk()).isTrue();
assertThat(result.getSubchannel()).isNull();
Subchannel subchannel = Iterables.getOnlyElement(subchannels.values());
verify(subchannel).requestConnection();
int expectedTimes = PickFirstLoadBalancerProvider.isEnabledHappyEyeballs() ? 1 : 2;
verify(subchannel, times(expectedTimes)).requestConnection();
verify(helper).updateBalancingState(eq(CONNECTING), any(SubchannelPicker.class));
verify(helper).createSubchannel(any(CreateSubchannelArgs.class));
deliverSubchannelState(subchannel, CSI_CONNECTING);
Expand Down Expand Up @@ -184,7 +185,8 @@ public void subchannelNotAutoReconnectAfterReenteringIdle() {
pickerCaptor.getValue().pickSubchannel(args);
Subchannel subchannel = subchannels.get(Collections.singletonList(childLbState.getEag()));
InOrder inOrder = Mockito.inOrder(helper, subchannel);
inOrder.verify(subchannel).requestConnection();
int expectedTimes = PickFirstLoadBalancerProvider.isEnabledHappyEyeballs() ? 1 : 2;
inOrder.verify(subchannel, times(expectedTimes)).requestConnection();
deliverSubchannelState(subchannel, CSI_READY);
inOrder.verify(helper).updateBalancingState(eq(READY), any(SubchannelPicker.class));
deliverSubchannelState(subchannel, ConnectivityStateInfo.forNonError(IDLE));
Expand Down Expand Up @@ -442,7 +444,8 @@ public void skipFailingHosts_pickNextNonFailingHost() {
PickResult result = pickerCaptor.getValue().pickSubchannel(args);
assertThat(result.getStatus().isOk()).isTrue();
assertThat(result.getSubchannel()).isNull(); // buffer request
verify(getSubChannel(servers.get(1))).requestConnection(); // kicked off connection to server2
int expectedTimes = PickFirstLoadBalancerProvider.isEnabledHappyEyeballs() ? 1 : 2;
verify(getSubChannel(servers.get(1)), times(expectedTimes)).requestConnection(); // kicked off connection to server2
assertThat(subchannels.size()).isEqualTo(2); // no excessive connection

deliverSubchannelState(getSubChannel(servers.get(1)), CSI_CONNECTING);
Expand Down

0 comments on commit dd6d125

Please sign in to comment.