| 132 | /** Unit tests for {@link XdsNameResolver}. */ |
| 133 | // TODO(chengyuanzhang): should do tests with ManagedChannelImpl. |
| 134 | @RunWith(JUnit4.class) |
| 135 | public 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 |
nothing calls this directly
no test coverage detected