From 179cff6404bf8e4c67f7f2f10d6365f272dcca36 Mon Sep 17 00:00:00 2001 From: Matt Klein Date: Sun, 11 Sep 2016 18:37:10 -0700 Subject: [PATCH] sds: add 1s timeout for refresh calls --- source/common/upstream/sds.cc | 3 ++- test/common/upstream/sds_test.cc | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/source/common/upstream/sds.cc b/source/common/upstream/sds.cc index 48bf721ebf82..ba4dd83d017d 100644 --- a/source/common/upstream/sds.cc +++ b/source/common/upstream/sds.cc @@ -109,7 +109,8 @@ void SdsClusterImpl::refreshHosts() { "/v1/registration/" + service_name_); message->headers().addViaMoveValue(Http::Headers::get().Host, "sds"); active_request_ = cm_.httpAsyncClientForCluster(sds_config_.sds_cluster_name_) - .send(std::move(message), *this, Optional()); + .send(std::move(message), *this, + Optional(std::chrono::milliseconds(1000))); } void SdsClusterImpl::requestComplete() { diff --git a/test/common/upstream/sds_test.cc b/test/common/upstream/sds_test.cc index 8e16e3fb42d1..59a10ccd6b17 100644 --- a/test/common/upstream/sds_test.cc +++ b/test/common/upstream/sds_test.cc @@ -62,7 +62,8 @@ class SdsTest : public testing::Test { void setupPoolFailure() { EXPECT_CALL(cm_, httpAsyncClientForCluster("sds")).WillOnce(ReturnRef(cm_.async_client_)); - EXPECT_CALL(cm_.async_client_, send_(_, _, _)) + EXPECT_CALL(cm_.async_client_, + send_(_, _, Optional(std::chrono::milliseconds(1000)))) .WillOnce(Invoke([](Http::MessagePtr&, Http::AsyncClient::Callbacks& callbacks, Optional) -> Http::AsyncClient::Request* { callbacks.onFailure(Http::AsyncClient::FailureReason::Reset); @@ -72,7 +73,8 @@ class SdsTest : public testing::Test { void setupRequest() { EXPECT_CALL(cm_, httpAsyncClientForCluster("sds")).WillOnce(ReturnRef(cm_.async_client_)); - EXPECT_CALL(cm_.async_client_, send_(_, _, _)) + EXPECT_CALL(cm_.async_client_, + send_(_, _, Optional(std::chrono::milliseconds(1000)))) .WillOnce(DoAll(WithArg<1>(SaveArgAddress(&callbacks_)), Return(&request_))); }