Skip to content

Commit 776ff31

Browse files
committed
address comments
1 parent 3b31e94 commit 776ff31

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2118,6 +2118,8 @@ public void pickFirstMode_serviceConfigTimeout_fallback() throws Exception {
21182118
}
21192119

21202120
private void pickFirstModeFallback(long timeout) throws Exception {
2121+
InOrder inOrder = inOrder(helper);
2122+
21212123
// Name resolver returns balancer and backend addresses
21222124
List<EquivalentAddressGroup> backendList = createResolvedBackendAddresses(2);
21232125
List<EquivalentAddressGroup> grpclbBalancerList = createResolvedBalancerAddresses(1);
@@ -2134,7 +2136,7 @@ private void pickFirstModeFallback(long timeout) throws Exception {
21342136
fakeClock.forwardTime(timeout, TimeUnit.MILLISECONDS);
21352137

21362138
// Entering fallback mode - child LB is created for fallback backends
2137-
verify(helper, atLeast(1)).createSubchannel(createSubchannelArgsCaptor.capture());
2139+
inOrder.verify(helper).createSubchannel(createSubchannelArgsCaptor.capture());
21382140
CreateSubchannelArgs createSubchannelArgs = createSubchannelArgsCaptor.getValue();
21392141
assertThat(createSubchannelArgs.getAddresses())
21402142
.containsExactly(backendList.get(0), backendList.get(1));
@@ -2143,13 +2145,15 @@ private void pickFirstModeFallback(long timeout) throws Exception {
21432145
Subchannel subchannel = mockSubchannels.poll();
21442146

21452147
// Child pick_first eagerly connects
2146-
verify(helper, atLeast(1)).updateBalancingState(eq(CONNECTING), any());
2148+
inOrder.verify(helper, times(2)).updateBalancingState(eq(CONNECTING), any());
21472149

21482150
// READY
21492151
deliverSubchannelState(subchannel, ConnectivityStateInfo.forNonError(READY));
2150-
verify(helper, atLeast(1)).updateBalancingState(eq(READY), pickerCaptor.capture());
2152+
inOrder.verify(helper).updateBalancingState(eq(READY), pickerCaptor.capture());
2153+
2154+
// IDLE
21512155
deliverSubchannelState(subchannel, ConnectivityStateInfo.forNonError(IDLE));
2152-
verify(helper, atLeast(1)).updateBalancingState(eq(IDLE), pickerCaptor.capture());
2156+
inOrder.verify(helper).updateBalancingState(eq(IDLE), pickerCaptor.capture());
21532157
RoundRobinPicker pickerIdle = (RoundRobinPicker) pickerCaptor.getValue();
21542158
verify(subchannel, times(1)).requestConnection();
21552159

@@ -2164,8 +2168,9 @@ private void pickFirstModeFallback(long timeout) throws Exception {
21642168
lbResponseObserver.onNext(buildInitialResponse());
21652169
lbResponseObserver.onNext(buildLbResponse(backends1));
21662170

2171+
deliverSubchannelState(subchannel, ConnectivityStateInfo.forNonError(READY));
21672172
// The state should become READY with a picker for the new backends.
2168-
verify(helper, atLeast(1)).updateBalancingState(eq(READY), pickerCaptor.capture());
2173+
inOrder.verify(helper).updateBalancingState(eq(READY), pickerCaptor.capture());
21692174
RoundRobinPicker picker2 = (RoundRobinPicker) pickerCaptor.getValue();
21702175

21712176
// Verify the picker contains a ChildLbPickerEntry for the new backend list
@@ -2178,6 +2183,7 @@ private void pickFirstModeFallback(long timeout) throws Exception {
21782183
finalEntry.getChildPicker().pickSubchannel(mock(PickSubchannelArgs.class));
21792184
assertThat(finalResult.getSubchannel()).isEqualTo(subchannel);
21802185
assertThat(finalResult.isDrop()).isFalse();
2186+
inOrder.verify(helper, never()).createSubchannel(any(CreateSubchannelArgs.class));
21812187

21822188
// PICK_FIRST doesn't use subchannelPool
21832189
verify(subchannelPool, never())

0 commit comments

Comments
 (0)