Skip to content

Commit 254e673

Browse files
committed
Test for making backoff timer expiry not make a RLS rpc directly but update the parent LB policy with picker after deleting backoff cache entry.
1 parent cd9835c commit 254e673

File tree

1 file changed

+9
-22
lines changed

1 file changed

+9
-22
lines changed

rls/src/test/java/io/grpc/rls/CachingRlsLbClientTest.java

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,9 @@ public void uncaughtException(Thread t, Throwable e) {
160160
fakeClock.getScheduledExecutorService());
161161
private final ChildLoadBalancingPolicy childLbPolicy =
162162
new ChildLoadBalancingPolicy("target", Collections.<String, Object>emptyMap(), lbProvider);
163+
private final FakeHelper fakeHelper = new FakeHelper();
163164
private final Helper helper =
164-
mock(Helper.class, delegatesTo(new FakeHelper()));
165+
mock(Helper.class, delegatesTo(fakeHelper));
165166
private final FakeThrottler fakeThrottler = new FakeThrottler();
166167
private final LbPolicyConfiguration lbPolicyConfiguration =
167168
new LbPolicyConfiguration(ROUTE_LOOKUP_CONFIG, null, childLbPolicy);
@@ -325,29 +326,14 @@ public void get_throttledAndRecover() throws Exception {
325326

326327
assertThat(resp.hasError()).isTrue();
327328

328-
fakeClock.forwardTime(10, TimeUnit.MILLISECONDS);
329-
// initially backed off entry is backed off again
330-
verify(evictionListener)
331-
.onEviction(eq(routeLookupRequest), any(CacheEntry.class), eq(EvictionType.EXPLICIT));
332-
333-
resp = getInSyncContext(routeLookupRequest);
334-
335-
assertThat(resp.hasError()).isTrue();
336-
337329
// let it pass throttler
338330
fakeThrottler.nextResult = false;
339331
fakeClock.forwardTime(10, TimeUnit.MILLISECONDS);
340-
341-
resp = getInSyncContext(routeLookupRequest);
342-
343-
assertThat(resp.isPending()).isTrue();
344-
345-
// server responses
346-
fakeClock.forwardTime(SERVER_LATENCY_MILLIS, TimeUnit.MILLISECONDS);
347-
348-
resp = getInSyncContext(routeLookupRequest);
349-
350-
assertThat(resp.hasData()).isTrue();
332+
// Backoff entry evicted from cache.
333+
verify(evictionListener)
334+
.onEviction(eq(routeLookupRequest), any(CacheEntry.class), eq(EvictionType.EXPLICIT));
335+
// Assert that Rls LB policy picker was updated.
336+
assertThat(fakeHelper.lastPicker.toString()).isEqualTo("RlsPicker{target=service1}");
351337
}
352338

353339
@Test
@@ -894,6 +880,7 @@ public void run() {
894880

895881
private final class FakeHelper extends Helper {
896882

883+
SubchannelPicker lastPicker;
897884
@Override
898885
public ManagedChannelBuilder<?> createResolvingOobChannelBuilder(
899886
String target, ChannelCredentials creds) {
@@ -948,7 +935,7 @@ public ManagedChannel createOobChannel(EquivalentAddressGroup eag, String author
948935
@Override
949936
public void updateBalancingState(
950937
@Nonnull ConnectivityState newState, @Nonnull SubchannelPicker newPicker) {
951-
// no-op
938+
lastPicker = newPicker;
952939
}
953940

954941
@Override

0 commit comments

Comments
 (0)