Skip to content

Commit

Permalink
Fix flaky http2 integration tests (envoyproxy#29)
Browse files Browse the repository at this point in the history
Signed-off-by: Yan Avlasov <yavlasov@google.com>
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
  • Loading branch information
yanavlasov authored and PiotrSikora committed Aug 2, 2019
1 parent 4ff1081 commit 1c4e958
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/integration/http2_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1048,6 +1048,21 @@ namespace {
const int64_t TransmitThreshold = 100 * 1024 * 1024;
} // namespace

void Http2FloodMitigationTest::setNetworkConnectionBufferSize() {
// nghttp2 library has its own internal mitigation for outbound control frames. The mitigation is
// trigerred when there are more than 10000 PING or SETTINGS frames with ACK flag in the nghttp2
// internal outbound queue. It is possible to trigger this mitigation in nghttp2 before triggering
// Envoy's own flood mitigation. This can happen when a buffer larger enough to contain over 10K
// PING or SETTINGS frames is dispatched to the nghttp2 library. To prevent this from happening
// the network connection receive buffer needs to be smaller than 90Kb (which is 10K SETTINGS
// frames). Set it to the arbitrarily chosen value of 32K.
config_helper_.addConfigModifier([](envoy::config::bootstrap::v2::Bootstrap& bootstrap) -> void {
RELEASE_ASSERT(bootstrap.mutable_static_resources()->listeners_size() >= 1, "");
auto* listener = bootstrap.mutable_static_resources()->mutable_listeners(0);
listener->mutable_per_connection_buffer_limit_bytes()->set_value(32 * 1024);
});
}

void Http2FloodMitigationTest::beginSession() {
setDownstreamProtocol(Http::CodecClient::Type::HTTP2);
setUpstreamProtocol(FakeHttpConnection::Type::HTTP2);
Expand Down Expand Up @@ -1152,11 +1167,13 @@ INSTANTIATE_TEST_SUITE_P(IpVersions, Http2FloodMitigationTest,
TestUtility::ipTestParamsToString);

TEST_P(Http2FloodMitigationTest, Ping) {
setNetworkConnectionBufferSize();
beginSession();
floodServer(Http2Frame::makePingFrame(), "http2.outbound_control_flood");
}

TEST_P(Http2FloodMitigationTest, Settings) {
setNetworkConnectionBufferSize();
beginSession();
floodServer(Http2Frame::makeEmptySettingsFrame(), "http2.outbound_control_flood");
}
Expand Down
1 change: 1 addition & 0 deletions test/integration/http2_integration_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class Http2FloodMitigationTest : public testing::TestWithParam<Network::Address:
Http2Frame::ResponseStatus expected_http_status, const std::string& flood_stat);
Http2Frame readFrame();
void sendFame(const Http2Frame& frame);
void setNetworkConnectionBufferSize();
void beginSession();

IntegrationTcpClientPtr tcp_client_;
Expand Down

0 comments on commit 1c4e958

Please sign in to comment.