-
Notifications
You must be signed in to change notification settings - Fork 5.5k
[balsa] Parametrize IntegrationTest on HTTP/1 implementation. #24254
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ecdb4d0
Parametrize IntegrationTest on HTTP/1 implementation.
bnc-google 75a3f28
Reviewer suggestions, plus adding using directives.
bnc-google 6d8bad6
Merge remote-tracking branch 'upstream/main' into integrationtest
bnc-google f90d1c8
Merge remote-tracking branch 'upstream/main' into integrationtest
bnc-google c9ea113
Merge remote-tracking branch 'upstream/main' into integrationtest
bnc-google 01ffd25
Merge remote-tracking branch 'upstream/main' into integrationtest
bnc-google File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -55,11 +55,20 @@ void setAllowHttp10WithDefaultHost( | |
| hcm.mutable_http_protocol_options()->set_default_host_for_http_10("default.com"); | ||
| } | ||
|
|
||
| std::string testParamToString( | ||
| const ::testing::TestParamInfo<std::tuple<Network::Address::IpVersion, Http1ParserImpl>>& | ||
| params) { | ||
| return absl::StrCat(TestUtility::ipVersionToString(std::get<0>(params.param)), | ||
| TestUtility::http1ParserImplToString(std::get<1>(params.param))); | ||
| } | ||
|
|
||
| } // namespace | ||
|
|
||
| INSTANTIATE_TEST_SUITE_P(IpVersions, IntegrationTest, | ||
| testing::ValuesIn(TestEnvironment::getIpVersionsForTest()), | ||
| TestUtility::ipTestParamsToString); | ||
| INSTANTIATE_TEST_SUITE_P( | ||
| IpVersions, IntegrationTest, | ||
|
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. optional: s/IpVersions/IpVersionsAndHttp1ParserVersions/ or similar.
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. How about IpVersionsAndHttp1Parser as a compromise for brevity? |
||
| testing::Combine(testing::ValuesIn(TestEnvironment::getIpVersionsForTest()), | ||
| testing::Values(Http1ParserImpl::HttpParser, Http1ParserImpl::BalsaParser)), | ||
| testParamToString); | ||
|
|
||
| // Verify that we gracefully handle an invalid pre-bind socket option when using reuse_port. | ||
| TEST_P(IntegrationTest, BadPrebindSocketOptionWithReusePort) { | ||
|
|
@@ -131,7 +140,7 @@ TEST_P(IntegrationTest, PerWorkerStatsAndBalancing) { | |
|
|
||
| // Per-worker listener stats. | ||
| auto check_listener_stats = [this](uint64_t cx_active, uint64_t cx_total) { | ||
| if (GetParam() == Network::Address::IpVersion::v4) { | ||
| if (ip_version_ == Network::Address::IpVersion::v4) { | ||
| test_server_->waitForGaugeEq("listener.127.0.0.1_0.worker_0.downstream_cx_active", cx_active); | ||
| test_server_->waitForGaugeEq("listener.127.0.0.1_0.worker_1.downstream_cx_active", cx_active); | ||
| test_server_->waitForCounterEq("listener.127.0.0.1_0.worker_0.downstream_cx_total", cx_total); | ||
|
|
@@ -201,7 +210,7 @@ TEST_P(IntegrationTest, ConnectionBalanceFactory) { | |
| initialize(); | ||
|
|
||
| auto check_listener_stats = [this](uint64_t cx_active, uint64_t cx_total) { | ||
| if (GetParam() == Network::Address::IpVersion::v4) { | ||
| if (ip_version_ == Network::Address::IpVersion::v4) { | ||
| test_server_->waitForGaugeEq("listener.127.0.0.1_0.worker_0.downstream_cx_active", cx_active); | ||
| test_server_->waitForGaugeEq("listener.127.0.0.1_0.worker_1.downstream_cx_active", cx_active); | ||
| test_server_->waitForCounterEq("listener.127.0.0.1_0.worker_0.downstream_cx_total", cx_total); | ||
|
|
@@ -240,7 +249,7 @@ TEST_P(IntegrationTest, AllWorkersAreHandlingLoad) { | |
| initialize(); | ||
|
|
||
| std::string worker0_stat_name, worker1_stat_name; | ||
| if (GetParam() == Network::Address::IpVersion::v4) { | ||
| if (ip_version_ == Network::Address::IpVersion::v4) { | ||
| worker0_stat_name = "listener.127.0.0.1_0.worker_0.downstream_cx_total"; | ||
| worker1_stat_name = "listener.127.0.0.1_0.worker_1.downstream_cx_total"; | ||
| } else { | ||
|
|
@@ -975,6 +984,11 @@ TEST_P(IntegrationTest, TestClientAllowChunkedLength) { | |
| } | ||
|
|
||
| TEST_P(IntegrationTest, BadFirstline) { | ||
| if (http1_implementation_ == Http1ParserImpl::BalsaParser) { | ||
| // TODO(#21245): Re-enable this test for BalsaParser. | ||
| return; | ||
| } | ||
|
|
||
| initialize(); | ||
| std::string response; | ||
| sendRawHttpAndWaitForResponse(lookupPort("http"), "hello", &response); | ||
|
|
@@ -1003,6 +1017,11 @@ TEST_P(IntegrationTest, InvalidCharacterInFirstline) { | |
| } | ||
|
|
||
| TEST_P(IntegrationTest, InvalidVersion) { | ||
| if (http1_implementation_ == Http1ParserImpl::BalsaParser) { | ||
| // TODO(#21245): Re-enable this test for BalsaParser. | ||
| return; | ||
| } | ||
|
|
||
| initialize(); | ||
| std::string response; | ||
| sendRawHttpAndWaitForResponse(lookupPort("http"), "GET / HTTP/1.01\r\nHost: host\r\n\r\n", | ||
|
|
@@ -1012,6 +1031,11 @@ TEST_P(IntegrationTest, InvalidVersion) { | |
|
|
||
| // Expect that malformed trailers to break the connection | ||
| TEST_P(IntegrationTest, BadTrailer) { | ||
| if (http1_implementation_ == Http1ParserImpl::BalsaParser) { | ||
| // TODO(#21245): Re-enable this test for BalsaParser. | ||
| return; | ||
| } | ||
|
|
||
| initialize(); | ||
| std::string response; | ||
| sendRawHttpAndWaitForResponse(lookupPort("http"), | ||
|
|
@@ -1028,6 +1052,11 @@ TEST_P(IntegrationTest, BadTrailer) { | |
|
|
||
| // Expect malformed headers to break the connection | ||
| TEST_P(IntegrationTest, BadHeader) { | ||
| if (http1_implementation_ == Http1ParserImpl::BalsaParser) { | ||
| // TODO(#21245): Re-enable this test for BalsaParser. | ||
| return; | ||
| } | ||
|
|
||
| initialize(); | ||
| std::string response; | ||
| sendRawHttpAndWaitForResponse(lookupPort("http"), | ||
|
|
@@ -1093,6 +1122,11 @@ TEST_P(IntegrationTest, Http09Enabled) { | |
| } | ||
|
|
||
| TEST_P(IntegrationTest, Http09WithKeepalive) { | ||
| if (http1_implementation_ == Http1ParserImpl::BalsaParser) { | ||
| // TODO(#21245): Re-enable this test for BalsaParser. | ||
| return; | ||
| } | ||
|
|
||
| #ifdef ENVOY_ENABLE_UHV | ||
| // TODO(#23287) - Determine HTTP/0.9 and HTTP/1.0 support within UHV | ||
| return; | ||
|
|
@@ -1440,7 +1474,7 @@ TEST_P(IntegrationTest, AbsolutePathUsingHttpsAllowedInternally) { | |
| TEST_P(IntegrationTest, TestHostWithAddress) { | ||
| useAccessLog("%REQ(Host)%"); | ||
| std::string address_string; | ||
| if (GetParam() == Network::Address::IpVersion::v4) { | ||
| if (ip_version_ == Network::Address::IpVersion::v4) { | ||
| address_string = TestUtility::getIpv4Loopback(); | ||
| } else { | ||
| address_string = "[::1]"; | ||
|
|
@@ -1524,7 +1558,13 @@ TEST_P(IntegrationTest, Connect) { | |
| } | ||
|
|
||
| // Test that Envoy returns HTTP code 502 on upstream protocol error. | ||
| TEST_P(IntegrationTest, UpstreamProtocolError) { testRouterUpstreamProtocolError("502", "UPE"); } | ||
| TEST_P(IntegrationTest, UpstreamProtocolError) { | ||
| if (http1_implementation_ == Http1ParserImpl::BalsaParser) { | ||
| // TODO(#21245): Re-enable this test for BalsaParser. | ||
| return; | ||
| } | ||
| testRouterUpstreamProtocolError("502", "UPE"); | ||
| } | ||
|
|
||
| TEST_P(IntegrationTest, TestHead) { | ||
| initialize(); | ||
|
|
@@ -1588,7 +1628,7 @@ TEST_P(IntegrationTest, TestHeadWithExplicitTE) { | |
|
|
||
| TEST_P(IntegrationTest, TestBind) { | ||
| std::string address_string; | ||
| if (GetParam() == Network::Address::IpVersion::v4) { | ||
| if (ip_version_ == Network::Address::IpVersion::v4) { | ||
| address_string = TestUtility::getIpv4Loopback(); | ||
| } else { | ||
| address_string = "::1"; | ||
|
|
@@ -1843,14 +1883,16 @@ TEST_P(IntegrationTest, TrailersDroppedDownstream) { | |
| testTrailers(10, 10, false, false); | ||
| } | ||
|
|
||
| INSTANTIATE_TEST_SUITE_P(IpVersions, UpstreamEndpointIntegrationTest, | ||
| testing::ValuesIn(TestEnvironment::getIpVersionsForTest()), | ||
| TestUtility::ipTestParamsToString); | ||
| INSTANTIATE_TEST_SUITE_P( | ||
| IpVersions, UpstreamEndpointIntegrationTest, | ||
| testing::Combine(testing::ValuesIn(TestEnvironment::getIpVersionsForTest()), | ||
| testing::Values(Http1ParserImpl::HttpParser, Http1ParserImpl::BalsaParser)), | ||
| testParamToString); | ||
|
|
||
| TEST_P(UpstreamEndpointIntegrationTest, TestUpstreamEndpointAddress) { | ||
| initialize(); | ||
| EXPECT_STREQ(fake_upstreams_[0]->localAddress()->ip()->addressAsString().c_str(), | ||
| Network::Test::getLoopbackAddressString(GetParam()).c_str()); | ||
| Network::Test::getLoopbackAddressString(ip_version_).c_str()); | ||
| } | ||
|
|
||
| // Send continuous pipelined requests while not reading responses, to check | ||
|
|
@@ -2435,7 +2477,7 @@ TEST_P(IntegrationTest, SetRouteToDelegatingRouteWithClusterOverride) { | |
| initialize(); | ||
|
|
||
| const std::string ip_port_pair = | ||
| absl::StrCat(Network::Test::getLoopbackAddressUrlString(GetParam()), ":", | ||
| absl::StrCat(Network::Test::getLoopbackAddressUrlString(ip_version_), ":", | ||
| fake_upstreams_[1]->localAddress()->ip()->port()); | ||
|
|
||
| Http::TestRequestHeaderMapImpl request_headers{ | ||
|
|
||
This file contains hidden or 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 |
|---|---|---|
| @@ -1,27 +1,45 @@ | ||
| #pragma once | ||
|
|
||
| #include "test/integration/http_integration.h" | ||
| #include "test/test_common/utility.h" | ||
|
|
||
| #include "gtest/gtest.h" | ||
|
|
||
| // A test class for testing HTTP/1.1 upstream and downstreams | ||
| namespace Envoy { | ||
| class IntegrationTest : public testing::TestWithParam<Network::Address::IpVersion>, | ||
| public HttpIntegrationTest { | ||
| class IntegrationTest | ||
| : public testing::TestWithParam<std::tuple<Network::Address::IpVersion, Http1ParserImpl>>, | ||
| public HttpIntegrationTest { | ||
| public: | ||
| IntegrationTest() : HttpIntegrationTest(Http::CodecType::HTTP1, GetParam()) {} | ||
| IntegrationTest() | ||
| : HttpIntegrationTest(Http::CodecType::HTTP1, std::get<0>(GetParam())), | ||
| ip_version_(std::get<0>(GetParam())), http1_implementation_(std::get<1>(GetParam())) { | ||
| setupHttp1ImplOverrides(http1_implementation_); | ||
| } | ||
|
|
||
| protected: | ||
| const Network::Address::IpVersion ip_version_; | ||
| const Http1ParserImpl http1_implementation_; | ||
| }; | ||
|
|
||
| class UpstreamEndpointIntegrationTest : public testing::TestWithParam<Network::Address::IpVersion>, | ||
| public HttpIntegrationTest { | ||
| class UpstreamEndpointIntegrationTest | ||
| : public testing::TestWithParam<std::tuple<Network::Address::IpVersion, Http1ParserImpl>>, | ||
| public HttpIntegrationTest { | ||
| public: | ||
| UpstreamEndpointIntegrationTest() | ||
| : HttpIntegrationTest( | ||
| Http::CodecType::HTTP1, | ||
| [](int) { | ||
| return Network::Utility::parseInternetAddress( | ||
| Network::Test::getLoopbackAddressString(GetParam()), 0); | ||
| Network::Test::getLoopbackAddressString(std::get<0>(GetParam())), 0); | ||
| }, | ||
| GetParam()) {} | ||
| std::get<0>(GetParam())), | ||
| ip_version_(std::get<0>(GetParam())), http1_implementation_(std::get<1>(GetParam())) { | ||
| setupHttp1ImplOverrides(http1_implementation_); | ||
| } | ||
|
|
||
| protected: | ||
| const Network::Address::IpVersion ip_version_; | ||
| const Http1ParserImpl http1_implementation_; | ||
| }; | ||
| } // namespace Envoy |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
nit: I think there's a preference here to avoid fully qualifying names with the leading "::" if possible, unless there's a using declaration or namespace alias. I like using the decision tree at internal TOTW 151 as a reference (unfortunately, there is no analogue at https://abseil.io/tips/ - the closest thing there seems to be https://abseil.io/tips/130).
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.
Good catch. I was not aware of that guidance, thank you for digging it up.
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.
On that note, also adding using directives for Combine, Values, and ValuesIn.