Search in sources :

Example 6 with HttpConnectionManager

use of io.envoyproxy.envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager in project grpc-java by grpc.

the class ClientXdsClientDataTest method parseHttpConnectionManager_emptyFilters.

@Test
public void parseHttpConnectionManager_emptyFilters() throws ResourceInvalidException {
    HttpConnectionManager hcm = HttpConnectionManager.newBuilder().build();
    thrown.expect(ResourceInvalidException.class);
    thrown.expectMessage("Missing HttpFilter in HttpConnectionManager.");
    ClientXdsClient.parseHttpConnectionManager(hcm, new HashSet<String>(), filterRegistry, true, /* parseHttpFilter */
    true);
}
Also used : HttpConnectionManager(io.envoyproxy.envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager) Test(org.junit.Test)

Example 7 with HttpConnectionManager

use of io.envoyproxy.envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager in project grpc-java by grpc.

the class ClientXdsClientDataTest method parseHttpConnectionManager_clusterSpecifierPlugin.

@Test
public void parseHttpConnectionManager_clusterSpecifierPlugin() throws Exception {
    ClientXdsClient.enableRouteLookup = true;
    RouteLookupConfig routeLookupConfig = RouteLookupConfig.newBuilder().addGrpcKeybuilders(GrpcKeyBuilder.newBuilder().addNames(Name.newBuilder().setService("service1")).addNames(Name.newBuilder().setService("service2")).addHeaders(NameMatcher.newBuilder().setKey("key1").addNames("v1").setRequiredMatch(true))).setLookupService("rls-cbt.googleapis.com").setLookupServiceTimeout(Durations.fromMillis(1234)).setCacheSizeBytes(5000).addValidTargets("valid-target").build();
    RouteLookupClusterSpecifier specifier = RouteLookupClusterSpecifier.newBuilder().setRouteLookupConfig(routeLookupConfig).build();
    TypedExtensionConfig typedExtensionConfig = TypedExtensionConfig.newBuilder().setName("rls-plugin-1").setTypedConfig(Any.pack(specifier)).build();
    io.envoyproxy.envoy.config.route.v3.Route route = io.envoyproxy.envoy.config.route.v3.Route.newBuilder().setName("route-1").setMatch(io.envoyproxy.envoy.config.route.v3.RouteMatch.newBuilder().setPrefix("")).setRoute(io.envoyproxy.envoy.config.route.v3.RouteAction.newBuilder().setClusterSpecifierPlugin("rls-plugin-1")).build();
    HttpConnectionManager hcm = HttpConnectionManager.newBuilder().setRouteConfig(RouteConfiguration.newBuilder().addClusterSpecifierPlugins(io.envoyproxy.envoy.config.route.v3.ClusterSpecifierPlugin.newBuilder().setExtension(typedExtensionConfig).build()).addVirtualHosts(io.envoyproxy.envoy.config.route.v3.VirtualHost.newBuilder().setName("virtual-host-1").addRoutes(route))).build();
    io.grpc.xds.HttpConnectionManager parsedHcm = ClientXdsClient.parseHttpConnectionManager(hcm, new HashSet<String>(), filterRegistry, false, /* parseHttpFilter */
    true);
    VirtualHost virtualHost = Iterables.getOnlyElement(parsedHcm.virtualHosts());
    Route parsedRoute = Iterables.getOnlyElement(virtualHost.routes());
    NamedPluginConfig namedPluginConfig = parsedRoute.routeAction().namedClusterSpecifierPluginConfig();
    assertThat(namedPluginConfig.name()).isEqualTo("rls-plugin-1");
    assertThat(namedPluginConfig.config()).isInstanceOf(RlsPluginConfig.class);
}
Also used : RouteLookupClusterSpecifier(io.grpc.lookup.v1.RouteLookupClusterSpecifier) RouteLookupConfig(io.grpc.lookup.v1.RouteLookupConfig) NamedPluginConfig(io.grpc.xds.ClusterSpecifierPlugin.NamedPluginConfig) HttpConnectionManager(io.envoyproxy.envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager) TypedExtensionConfig(io.envoyproxy.envoy.config.core.v3.TypedExtensionConfig) RBACPerRoute(io.envoyproxy.envoy.extensions.filters.http.rbac.v3.RBACPerRoute) Route(io.grpc.xds.VirtualHost.Route) Test(org.junit.Test)

Example 8 with HttpConnectionManager

use of io.envoyproxy.envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager in project grpc-java by grpc.

the class ClientXdsClientDataTest method parseHttpConnectionManager_unknownFilters.

