diff --git a/library/common/config/config.cc b/library/common/config/config.cc index 58748c8e6d..6ba541dc7b 100644 --- a/library/common/config/config.cc +++ b/library/common/config/config.cc @@ -480,7 +480,6 @@ stats_sinks: *stats_sinks envoy: reloadable_features: allow_multiple_dns_addresses: *dns_multiple_addresses - override_request_timeout_by_gateway_timeout: false http2_delay_keepalive_timeout: *h2_delay_keepalive_timeout )" // Needed due to warning in diff --git a/test/common/integration/client_integration_test.cc b/test/common/integration/client_integration_test.cc index 76ef6693c4..d063f30073 100644 --- a/test/common/integration/client_integration_test.cc +++ b/test/common/integration/client_integration_test.cc @@ -156,6 +156,9 @@ class ClientIntegrationTest : public BaseIntegrationTest, } void TearDown() override { + // Right now each test does one request - if this changes, make the 1 + // configurable. + ASSERT_EQ(cc_.on_complete_calls + cc_.on_cancel_calls + cc_.on_error_calls, 1); test_server_.reset(); fake_upstreams_.clear(); } @@ -466,7 +469,7 @@ TEST_P(ClientIntegrationTest, CaseSensitive) { test_server_->waitForCounterEq("http.client.stream_success", 1); } -TEST_P(ClientIntegrationTest, Timeout) { +TEST_P(ClientIntegrationTest, TimeoutOnRequestPath) { config_helper_.addConfigModifier([](envoy::config::bootstrap::v3::Bootstrap& bootstrap) { auto* listener = bootstrap.mutable_static_resources()->mutable_listeners(0); auto* em_hcm = listener->mutable_api_listener()->mutable_api_listener(); @@ -501,6 +504,52 @@ TEST_P(ClientIntegrationTest, Timeout) { Envoy::FakeRawConnectionPtr upstream_connection; ASSERT_TRUE(fake_upstreams_[0]->waitForRawConnection(upstream_connection)); + std::string upstream_request; + EXPECT_TRUE(upstream_connection->waitForData(FakeRawConnection::waitForInexactMatch("GET /"), + &upstream_request)); + terminal_callback_.waitReady(); + + ASSERT_EQ(cc_.on_headers_calls, 0); + ASSERT_EQ(cc_.on_data_calls, 0); + ASSERT_EQ(cc_.on_complete_calls, 0); + ASSERT_EQ(cc_.on_error_calls, 1); +} + +TEST_P(ClientIntegrationTest, TimeoutOnResponsePath) { + config_helper_.addConfigModifier([](envoy::config::bootstrap::v3::Bootstrap& bootstrap) { + auto* listener = bootstrap.mutable_static_resources()->mutable_listeners(0); + auto* em_hcm = listener->mutable_api_listener()->mutable_api_listener(); + auto hcm = + MessageUtil::anyConvert(*em_hcm); + hcm.mutable_config()->mutable_stream_idle_timeout()->set_seconds(1); + em_hcm->PackFrom(hcm); + }); + + autonomous_upstream_ = false; + initialize(); + + bridge_callbacks_.on_headers = [](envoy_headers c_headers, bool, envoy_stream_intel, + void* context) -> void* { + Http::ResponseHeaderMapPtr response_headers = toResponseHeaders(c_headers); + callbacks_called* cc_ = static_cast(context); + cc_->on_headers_calls++; + cc_->status = response_headers->Status()->value().getStringView(); + return nullptr; + }; + + // Build a set of request headers. + envoy_headers c_headers = Http::Utility::toBridgeHeaders(default_request_headers_); + + // Create a stream. + dispatcher_->post([&]() -> void { + http_client_->startStream(stream_, bridge_callbacks_, false); + http_client_->sendHeaders(stream_, c_headers, true); + }); + + Envoy::FakeRawConnectionPtr upstream_connection; + ASSERT_TRUE(fake_upstreams_[0]->waitForRawConnection(upstream_connection)); + std::string upstream_request; EXPECT_TRUE(upstream_connection->waitForData(FakeRawConnection::waitForInexactMatch("GET /"), &upstream_request));