diff --git a/xds/src/test/java/io/grpc/xds/XdsClientImplTestBase.java b/xds/src/test/java/io/grpc/xds/XdsClientImplTestBase.java index dd47ff3f2bc..b864681146a 100644 --- a/xds/src/test/java/io/grpc/xds/XdsClientImplTestBase.java +++ b/xds/src/test/java/io/grpc/xds/XdsClientImplTestBase.java @@ -3768,30 +3768,28 @@ private BootstrapInfo buildBootStrap(String serverUri) { private DiscoveryRpcCall startResourceWatcher( XdsResourceType type, String name, ResourceWatcher watcher, Executor executor) { + xdsClient.watchXdsResource(type, name, watcher, executor); + DiscoveryRpcCall call = resourceDiscoveryCalls.poll(); + assertThat(call).isNotNull(); + call.verifyRequest(type, Collections.singletonList(name), "", "", NODE); + FakeClock.TaskFilter timeoutTaskFilter; switch (type.typeName()) { case "LDS": timeoutTaskFilter = LDS_RESOURCE_FETCH_TIMEOUT_TASK_FILTER; - xdsClient.watchXdsResource(type, name, watcher, executor); break; case "RDS": timeoutTaskFilter = RDS_RESOURCE_FETCH_TIMEOUT_TASK_FILTER; - xdsClient.watchXdsResource(type, name, watcher, executor); break; case "CDS": timeoutTaskFilter = CDS_RESOURCE_FETCH_TIMEOUT_TASK_FILTER; - xdsClient.watchXdsResource(type, name, watcher, executor); break; case "EDS": timeoutTaskFilter = EDS_RESOURCE_FETCH_TIMEOUT_TASK_FILTER; - xdsClient.watchXdsResource(type, name, watcher, executor); break; default: throw new AssertionError("should never be here"); } - - DiscoveryRpcCall call = resourceDiscoveryCalls.poll(); - call.verifyRequest(type, Collections.singletonList(name), "", "", NODE); ScheduledTask timeoutTask = Iterables.getOnlyElement(fakeClock.getPendingTasks(timeoutTaskFilter)); assertThat(timeoutTask.getDelay(TimeUnit.SECONDS)) @@ -3801,35 +3799,7 @@ private DiscoveryRpcCall startResourceWatcher( private DiscoveryRpcCall startResourceWatcher( XdsResourceType type, String name, ResourceWatcher watcher) { - FakeClock.TaskFilter timeoutTaskFilter; - switch (type.typeName()) { - case "LDS": - timeoutTaskFilter = LDS_RESOURCE_FETCH_TIMEOUT_TASK_FILTER; - xdsClient.watchXdsResource(type, name, watcher); - break; - case "RDS": - timeoutTaskFilter = RDS_RESOURCE_FETCH_TIMEOUT_TASK_FILTER; - xdsClient.watchXdsResource(type, name, watcher); - break; - case "CDS": - timeoutTaskFilter = CDS_RESOURCE_FETCH_TIMEOUT_TASK_FILTER; - xdsClient.watchXdsResource(type, name, watcher); - break; - case "EDS": - timeoutTaskFilter = EDS_RESOURCE_FETCH_TIMEOUT_TASK_FILTER; - xdsClient.watchXdsResource(type, name, watcher); - break; - default: - throw new AssertionError("should never be here"); - } - - DiscoveryRpcCall call = resourceDiscoveryCalls.poll(); - call.verifyRequest(type, Collections.singletonList(name), "", "", NODE); - ScheduledTask timeoutTask = - Iterables.getOnlyElement(fakeClock.getPendingTasks(timeoutTaskFilter)); - assertThat(timeoutTask.getDelay(TimeUnit.SECONDS)) - .isEqualTo(XdsClientImpl.INITIAL_RESOURCE_FETCH_TIMEOUT_SEC); - return call; + return startResourceWatcher(type, name, watcher, MoreExecutors.directExecutor()); } protected abstract static class DiscoveryRpcCall {