use of io.grpc.xds.XdsClient.LdsUpdate in project grpc-java by grpc.
the class XdsServerTestHelper method generateListenerUpdate.
static void generateListenerUpdate(FakeXdsClient xdsClient, ImmutableList<Integer> sourcePorts, EnvoyServerProtoData.DownstreamTlsContext tlsContext, EnvoyServerProtoData.DownstreamTlsContext tlsContextForDefaultFilterChain, TlsContextManager tlsContextManager) {
EnvoyServerProtoData.Listener listener = buildTestListener("listener1", "10.1.2.3", sourcePorts, tlsContext, tlsContextForDefaultFilterChain, tlsContextManager);
LdsUpdate listenerUpdate = LdsUpdate.forTcpListener(listener);
xdsClient.deliverLdsUpdate(listenerUpdate);
}
use of io.grpc.xds.XdsClient.LdsUpdate in project grpc-java by grpc.
the class XdsServerTestHelper method generateListenerUpdate.
static void generateListenerUpdate(FakeXdsClient xdsClient, EnvoyServerProtoData.DownstreamTlsContext tlsContext, TlsContextManager tlsContextManager) {
EnvoyServerProtoData.Listener listener = buildTestListener("listener1", "10.1.2.3", ImmutableList.of(), tlsContext, null, tlsContextManager);
LdsUpdate listenerUpdate = LdsUpdate.forTcpListener(listener);
xdsClient.deliverLdsUpdate(listenerUpdate);
}
use of io.grpc.xds.XdsClient.LdsUpdate in project grpc-java by grpc.
the class ClientXdsClientTestBase method ldsResourceUpdate_withFaultInjection.
@Test
public void ldsResourceUpdate_withFaultInjection() {
Assume.assumeTrue(useProtocolV3());
DiscoveryRpcCall call = startResourceWatcher(LDS, LDS_RESOURCE, ldsResourceWatcher);
Any listener = Any.pack(mf.buildListenerWithApiListener(LDS_RESOURCE, mf.buildRouteConfiguration("do not care", ImmutableList.of(mf.buildVirtualHost(mf.buildOpaqueRoutes(1), ImmutableMap.of("irrelevant", Any.pack(FilterConfig.newBuilder().setIsOptional(true).build()), "envoy.fault", mf.buildHttpFaultTypedConfig(300L, 1000, "cluster1", ImmutableList.<String>of(), 100, null, null, null))), mf.buildVirtualHost(mf.buildOpaqueRoutes(2), ImmutableMap.of("envoy.fault", mf.buildHttpFaultTypedConfig(null, null, "cluster2", ImmutableList.<String>of(), 101, null, 503, 2000))))), ImmutableList.of(mf.buildHttpFilter("irrelevant", null, true), mf.buildHttpFilter("envoy.fault", mf.buildHttpFaultTypedConfig(1L, 2, "cluster1", ImmutableList.<String>of(), 3, null, null, null), false), mf.buildHttpFilter("terminal", Any.pack(Router.newBuilder().build()), true))));
call.sendResponse(LDS, listener, VERSION_1, "0000");
// Client sends an ACK LDS request.
call.verifyRequest(LDS, LDS_RESOURCE, VERSION_1, "0000", NODE);
verify(ldsResourceWatcher).onChanged(ldsUpdateCaptor.capture());
verifyResourceMetadataAcked(LDS, LDS_RESOURCE, listener, VERSION_1, TIME_INCREMENT);
verifySubscribedResourcesMetadataSizes(1, 0, 0, 0);
LdsUpdate ldsUpdate = ldsUpdateCaptor.getValue();
assertThat(ldsUpdate.httpConnectionManager().virtualHosts()).hasSize(2);
assertThat(ldsUpdate.httpConnectionManager().httpFilterConfigs().get(0).name).isEqualTo("envoy.fault");
FaultConfig faultConfig = (FaultConfig) ldsUpdate.httpConnectionManager().virtualHosts().get(0).filterConfigOverrides().get("envoy.fault");
assertThat(faultConfig.faultDelay().delayNanos()).isEqualTo(300);
assertThat(faultConfig.faultDelay().percent().numerator()).isEqualTo(1000);
assertThat(faultConfig.faultDelay().percent().denominatorType()).isEqualTo(DenominatorType.MILLION);
assertThat(faultConfig.faultAbort()).isNull();
assertThat(faultConfig.maxActiveFaults()).isEqualTo(100);
faultConfig = (FaultConfig) ldsUpdate.httpConnectionManager().virtualHosts().get(1).filterConfigOverrides().get("envoy.fault");
assertThat(faultConfig.faultDelay()).isNull();
assertThat(faultConfig.faultAbort().status().getCode()).isEqualTo(Status.Code.UNAVAILABLE);
assertThat(faultConfig.faultAbort().percent().numerator()).isEqualTo(2000);
assertThat(faultConfig.faultAbort().percent().denominatorType()).isEqualTo(DenominatorType.MILLION);
assertThat(faultConfig.maxActiveFaults()).isEqualTo(101);
}
use of io.grpc.xds.XdsClient.LdsUpdate in project grpc-java by grpc.
the class XdsClientWrapperForServerSdsTestMisc method emptyFilterChain_expectNull.
@Test
public void emptyFilterChain_expectNull() throws Exception {
InetAddress ipLocalAddress = InetAddress.getByName("10.1.2.3");
final InetSocketAddress localAddress = new InetSocketAddress(ipLocalAddress, PORT);
InetAddress ipRemoteAddress = InetAddress.getByName("10.4.5.6");
final InetSocketAddress remoteAddress = new InetSocketAddress(ipRemoteAddress, 1234);
channel = new EmbeddedChannel() {
@Override
public SocketAddress localAddress() {
return localAddress;
}
@Override
public SocketAddress remoteAddress() {
return remoteAddress;
}
};
pipeline = channel.pipeline();
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);
}
}
});
String ldsWatched = xdsClient.ldsResource.get(5, TimeUnit.SECONDS);
assertThat(ldsWatched).isEqualTo("grpc/server?udpa.resource.listening_address=0.0.0.0:" + PORT);
EnvoyServerProtoData.Listener listener = EnvoyServerProtoData.Listener.create("listener1", "10.1.2.3", ImmutableList.of(), null);
LdsUpdate listenerUpdate = LdsUpdate.forTcpListener(listener);
xdsClient.ldsWatcher.onChanged(listenerUpdate);
start.get(5, TimeUnit.SECONDS);
FilterChainSelector selector = selectorManager.getSelectorToUpdateSelector();
assertThat(getSslContextProviderSupplier(selector)).isNull();
}
use of io.grpc.xds.XdsClient.LdsUpdate in project grpc-java by grpc.
the class XdsSdsClientServerTest method buildServer.
private void buildServer(XdsServerBuilder builder, DownstreamTlsContext downstreamTlsContext) throws Exception {
tlsContextManagerForServer = new TlsContextManagerImpl(bootstrapInfoForServer);
XdsServerWrapper xdsServer = (XdsServerWrapper) builder.build();
SettableFuture<Throwable> startFuture = startServerAsync(xdsServer);
EnvoyServerProtoData.Listener listener = buildListener("listener1", "10.1.2.3", downstreamTlsContext, tlsContextManagerForServer);
LdsUpdate listenerUpdate = LdsUpdate.forTcpListener(listener);
xdsClient.deliverLdsUpdate(listenerUpdate);
startFuture.get(10, TimeUnit.SECONDS);
port = xdsServer.getPort();
URI expectedUri = new URI("sdstest://localhost:" + port);
fakeNameResolverFactory = new FakeNameResolverFactory.Builder(expectedUri).build();
NameResolverRegistry.getDefaultRegistry().register(fakeNameResolverFactory);
}
Aggregations