use of io.grpc.xds.XdsServerTestHelper.FakeXdsClientPoolFactory in project grpc-java by grpc.
the class XdsServerWrapperTest method testBootstrap_templateWithXdstp.
@Test
public void testBootstrap_templateWithXdstp() throws Exception {
Bootstrapper.BootstrapInfo b = Bootstrapper.BootstrapInfo.builder().servers(Arrays.asList(Bootstrapper.ServerInfo.create("uri", InsecureChannelCredentials.create(), true))).node(EnvoyProtoData.Node.newBuilder().setId("id").build()).serverListenerResourceNameTemplate("xdstp://xds.authority.com/envoy.config.listener.v3.Listener/grpc/server/%s").build();
XdsClient xdsClient = mock(XdsClient.class);
when(xdsClient.getBootstrapInfo()).thenReturn(b);
xdsServerWrapper = new XdsServerWrapper("[::FFFF:129.144.52.38]:80", mockBuilder, listener, selectorManager, new FakeXdsClientPoolFactory(xdsClient), filterRegistry);
Executors.newSingleThreadExecutor().execute(new Runnable() {
@Override
public void run() {
try {
xdsServerWrapper.start();
} catch (IOException ex) {
// ignore
}
}
});
verify(xdsClient, timeout(5000)).watchLdsResource(eq("xdstp://xds.authority.com/envoy.config.listener.v3.Listener/grpc/server/" + "%5B::FFFF:129.144.52.38%5D:80"), any(LdsResourceWatcher.class));
}
use of io.grpc.xds.XdsServerTestHelper.FakeXdsClientPoolFactory in project grpc-java by grpc.
the class XdsServerWrapperTest method verifyBootstrapFail.
private void verifyBootstrapFail(Bootstrapper.BootstrapInfo b) throws Exception {
XdsClient xdsClient = mock(XdsClient.class);
when(xdsClient.getBootstrapInfo()).thenReturn(b);
xdsServerWrapper = new XdsServerWrapper("0.0.0.0:1", mockBuilder, listener, selectorManager, new FakeXdsClientPoolFactory(xdsClient), filterRegistry);
final SettableFuture<Server> start = SettableFuture.create();
Executors.newSingleThreadExecutor().execute(new Runnable() {
@Override
public void run() {
try {
start.set(xdsServerWrapper.start());
} catch (Exception ex) {
start.setException(ex);
}
}
});
try {
start.get(5000, TimeUnit.MILLISECONDS);
fail("Start should throw exception");
} catch (ExecutionException ex) {
assertThat(ex.getCause()).isInstanceOf(IOException.class);
Throwable cause = ex.getCause().getCause();
assertThat(cause).isInstanceOf(StatusException.class);
assertThat(((StatusException) cause).getStatus().getCode()).isEqualTo(Status.UNAVAILABLE.getCode());
}
}
Aggregations