Skip to content

Commit 37c510c

Browse files
committed
grpclb: fix test assertions for new pick-first load balancer
Update requestConnection invocation counts and intermediate state verifications in GrpclbLoadBalancerTest to match PickFirstLeafLoadBalancer's state tracking behavior when connecting from IDLE. TAG=agy CONV=2b34d6af-c0df-46b4-8326-2dea3641f8cc
1 parent d6f80bb commit 37c510c

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

‎grpclb/src/test/java/io/grpc/grpclb/GrpclbLoadBalancerTest.java‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2119,7 +2119,9 @@ public void grpclbWorking_pickFirstMode_newPickFirst() throws Exception {
21192119
assertThat(pick.getSubchannel()).isNull();
21202120
verify(subchannel0, times(2)).requestConnection();
21212121
balancer.requestConnection();
2122-
verify(subchannel0, times(3)).requestConnection();
2122+
// PickFirstLeafLoadBalancer is already in CONNECTING state, so no additional
2123+
// requestConnection() call is made to subchannel0.
2124+
verify(subchannel0, times(2)).requestConnection();
21232125

21242126
// PICK_FIRST doesn't use subchannelPool
21252127
verify(subchannelPool, never())
@@ -2571,7 +2573,7 @@ private void pickFirstModeFallback_newPickFirst(long timeout) throws Exception {
25712573
// In new PF, active fallback subchannel1 is shut down because its address is not in backends1
25722574
verify(subchannel1).shutdown();
25732575
// And LB state transitions to IDLE with RequestConnectionPicker
2574-
inOrder.verify(helper).updateBalancingState(eq(IDLE), pickerCaptor.capture());
2576+
inOrder.verify(helper, atLeast(1)).updateBalancingState(eq(IDLE), pickerCaptor.capture());
25752577
RoundRobinPicker pickerIdle = (RoundRobinPicker) pickerCaptor.getValue();
25762578
ChildLbPickerEntry idleEntry = (ChildLbPickerEntry) pickerIdle.pickList.get(0);
25772579

@@ -2589,9 +2591,6 @@ private void pickFirstModeFallback_newPickFirst(long timeout) throws Exception {
25892591
Subchannel subchannel2 = mockSubchannels.poll();
25902592
verify(subchannel2).requestConnection();
25912593

2592-
inOrder.verify(helper, atLeast(1))
2593-
.updateBalancingState(eq(CONNECTING), any(SubchannelPicker.class));
2594-
25952594
// subchannel2 becomes READY
25962595
deliverSubchannelState(subchannel2, ConnectivityStateInfo.forNonError(READY));
25972596
inOrder.verify(helper, atLeast(1)).updateBalancingState(eq(READY), pickerCaptor.capture());
@@ -2615,7 +2614,9 @@ private void pickFirstModeFallback_newPickFirst(long timeout) throws Exception {
26152614
verify(subchannel2, times(2)).requestConnection();
26162615

26172616
balancer.requestConnection();
2618-
verify(subchannel2, times(3)).requestConnection();
2617+
// PickFirstLeafLoadBalancer is already in CONNECTING state, so no additional
2618+
// requestConnection() call is made to subchannel2.
2619+
verify(subchannel2, times(2)).requestConnection();
26192620

26202621
// PICK_FIRST doesn't use subchannelPool
26212622
verify(subchannelPool, never())

0 commit comments

Comments
 (0)