MCPcopy Create free account
hub / github.com/grpc/grpc-java / XdsNameResolverTest

Class XdsNameResolverTest

xds/src/test/java/io/grpc/xds/XdsNameResolverTest.java:134–2960  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

132/** Unit tests for {@link XdsNameResolver}. */
133// TODO(chengyuanzhang): should do tests with ManagedChannelImpl.
134@RunWith(JUnit4.class)
135public class XdsNameResolverTest {
136 private static final String AUTHORITY = "foo.googleapis.com:80";
137 private static final String RDS_RESOURCE_NAME = "route-configuration.googleapis.com";
138 private static final String FAULT_FILTER_INSTANCE_NAME = "envoy.fault";
139 private static final String ROUTER_FILTER_INSTANCE_NAME = "envoy.router";
140 private static final FaultFilter.Provider FAULT_FILTER_PROVIDER = new FaultFilter.Provider();
141 private static final RouterFilter.Provider ROUTER_FILTER_PROVIDER = new RouterFilter.Provider();
142
143 // Readability: makes it simpler to distinguish resource parameters.
144 private static final ImmutableMap<String, FilterConfig> NO_FILTER_OVERRIDES = ImmutableMap.of();
145 private static final ImmutableList<HashPolicy> NO_HASH_POLICIES = ImmutableList.of();
146
147 // Stateful instance filter names.
148 private static final String STATEFUL_1 = "test.stateful.filter.1";
149 private static final String STATEFUL_2 = "test.stateful.filter.2";
150
151 @Rule
152 public final MockitoRule mocks = MockitoJUnit.rule();
153 private final SynchronizationContext syncContext = new SynchronizationContext(
154 new Thread.UncaughtExceptionHandler() {
155 @Override
156 public void uncaughtException(Thread t, Throwable e) {
157 throw new AssertionError(e);
158 }
159 });
160 private final FakeClock fakeClock = new FakeClock();
161 private final ScheduledExecutorService scheduler = fakeClock.getScheduledExecutorService();
162 private final ServiceConfigParser serviceConfigParser = new ServiceConfigParser() {
163 @Override
164 public ConfigOrError parseServiceConfig(Map<String, ?> rawServiceConfig) {
165 return ConfigOrError.fromConfig(rawServiceConfig);
166 }
167 };
168 private final FakeXdsClientPoolFactory xdsClientPoolFactory = new FakeXdsClientPoolFactory();
169 private final String cluster1 = "cluster-foo.googleapis.com";
170 private final String cluster2 = "cluster-bar.googleapis.com";
171 private final CallInfo call1 = new CallInfo("HelloService", "hi");
172 private final CallInfo call2 = new CallInfo("GreetService", "bye");
173 private final TestChannel channel = new TestChannel();
174 private final MetricRecorder metricRecorder = new MetricRecorder() {};
175 private final Map<String, ?> rawBootstrap = ImmutableMap.of(
176 "xds_servers", ImmutableList.of(
177 ImmutableMap.of(
178 "server_uri", "td.googleapis.com",
179 "channel_creds", ImmutableList.of(
180 ImmutableMap.of(
181 "type", "insecure")))
182 ));
183
184 private BootstrapInfo bootstrapInfo = BootstrapInfo.builder()
185 .servers(ImmutableList.of(ServerInfo.create(
186 "td.googleapis.com", InsecureChannelCredentials.create())))
187 .node(Node.newBuilder().build())
188 .build();
189 private String expectedLdsResourceName = AUTHORITY;
190
191 @Mock

Callers

nothing calls this directly

Calls 15

builderMethod · 0.95
createMethod · 0.95
createMethod · 0.95
newBuilderMethod · 0.95
setProxyDetectorMethod · 0.80
setDefaultPortMethod · 0.80
buildMethod · 0.65
ofMethod · 0.45

Tested by

no test coverage detected