Skip to content

Commit

Permalink
Enable HTTP/3 in tests (#26309)
Browse files Browse the repository at this point in the history
Enable HTTP/3 in tests

This PR sets the stage to work on HTTP/3 upgrade header normalization by enabling HTTP/3 in various tests
This PR is a relanding of #26197 with all the non-test changes reverted
This PR is based on #26107 by @asingh-g
Risk Level: Low
Testing: Existing tests
Docs Changes: none
Release Notes: none
Platform Specific Features: none

Signed-off-by: David Schinazi <dschinazi@google.com>
  • Loading branch information
DavidSchinazi authored Mar 23, 2023
1 parent 17844b1 commit 9d4d181
Show file tree
Hide file tree
Showing 28 changed files with 285 additions and 152 deletions.
4 changes: 2 additions & 2 deletions test/common/common/packed_struct_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ TEST_F(PackedStructTest, StringStructMove) {
EXPECT_FALSE(redirect_strings.get<RedirectStringElement::HostRedirect>().has_value());

// Invoke move constructor.
RedirectStringsPackedStruct redirect_strings2(move(redirect_strings));
RedirectStringsPackedStruct redirect_strings2(std::move(redirect_strings));
// Ensure no memory was allocated on the heap by the move constructor.
EXPECT_MEMORY_LE(memory_test.consumedBytes(), 2 * sizeof(std::string) + 16);

Expand All @@ -77,7 +77,7 @@ TEST_F(PackedStructTest, StringStructMove) {

// Invoke move assignment.
RedirectStringsPackedStruct redirect_strings3(0);
redirect_strings3 = move(redirect_strings2);
redirect_strings3 = std::move(redirect_strings2);
// Ensure no memory was allocated on the heap by the move assignment.
EXPECT_MEMORY_LE(memory_test.consumedBytes(), 2 * sizeof(std::string) + 16);

Expand Down
2 changes: 1 addition & 1 deletion test/common/http/http3/conn_pool_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class MockQuicClientTransportSocketFactory : public Quic::QuicClientTransportSoc
MockQuicClientTransportSocketFactory(
Ssl::ClientContextConfigPtr config,
Server::Configuration::TransportSocketFactoryContext& factory_context)
: Quic::QuicClientTransportSocketFactory(move(config), factory_context) {}
: Quic::QuicClientTransportSocketFactory(std::move(config), factory_context) {}

MOCK_METHOD(Envoy::Ssl::ClientContextSharedPtr, sslCtx, ());
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ TEST_P(BufferIntegrationTest, RouterNotFoundBodyBuffer) {
}

TEST_P(BufferIntegrationTest, RouterRequestAndResponseWithGiantBodyBuffer) {
if (upstreamProtocol() == Http::CodecType::HTTP3 ||
downstreamProtocol() == Http::CodecType::HTTP3) {
// TODO(#26236) - Fix test flakiness over HTTP/3.
return;
}
config_helper_.prependFilter(ConfigHelper::defaultBufferFilter(), testing_downstream_filter_);
testRouterRequestAndResponseWithBody(4 * 1024 * 1024, 4 * 1024 * 1024, false);
}
Expand All @@ -46,8 +51,11 @@ TEST_P(BufferIntegrationTest, RouterRequestPopulateContentLength) {
initialize();

codec_client_ = makeHttpConnection(lookupPort("http"));
auto encoder_decoder = codec_client_->startRequest(Http::TestRequestHeaderMapImpl{
{":method", "POST"}, {":scheme", "http"}, {":path", "/shelf"}, {":authority", "host"}});
auto encoder_decoder =
codec_client_->startRequest(Http::TestRequestHeaderMapImpl{{":method", "POST"},
{":scheme", "http"},
{":path", "/shelf"},
{":authority", "sni.lyft.com"}});
request_encoder_ = &encoder_decoder.first;
IntegrationStreamDecoderPtr response = std::move(encoder_decoder.second);
codec_client_->sendData(*request_encoder_, "123", false);
Expand All @@ -74,8 +82,11 @@ TEST_P(BufferIntegrationTest, RouterRequestPopulateContentLengthOnTrailers) {
initialize();

codec_client_ = makeHttpConnection(lookupPort("http"));
auto encoder_decoder = codec_client_->startRequest(Http::TestRequestHeaderMapImpl{
{":method", "POST"}, {":scheme", "http"}, {":path", "/shelf"}, {":authority", "host"}});
auto encoder_decoder =
codec_client_->startRequest(Http::TestRequestHeaderMapImpl{{":method", "POST"},
{":scheme", "http"},
{":path", "/shelf"},
{":authority", "sni.lyft.com"}});
request_encoder_ = &encoder_decoder.first;
IntegrationStreamDecoderPtr response = std::move(encoder_decoder.second);
codec_client_->sendData(*request_encoder_, "0123", false);
Expand Down Expand Up @@ -116,7 +127,7 @@ TEST_P(BufferIntegrationTest, RouterRequestBufferLimitExceeded) {
Http::TestRequestHeaderMapImpl{{":method", "POST"},
{":path", "/dynamo/url"},
{":scheme", "http"},
{":authority", "host"},
{":authority", "sni.lyft.com"},
{"x-forwarded-for", "10.0.0.1"},
{"x-envoy-retry-on", "5xx"}},
1024 * 65, false);
Expand Down Expand Up @@ -159,7 +170,7 @@ TEST_P(BufferIntegrationTest, RouteDisabled) {
Http::TestRequestHeaderMapImpl{{":method", "POST"},
{":path", "/test/long/url"},
{":scheme", "http"},
{":authority", "host"},
{":authority", "sni.lyft.com"},
{"x-forwarded-for", "10.0.0.1"}},
1024 * 65);

Expand Down Expand Up @@ -188,7 +199,7 @@ TEST_P(BufferIntegrationTest, RouteOverride) {
Http::TestRequestHeaderMapImpl{{":method", "POST"},
{":path", "/test/long/url"},
{":scheme", "http"},
{":authority", "host"},
{":authority", "sni.lyft.com"},
{"x-forwarded-for", "10.0.0.1"}},
1024 * 65);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,11 @@ class CacheIntegrationTest : public Event::TestUsingSimulatedTime,
OptRef<const Http::TestResponseTrailerMapImpl> empty_trailers_;
};

INSTANTIATE_TEST_SUITE_P(Protocols, CacheIntegrationTest,
testing::ValuesIn(HttpProtocolIntegrationTest::getProtocolTestParams()),
HttpProtocolIntegrationTest::protocolTestParamsToString);
// TODO(#26236): Fix test suite for HTTP/3.
INSTANTIATE_TEST_SUITE_P(
Protocols, CacheIntegrationTest,
testing::ValuesIn(HttpProtocolIntegrationTest::getProtocolTestParamsWithoutHTTP3()),
HttpProtocolIntegrationTest::protocolTestParamsToString);

TEST_P(CacheIntegrationTest, MissInsertHit) {
initializeFilter(default_config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,13 @@ void WebsocketWithCompressorIntegrationTest::validateUpgradeResponseHeaders(
EXPECT_THAT(&proxied_response_headers, HeaderMapEqualIgnoreOrder(&original_response_headers));
}

INSTANTIATE_TEST_SUITE_P(Protocols, WebsocketWithCompressorIntegrationTest,
testing::ValuesIn(HttpProtocolIntegrationTest::getProtocolTestParams()),
HttpProtocolIntegrationTest::protocolTestParamsToString);
// TODO(#26236): Fix test suite for HTTP/3.
INSTANTIATE_TEST_SUITE_P(
Protocols, WebsocketWithCompressorIntegrationTest,
testing::ValuesIn(HttpProtocolIntegrationTest::getProtocolTestParams(
/*downstream_protocols = */ {Envoy::Http::CodecType::HTTP1, Envoy::Http::CodecType::HTTP2},
/*upstream_protocols = */ {Envoy::Http::CodecType::HTTP1, Envoy::Http::CodecType::HTTP2})),
HttpProtocolIntegrationTest::protocolTestParamsToString);

ConfigHelper::HttpModifierFunction setRouteUsingWebsocket() {
return [](envoy::extensions::filters::network::http_connection_manager::v3::HttpConnectionManager&
Expand Down Expand Up @@ -244,9 +248,12 @@ TEST_P(WebsocketWithCompressorIntegrationTest, NonWebsocketUpgrade) {
ASSERT_EQ(1, response_uncompressed_counter->value());
}

INSTANTIATE_TEST_SUITE_P(Protocols, CompressorProxyingConnectIntegrationTest,
testing::ValuesIn(HttpProtocolIntegrationTest::getProtocolTestParams()),
HttpProtocolIntegrationTest::protocolTestParamsToString);
INSTANTIATE_TEST_SUITE_P(
Protocols, CompressorProxyingConnectIntegrationTest,
testing::ValuesIn(HttpProtocolIntegrationTest::getProtocolTestParams(
/*downstream_protocols = */ {Envoy::Http::CodecType::HTTP1, Envoy::Http::CodecType::HTTP2},
/*upstream_protocols = */ {Envoy::Http::CodecType::HTTP1, Envoy::Http::CodecType::HTTP2})),
HttpProtocolIntegrationTest::protocolTestParamsToString);

void CompressorProxyingConnectIntegrationTest::initialize() {
config_helper_.addConfigModifier(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,11 @@ class CsrfFilterIntegrationTest : public HttpProtocolIntegrationTest {
}
};

INSTANTIATE_TEST_SUITE_P(Protocols, CsrfFilterIntegrationTest,
testing::ValuesIn(HttpProtocolIntegrationTest::getProtocolTestParams()),
HttpProtocolIntegrationTest::protocolTestParamsToString);
// TODO(#26236): Fix test suite for HTTP/3.
INSTANTIATE_TEST_SUITE_P(
Protocols, CsrfFilterIntegrationTest,
testing::ValuesIn(HttpProtocolIntegrationTest::getProtocolTestParamsWithoutHTTP3()),
HttpProtocolIntegrationTest::protocolTestParamsToString);

TEST_P(CsrfFilterIntegrationTest, TestCsrfSuccess) {
config_helper_.prependFilter(CSRF_FILTER_ENABLED_CONFIG);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -643,9 +643,11 @@ TEST_P(CustomResponseIntegrationTest, ModifyRequestHeaders) {
EXPECT_EQ("Modify action response body", response->body());
}

INSTANTIATE_TEST_SUITE_P(Protocols, CustomResponseIntegrationTest,
testing::ValuesIn(HttpProtocolIntegrationTest::getProtocolTestParams()),
HttpProtocolIntegrationTest::protocolTestParamsToString);
// TODO(#26236): Fix test suite for HTTP/3.
INSTANTIATE_TEST_SUITE_P(
Protocols, CustomResponseIntegrationTest,
testing::ValuesIn(HttpProtocolIntegrationTest::getProtocolTestParamsWithoutHTTP3()),
HttpProtocolIntegrationTest::protocolTestParamsToString);
} // namespace CustomResponse
} // namespace HttpFilters
} // namespace Extensions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,12 @@ name: fault
// Fault integration tests that should run with all protocols, useful for testing various
// end_stream permutations when rate limiting.
class FaultIntegrationTestAllProtocols : public FaultIntegrationTest {};
INSTANTIATE_TEST_SUITE_P(Protocols, FaultIntegrationTestAllProtocols,
testing::ValuesIn(HttpProtocolIntegrationTest::getProtocolTestParams()),
HttpProtocolIntegrationTest::protocolTestParamsToString);

// TODO(#26236): Fix test suite for HTTP/3.
INSTANTIATE_TEST_SUITE_P(
Protocols, FaultIntegrationTestAllProtocols,
testing::ValuesIn(HttpProtocolIntegrationTest::getProtocolTestParamsWithoutHTTP3()),
HttpProtocolIntegrationTest::protocolTestParamsToString);

// No fault injected.
TEST_P(FaultIntegrationTestAllProtocols, NoFault) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,13 @@ std::string smallRequestBufferConfig() {

using FileSystemBufferIntegrationTest = HttpProtocolIntegrationTest;

INSTANTIATE_TEST_SUITE_P(Protocols, FileSystemBufferIntegrationTest,
testing::ValuesIn(HttpProtocolIntegrationTest::getProtocolTestParams()),
HttpProtocolIntegrationTest::protocolTestParamsToString);
// TODO(#26236): Fix test suite for HTTP/3.
INSTANTIATE_TEST_SUITE_P(
Protocols, FileSystemBufferIntegrationTest,
testing::ValuesIn(HttpProtocolIntegrationTest::getProtocolTestParams(
/*downstream_protocols = */ {Envoy::Http::CodecType::HTTP1, Envoy::Http::CodecType::HTTP2},
/*upstream_protocols = */ {Envoy::Http::CodecType::HTTP1, Envoy::Http::CodecType::HTTP2})),
HttpProtocolIntegrationTest::protocolTestParamsToString);

TEST_P(FileSystemBufferIntegrationTest, NotFoundBodyBuffer) {
config_helper_.prependFilter(contentLengthConfig());
Expand Down
22 changes: 13 additions & 9 deletions test/extensions/filters/http/jwt_authn/filter_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ std::string getFilterConfig(bool use_local_jwks) {

class LocalJwksIntegrationTest : public HttpProtocolIntegrationTest {};

INSTANTIATE_TEST_SUITE_P(Protocols, LocalJwksIntegrationTest,
testing::ValuesIn(HttpProtocolIntegrationTest::getProtocolTestParams()),
HttpProtocolIntegrationTest::protocolTestParamsToString);
// TODO(#26236): Fix test suite for HTTP/3.
INSTANTIATE_TEST_SUITE_P(
Protocols, LocalJwksIntegrationTest,
testing::ValuesIn(HttpProtocolIntegrationTest::getProtocolTestParamsWithoutHTTP3()),
HttpProtocolIntegrationTest::protocolTestParamsToString);

// With local Jwks, this test verifies a request is passed with a good Jwt token.
TEST_P(LocalJwksIntegrationTest, WithGoodToken) {
Expand Down Expand Up @@ -385,9 +387,10 @@ class RemoteJwksIntegrationTest : public HttpProtocolIntegrationTest {
FakeStreamPtr jwks_request_{};
};

INSTANTIATE_TEST_SUITE_P(Protocols, RemoteJwksIntegrationTest,
testing::ValuesIn(HttpProtocolIntegrationTest::getProtocolTestParams()),
HttpProtocolIntegrationTest::protocolTestParamsToString);
INSTANTIATE_TEST_SUITE_P(
Protocols, RemoteJwksIntegrationTest,
testing::ValuesIn(HttpProtocolIntegrationTest::getProtocolTestParamsWithoutHTTP3()),
HttpProtocolIntegrationTest::protocolTestParamsToString);

// With remote Jwks, this test verifies a request is passed with a good Jwt token
// and a good public key fetched from a remote server.
Expand Down Expand Up @@ -609,9 +612,10 @@ class PerRouteIntegrationTest : public HttpProtocolIntegrationTest {
}
};

INSTANTIATE_TEST_SUITE_P(Protocols, PerRouteIntegrationTest,
testing::ValuesIn(HttpProtocolIntegrationTest::getProtocolTestParams()),
HttpProtocolIntegrationTest::protocolTestParamsToString);
INSTANTIATE_TEST_SUITE_P(
Protocols, PerRouteIntegrationTest,
testing::ValuesIn(HttpProtocolIntegrationTest::getProtocolTestParamsWithoutHTTP3()),
HttpProtocolIntegrationTest::protocolTestParamsToString);

// This test verifies per-route config disabled.
TEST_P(PerRouteIntegrationTest, PerRouteConfigDisabled) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,12 @@ class CrashIntegrationTest : public Event::TestUsingSimulatedTime,

// Tests should run with all protocols.
class CrashIntegrationTestAllProtocols : public CrashIntegrationTest {};
INSTANTIATE_TEST_SUITE_P(Protocols, CrashIntegrationTestAllProtocols,
testing::ValuesIn(HttpProtocolIntegrationTest::getProtocolTestParams()),
HttpProtocolIntegrationTest::protocolTestParamsToString);

// TODO(#26236): Fix test suite for HTTP/3.
INSTANTIATE_TEST_SUITE_P(
Protocols, CrashIntegrationTestAllProtocols,
testing::ValuesIn(HttpProtocolIntegrationTest::getProtocolTestParamsWithoutHTTP3()),
HttpProtocolIntegrationTest::protocolTestParamsToString);

TEST_P(CrashIntegrationTestAllProtocols, UnwindsTrackedObjectStack) {
const std::string request_kill_config =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@ name: envoy.filters.http.kill_request

// Tests should run with all protocols.
class KillRequestFilterIntegrationTestAllProtocols : public KillRequestFilterIntegrationTest {};
INSTANTIATE_TEST_SUITE_P(Protocols, KillRequestFilterIntegrationTestAllProtocols,
testing::ValuesIn(HttpProtocolIntegrationTest::getProtocolTestParams()),
HttpProtocolIntegrationTest::protocolTestParamsToString);

// TODO(#26236): Fix test suite for HTTP/3.
INSTANTIATE_TEST_SUITE_P(
Protocols, KillRequestFilterIntegrationTestAllProtocols,
testing::ValuesIn(HttpProtocolIntegrationTest::getProtocolTestParamsWithoutHTTP3()),
HttpProtocolIntegrationTest::protocolTestParamsToString);

// Request crash Envoy controlled via header configuration.
TEST_P(KillRequestFilterIntegrationTestAllProtocols, KillRequestCrashEnvoy) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,11 @@ name: basic_routes
)EOF";
};

INSTANTIATE_TEST_SUITE_P(Protocols, LocalRateLimitFilterIntegrationTest,
testing::ValuesIn(HttpProtocolIntegrationTest::getProtocolTestParams()),
HttpProtocolIntegrationTest::protocolTestParamsToString);
// TODO(#26236): Fix test suite for HTTP/3.
INSTANTIATE_TEST_SUITE_P(
Protocols, LocalRateLimitFilterIntegrationTest,
testing::ValuesIn(HttpProtocolIntegrationTest::getProtocolTestParamsWithoutHTTP3()),
HttpProtocolIntegrationTest::protocolTestParamsToString);

TEST_P(LocalRateLimitFilterIntegrationTest, DenyRequestPerProcess) {
initializeFilter(fmt::format(fmt::runtime(filter_config_), "false"));
Expand Down
Loading

0 comments on commit 9d4d181

Please sign in to comment.