diff --git a/source/extensions/filters/http/grpc_http1_bridge/BUILD b/source/extensions/filters/http/grpc_http1_bridge/BUILD index c812c4e4c990..6b0c58125b6a 100644 --- a/source/extensions/filters/http/grpc_http1_bridge/BUILD +++ b/source/extensions/filters/http/grpc_http1_bridge/BUILD @@ -33,12 +33,6 @@ envoy_cc_extension( name = "config", srcs = ["config.cc"], hdrs = ["config.h"], - # Legacy test use. TODO(#9953) clean up. - extra_visibility = [ - "//source/exe:__pkg__", - "//test/integration:__subpackages__", - "//test/server:__subpackages__", - ], deps = [ "//envoy/registry", "//envoy/server:filter_config_interface", diff --git a/test/extensions/filters/http/grpc_http1_bridge/BUILD b/test/extensions/filters/http/grpc_http1_bridge/BUILD index 24139e98a4b5..1cd2e3dda5c2 100644 --- a/test/extensions/filters/http/grpc_http1_bridge/BUILD +++ b/test/extensions/filters/http/grpc_http1_bridge/BUILD @@ -35,3 +35,18 @@ envoy_extension_cc_test( "//test/mocks/server:factory_context_mocks", ], ) + +envoy_extension_cc_test( + name = "grpc_http1_bridge_integration_test", + srcs = [ + "grpc_http1_bridge_integration_test.cc", + ], + extension_names = ["envoy.filters.http.grpc_http1_bridge"], + deps = [ + "//source/common/http:header_map_lib", + "//source/common/http:headers_lib", + "//source/extensions/filters/http/grpc_http1_bridge:config", + "//source/extensions/filters/http/health_check:config", + "//test/integration:http_integration_lib", + ], +) diff --git a/test/extensions/filters/http/grpc_http1_bridge/grpc_http1_bridge_integration_test.cc b/test/extensions/filters/http/grpc_http1_bridge/grpc_http1_bridge_integration_test.cc new file mode 100644 index 000000000000..f8721b0c3121 --- /dev/null +++ b/test/extensions/filters/http/grpc_http1_bridge/grpc_http1_bridge_integration_test.cc @@ -0,0 +1,53 @@ +#include "test/integration/http_integration.h" + +#include "gtest/gtest.h" + +namespace Envoy { +namespace { + +// A test class for testing HTTP/1.1 upstream and downstreams + +class GrpcIntegrationTest : public testing::TestWithParam, + public HttpIntegrationTest { +public: + GrpcIntegrationTest() : HttpIntegrationTest(Http::CodecType::HTTP1, GetParam()) {} +}; + +// Test hitting the bridge filter with too many response bytes to buffer. Given +// the headers are not proxied, the connection manager will send a local error reply. +TEST_P(GrpcIntegrationTest, HittingGrpcFilterLimitBufferingHeaders) { + config_helper_.prependFilter( + "{ name: grpc_http1_bridge, typed_config: { \"@type\": " + "type.googleapis.com/envoy.extensions.filters.http.grpc_http1_bridge.v3.Config } }"); + config_helper_.setBufferLimits(1024, 1024); + initialize(); + codec_client_ = makeHttpConnection(lookupPort("http")); + + auto response = codec_client_->makeHeaderOnlyRequest( + Http::TestRequestHeaderMapImpl{{":method", "POST"}, + {":path", "/test/long/url"}, + {":scheme", "http"}, + {":authority", "host"}, + {"content-type", "application/grpc"}, + {"x-envoy-retry-grpc-on", "cancelled"}}); + waitForNextUpstreamRequest(); + + // Send the overly large response. Because the grpc_http1_bridge filter buffers and buffer + // limits are exceeded, this will be translated into an unknown gRPC error. + upstream_request_->encodeHeaders(Http::TestResponseHeaderMapImpl{{":status", "200"}}, false); + upstream_request_->encodeData(1024 * 65, false); + ASSERT_TRUE(fake_upstream_connection_->waitForDisconnect()); + + ASSERT_TRUE(response->waitForEndStream()); + EXPECT_TRUE(response->complete()); + EXPECT_THAT(response->headers(), Http::HttpStatusIs("200")); + EXPECT_THAT(response->headers(), + HeaderValueOf(Http::Headers::get().GrpcStatus, "2")); // Unknown gRPC error +} + +INSTANTIATE_TEST_SUITE_P(IpVersions, GrpcIntegrationTest, + testing::ValuesIn(TestEnvironment::getIpVersionsForTest()), + TestUtility::ipTestParamsToString); + +} // namespace +} // namespace Envoy diff --git a/test/integration/BUILD b/test/integration/BUILD index efa5e78a9abd..3c4709acfeea 100644 --- a/test/integration/BUILD +++ b/test/integration/BUILD @@ -942,7 +942,6 @@ envoy_cc_test( ":http_integration_lib", "//source/common/http:header_map_lib", "//source/common/http:headers_lib", - "//source/extensions/filters/http/grpc_http1_bridge:config", "//source/extensions/filters/http/health_check:config", "//test/integration/filters:clear_route_cache_filter_lib", "//test/integration/filters:encoder_decoder_buffer_filter_lib", @@ -956,7 +955,6 @@ envoy_cc_test( "//test/test_common:utility_lib", "@envoy_api//envoy/config/bootstrap/v3:pkg_cc_proto", "@envoy_api//envoy/config/route/v3:pkg_cc_proto", - "@envoy_api//envoy/extensions/filters/http/grpc_http1_bridge/v3:pkg_cc_proto", "@envoy_api//envoy/extensions/filters/network/http_connection_manager/v3:pkg_cc_proto", ], ) diff --git a/test/integration/integration_test.cc b/test/integration/integration_test.cc index cc004f0a616f..5e8d025aa1ad 100644 --- a/test/integration/integration_test.cc +++ b/test/integration/integration_test.cc @@ -4,7 +4,6 @@ #include "envoy/config/bootstrap/v3/bootstrap.pb.h" #include "envoy/config/route/v3/route_components.pb.h" -#include "envoy/extensions/filters/http/grpc_http1_bridge/v3/config.pb.h" #include "envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.pb.h" #include "source/common/http/header_map_impl.h" @@ -624,38 +623,6 @@ TEST_P(IntegrationTest, UpstreamDisconnectWithTwoRequests) { test_server_->waitForCounterGe("cluster.cluster_0.upstream_rq_200", 2); } -// Test hitting the bridge filter with too many response bytes to buffer. Given -// the headers are not proxied, the connection manager will send a local error reply. -TEST_P(IntegrationTest, HittingGrpcFilterLimitBufferingHeaders) { - config_helper_.prependFilter( - "{ name: grpc_http1_bridge, typed_config: { \"@type\": " - "type.googleapis.com/envoy.extensions.filters.http.grpc_http1_bridge.v3.Config } }"); - config_helper_.setBufferLimits(1024, 1024); - initialize(); - codec_client_ = makeHttpConnection(lookupPort("http")); - - auto response = codec_client_->makeHeaderOnlyRequest( - Http::TestRequestHeaderMapImpl{{":method", "POST"}, - {":path", "/test/long/url"}, - {":scheme", "http"}, - {":authority", "host"}, - {"content-type", "application/grpc"}, - {"x-envoy-retry-grpc-on", "cancelled"}}); - waitForNextUpstreamRequest(); - - // Send the overly large response. Because the grpc_http1_bridge filter buffers and buffer - // limits are exceeded, this will be translated into an unknown gRPC error. - upstream_request_->encodeHeaders(Http::TestResponseHeaderMapImpl{{":status", "200"}}, false); - upstream_request_->encodeData(1024 * 65, false); - ASSERT_TRUE(fake_upstream_connection_->waitForDisconnect()); - - ASSERT_TRUE(response->waitForEndStream()); - EXPECT_TRUE(response->complete()); - EXPECT_THAT(response->headers(), HttpStatusIs("200")); - EXPECT_THAT(response->headers(), - HeaderValueOf(Headers::get().GrpcStatus, "2")); // Unknown gRPC error -} - TEST_P(IntegrationTest, TestSmuggling) { initialize();