Skip to content
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

test: restoring prior behavior for http2 flood tests #11319

Merged
merged 1 commit into from
May 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions test/integration/http2_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1563,6 +1563,8 @@ void Http2FloodMitigationTest::floodServer(const Http2Frame& frame, const std::s

EXPECT_LE(total_bytes_sent, TransmitThreshold) << "Flood mitigation is broken.";
EXPECT_EQ(1, test_server_->counter(flood_stat)->value());
EXPECT_EQ(1,
test_server_->counter("http.config_test.downstream_cx_delayed_close_timeout")->value());
}

// Verify that the server detects the flood using specified request parameters.
Expand All @@ -1586,6 +1588,8 @@ void Http2FloodMitigationTest::floodServer(absl::string_view host, absl::string_
if (!flood_stat.empty()) {
EXPECT_EQ(1, test_server_->counter(flood_stat)->value());
}
EXPECT_EQ(1,
test_server_->counter("http.config_test.downstream_cx_delayed_close_timeout")->value());
}

INSTANTIATE_TEST_SUITE_P(IpVersions, Http2FloodMitigationTest,
Expand Down Expand Up @@ -1653,6 +1657,8 @@ TEST_P(Http2FloodMitigationTest, RST_STREAM) {
}
EXPECT_LE(total_bytes_sent, TransmitThreshold) << "Flood mitigation is broken.";
EXPECT_EQ(1, test_server_->counter("http2.outbound_control_flood")->value());
EXPECT_EQ(1,
test_server_->counter("http.config_test.downstream_cx_delayed_close_timeout")->value());
}

// Verify that the server stop reading downstream connection on protocol error.
Expand Down Expand Up @@ -1688,6 +1694,8 @@ TEST_P(Http2FloodMitigationTest, EmptyHeaders) {
tcp_client_->waitForDisconnect();

EXPECT_EQ(1, test_server_->counter("http2.inbound_empty_frames_flood")->value());
EXPECT_EQ(1,
test_server_->counter("http.config_test.downstream_cx_delayed_close_timeout")->value());
}

TEST_P(Http2FloodMitigationTest, EmptyHeadersContinuation) {
Expand All @@ -1705,6 +1713,8 @@ TEST_P(Http2FloodMitigationTest, EmptyHeadersContinuation) {
tcp_client_->waitForDisconnect();

EXPECT_EQ(1, test_server_->counter("http2.inbound_empty_frames_flood")->value());
EXPECT_EQ(1,
test_server_->counter("http.config_test.downstream_cx_delayed_close_timeout")->value());
}

TEST_P(Http2FloodMitigationTest, EmptyData) {
Expand All @@ -1723,6 +1733,8 @@ TEST_P(Http2FloodMitigationTest, EmptyData) {
tcp_client_->waitForDisconnect();

EXPECT_EQ(1, test_server_->counter("http2.inbound_empty_frames_flood")->value());
EXPECT_EQ(1,
test_server_->counter("http.config_test.downstream_cx_delayed_close_timeout")->value());
}

TEST_P(Http2FloodMitigationTest, PriorityIdleStream) {
Expand Down Expand Up @@ -1787,6 +1799,8 @@ TEST_P(Http2FloodMitigationTest, ZerolenHeader) {
tcp_client_->waitForDisconnect();

EXPECT_EQ(1, test_server_->counter("http2.rx_messaging_error")->value());
EXPECT_EQ(1,
test_server_->counter("http.config_test.downstream_cx_delayed_close_timeout")->value());
EXPECT_THAT(waitForAccessLog(access_log_name_), HasSubstr("http2.invalid.header.field"));
// expect a downstream protocol error.
EXPECT_THAT(waitForAccessLog(access_log_name_), HasSubstr("DPE"));
Expand Down Expand Up @@ -1823,6 +1837,8 @@ TEST_P(Http2FloodMitigationTest, ZerolenHeaderAllowed) {
tcp_client_->close();

EXPECT_EQ(1, test_server_->counter("http2.rx_messaging_error")->value());
EXPECT_EQ(0,
test_server_->counter("http.config_test.downstream_cx_delayed_close_timeout")->value());
EXPECT_THAT(waitForAccessLog(access_log_name_), HasSubstr("http2.invalid.header.field"));
// expect Downstream Protocol Error
EXPECT_THAT(waitForAccessLog(access_log_name_), HasSubstr("DPE"));
Expand Down
6 changes: 5 additions & 1 deletion test/integration/http2_integration_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ class Http2MetadataIntegrationTest : public Http2IntegrationTest {
class Http2FloodMitigationTest : public testing::TestWithParam<Network::Address::IpVersion>,
public HttpIntegrationTest {
public:
Http2FloodMitigationTest() : HttpIntegrationTest(Http::CodecClient::Type::HTTP2, GetParam()) {}
Http2FloodMitigationTest() : HttpIntegrationTest(Http::CodecClient::Type::HTTP2, GetParam()) {
config_helper_.addConfigModifier(
[](envoy::extensions::filters::network::http_connection_manager::v3::HttpConnectionManager&
hcm) { hcm.mutable_delayed_close_timeout()->set_seconds(1); });
}

protected:
void startHttp2Session();
Expand Down