-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
conn_pool: allowing multiple protocols in ALPN (#13901)
Extending the TransportSocketOptions to allow for multiple fallback ALPN for the upcoming connection pool which supports both HTTP/1 and HTTP/2 Risk Level: Low (data plane refactor, but a pretty minor one) Testing: new unit tests Docs Changes: n/a Release Notes: n/a Part of #3431 Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
- Loading branch information
1 parent
2f72126
commit 9a205da
Showing
14 changed files
with
159 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#include <memory> | ||
|
||
#include "common/http/conn_pool_base.h" | ||
#include "common/http/utility.h" | ||
|
||
#include "test/common/upstream/utility.h" | ||
#include "test/mocks/common.h" | ||
#include "test/mocks/event/mocks.h" | ||
#include "test/mocks/runtime/mocks.h" | ||
#include "test/mocks/upstream/cluster_info.h" | ||
#include "test/test_common/simulated_time_system.h" | ||
#include "test/test_common/utility.h" | ||
|
||
#include "gmock/gmock.h" | ||
#include "gtest/gtest.h" | ||
|
||
namespace Envoy { | ||
namespace Http { | ||
namespace { | ||
|
||
// TODO(alyssawilk) replace this with the MixedConnectionPool once it lands. | ||
class ConnPoolImplForTest : public HttpConnPoolImplBase { | ||
public: | ||
ConnPoolImplForTest(Event::MockDispatcher& dispatcher, Random::RandomGenerator& random, | ||
Upstream::ClusterInfoConstSharedPtr cluster) | ||
: HttpConnPoolImplBase(Upstream::makeTestHost(cluster, "tcp://127.0.0.1:9000"), | ||
Upstream::ResourcePriority::Default, dispatcher, nullptr, nullptr, | ||
random, {Http::Protocol::Http2, Http::Protocol::Http11}) {} | ||
|
||
Envoy::ConnectionPool::ActiveClientPtr instantiateActiveClient() override { return nullptr; } | ||
Http::Protocol protocol() const override { return Http::Protocol::Http2; } | ||
CodecClientPtr createCodecClient(Upstream::Host::CreateConnectionData&) override { | ||
return nullptr; | ||
} | ||
}; | ||
|
||
/** | ||
* Test fixture for a connection pool which can have HTTP/2 or HTTP/1.1 connections. | ||
*/ | ||
class MixedConnPoolImplTest : public testing::Test { | ||
public: | ||
MixedConnPoolImplTest() | ||
: conn_pool_(std::make_unique<ConnPoolImplForTest>(dispatcher_, random_, cluster_)) {} | ||
|
||
~MixedConnPoolImplTest() override { | ||
EXPECT_EQ("", TestUtility::nonZeroedGauges(cluster_->stats_store_.gauges())); | ||
} | ||
|
||
NiceMock<Event::MockDispatcher> dispatcher_; | ||
std::shared_ptr<Upstream::MockClusterInfo> cluster_{new NiceMock<Upstream::MockClusterInfo>()}; | ||
std::unique_ptr<ConnPoolImplForTest> conn_pool_; | ||
NiceMock<Runtime::MockLoader> runtime_; | ||
NiceMock<Random::MockRandomGenerator> random_; | ||
}; | ||
|
||
TEST_F(MixedConnPoolImplTest, AlpnTest) { | ||
auto& fallback = conn_pool_->transportSocketOptions()->applicationProtocolFallback(); | ||
ASSERT_EQ(2, fallback.size()); | ||
EXPECT_EQ(fallback[0], Http::Utility::AlpnNames::get().Http2); | ||
EXPECT_EQ(fallback[1], Http::Utility::AlpnNames::get().Http11); | ||
} | ||
|
||
} // namespace | ||
} // namespace Http | ||
} // namespace Envoy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.