@Test
public void parseHttpConnectionManager_unknownFilters() throws ResourceInvalidException {
    HttpConnectionManager hcm = HttpConnectionManager.newBuilder().addHttpFilters(HttpFilter.newBuilder().setName("envoy.filter.foo").setIsOptional(true)).addHttpFilters(HttpFilter.newBuilder().setName("envoy.filter.bar").setIsOptional(true)).build();
    thrown.expect(ResourceInvalidException.class);
    thrown.expectMessage("The last HttpFilter must be a terminal filter: envoy.filter.bar");
    ClientXdsClient.parseHttpConnectionManager(hcm, new HashSet<String>(), filterRegistry, true, /* parseHttpFilter */
    true);
}
Also used : HttpConnectionManager(io.envoyproxy.envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager) Test(org.junit.Test)

Example 9 with HttpConnectionManager

use of io.envoyproxy.envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager in project grpc-java by grpc.

the class ClientXdsClientDataTest method parseFilterChain_duplicateFilter.

@Test
public void parseFilterChain_duplicateFilter() throws ResourceInvalidException {
    Filter filter = buildHttpConnectionManagerFilter(HttpFilter.newBuilder().setName("http-filter-foo").setIsOptional(true).build());
    FilterChain filterChain = FilterChain.newBuilder().setName("filter-chain-foo").setFilterChainMatch(FilterChainMatch.getDefaultInstance()).setTransportSocket(TransportSocket.getDefaultInstance()).addAllFilters(Arrays.asList(filter, filter)).build();
    thrown.expect(ResourceInvalidException.class);
    thrown.expectMessage("FilterChain filter-chain-foo should contain exact one HttpConnectionManager filter");
    ClientXdsClient.parseFilterChain(filterChain, new HashSet<String>(), null, filterRegistry, null, null, true);
}
Also used : ListenerFilter(io.envoyproxy.envoy.config.listener.v3.ListenerFilter) HttpFilter(io.envoyproxy.envoy.extensions.filters.network.http_connection_manager.v3.HttpFilter) Filter(io.envoyproxy.envoy.config.listener.v3.Filter) FilterChain(io.envoyproxy.envoy.config.listener.v3.FilterChain) Test(org.junit.Test)

Example 10 with HttpConnectionManager

use of io.envoyproxy.envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager in project grpc-java by grpc.

the class ClientXdsClientDataTest method parseHttpConnectionManager_OriginalIpDetectionExtensionsMustEmpty.

@Test
public void parseHttpConnectionManager_OriginalIpDetectionExtensionsMustEmpty() throws ResourceInvalidException {
    @SuppressWarnings("deprecation") HttpConnectionManager hcm = HttpConnectionManager.newBuilder().addOriginalIpDetectionExtensions(TypedExtensionConfig.newBuilder().build()).build();
    thrown.expect(ResourceInvalidException.class);
    thrown.expectMessage("HttpConnectionManager with original_ip_detection_extensions unsupported");
    ClientXdsClient.parseHttpConnectionManager(hcm, new HashSet<String>(), filterRegistry, false, /* does not matter */
    false);
}
Also used : HttpConnectionManager(io.envoyproxy.envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager) Test(org.junit.Test)

Aggregations

HttpConnectionManager (io.envoyproxy.envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager)13 Test (org.junit.Test)13 TypedExtensionConfig (io.envoyproxy.envoy.config.core.v3.TypedExtensionConfig)3 RouteLookupClusterSpecifier (io.grpc.lookup.v1.RouteLookupClusterSpecifier)3 RouteLookupConfig (io.grpc.lookup.v1.RouteLookupConfig)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 HashSet (java.util.HashSet)2 Any (com.google.protobuf.Any)1 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)1 HttpProtocolOptions (io.envoyproxy.envoy.config.core.v3.HttpProtocolOptions)1 Filter (io.envoyproxy.envoy.config.listener.v3.Filter)1 FilterChain (io.envoyproxy.envoy.config.listener.v3.FilterChain)1 ListenerFilter (io.envoyproxy.envoy.config.listener.v3.ListenerFilter)1 RBACPerRoute (io.envoyproxy.envoy.extensions.filters.http.rbac.v3.RBACPerRoute)1 HttpFilter (io.envoyproxy.envoy.extensions.filters.network.http_connection_manager.v3.HttpFilter)1 Rds (io.envoyproxy.envoy.extensions.filters.network.http_connection_manager.v3.Rds)1 DownstreamTlsContext (io.envoyproxy.envoy.extensions.transport_sockets.tls.v3.DownstreamTlsContext)1 NamedPluginConfig (io.grpc.xds.ClusterSpecifierPlugin.NamedPluginConfig)1 LbEndpoint (io.grpc.xds.Endpoints.LbEndpoint)1 FilterChainMatch (io.grpc.xds.EnvoyServerProtoData.FilterChainMatch)1