Skip to content

Commit

Permalink
test: restoring prior behavior for http2 flood tests (#11319)
Browse files Browse the repository at this point in the history
Signed-off-by: Alyssa Wilk <[email protected]>
  • Loading branch information
alyssawilk authored May 26, 2020
1 parent c8c7d1a commit f61b096
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
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

0 comments on commit f61b096

Please sign in to comment.