-
Notifications
You must be signed in to change notification settings - Fork 5.5k
http3: applying config options upstream #16532
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| load( | ||
| "//bazel:envoy_build_system.bzl", | ||
| "envoy_cc_test", | ||
| "envoy_package", | ||
| "envoy_select_enable_http3", | ||
| ) | ||
|
|
||
| licenses(["notice"]) # Apache 2 | ||
|
|
||
| envoy_package() | ||
|
|
||
| envoy_cc_test( | ||
| name = "conn_pool_test", | ||
| srcs = envoy_select_enable_http3(["conn_pool_test.cc"]), | ||
| tags = ["nofips"], | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nofips? As in the compliance standard?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah. they did a fips version of boring a year or two back but we need a more modern version of boringssl for some of the QUIC crypto functions, so our QUIC impl is not compatible with Envoy builds latched to the fips boring. |
||
| deps = | ||
| envoy_select_enable_http3([ | ||
| "//source/common/event:dispatcher_lib", | ||
| "//source/common/http/http3:conn_pool_lib", | ||
| "//source/common/network:utility_lib", | ||
| "//source/common/upstream:upstream_includes", | ||
| "//source/common/upstream:upstream_lib", | ||
| "//test/common/http:common_lib", | ||
| "//test/common/upstream:utility_lib", | ||
| "//test/mocks/event:event_mocks", | ||
| "//test/mocks/http:http_mocks", | ||
| "//test/mocks/network:network_mocks", | ||
| "//test/mocks/runtime:runtime_mocks", | ||
| "//test/mocks/server:transport_socket_factory_context_mocks", | ||
| "//test/mocks/upstream:cluster_info_mocks", | ||
| "//test/mocks/upstream:transport_socket_match_mocks", | ||
| "//test/test_common:test_runtime_lib", | ||
| ]), | ||
| ) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| #include "common/http/http3/conn_pool.h" | ||
| #include "common/quic/quic_transport_socket_factory.h" | ||
|
|
||
| #include "test/common/upstream/utility.h" | ||
| #include "test/mocks/common.h" | ||
| #include "test/mocks/event/mocks.h" | ||
| #include "test/mocks/server/transport_socket_factory_context.h" | ||
| #include "test/mocks/ssl/mocks.h" | ||
| #include "test/mocks/upstream/cluster_info.h" | ||
| #include "test/mocks/upstream/host.h" | ||
| #include "test/test_common/simulated_time_system.h" | ||
|
|
||
| using testing::NiceMock; | ||
| using testing::Return; | ||
|
|
||
| namespace Envoy { | ||
| namespace Http { | ||
| namespace Http3 { | ||
|
|
||
| TEST(Convert, Basic) { | ||
| NiceMock<Upstream::MockClusterInfo> cluster_info; | ||
| quic::QuicConfig config; | ||
|
|
||
| EXPECT_CALL(cluster_info, connectTimeout).WillOnce(Return(std::chrono::milliseconds(42))); | ||
| auto* protocol_options = cluster_info.http3_options_.mutable_quic_protocol_options(); | ||
| protocol_options->mutable_max_concurrent_streams()->set_value(43); | ||
| protocol_options->mutable_initial_stream_window_size()->set_value(65555); | ||
|
|
||
| Http3ConnPoolImpl::setQuicConfigFromClusterConfig(cluster_info, config); | ||
|
|
||
| EXPECT_EQ(config.max_time_before_crypto_handshake(), quic::QuicTime::Delta::FromMilliseconds(42)); | ||
| EXPECT_EQ(config.GetMaxBidirectionalStreamsToSend(), | ||
| protocol_options->max_concurrent_streams().value()); | ||
| EXPECT_EQ(config.GetMaxUnidirectionalStreamsToSend(), | ||
| protocol_options->max_concurrent_streams().value()); | ||
| EXPECT_EQ(config.GetInitialMaxStreamDataBytesIncomingBidirectionalToSend(), | ||
| protocol_options->initial_stream_window_size().value()); | ||
| } | ||
|
|
||
| class Http3ConnPoolImplTest : public Event::TestUsingSimulatedTime, public testing::Test { | ||
| public: | ||
| void initialize() { | ||
| EXPECT_CALL(mockHost(), address()).WillRepeatedly(Return(test_address_)); | ||
| EXPECT_CALL(mockHost(), transportSocketFactory()).WillRepeatedly(testing::ReturnRef(factory_)); | ||
| new Event::MockSchedulableCallback(&dispatcher_); | ||
| Network::ConnectionSocket::OptionsSharedPtr options; | ||
| Network::TransportSocketOptionsSharedPtr transport_options; | ||
| pool_ = allocateConnPool(dispatcher_, random_, host_, Upstream::ResourcePriority::Default, | ||
| options, transport_options, state_, simTime()); | ||
| } | ||
|
|
||
| Upstream::MockHost& mockHost() { return static_cast<Upstream::MockHost&>(*host_); } | ||
|
|
||
| NiceMock<Event::MockDispatcher> dispatcher_; | ||
| Upstream::HostSharedPtr host_{new NiceMock<Upstream::MockHost>}; | ||
| NiceMock<Random::MockRandomGenerator> random_; | ||
| Upstream::ClusterConnectivityState state_; | ||
| Network::Address::InstanceConstSharedPtr test_address_ = | ||
| Network::Utility::resolveUrl("tcp://127.0.0.1:3000"); | ||
| NiceMock<Server::Configuration::MockTransportSocketFactoryContext> context_; | ||
| Quic::QuicClientTransportSocketFactory factory_{ | ||
| std::unique_ptr<Envoy::Ssl::ClientContextConfig>(new NiceMock<Ssl::MockClientContextConfig>), | ||
| context_}; | ||
| ConnectionPool::InstancePtr pool_; | ||
| }; | ||
|
|
||
| TEST_F(Http3ConnPoolImplTest, CreationWithConfig) { | ||
| // Set a couple of options from setQuicConfigFromClusterConfig to make sure they are applied. | ||
| auto* options = mockHost().cluster_.http3_options_.mutable_quic_protocol_options(); | ||
| options->mutable_max_concurrent_streams()->set_value(15); | ||
| options->mutable_initial_stream_window_size()->set_value(65555); | ||
| initialize(); | ||
|
|
||
| Quic::PersistentQuicInfoImpl& info = static_cast<Http3ConnPoolImpl*>(pool_.get())->quicInfo(); | ||
| EXPECT_EQ(info.quic_config_.GetMaxUnidirectionalStreamsToSend(), | ||
| options->max_concurrent_streams().value()); | ||
| EXPECT_EQ(info.quic_config_.GetInitialMaxStreamDataBytesIncomingBidirectionalToSend(), | ||
| options->initial_stream_window_size().value()); | ||
| } | ||
|
|
||
| } // namespace Http3 | ||
| } // namespace Http | ||
| } // namespace Envoy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Http3ConnPoolImplTestis not used in this header?