From 19c6422944f375c16c0d75bdd2b3ca3caf208adb Mon Sep 17 00:00:00 2001 From: Alyssa Wilk Date: Tue, 20 Aug 2019 14:30:38 -0400 Subject: [PATCH] adding the capability of creating an alarm with a given scope Signed-off-by: Alyssa Wilk --- include/envoy/event/timer.h | 13 +- source/common/event/BUILD | 1 + source/common/event/dispatcher_impl.cc | 2 +- source/common/event/libevent_scheduler.cc | 4 +- source/common/event/libevent_scheduler.h | 2 +- source/common/event/real_time_system.cc | 4 +- source/common/event/timer_impl.cc | 18 +- source/common/event/timer_impl.h | 7 +- .../access_log_manager_impl_test.cc | 8 +- .../config/delta_subscription_test_harness.h | 2 +- test/common/config/grpc_mux_impl_test.cc | 7 +- .../config/grpc_subscription_impl_test.cc | 4 +- .../config/grpc_subscription_test_harness.h | 2 +- .../config/http_subscription_impl_test.cc | 4 +- .../config/http_subscription_test_harness.h | 4 +- test/common/http/async_client_impl_test.cc | 10 +- test/common/http/conn_manager_impl_test.cc | 72 +-- test/common/http/date_provider_impl_test.cc | 4 +- test/common/http/http1/conn_pool_test.cc | 4 +- test/common/http/http2/conn_pool_test.cc | 2 +- test/common/network/connection_impl_test.cc | 10 +- test/common/network/dns_impl_test.cc | 2 +- test/common/router/retry_state_impl_test.cc | 28 +- test/common/router/router_test.cc | 8 +- .../common/router/router_upstream_log_test.cc | 4 +- test/common/tcp/conn_pool_test.cc | 8 +- test/common/tcp_proxy/tcp_proxy_test.cc | 30 +- test/common/upstream/eds_test.cc | 8 +- test/common/upstream/hds_test.cc | 16 +- .../upstream/health_checker_impl_test.cc | 479 +++++++++--------- .../upstream/load_stats_reporter_test.cc | 18 +- .../upstream/logical_dns_cluster_test.cc | 10 +- .../upstream/original_dst_cluster_test.cc | 24 +- .../upstream/outlier_detection_impl_test.cc | 88 ++-- test/common/upstream/upstream_impl_test.cc | 52 +- .../grpc/grpc_access_log_impl_test.cc | 8 +- .../clusters/redis/redis_cluster_test.cc | 8 +- .../dns_cache_impl_test.cc | 24 +- .../filters/http/fault/fault_filter_test.cc | 16 +- .../http/health_check/health_check_test.cc | 6 +- .../filters/http/squash/squash_filter_test.cc | 17 +- .../client_ssl_auth/client_ssl_auth_test.cc | 10 +- .../network/common/redis/client_impl_test.cc | 24 +- .../filters/network/mongo_proxy/proxy_test.cc | 8 +- .../health_checkers/redis/redis_test.cc | 40 +- .../datadog/datadog_tracer_impl_test.cc | 4 +- .../lightstep/lightstep_tracer_impl_test.cc | 4 +- .../tracers/zipkin/zipkin_tracer_impl_test.cc | 4 +- test/mocks/event/mocks.cc | 7 +- test/mocks/event/mocks.h | 13 +- test/server/connection_handler_test.cc | 6 +- test/server/drain_manager_impl_test.cc | 6 +- test/test_common/BUILD | 1 + test/test_common/simulated_time_system.cc | 24 +- .../test_common/simulated_time_system_test.cc | 40 +- 55 files changed, 651 insertions(+), 578 deletions(-) diff --git a/include/envoy/event/timer.h b/include/envoy/event/timer.h index 3a6771904cd7..c2255e8dece9 100644 --- a/include/envoy/event/timer.h +++ b/include/envoy/event/timer.h @@ -8,8 +8,13 @@ #include "envoy/common/time.h" namespace Envoy { + +class ScopeTrackedObject; + namespace Event { +class Dispatcher; + /** * Callback invoked when a timer event fires. */ @@ -30,8 +35,12 @@ class Timer { /** * Enable a pending timeout. If a timeout is already pending, it will be reset to the new timeout. + * + * @param ms supplies the duration of the alarm in milliseconds. + * @param object supplies an optional scope for the duration of the alarm. */ - virtual void enableTimer(const std::chrono::milliseconds& d) PURE; + virtual void enableTimer(const std::chrono::milliseconds& ms, + const ScopeTrackedObject* object = nullptr) PURE; /** * Return whether the timer is currently armed. @@ -48,7 +57,7 @@ class Scheduler { /** * Creates a timer. */ - virtual TimerPtr createTimer(const TimerCb& cb) PURE; + virtual TimerPtr createTimer(const TimerCb& cb, Dispatcher& dispatcher) PURE; }; using SchedulerPtr = std::unique_ptr; diff --git a/source/common/event/BUILD b/source/common/event/BUILD index 78461dcd3181..76c0dc627cc2 100644 --- a/source/common/event/BUILD +++ b/source/common/event/BUILD @@ -120,6 +120,7 @@ envoy_cc_library( ":event_impl_base_lib", ":libevent_lib", "//include/envoy/event:timer_interface", + "//source/common/common:scope_tracker", ], ) diff --git a/source/common/event/dispatcher_impl.cc b/source/common/event/dispatcher_impl.cc index 7b718b8daf57..28fc0f6b8312 100644 --- a/source/common/event/dispatcher_impl.cc +++ b/source/common/event/dispatcher_impl.cc @@ -149,7 +149,7 @@ TimerPtr DispatcherImpl::createTimer(TimerCb cb) { return createTimerInternal(cb TimerPtr DispatcherImpl::createTimerInternal(TimerCb cb) { ASSERT(isThreadSafe()); - return scheduler_->createTimer(cb); + return scheduler_->createTimer(cb, *this); } void DispatcherImpl::deferredDelete(DeferredDeletablePtr&& to_delete) { diff --git a/source/common/event/libevent_scheduler.cc b/source/common/event/libevent_scheduler.cc index df22b45ba737..dcdca25c69a1 100644 --- a/source/common/event/libevent_scheduler.cc +++ b/source/common/event/libevent_scheduler.cc @@ -19,8 +19,8 @@ LibeventScheduler::LibeventScheduler() : libevent_(event_base_new()) { RELEASE_ASSERT(Libevent::Global::initialized(), ""); } -TimerPtr LibeventScheduler::createTimer(const TimerCb& cb) { - return std::make_unique(libevent_, cb); +TimerPtr LibeventScheduler::createTimer(const TimerCb& cb, Dispatcher& dispatcher) { + return std::make_unique(libevent_, cb, dispatcher); }; void LibeventScheduler::run(Dispatcher::RunType mode) { diff --git a/source/common/event/libevent_scheduler.h b/source/common/event/libevent_scheduler.h index b9157bf4059b..7694a69ea8d3 100644 --- a/source/common/event/libevent_scheduler.h +++ b/source/common/event/libevent_scheduler.h @@ -17,7 +17,7 @@ class LibeventScheduler : public Scheduler { LibeventScheduler(); // Scheduler - TimerPtr createTimer(const TimerCb& cb) override; + TimerPtr createTimer(const TimerCb& cb, Dispatcher& dispatcher) override; /** * Runs the event loop. diff --git a/source/common/event/real_time_system.cc b/source/common/event/real_time_system.cc index 9621611c2df0..c528b58b4e8c 100644 --- a/source/common/event/real_time_system.cc +++ b/source/common/event/real_time_system.cc @@ -12,7 +12,9 @@ namespace { class RealScheduler : public Scheduler { public: RealScheduler(Scheduler& base_scheduler) : base_scheduler_(base_scheduler) {} - TimerPtr createTimer(const TimerCb& cb) override { return base_scheduler_.createTimer(cb); }; + TimerPtr createTimer(const TimerCb& cb, Dispatcher& d) override { + return base_scheduler_.createTimer(cb, d); + }; private: Scheduler& base_scheduler_; diff --git a/source/common/event/timer_impl.cc b/source/common/event/timer_impl.cc index 4725e2018c39..ba9ea231c57b 100644 --- a/source/common/event/timer_impl.cc +++ b/source/common/event/timer_impl.cc @@ -17,16 +17,28 @@ void TimerUtils::millisecondsToTimeval(const std::chrono::milliseconds& d, timev tv.tv_usec = usecs.count(); } -TimerImpl::TimerImpl(Libevent::BasePtr& libevent, TimerCb cb) : cb_(cb) { +TimerImpl::TimerImpl(Libevent::BasePtr& libevent, TimerCb cb, Dispatcher& dispatcher) + : cb_(cb), dispatcher_(dispatcher) { ASSERT(cb_); evtimer_assign( &raw_event_, libevent.get(), - [](evutil_socket_t, short, void* arg) -> void { static_cast(arg)->cb_(); }, this); + [](evutil_socket_t, short, void* arg) -> void { + TimerImpl* timer = static_cast(arg); + if (timer->object_ == nullptr) { + timer->cb_(); + return; + } + ScopeTrackerScopeState scope(timer->object_, timer->dispatcher_); + timer->object_ = nullptr; + timer->cb_(); + }, + this); } void TimerImpl::disableTimer() { event_del(&raw_event_); } -void TimerImpl::enableTimer(const std::chrono::milliseconds& d) { +void TimerImpl::enableTimer(const std::chrono::milliseconds& d, const ScopeTrackedObject* object) { + object_ = object; if (d.count() == 0) { event_active(&raw_event_, EV_TIMEOUT, 0); } else { diff --git a/source/common/event/timer_impl.h b/source/common/event/timer_impl.h index 206525ec1e44..bb18851bc021 100644 --- a/source/common/event/timer_impl.h +++ b/source/common/event/timer_impl.h @@ -4,6 +4,7 @@ #include "envoy/event/timer.h" +#include "common/common/scope_tracker.h" #include "common/event/event_impl_base.h" #include "common/event/libevent.h" @@ -23,15 +24,17 @@ class TimerUtils { */ class TimerImpl : public Timer, ImplBase { public: - TimerImpl(Libevent::BasePtr& libevent, TimerCb cb); + TimerImpl(Libevent::BasePtr& libevent, TimerCb cb, Event::Dispatcher& dispatcher); // Timer void disableTimer() override; - void enableTimer(const std::chrono::milliseconds& d) override; + void enableTimer(const std::chrono::milliseconds& d, const ScopeTrackedObject* scope) override; bool enabled() override; private: TimerCb cb_; + Dispatcher& dispatcher_; + const ScopeTrackedObject* object_{}; }; } // namespace Event diff --git a/test/common/access_log/access_log_manager_impl_test.cc b/test/common/access_log/access_log_manager_impl_test.cc index 151ac7544b47..e7bf863df009 100644 --- a/test/common/access_log/access_log_manager_impl_test.cc +++ b/test/common/access_log/access_log_manager_impl_test.cc @@ -59,7 +59,7 @@ TEST_F(AccessLogManagerImplTest, flushToLogFilePeriodically) { EXPECT_CALL(*file_, open_()).WillOnce(Return(ByMove(Filesystem::resultSuccess(true)))); AccessLogFileSharedPtr log_file = access_log_manager_.createAccessLog("foo"); - EXPECT_CALL(*timer, enableTimer(timeout_40ms_)); + EXPECT_CALL(*timer, enableTimer(timeout_40ms_, _)); EXPECT_CALL(*file_, write_(_)) .WillOnce(Invoke([](absl::string_view data) -> Api::IoCallSizeResult { EXPECT_EQ(0, data.compare("test")); @@ -83,7 +83,7 @@ TEST_F(AccessLogManagerImplTest, flushToLogFilePeriodically) { // make sure timer is re-enabled on callback call log_file->write("test2"); - EXPECT_CALL(*timer, enableTimer(timeout_40ms_)); + EXPECT_CALL(*timer, enableTimer(timeout_40ms_, _)); timer->invokeCallback(); { @@ -101,7 +101,7 @@ TEST_F(AccessLogManagerImplTest, flushToLogFileOnDemand) { EXPECT_CALL(*file_, open_()).WillOnce(Return(ByMove(Filesystem::resultSuccess(true)))); AccessLogFileSharedPtr log_file = access_log_manager_.createAccessLog("foo"); - EXPECT_CALL(*timer, enableTimer(timeout_40ms_)); + EXPECT_CALL(*timer, enableTimer(timeout_40ms_, _)); // The first write to a given file will start the flush thread, which can flush // immediately (race on whether it will or not). So do a write and flush to @@ -146,7 +146,7 @@ TEST_F(AccessLogManagerImplTest, flushToLogFileOnDemand) { // make sure timer is re-enabled on callback call log_file->write("test2"); - EXPECT_CALL(*timer, enableTimer(timeout_40ms_)); + EXPECT_CALL(*timer, enableTimer(timeout_40ms_, _)); timer->invokeCallback(); expected_writes++; diff --git a/test/common/config/delta_subscription_test_harness.h b/test/common/config/delta_subscription_test_harness.h index cae4cebbf298..4414aa77489c 100644 --- a/test/common/config/delta_subscription_test_harness.h +++ b/test/common/config/delta_subscription_test_harness.h @@ -157,7 +157,7 @@ class DeltaSubscriptionTestHarness : public SubscriptionTestHarness { void expectEnableInitFetchTimeoutTimer(std::chrono::milliseconds timeout) override { init_timeout_timer_ = new Event::MockTimer(&dispatcher_); - EXPECT_CALL(*init_timeout_timer_, enableTimer(std::chrono::milliseconds(timeout))); + EXPECT_CALL(*init_timeout_timer_, enableTimer(std::chrono::milliseconds(timeout), _)); } void expectDisableInitFetchTimeoutTimer() override { diff --git a/test/common/config/grpc_mux_impl_test.cc b/test/common/config/grpc_mux_impl_test.cc index 72b556277a62..c2493c0934f5 100644 --- a/test/common/config/grpc_mux_impl_test.cc +++ b/test/common/config/grpc_mux_impl_test.cc @@ -154,7 +154,7 @@ TEST_F(GrpcMuxImplTest, ResetStream) { .Times(3); EXPECT_CALL(random_, random()); ASSERT_TRUE(timer != nullptr); // initialized from dispatcher mock. - EXPECT_CALL(*timer, enableTimer(_)); + EXPECT_CALL(*timer, enableTimer(_, _)); grpc_mux_->grpcStreamForTest().onRemoteClose(Grpc::Status::GrpcStatus::Canceled, ""); EXPECT_EQ(0, control_plane_connected_state_.value()); EXPECT_CALL(*async_client_, startRaw(_, _, _)).WillOnce(Return(&async_stream_)); @@ -481,7 +481,7 @@ TEST_F(GrpcMuxImplTestWithMockTimeSystem, TooManyRequestsWithEmptyRateLimitSetti grpc_mux_->start(); // Validate that drain_request_timer is enabled when there are no tokens. - EXPECT_CALL(*drain_request_timer, enableTimer(std::chrono::milliseconds(100))); + EXPECT_CALL(*drain_request_timer, enableTimer(std::chrono::milliseconds(100), _)); onReceiveMessage(99); EXPECT_EQ(1, stats_.counter("control_plane.rate_limit_enforced").value()); EXPECT_EQ( @@ -541,7 +541,8 @@ TEST_F(GrpcMuxImplTest, TooManyRequestsWithCustomRateLimitSettings) { EXPECT_EQ(0, stats_.counter("control_plane.rate_limit_enforced").value()); // Validate that drain_request_timer is enabled when there are no tokens. - EXPECT_CALL(*drain_request_timer, enableTimer(std::chrono::milliseconds(500))).Times(AtLeast(1)); + EXPECT_CALL(*drain_request_timer, enableTimer(std::chrono::milliseconds(500), _)) + .Times(AtLeast(1)); onReceiveMessage(160); EXPECT_EQ(12, stats_.counter("control_plane.rate_limit_enforced").value()); Stats::Gauge& pending_requests = diff --git a/test/common/config/grpc_subscription_impl_test.cc b/test/common/config/grpc_subscription_impl_test.cc index ea773b24f1f8..7a1ca435985d 100644 --- a/test/common/config/grpc_subscription_impl_test.cc +++ b/test/common/config/grpc_subscription_impl_test.cc @@ -18,7 +18,7 @@ TEST_F(GrpcSubscriptionImplTest, StreamCreationFailure) { EXPECT_CALL(callbacks_, onConfigUpdateFailed(Envoy::Config::ConfigUpdateFailureReason::ConnectionFailure, _)); EXPECT_CALL(random_, random()); - EXPECT_CALL(*timer_, enableTimer(_)); + EXPECT_CALL(*timer_, enableTimer(_, _)); subscription_->start({"cluster0", "cluster1"}); EXPECT_TRUE(statsAre(2, 0, 0, 1, 0, 0)); // Ensure this doesn't cause an issue by sending a request, since we don't @@ -40,7 +40,7 @@ TEST_F(GrpcSubscriptionImplTest, RemoteStreamClose) { EXPECT_TRUE(statsAre(1, 0, 0, 0, 0, 0)); EXPECT_CALL(callbacks_, onConfigUpdateFailed(Envoy::Config::ConfigUpdateFailureReason::ConnectionFailure, _)); - EXPECT_CALL(*timer_, enableTimer(_)); + EXPECT_CALL(*timer_, enableTimer(_, _)); EXPECT_CALL(random_, random()); subscription_->grpcMux().grpcStreamForTest().onRemoteClose(Grpc::Status::GrpcStatus::Canceled, ""); diff --git a/test/common/config/grpc_subscription_test_harness.h b/test/common/config/grpc_subscription_test_harness.h index 3031c2e947ef..9e68838ee646 100644 --- a/test/common/config/grpc_subscription_test_harness.h +++ b/test/common/config/grpc_subscription_test_harness.h @@ -142,7 +142,7 @@ class GrpcSubscriptionTestHarness : public SubscriptionTestHarness { void expectEnableInitFetchTimeoutTimer(std::chrono::milliseconds timeout) override { init_timeout_timer_ = new Event::MockTimer(&dispatcher_); - EXPECT_CALL(*init_timeout_timer_, enableTimer(std::chrono::milliseconds(timeout))); + EXPECT_CALL(*init_timeout_timer_, enableTimer(std::chrono::milliseconds(timeout), _)); } void expectDisableInitFetchTimeoutTimer() override { diff --git a/test/common/config/http_subscription_impl_test.cc b/test/common/config/http_subscription_impl_test.cc index 258357452c12..afd592c0220e 100644 --- a/test/common/config/http_subscription_impl_test.cc +++ b/test/common/config/http_subscription_impl_test.cc @@ -14,7 +14,7 @@ class HttpSubscriptionImplTest : public testing::Test, public HttpSubscriptionTe TEST_F(HttpSubscriptionImplTest, OnRequestReset) { startSubscription({"cluster0", "cluster1"}); EXPECT_CALL(random_gen_, random()).WillOnce(Return(0)); - EXPECT_CALL(*timer_, enableTimer(_)); + EXPECT_CALL(*timer_, enableTimer(_, _)); EXPECT_CALL(callbacks_, onConfigUpdateFailed(Envoy::Config::ConfigUpdateFailureReason::ConnectionFailure, _)); http_callbacks_->onFailure(Http::AsyncClient::FailureReason::Reset); @@ -32,7 +32,7 @@ TEST_F(HttpSubscriptionImplTest, BadJsonRecovery) { Http::MessagePtr message{new Http::ResponseMessageImpl(std::move(response_headers))}; message->body() = std::make_unique(";!@#badjso n"); EXPECT_CALL(random_gen_, random()).WillOnce(Return(0)); - EXPECT_CALL(*timer_, enableTimer(_)); + EXPECT_CALL(*timer_, enableTimer(_, _)); EXPECT_CALL(callbacks_, onConfigUpdateFailed(Envoy::Config::ConfigUpdateFailureReason::ConnectionFailure, _)); http_callbacks_->onSuccess(std::move(message)); diff --git a/test/common/config/http_subscription_test_harness.h b/test/common/config/http_subscription_test_harness.h index 95d1123be5b5..1d41ee38019c 100644 --- a/test/common/config/http_subscription_test_harness.h +++ b/test/common/config/http_subscription_test_harness.h @@ -144,7 +144,7 @@ class HttpSubscriptionTestHarness : public SubscriptionTestHarness { Envoy::Config::ConfigUpdateFailureReason::UpdateRejected, _)); } EXPECT_CALL(random_gen_, random()).WillOnce(Return(0)); - EXPECT_CALL(*timer_, enableTimer(_)); + EXPECT_CALL(*timer_, enableTimer(_, _)); http_callbacks_->onSuccess(std::move(message)); if (accept) { version_ = version; @@ -159,7 +159,7 @@ class HttpSubscriptionTestHarness : public SubscriptionTestHarness { void expectEnableInitFetchTimeoutTimer(std::chrono::milliseconds timeout) override { init_timeout_timer_ = new Event::MockTimer(&dispatcher_); - EXPECT_CALL(*init_timeout_timer_, enableTimer(std::chrono::milliseconds(timeout))); + EXPECT_CALL(*init_timeout_timer_, enableTimer(std::chrono::milliseconds(timeout), _)); } void expectDisableInitFetchTimeoutTimer() override { diff --git a/test/common/http/async_client_impl_test.cc b/test/common/http/async_client_impl_test.cc index ae5b7cdbb6fb..29985046fa7f 100644 --- a/test/common/http/async_client_impl_test.cc +++ b/test/common/http/async_client_impl_test.cc @@ -719,7 +719,7 @@ TEST_F(AsyncClientImplTest, StreamTimeout) { EXPECT_CALL(stream_encoder_, encodeHeaders(HeaderMapEqualRef(&message_->headers()), true)); timer_ = new NiceMock(&dispatcher_); - EXPECT_CALL(*timer_, enableTimer(std::chrono::milliseconds(40))); + EXPECT_CALL(*timer_, enableTimer(std::chrono::milliseconds(40), _)); EXPECT_CALL(stream_encoder_.stream_, resetStream(_)); TestHeaderMapImpl expected_timeout{ @@ -754,7 +754,7 @@ TEST_F(AsyncClientImplTest, StreamTimeoutHeadReply) { HttpTestUtility::addDefaultHeaders(message->headers(), "HEAD"); EXPECT_CALL(stream_encoder_, encodeHeaders(HeaderMapEqualRef(&message->headers()), true)); timer_ = new NiceMock(&dispatcher_); - EXPECT_CALL(*timer_, enableTimer(std::chrono::milliseconds(40))); + EXPECT_CALL(*timer_, enableTimer(std::chrono::milliseconds(40), _)); EXPECT_CALL(stream_encoder_.stream_, resetStream(_)); TestHeaderMapImpl expected_timeout{ @@ -779,7 +779,7 @@ TEST_F(AsyncClientImplTest, RequestTimeout) { EXPECT_CALL(stream_encoder_, encodeHeaders(HeaderMapEqualRef(&message_->headers()), true)); expectSuccess(504); timer_ = new NiceMock(&dispatcher_); - EXPECT_CALL(*timer_, enableTimer(std::chrono::milliseconds(40))); + EXPECT_CALL(*timer_, enableTimer(std::chrono::milliseconds(40), _)); EXPECT_CALL(stream_encoder_.stream_, resetStream(_)); client_.send(std::move(message_), callbacks_, AsyncClient::RequestOptions().setTimeout(std::chrono::milliseconds(40))); @@ -804,7 +804,7 @@ TEST_F(AsyncClientImplTest, DisableTimer) { EXPECT_CALL(stream_encoder_, encodeHeaders(HeaderMapEqualRef(&message_->headers()), true)); timer_ = new NiceMock(&dispatcher_); - EXPECT_CALL(*timer_, enableTimer(std::chrono::milliseconds(200))); + EXPECT_CALL(*timer_, enableTimer(std::chrono::milliseconds(200), _)); EXPECT_CALL(*timer_, disableTimer()); EXPECT_CALL(stream_encoder_.stream_, resetStream(_)); AsyncClient::Request* request = @@ -823,7 +823,7 @@ TEST_F(AsyncClientImplTest, DisableTimerWithStream) { EXPECT_CALL(stream_encoder_, encodeHeaders(HeaderMapEqualRef(&message_->headers()), true)); timer_ = new NiceMock(&dispatcher_); - EXPECT_CALL(*timer_, enableTimer(std::chrono::milliseconds(40))); + EXPECT_CALL(*timer_, enableTimer(std::chrono::milliseconds(40), _)); EXPECT_CALL(*timer_, disableTimer()); EXPECT_CALL(stream_encoder_.stream_, resetStream(_)); EXPECT_CALL(stream_callbacks_, onReset()); diff --git a/test/common/http/conn_manager_impl_test.cc b/test/common/http/conn_manager_impl_test.cc index 083bbbe73753..ea6f27e236a0 100644 --- a/test/common/http/conn_manager_impl_test.cc +++ b/test/common/http/conn_manager_impl_test.cc @@ -1403,12 +1403,12 @@ TEST_F(HttpConnectionManagerImplTest, PerStreamIdleTimeoutGlobal) { EXPECT_CALL(*codec_, dispatch(_)).WillRepeatedly(Invoke([&](Buffer::Instance&) -> void { Event::MockTimer* idle_timer = setUpTimer(); - EXPECT_CALL(*idle_timer, enableTimer(std::chrono::milliseconds(10))); + EXPECT_CALL(*idle_timer, enableTimer(std::chrono::milliseconds(10), _)); conn_manager_->newStream(response_encoder_); // Expect resetIdleTimer() to be called for the response // encodeHeaders()/encodeData(). - EXPECT_CALL(*idle_timer, enableTimer(_)).Times(2); + EXPECT_CALL(*idle_timer, enableTimer(_, _)).Times(2); EXPECT_CALL(*idle_timer, disableTimer()); idle_timer->invokeCallback(); })); @@ -1441,12 +1441,12 @@ TEST_F(HttpConnectionManagerImplTest, AccessEncoderRouteBeforeHeadersArriveOnIdl EXPECT_CALL(*codec_, dispatch(_)).WillOnce(Invoke([&](Buffer::Instance&) -> void { Event::MockTimer* idle_timer = setUpTimer(); - EXPECT_CALL(*idle_timer, enableTimer(std::chrono::milliseconds(10))); + EXPECT_CALL(*idle_timer, enableTimer(std::chrono::milliseconds(10), _)); conn_manager_->newStream(response_encoder_); // Expect resetIdleTimer() to be called for the response // encodeHeaders()/encodeData(). - EXPECT_CALL(*idle_timer, enableTimer(_)).Times(2); + EXPECT_CALL(*idle_timer, enableTimer(_, _)).Times(2); EXPECT_CALL(*idle_timer, disableTimer()); // Simulate and idle timeout so that the filter chain gets created. idle_timer->invokeCallback(); @@ -1482,12 +1482,12 @@ TEST_F(HttpConnectionManagerImplTest, TestStreamIdleAccessLog) { NiceMock encoder; EXPECT_CALL(*codec_, dispatch(_)).WillRepeatedly(Invoke([&](Buffer::Instance&) -> void { Event::MockTimer* idle_timer = setUpTimer(); - EXPECT_CALL(*idle_timer, enableTimer(std::chrono::milliseconds(10))); + EXPECT_CALL(*idle_timer, enableTimer(std::chrono::milliseconds(10), _)); conn_manager_->newStream(response_encoder_); // Expect resetIdleTimer() to be called for the response // encodeHeaders()/encodeData(). - EXPECT_CALL(*idle_timer, enableTimer(_)).Times(2); + EXPECT_CALL(*idle_timer, enableTimer(_, _)).Times(2); EXPECT_CALL(*idle_timer, disableTimer()); idle_timer->invokeCallback(); })); @@ -1534,12 +1534,12 @@ TEST_F(HttpConnectionManagerImplTest, PerStreamIdleTimeoutRouteOverride) { EXPECT_CALL(*codec_, dispatch(_)).WillRepeatedly(Invoke([&](Buffer::Instance& data) -> void { Event::MockTimer* idle_timer = setUpTimer(); - EXPECT_CALL(*idle_timer, enableTimer(std::chrono::milliseconds(10))); + EXPECT_CALL(*idle_timer, enableTimer(std::chrono::milliseconds(10), _)); StreamDecoder* decoder = &conn_manager_->newStream(response_encoder_); HeaderMapPtr headers{ new TestHeaderMapImpl{{":authority", "host"}, {":path", "/"}, {":method", "GET"}}}; - EXPECT_CALL(*idle_timer, enableTimer(std::chrono::milliseconds(30))); + EXPECT_CALL(*idle_timer, enableTimer(std::chrono::milliseconds(30), _)); decoder->decodeHeaders(std::move(headers), false); data.drain(4); @@ -1560,7 +1560,7 @@ TEST_F(HttpConnectionManagerImplTest, PerStreamIdleTimeoutRouteZeroOverride) { EXPECT_CALL(*codec_, dispatch(_)).WillRepeatedly(Invoke([&](Buffer::Instance& data) -> void { Event::MockTimer* idle_timer = setUpTimer(); - EXPECT_CALL(*idle_timer, enableTimer(std::chrono::milliseconds(10))); + EXPECT_CALL(*idle_timer, enableTimer(std::chrono::milliseconds(10), _)); StreamDecoder* decoder = &conn_manager_->newStream(response_encoder_); HeaderMapPtr headers{ @@ -1590,12 +1590,12 @@ TEST_F(HttpConnectionManagerImplTest, PerStreamIdleTimeoutAfterDownstreamHeaders Event::MockTimer* idle_timer = setUpTimer(); HeaderMapPtr headers{ new TestHeaderMapImpl{{":authority", "host"}, {":path", "/"}, {":method", "GET"}}}; - EXPECT_CALL(*idle_timer, enableTimer(_)); + EXPECT_CALL(*idle_timer, enableTimer(_, _)); decoder->decodeHeaders(std::move(headers), false); // Expect resetIdleTimer() to be called for the response // encodeHeaders()/encodeData(). - EXPECT_CALL(*idle_timer, enableTimer(_)).Times(2); + EXPECT_CALL(*idle_timer, enableTimer(_, _)).Times(2); EXPECT_CALL(*idle_timer, disableTimer()); idle_timer->invokeCallback(); @@ -1630,7 +1630,7 @@ TEST_F(HttpConnectionManagerImplTest, PerStreamIdleTimeoutNormalTermination) { HeaderMapPtr headers{ new TestHeaderMapImpl{{":authority", "host"}, {":path", "/"}, {":method", "GET"}}}; - EXPECT_CALL(*idle_timer, enableTimer(_)); + EXPECT_CALL(*idle_timer, enableTimer(_, _)); decoder->decodeHeaders(std::move(headers), false); data.drain(4); @@ -1659,15 +1659,15 @@ TEST_F(HttpConnectionManagerImplTest, PerStreamIdleTimeoutAfterDownstreamHeaders Event::MockTimer* idle_timer = setUpTimer(); HeaderMapPtr headers{ new TestHeaderMapImpl{{":authority", "host"}, {":path", "/"}, {":method", "GET"}}}; - EXPECT_CALL(*idle_timer, enableTimer(_)); + EXPECT_CALL(*idle_timer, enableTimer(_, _)); decoder->decodeHeaders(std::move(headers), false); - EXPECT_CALL(*idle_timer, enableTimer(_)); + EXPECT_CALL(*idle_timer, enableTimer(_, _)); decoder->decodeData(data, false); // Expect resetIdleTimer() to be called for the response // encodeHeaders()/encodeData(). - EXPECT_CALL(*idle_timer, enableTimer(_)).Times(2); + EXPECT_CALL(*idle_timer, enableTimer(_, _)).Times(2); EXPECT_CALL(*idle_timer, disableTimer()); idle_timer->invokeCallback(); @@ -1712,11 +1712,11 @@ TEST_F(HttpConnectionManagerImplTest, PerStreamIdleTimeoutAfterUpstreamHeaders) Event::MockTimer* idle_timer = setUpTimer(); HeaderMapPtr headers{ new TestHeaderMapImpl{{":authority", "host"}, {":path", "/"}, {":method", "GET"}}}; - EXPECT_CALL(*idle_timer, enableTimer(_)); + EXPECT_CALL(*idle_timer, enableTimer(_, _)); decoder->decodeHeaders(std::move(headers), false); HeaderMapPtr response_headers{new TestHeaderMapImpl{{":status", "200"}}}; - EXPECT_CALL(*idle_timer, enableTimer(_)); + EXPECT_CALL(*idle_timer, enableTimer(_, _)); filter->callbacks_->encodeHeaders(std::move(response_headers), false); EXPECT_CALL(*idle_timer, disableTimer()); @@ -1761,26 +1761,26 @@ TEST_F(HttpConnectionManagerImplTest, PerStreamIdleTimeoutAfterBidiData) { decoder = &conn_manager_->newStream(response_encoder_); HeaderMapPtr headers{ new TestHeaderMapImpl{{":authority", "host"}, {":path", "/"}, {":method", "GET"}}}; - EXPECT_CALL(*idle_timer, enableTimer(_)); + EXPECT_CALL(*idle_timer, enableTimer(_, _)); decoder->decodeHeaders(std::move(headers), false); HeaderMapPtr response_continue_headers{new TestHeaderMapImpl{{":status", "100"}}}; - EXPECT_CALL(*idle_timer, enableTimer(_)); + EXPECT_CALL(*idle_timer, enableTimer(_, _)); filter->callbacks_->encode100ContinueHeaders(std::move(response_continue_headers)); HeaderMapPtr response_headers{new TestHeaderMapImpl{{":status", "200"}}}; - EXPECT_CALL(*idle_timer, enableTimer(_)); + EXPECT_CALL(*idle_timer, enableTimer(_, _)); filter->callbacks_->encodeHeaders(std::move(response_headers), false); - EXPECT_CALL(*idle_timer, enableTimer(_)); + EXPECT_CALL(*idle_timer, enableTimer(_, _)); decoder->decodeData(data, false); HeaderMapPtr trailers{new TestHeaderMapImpl{{"foo", "bar"}}}; - EXPECT_CALL(*idle_timer, enableTimer(_)); + EXPECT_CALL(*idle_timer, enableTimer(_, _)); decoder->decodeTrailers(std::move(trailers)); Buffer::OwnedImpl fake_response("world"); - EXPECT_CALL(*idle_timer, enableTimer(_)); + EXPECT_CALL(*idle_timer, enableTimer(_, _)); filter->callbacks_->encodeData(fake_response, false); EXPECT_CALL(*idle_timer, disableTimer()); @@ -1839,7 +1839,7 @@ TEST_F(HttpConnectionManagerImplTest, RequestTimeoutValidlyConfigured) { EXPECT_CALL(*codec_, dispatch(_)).Times(1).WillOnce(Invoke([&](Buffer::Instance&) -> void { Event::MockTimer* request_timer = setUpTimer(); - EXPECT_CALL(*request_timer, enableTimer(request_timeout_)); + EXPECT_CALL(*request_timer, enableTimer(request_timeout_, _)); conn_manager_->newStream(response_encoder_); })); @@ -1855,7 +1855,7 @@ TEST_F(HttpConnectionManagerImplTest, RequestTimeoutCallbackDisarmsAndReturns408 std::string response_body; EXPECT_CALL(*codec_, dispatch(_)).Times(1).WillOnce(Invoke([&](Buffer::Instance&) -> void { Event::MockTimer* request_timer = setUpTimer(); - EXPECT_CALL(*request_timer, enableTimer(request_timeout_)).Times(1); + EXPECT_CALL(*request_timer, enableTimer(request_timeout_, _)).Times(1); EXPECT_CALL(*request_timer, disableTimer()).Times(AtLeast(1)); EXPECT_CALL(response_encoder_, encodeHeaders(_, false)) @@ -1881,7 +1881,7 @@ TEST_F(HttpConnectionManagerImplTest, RequestTimeoutIsNotDisarmedOnIncompleteReq EXPECT_CALL(*codec_, dispatch(_)).Times(1).WillOnce(Invoke([&](Buffer::Instance&) -> void { Event::MockTimer* request_timer = setUpTimer(); - EXPECT_CALL(*request_timer, enableTimer(request_timeout_)).Times(1); + EXPECT_CALL(*request_timer, enableTimer(request_timeout_, _)).Times(1); EXPECT_CALL(*request_timer, disableTimer()).Times(0); StreamDecoder* decoder = &conn_manager_->newStream(response_encoder_); @@ -1904,7 +1904,7 @@ TEST_F(HttpConnectionManagerImplTest, RequestTimeoutIsDisarmedOnCompleteRequestW EXPECT_CALL(*codec_, dispatch(_)).Times(1).WillOnce(Invoke([&](Buffer::Instance&) -> void { Event::MockTimer* request_timer = setUpTimer(); - EXPECT_CALL(*request_timer, enableTimer(request_timeout_)).Times(1); + EXPECT_CALL(*request_timer, enableTimer(request_timeout_, _)).Times(1); StreamDecoder* decoder = &conn_manager_->newStream(response_encoder_); HeaderMapPtr headers{ @@ -1926,7 +1926,7 @@ TEST_F(HttpConnectionManagerImplTest, RequestTimeoutIsDisarmedOnCompleteRequestW EXPECT_CALL(*codec_, dispatch(_)).WillOnce(Invoke([&](Buffer::Instance& data) -> void { Event::MockTimer* request_timer = setUpTimer(); - EXPECT_CALL(*request_timer, enableTimer(request_timeout_)).Times(1); + EXPECT_CALL(*request_timer, enableTimer(request_timeout_, _)).Times(1); StreamDecoder* decoder = &conn_manager_->newStream(response_encoder_); HeaderMapPtr headers{ @@ -1949,7 +1949,7 @@ TEST_F(HttpConnectionManagerImplTest, RequestTimeoutIsDisarmedOnCompleteRequestW EXPECT_CALL(*codec_, dispatch(_)).WillOnce(Invoke([&](Buffer::Instance& data) -> void { Event::MockTimer* request_timer = setUpTimer(); - EXPECT_CALL(*request_timer, enableTimer(request_timeout_)).Times(1); + EXPECT_CALL(*request_timer, enableTimer(request_timeout_, _)).Times(1); StreamDecoder* decoder = &conn_manager_->newStream(response_encoder_); HeaderMapPtr headers{ @@ -1980,7 +1980,7 @@ TEST_F(HttpConnectionManagerImplTest, RequestTimeoutIsDisarmedOnEncodeHeaders) { EXPECT_CALL(*codec_, dispatch(_)).Times(1).WillOnce(Invoke([&](Buffer::Instance&) -> void { Event::MockTimer* request_timer = setUpTimer(); - EXPECT_CALL(*request_timer, enableTimer(request_timeout_)).Times(1); + EXPECT_CALL(*request_timer, enableTimer(request_timeout_, _)).Times(1); StreamDecoder* decoder = &conn_manager_->newStream(response_encoder_); HeaderMapPtr headers{ @@ -2014,7 +2014,7 @@ TEST_F(HttpConnectionManagerImplTest, RequestTimeoutIsDisarmedOnConnectionTermin Buffer::OwnedImpl fake_input("1234"); - EXPECT_CALL(*request_timer, enableTimer(request_timeout_)).Times(1); + EXPECT_CALL(*request_timer, enableTimer(request_timeout_, _)).Times(1); conn_manager_->onData(fake_input, false); // kick off request EXPECT_CALL(*request_timer, disableTimer()).Times(1); @@ -2138,7 +2138,7 @@ TEST_F(HttpConnectionManagerImplTest, DrainClose) { HeaderMapPtr response_headers{new TestHeaderMapImpl{{":status", "300"}}}; Event::MockTimer* drain_timer = setUpTimer(); - EXPECT_CALL(*drain_timer, enableTimer(_)); + EXPECT_CALL(*drain_timer, enableTimer(_, _)); EXPECT_CALL(drain_close_, drainClose()).WillOnce(Return(true)); EXPECT_CALL(*codec_, shutdownNotice()); filter->callbacks_->encodeHeaders(std::move(response_headers), true); @@ -2376,7 +2376,7 @@ TEST_F(HttpConnectionManagerImplTest, IdleTimeoutNoCodec) { idle_timeout_ = (std::chrono::milliseconds(10)); Event::MockTimer* idle_timer = setUpTimer(); - EXPECT_CALL(*idle_timer, enableTimer(_)); + EXPECT_CALL(*idle_timer, enableTimer(_, _)); setup(false, ""); EXPECT_CALL(filter_callbacks_.connection_, close(Network::ConnectionCloseType::FlushWrite)); @@ -2389,7 +2389,7 @@ TEST_F(HttpConnectionManagerImplTest, IdleTimeoutNoCodec) { TEST_F(HttpConnectionManagerImplTest, IdleTimeout) { idle_timeout_ = (std::chrono::milliseconds(10)); Event::MockTimer* idle_timer = setUpTimer(); - EXPECT_CALL(*idle_timer, enableTimer(_)); + EXPECT_CALL(*idle_timer, enableTimer(_, _)); setup(false, ""); MockStreamDecoderFilter* filter = new NiceMock(); @@ -2420,12 +2420,12 @@ TEST_F(HttpConnectionManagerImplTest, IdleTimeout) { Buffer::OwnedImpl fake_input("1234"); conn_manager_->onData(fake_input, false); - EXPECT_CALL(*idle_timer, enableTimer(_)); + EXPECT_CALL(*idle_timer, enableTimer(_, _)); HeaderMapPtr response_headers{new TestHeaderMapImpl{{":status", "200"}}}; filter->callbacks_->encodeHeaders(std::move(response_headers), true); Event::MockTimer* drain_timer = setUpTimer(); - EXPECT_CALL(*drain_timer, enableTimer(_)); + EXPECT_CALL(*drain_timer, enableTimer(_, _)); idle_timer->invokeCallback(); EXPECT_CALL(*codec_, goAway()); diff --git a/test/common/http/date_provider_impl_test.cc b/test/common/http/date_provider_impl_test.cc index 619a5f9a96e3..41594a30a6ea 100644 --- a/test/common/http/date_provider_impl_test.cc +++ b/test/common/http/date_provider_impl_test.cc @@ -19,14 +19,14 @@ TEST(DateProviderImplTest, All) { Event::MockDispatcher dispatcher; NiceMock tls; Event::MockTimer* timer = new Event::MockTimer(&dispatcher); - EXPECT_CALL(*timer, enableTimer(std::chrono::milliseconds(500))); + EXPECT_CALL(*timer, enableTimer(std::chrono::milliseconds(500), _)); TlsCachingDateProviderImpl provider(dispatcher, tls); HeaderMapImpl headers; provider.setDateHeader(headers); EXPECT_NE(nullptr, headers.Date()); - EXPECT_CALL(*timer, enableTimer(std::chrono::milliseconds(500))); + EXPECT_CALL(*timer, enableTimer(std::chrono::milliseconds(500), _)); timer->invokeCallback(); headers.removeDate(); diff --git a/test/common/http/http1/conn_pool_test.cc b/test/common/http/http1/conn_pool_test.cc index d91c9cd862a7..73b79b35205f 100644 --- a/test/common/http/http1/conn_pool_test.cc +++ b/test/common/http/http1/conn_pool_test.cc @@ -98,13 +98,13 @@ class ConnPoolImplForTest : public ConnPoolImpl { EXPECT_CALL(mock_dispatcher_, createClientConnection_(_, _, _, _)) .WillOnce(Return(test_client.connection_)); EXPECT_CALL(*this, createCodecClient_()).WillOnce(Return(test_client.codec_client_)); - EXPECT_CALL(*test_client.connect_timer_, enableTimer(_)); + EXPECT_CALL(*test_client.connect_timer_, enableTimer(_, _)); ON_CALL(*test_client.codec_, protocol()).WillByDefault(Return(protocol)); } void expectEnableUpstreamReady() { EXPECT_FALSE(upstream_ready_enabled_); - EXPECT_CALL(*mock_upstream_ready_timer_, enableTimer(_)).Times(1).RetiresOnSaturation(); + EXPECT_CALL(*mock_upstream_ready_timer_, enableTimer(_, _)).Times(1).RetiresOnSaturation(); } void expectAndRunUpstreamReady() { diff --git a/test/common/http/http2/conn_pool_test.cc b/test/common/http/http2/conn_pool_test.cc index 6490da7337e1..5e2cac038136 100644 --- a/test/common/http/http2/conn_pool_test.cc +++ b/test/common/http/http2/conn_pool_test.cc @@ -96,7 +96,7 @@ class Http2ConnPoolImplTest : public testing::Test { .WillOnce(Invoke([this](Upstream::Host::CreateConnectionData&) -> CodecClient* { return test_clients_.back().codec_client_; })); - EXPECT_CALL(*test_client.connect_timer_, enableTimer(_)); + EXPECT_CALL(*test_client.connect_timer_, enableTimer(_, _)); } // Connects a pending connection for client with the given index, asserting diff --git a/test/common/network/connection_impl_test.cc b/test/common/network/connection_impl_test.cc index 734734f09bfc..7e22ba77e941 100644 --- a/test/common/network/connection_impl_test.cc +++ b/test/common/network/connection_impl_test.cc @@ -1224,7 +1224,7 @@ TEST_P(ConnectionImplTest, DelayedCloseTimerResetWithPendingWriteBufferFlushes) Buffer::OwnedImpl data("data"); server_connection->write(data, false); - EXPECT_CALL(*mocks.timer_, enableTimer(timeout)).Times(1); + EXPECT_CALL(*mocks.timer_, enableTimer(timeout, _)).Times(1); server_connection->close(ConnectionCloseType::FlushWriteAndDelay); // The write ready event cb (ConnectionImpl::onWriteReady()) will reset the timer to its original @@ -1234,7 +1234,7 @@ TEST_P(ConnectionImplTest, DelayedCloseTimerResetWithPendingWriteBufferFlushes) // Partial flush. return IoResult{PostIoAction::KeepOpen, 1, false}; })); - EXPECT_CALL(*mocks.timer_, enableTimer(timeout)).Times(1); + EXPECT_CALL(*mocks.timer_, enableTimer(timeout, _)).Times(1); (*mocks.file_ready_cb_)(Event::FileReadyType::Write); EXPECT_CALL(*transport_socket, doWrite(BufferStringEqual("data"), _)) @@ -1243,7 +1243,7 @@ TEST_P(ConnectionImplTest, DelayedCloseTimerResetWithPendingWriteBufferFlushes) buffer.drain(buffer.length()); return IoResult{PostIoAction::KeepOpen, buffer.length(), false}; })); - EXPECT_CALL(*mocks.timer_, enableTimer(timeout)).Times(1); + EXPECT_CALL(*mocks.timer_, enableTimer(timeout, _)).Times(1); (*mocks.file_ready_cb_)(Event::FileReadyType::Write); // Force the delayed close timeout to trigger so the connection is cleaned up. @@ -1277,7 +1277,7 @@ TEST_P(ConnectionImplTest, DelayedCloseTimeoutDisableOnSocketClose) { return IoResult{PostIoAction::KeepOpen, buffer.length(), false}; })); server_connection->write(data, false); - EXPECT_CALL(*mocks.timer_, enableTimer(_)).Times(1); + EXPECT_CALL(*mocks.timer_, enableTimer(_, _)).Times(1); // Enable the delayed close timer. server_connection->close(ConnectionCloseType::FlushWriteAndDelay); EXPECT_CALL(*mocks.timer_, disableTimer()).Times(1); @@ -1318,7 +1318,7 @@ TEST_P(ConnectionImplTest, DelayedCloseTimeoutNullStats) { })); server_connection->write(data, false); - EXPECT_CALL(*mocks.timer_, enableTimer(_)).Times(1); + EXPECT_CALL(*mocks.timer_, enableTimer(_, _)).Times(1); server_connection->close(ConnectionCloseType::FlushWriteAndDelay); EXPECT_CALL(*mocks.timer_, disableTimer()).Times(1); // The following close() will call closeSocket() and reset internal data structures such as diff --git a/test/common/network/dns_impl_test.cc b/test/common/network/dns_impl_test.cc index eaa925b9e06a..49d01a430d0c 100644 --- a/test/common/network/dns_impl_test.cc +++ b/test/common/network/dns_impl_test.cc @@ -857,7 +857,7 @@ TEST(DnsImplUnitTest, PendingTimerEnable) { DnsResolverImpl resolver(dispatcher, {}); Event::FileEvent* file_event = new NiceMock(); EXPECT_CALL(dispatcher, createFileEvent_(_, _, _, _)).WillOnce(Return(file_event)); - EXPECT_CALL(*timer, enableTimer(_)); + EXPECT_CALL(*timer, enableTimer(_, _)); EXPECT_NE(nullptr, resolver.resolve("some.bad.domain.invalid", DnsLookupFamily::V4Only, [&](std::list&& results) { UNREFERENCED_PARAMETER(results); diff --git a/test/common/router/retry_state_impl_test.cc b/test/common/router/retry_state_impl_test.cc index 6120470db1cb..64de11d0215d 100644 --- a/test/common/router/retry_state_impl_test.cc +++ b/test/common/router/retry_state_impl_test.cc @@ -43,7 +43,7 @@ class RouterRetryStateImplTest : public testing::Test { void expectTimerCreateAndEnable() { retry_timer_ = new Event::MockTimer(&dispatcher_); - EXPECT_CALL(*retry_timer_, enableTimer(_)); + EXPECT_CALL(*retry_timer_, enableTimer(_, _)); } NiceMock policy_; @@ -466,12 +466,12 @@ TEST_F(RouterRetryStateImplTest, MaxRetriesHeader) { EXPECT_CALL(callback_ready_, ready()); retry_timer_->invokeCallback(); - EXPECT_CALL(*retry_timer_, enableTimer(_)); + EXPECT_CALL(*retry_timer_, enableTimer(_, _)); EXPECT_EQ(RetryStatus::Yes, state_->shouldRetryReset(connect_failure_, callback_)); EXPECT_CALL(callback_ready_, ready()); retry_timer_->invokeCallback(); - EXPECT_CALL(*retry_timer_, enableTimer(_)); + EXPECT_CALL(*retry_timer_, enableTimer(_, _)); EXPECT_EQ(RetryStatus::Yes, state_->shouldRetryReset(connect_failure_, callback_)); EXPECT_CALL(callback_ready_, ready()); retry_timer_->invokeCallback(); @@ -493,19 +493,19 @@ TEST_F(RouterRetryStateImplTest, Backoff) { EXPECT_CALL(random_, random()).WillOnce(Return(49)); retry_timer_ = new Event::MockTimer(&dispatcher_); - EXPECT_CALL(*retry_timer_, enableTimer(std::chrono::milliseconds(24))); + EXPECT_CALL(*retry_timer_, enableTimer(std::chrono::milliseconds(24), _)); EXPECT_EQ(RetryStatus::Yes, state_->shouldRetryReset(connect_failure_, callback_)); EXPECT_CALL(callback_ready_, ready()); retry_timer_->invokeCallback(); EXPECT_CALL(random_, random()).WillOnce(Return(149)); - EXPECT_CALL(*retry_timer_, enableTimer(std::chrono::milliseconds(74))); + EXPECT_CALL(*retry_timer_, enableTimer(std::chrono::milliseconds(74), _)); EXPECT_EQ(RetryStatus::Yes, state_->shouldRetryReset(connect_failure_, callback_)); EXPECT_CALL(callback_ready_, ready()); retry_timer_->invokeCallback(); EXPECT_CALL(random_, random()).WillOnce(Return(349)); - EXPECT_CALL(*retry_timer_, enableTimer(std::chrono::milliseconds(174))); + EXPECT_CALL(*retry_timer_, enableTimer(std::chrono::milliseconds(174), _)); EXPECT_EQ(RetryStatus::Yes, state_->shouldRetryReset(connect_failure_, callback_)); EXPECT_CALL(callback_ready_, ready()); retry_timer_->invokeCallback(); @@ -530,25 +530,25 @@ TEST_F(RouterRetryStateImplTest, CustomBackOffInterval) { EXPECT_CALL(random_, random()).WillOnce(Return(149)); retry_timer_ = new Event::MockTimer(&dispatcher_); - EXPECT_CALL(*retry_timer_, enableTimer(std::chrono::milliseconds(49))); + EXPECT_CALL(*retry_timer_, enableTimer(std::chrono::milliseconds(49), _)); EXPECT_EQ(RetryStatus::Yes, state_->shouldRetryReset(connect_failure_, callback_)); EXPECT_CALL(callback_ready_, ready()); retry_timer_->invokeCallback(); EXPECT_CALL(random_, random()).WillOnce(Return(350)); - EXPECT_CALL(*retry_timer_, enableTimer(std::chrono::milliseconds(50))); + EXPECT_CALL(*retry_timer_, enableTimer(std::chrono::milliseconds(50), _)); EXPECT_EQ(RetryStatus::Yes, state_->shouldRetryReset(connect_failure_, callback_)); EXPECT_CALL(callback_ready_, ready()); retry_timer_->invokeCallback(); EXPECT_CALL(random_, random()).WillOnce(Return(751)); - EXPECT_CALL(*retry_timer_, enableTimer(std::chrono::milliseconds(51))); + EXPECT_CALL(*retry_timer_, enableTimer(std::chrono::milliseconds(51), _)); EXPECT_EQ(RetryStatus::Yes, state_->shouldRetryReset(connect_failure_, callback_)); EXPECT_CALL(callback_ready_, ready()); retry_timer_->invokeCallback(); EXPECT_CALL(random_, random()).WillOnce(Return(1499)); - EXPECT_CALL(*retry_timer_, enableTimer(std::chrono::milliseconds(1200))); + EXPECT_CALL(*retry_timer_, enableTimer(std::chrono::milliseconds(1200), _)); EXPECT_EQ(RetryStatus::Yes, state_->shouldRetryReset(connect_failure_, callback_)); EXPECT_CALL(callback_ready_, ready()); retry_timer_->invokeCallback(); @@ -565,25 +565,25 @@ TEST_F(RouterRetryStateImplTest, CustomBackOffIntervalDefaultMax) { EXPECT_CALL(random_, random()).WillOnce(Return(149)); retry_timer_ = new Event::MockTimer(&dispatcher_); - EXPECT_CALL(*retry_timer_, enableTimer(std::chrono::milliseconds(49))); + EXPECT_CALL(*retry_timer_, enableTimer(std::chrono::milliseconds(49), _)); EXPECT_EQ(RetryStatus::Yes, state_->shouldRetryReset(connect_failure_, callback_)); EXPECT_CALL(callback_ready_, ready()); retry_timer_->invokeCallback(); EXPECT_CALL(random_, random()).WillOnce(Return(350)); - EXPECT_CALL(*retry_timer_, enableTimer(std::chrono::milliseconds(50))); + EXPECT_CALL(*retry_timer_, enableTimer(std::chrono::milliseconds(50), _)); EXPECT_EQ(RetryStatus::Yes, state_->shouldRetryReset(connect_failure_, callback_)); EXPECT_CALL(callback_ready_, ready()); retry_timer_->invokeCallback(); EXPECT_CALL(random_, random()).WillOnce(Return(751)); - EXPECT_CALL(*retry_timer_, enableTimer(std::chrono::milliseconds(51))); + EXPECT_CALL(*retry_timer_, enableTimer(std::chrono::milliseconds(51), _)); EXPECT_EQ(RetryStatus::Yes, state_->shouldRetryReset(connect_failure_, callback_)); EXPECT_CALL(callback_ready_, ready()); retry_timer_->invokeCallback(); EXPECT_CALL(random_, random()).WillOnce(Return(1499)); - EXPECT_CALL(*retry_timer_, enableTimer(std::chrono::milliseconds(1000))); + EXPECT_CALL(*retry_timer_, enableTimer(std::chrono::milliseconds(1000), _)); EXPECT_EQ(RetryStatus::Yes, state_->shouldRetryReset(connect_failure_, callback_)); EXPECT_CALL(callback_ready_, ready()); retry_timer_->invokeCallback(); diff --git a/test/common/router/router_test.cc b/test/common/router/router_test.cc index 770ce8bef6ae..fd91559acc1e 100644 --- a/test/common/router/router_test.cc +++ b/test/common/router/router_test.cc @@ -106,13 +106,13 @@ class RouterTestBase : public testing::Test { void expectResponseTimerCreate() { response_timeout_ = new Event::MockTimer(&callbacks_.dispatcher_); - EXPECT_CALL(*response_timeout_, enableTimer(_)); + EXPECT_CALL(*response_timeout_, enableTimer(_, _)); EXPECT_CALL(*response_timeout_, disableTimer()); } void expectPerTryTimerCreate() { per_try_timeout_ = new Event::MockTimer(&callbacks_.dispatcher_); - EXPECT_CALL(*per_try_timeout_, enableTimer(_)); + EXPECT_CALL(*per_try_timeout_, enableTimer(_, _)); EXPECT_CALL(*per_try_timeout_, disableTimer()); } @@ -1491,7 +1491,7 @@ TEST_F(RouterTest, UpstreamPerTryTimeoutExcludesNewStream) { })); response_timeout_ = new Event::MockTimer(&callbacks_.dispatcher_); - EXPECT_CALL(*response_timeout_, enableTimer(_)); + EXPECT_CALL(*response_timeout_, enableTimer(_, _)); EXPECT_CALL(callbacks_.stream_info_, onUpstreamHostSelected(_)) .WillOnce(Invoke([&](const Upstream::HostDescriptionConstSharedPtr host) -> void { @@ -1506,7 +1506,7 @@ TEST_F(RouterTest, UpstreamPerTryTimeoutExcludesNewStream) { router_.decodeData(data, true); per_try_timeout_ = new Event::MockTimer(&callbacks_.dispatcher_); - EXPECT_CALL(*per_try_timeout_, enableTimer(_)); + EXPECT_CALL(*per_try_timeout_, enableTimer(_, _)); // The per try timeout timer should not be started yet. pool_callbacks->onPoolReady(encoder, cm_.conn_pool_.host_); diff --git a/test/common/router/router_upstream_log_test.cc b/test/common/router/router_upstream_log_test.cc index 581db1087f3c..554aa3c198f5 100644 --- a/test/common/router/router_upstream_log_test.cc +++ b/test/common/router/router_upstream_log_test.cc @@ -106,13 +106,13 @@ class RouterUpstreamLogTest : public testing::Test { void expectResponseTimerCreate() { response_timeout_ = new Event::MockTimer(&callbacks_.dispatcher_); - EXPECT_CALL(*response_timeout_, enableTimer(_)); + EXPECT_CALL(*response_timeout_, enableTimer(_, _)); EXPECT_CALL(*response_timeout_, disableTimer()); } void expectPerTryTimerCreate() { per_try_timeout_ = new Event::MockTimer(&callbacks_.dispatcher_); - EXPECT_CALL(*per_try_timeout_, enableTimer(_)); + EXPECT_CALL(*per_try_timeout_, enableTimer(_, _)); EXPECT_CALL(*per_try_timeout_, disableTimer()); } diff --git a/test/common/tcp/conn_pool_test.cc b/test/common/tcp/conn_pool_test.cc index ec42cf60e602..d1521e28226a 100644 --- a/test/common/tcp/conn_pool_test.cc +++ b/test/common/tcp/conn_pool_test.cc @@ -106,12 +106,12 @@ class ConnPoolImplForTest : public ConnPoolImpl { .WillOnce(Invoke( [&](Network::ReadFilterSharedPtr filter) -> void { test_conn.filter_ = filter; })); EXPECT_CALL(*test_conn.connection_, connect()); - EXPECT_CALL(*test_conn.connect_timer_, enableTimer(_)); + EXPECT_CALL(*test_conn.connect_timer_, enableTimer(_, _)); } void expectEnableUpstreamReady() { EXPECT_FALSE(upstream_ready_enabled_); - EXPECT_CALL(*mock_upstream_ready_timer_, enableTimer(_)).Times(1).RetiresOnSaturation(); + EXPECT_CALL(*mock_upstream_ready_timer_, enableTimer(_, _)).Times(1).RetiresOnSaturation(); } void expectAndRunUpstreamReady() { @@ -186,7 +186,7 @@ class TcpConnPoolImplDestructorTest : public testing::Test { connection_ = new NiceMock(); connect_timer_ = new NiceMock(&dispatcher_); EXPECT_CALL(dispatcher_, createClientConnection_(_, _, _, _)).WillOnce(Return(connection_)); - EXPECT_CALL(*connect_timer_, enableTimer(_)); + EXPECT_CALL(*connect_timer_, enableTimer(_, _)); callbacks_ = std::make_unique(); ConnectionPool::Cancellable* handle = conn_pool_->newConnection(*callbacks_); @@ -921,7 +921,7 @@ TEST_F(TcpConnPoolImplDestructorTest, TestPendingConnectionsAreClosed) { connection_ = new NiceMock(); connect_timer_ = new NiceMock(&dispatcher_); EXPECT_CALL(dispatcher_, createClientConnection_(_, _, _, _)).WillOnce(Return(connection_)); - EXPECT_CALL(*connect_timer_, enableTimer(_)); + EXPECT_CALL(*connect_timer_, enableTimer(_, _)); callbacks_ = std::make_unique(); ConnectionPool::Cancellable* handle = conn_pool_->newConnection(*callbacks_); diff --git a/test/common/tcp_proxy/tcp_proxy_test.cc b/test/common/tcp_proxy/tcp_proxy_test.cc index 903249d9a06e..88d21bfdc4b6 100644 --- a/test/common/tcp_proxy/tcp_proxy_test.cc +++ b/test/common/tcp_proxy/tcp_proxy_test.cc @@ -821,21 +821,21 @@ TEST_F(TcpProxyTest, IdleTimeout) { setup(1, config); Event::MockTimer* idle_timer = new Event::MockTimer(&filter_callbacks_.connection_.dispatcher_); - EXPECT_CALL(*idle_timer, enableTimer(std::chrono::milliseconds(1000))); + EXPECT_CALL(*idle_timer, enableTimer(std::chrono::milliseconds(1000), _)); raiseEventUpstreamConnected(0); Buffer::OwnedImpl buffer("hello"); - EXPECT_CALL(*idle_timer, enableTimer(std::chrono::milliseconds(1000))); + EXPECT_CALL(*idle_timer, enableTimer(std::chrono::milliseconds(1000), _)); filter_->onData(buffer, false); buffer.add("hello2"); - EXPECT_CALL(*idle_timer, enableTimer(std::chrono::milliseconds(1000))); + EXPECT_CALL(*idle_timer, enableTimer(std::chrono::milliseconds(1000), _)); upstream_callbacks_->onUpstreamData(buffer, false); - EXPECT_CALL(*idle_timer, enableTimer(std::chrono::milliseconds(1000))); + EXPECT_CALL(*idle_timer, enableTimer(std::chrono::milliseconds(1000), _)); filter_callbacks_.connection_.raiseBytesSentCallbacks(1); - EXPECT_CALL(*idle_timer, enableTimer(std::chrono::milliseconds(1000))); + EXPECT_CALL(*idle_timer, enableTimer(std::chrono::milliseconds(1000), _)); upstream_connections_.at(0)->raiseBytesSentCallbacks(2); EXPECT_CALL(*upstream_connections_.at(0), close(Network::ConnectionCloseType::NoFlush)); @@ -851,7 +851,7 @@ TEST_F(TcpProxyTest, IdleTimerDisabledDownstreamClose) { setup(1, config); Event::MockTimer* idle_timer = new Event::MockTimer(&filter_callbacks_.connection_.dispatcher_); - EXPECT_CALL(*idle_timer, enableTimer(std::chrono::milliseconds(1000))); + EXPECT_CALL(*idle_timer, enableTimer(std::chrono::milliseconds(1000), _)); raiseEventUpstreamConnected(0); EXPECT_CALL(*idle_timer, disableTimer()); @@ -865,7 +865,7 @@ TEST_F(TcpProxyTest, IdleTimerDisabledUpstreamClose) { setup(1, config); Event::MockTimer* idle_timer = new Event::MockTimer(&filter_callbacks_.connection_.dispatcher_); - EXPECT_CALL(*idle_timer, enableTimer(std::chrono::milliseconds(1000))); + EXPECT_CALL(*idle_timer, enableTimer(std::chrono::milliseconds(1000), _)); raiseEventUpstreamConnected(0); EXPECT_CALL(*idle_timer, disableTimer()); @@ -879,21 +879,21 @@ TEST_F(TcpProxyTest, IdleTimeoutWithOutstandingDataFlushed) { setup(1, config); Event::MockTimer* idle_timer = new Event::MockTimer(&filter_callbacks_.connection_.dispatcher_); - EXPECT_CALL(*idle_timer, enableTimer(std::chrono::milliseconds(1000))); + EXPECT_CALL(*idle_timer, enableTimer(std::chrono::milliseconds(1000), _)); raiseEventUpstreamConnected(0); Buffer::OwnedImpl buffer("hello"); - EXPECT_CALL(*idle_timer, enableTimer(std::chrono::milliseconds(1000))); + EXPECT_CALL(*idle_timer, enableTimer(std::chrono::milliseconds(1000), _)); filter_->onData(buffer, false); buffer.add("hello2"); - EXPECT_CALL(*idle_timer, enableTimer(std::chrono::milliseconds(1000))); + EXPECT_CALL(*idle_timer, enableTimer(std::chrono::milliseconds(1000), _)); upstream_callbacks_->onUpstreamData(buffer, false); - EXPECT_CALL(*idle_timer, enableTimer(std::chrono::milliseconds(1000))); + EXPECT_CALL(*idle_timer, enableTimer(std::chrono::milliseconds(1000), _)); filter_callbacks_.connection_.raiseBytesSentCallbacks(1); - EXPECT_CALL(*idle_timer, enableTimer(std::chrono::milliseconds(1000))); + EXPECT_CALL(*idle_timer, enableTimer(std::chrono::milliseconds(1000), _)); upstream_connections_.at(0)->raiseBytesSentCallbacks(2); // Mark the upstream connection as blocked. @@ -1043,7 +1043,7 @@ TEST_F(TcpProxyTest, UpstreamFlushTimeoutConfigured) { NiceMock* idle_timer = new NiceMock(&filter_callbacks_.connection_.dispatcher_); - EXPECT_CALL(*idle_timer, enableTimer(_)); + EXPECT_CALL(*idle_timer, enableTimer(_, _)); raiseEventUpstreamConnected(0); EXPECT_CALL(*upstream_connections_.at(0), @@ -1056,7 +1056,7 @@ TEST_F(TcpProxyTest, UpstreamFlushTimeoutConfigured) { filter_.reset(); EXPECT_EQ(1U, config_->stats().upstream_flush_active_.value()); - EXPECT_CALL(*idle_timer, enableTimer(std::chrono::milliseconds(1000))); + EXPECT_CALL(*idle_timer, enableTimer(std::chrono::milliseconds(1000), _)); upstream_connections_.at(0)->raiseBytesSentCallbacks(1); // Simulate flush complete. @@ -1075,7 +1075,7 @@ TEST_F(TcpProxyTest, UpstreamFlushTimeoutExpired) { NiceMock* idle_timer = new NiceMock(&filter_callbacks_.connection_.dispatcher_); - EXPECT_CALL(*idle_timer, enableTimer(_)); + EXPECT_CALL(*idle_timer, enableTimer(_, _)); raiseEventUpstreamConnected(0); EXPECT_CALL(*upstream_connections_.at(0), diff --git a/test/common/upstream/eds_test.cc b/test/common/upstream/eds_test.cc index 988df7fc7ee4..b71150712939 100644 --- a/test/common/upstream/eds_test.cc +++ b/test/common/upstream/eds_test.cc @@ -1713,9 +1713,9 @@ TEST_F(EdsAssignmentTimeoutTest, AssignmentTimeoutEnableDisable) { cluster_load_assignment_lease.mutable_policy()->mutable_endpoint_stale_after()->MergeFrom( Protobuf::util::TimeUtil::SecondsToDuration(1)); - EXPECT_CALL(*interval_timer_, enableTimer(_)).Times(2); // Timer enabled twice. - EXPECT_CALL(*interval_timer_, disableTimer()).Times(1); // Timer disabled once. - EXPECT_CALL(*interval_timer_, enabled()).Times(6); // Includes calls by test. + EXPECT_CALL(*interval_timer_, enableTimer(_, _)).Times(2); // Timer enabled twice. + EXPECT_CALL(*interval_timer_, disableTimer()).Times(1); // Timer disabled once. + EXPECT_CALL(*interval_timer_, enabled()).Times(6); // Includes calls by test. doOnConfigUpdateVerifyNoThrow(cluster_load_assignment_lease); // Check that the timer is enabled. EXPECT_EQ(interval_timer_->enabled(), true); @@ -1755,7 +1755,7 @@ TEST_F(EdsAssignmentTimeoutTest, AssignmentLeaseExpired) { add_endpoint(81); // Expect the timer to be enabled once. - EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(1000))); + EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(1000), _)); // Expect the timer to be disabled when stale assignments are removed. EXPECT_CALL(*interval_timer_, disableTimer()); EXPECT_CALL(*interval_timer_, enabled()).Times(2); diff --git a/test/common/upstream/hds_test.cc b/test/common/upstream/hds_test.cc index c7fe3af8d73e..3a442a1924b5 100644 --- a/test/common/upstream/hds_test.cc +++ b/test/common/upstream/hds_test.cc @@ -232,7 +232,7 @@ TEST_F(HdsTest, TestMinimalOnReceiveMessage) { message->mutable_interval()->set_seconds(1); // Process message - EXPECT_CALL(*server_response_timer_, enableTimer(_)).Times(AtLeast(1)); + EXPECT_CALL(*server_response_timer_, enableTimer(_, _)).Times(AtLeast(1)); hds_delegate_->onReceiveMessage(std::move(message)); } @@ -248,7 +248,7 @@ TEST_F(HdsTest, TestMinimalSendResponse) { message->mutable_interval()->set_seconds(1); // Process message and send 2 responses - EXPECT_CALL(*server_response_timer_, enableTimer(_)).Times(AtLeast(1)); + EXPECT_CALL(*server_response_timer_, enableTimer(_, _)).Times(AtLeast(1)); EXPECT_CALL(async_stream_, sendMessageRaw_(_, _)).Times(2); hds_delegate_->onReceiveMessage(std::move(message)); hds_delegate_->sendResponse(); @@ -265,11 +265,11 @@ TEST_F(HdsTest, TestStreamConnectionFailure) { .WillOnce(Return(&async_stream_)); EXPECT_CALL(random_, random()).WillOnce(Return(1000005)).WillRepeatedly(Return(1234567)); - EXPECT_CALL(*retry_timer_, enableTimer(std::chrono::milliseconds(5))); - EXPECT_CALL(*retry_timer_, enableTimer(std::chrono::milliseconds(1567))); - EXPECT_CALL(*retry_timer_, enableTimer(std::chrono::milliseconds(2567))); - EXPECT_CALL(*retry_timer_, enableTimer(std::chrono::milliseconds(4567))); - EXPECT_CALL(*retry_timer_, enableTimer(std::chrono::milliseconds(25567))); + EXPECT_CALL(*retry_timer_, enableTimer(std::chrono::milliseconds(5), _)); + EXPECT_CALL(*retry_timer_, enableTimer(std::chrono::milliseconds(1567), _)); + EXPECT_CALL(*retry_timer_, enableTimer(std::chrono::milliseconds(2567), _)); + EXPECT_CALL(*retry_timer_, enableTimer(std::chrono::milliseconds(4567), _)); + EXPECT_CALL(*retry_timer_, enableTimer(std::chrono::milliseconds(25567), _)); EXPECT_CALL(async_stream_, sendMessageRaw_(_, _)); // Test connection failure and retry @@ -297,7 +297,7 @@ TEST_F(HdsTest, TestSendResponseOneEndpointTimeout) { Network::MockClientConnection* connection_ = new NiceMock(); EXPECT_CALL(dispatcher_, createClientConnection_(_, _, _, _)).WillRepeatedly(Return(connection_)); - EXPECT_CALL(*server_response_timer_, enableTimer(_)).Times(2); + EXPECT_CALL(*server_response_timer_, enableTimer(_, _)).Times(2); EXPECT_CALL(async_stream_, sendMessageRaw_(_, false)); EXPECT_CALL(test_factory_, createClusterInfo(_)).WillOnce(Return(cluster_info_)); EXPECT_CALL(*connection_, setBufferLimits(_)); diff --git a/test/common/upstream/health_checker_impl_test.cc b/test/common/upstream/health_checker_impl_test.cc index 7c8d7cfb5701..cb599a08b5b8 100644 --- a/test/common/upstream/health_checker_impl_test.cc +++ b/test/common/upstream/health_checker_impl_test.cc @@ -543,12 +543,12 @@ class HttpHealthCheckerImplTest : public testing::Test { Host::HealthFlag::FAILED_ACTIVE_HC); expectSessionCreate(); expectStreamCreate(0); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); health_checker_->start(); // Test that failing first disables fast success. EXPECT_CALL(*this, onHostStatus(_, HealthTransition::Unchanged)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_, _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); EXPECT_CALL(*event_logger_, logUnhealthy(_, _, _, true)); respond(0, "503", false, false, false, false, health_checked_cluster); @@ -557,12 +557,12 @@ class HttpHealthCheckerImplTest : public testing::Test { EXPECT_EQ(Host::Health::Unhealthy, cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->health()); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); expectStreamCreate(0); test_sessions_[0]->interval_timer_->invokeCallback(); EXPECT_CALL(*this, onHostStatus(_, HealthTransition::ChangePending)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_, _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respond(0, "200", false, false, false, false, health_checked_cluster); EXPECT_TRUE(cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->healthFlagGet( @@ -570,13 +570,13 @@ class HttpHealthCheckerImplTest : public testing::Test { EXPECT_EQ(Host::Health::Unhealthy, cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->health()); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); expectStreamCreate(0); test_sessions_[0]->interval_timer_->invokeCallback(); EXPECT_CALL(*this, onHostStatus(_, HealthTransition::Changed)); EXPECT_CALL(*event_logger_, logAddHealthy(_, _, false)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_, _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respond(0, "200", false, false, false, false, health_checked_cluster); EXPECT_EQ(Host::Health::Healthy, @@ -606,13 +606,14 @@ TEST_F(HttpHealthCheckerImplTest, Success) { cluster_->info_->stats().upstream_cx_total_.inc(); expectSessionCreate(); expectStreamCreate(0); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); health_checker_->start(); EXPECT_CALL(runtime_.snapshot_, getInteger("health_check.max_interval", _)); EXPECT_CALL(runtime_.snapshot_, getInteger("health_check.min_interval", _)) .WillOnce(Return(45000)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(45000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, + enableTimer(std::chrono::milliseconds(45000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respond(0, "200", false, false, true); EXPECT_EQ(Host::Health::Healthy, cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->health()); @@ -627,7 +628,7 @@ TEST_F(HttpHealthCheckerImplTest, Degraded) { cluster_->info_->stats().upstream_cx_total_.inc(); expectSessionCreate(); expectStreamCreate(0); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); health_checker_->start(); EXPECT_CALL(runtime_.snapshot_, getInteger("health_check.max_interval", _)); @@ -635,19 +636,19 @@ TEST_F(HttpHealthCheckerImplTest, Degraded) { .WillRepeatedly(Return(45000)); // We start off as healthy, and should go degraded after receiving the degraded health response. - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_, _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); EXPECT_CALL(*event_logger_, logDegraded(_, _)); respond(0, "200", false, false, true, false, {}, true); EXPECT_EQ(Host::Health::Degraded, cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->health()); // Then, after receiving a regular health check response we should go back to healthy. - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); expectStreamCreate(0); EXPECT_CALL(runtime_.snapshot_, getInteger("health_check.max_interval", _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); test_sessions_[0]->interval_timer_->invokeCallback(); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_, _)); EXPECT_CALL(*event_logger_, logNoLongerDegraded(_, _)); respond(0, "200", false, false, true, false, {}, false); EXPECT_EQ(Host::Health::Healthy, cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->health()); @@ -661,22 +662,22 @@ TEST_F(HttpHealthCheckerImplTest, SuccessIntervalJitter) { makeTestHost(cluster_->info_, "tcp://127.0.0.1:80")}; expectSessionCreate(); expectStreamCreate(0); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); health_checker_->start(); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_, _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respond(0, "200", false, false, true, true); EXPECT_EQ(Host::Health::Healthy, cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->health()); for (int i = 0; i < 50000; i += 239) { EXPECT_CALL(random_, random()).WillOnce(Return(i)); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); expectStreamCreate(0); test_sessions_[0]->interval_timer_->invokeCallback(); // the jitter is 1000ms here EXPECT_CALL(*test_sessions_[0]->interval_timer_, - enableTimer(std::chrono::milliseconds(5000 + i % 1000))); + enableTimer(std::chrono::milliseconds(5000 + i % 1000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respond(0, "200", false, false, true, true); } @@ -690,24 +691,24 @@ TEST_F(HttpHealthCheckerImplTest, InitialJitterNoTraffic) { makeTestHost(cluster_->info_, "tcp://127.0.0.1:80")}; expectSessionCreate(); expectStreamCreate(0); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_)); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_, _)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); health_checker_->start(); test_sessions_[0]->interval_timer_->invokeCallback(); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_, _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respond(0, "200", false, false, true, true); EXPECT_EQ(Host::Health::Healthy, cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->health()); for (int i = 0; i < 2; i += 1) { EXPECT_CALL(random_, random()).WillOnce(Return(i)); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); expectStreamCreate(0); test_sessions_[0]->interval_timer_->invokeCallback(); // the jitter is 40% of 5000, so should be 2000 EXPECT_CALL(*test_sessions_[0]->interval_timer_, - enableTimer(std::chrono::milliseconds(5000 + i % 2000))); + enableTimer(std::chrono::milliseconds(5000 + i % 2000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respond(0, "200", false, false, true, true); } @@ -721,22 +722,22 @@ TEST_F(HttpHealthCheckerImplTest, SuccessIntervalJitterPercentNoTraffic) { makeTestHost(cluster_->info_, "tcp://127.0.0.1:80")}; expectSessionCreate(); expectStreamCreate(0); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); health_checker_->start(); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_, _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respond(0, "200", false, false, true, true); EXPECT_EQ(Host::Health::Healthy, cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->health()); for (int i = 0; i < 50000; i += 239) { EXPECT_CALL(random_, random()).WillOnce(Return(i)); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); expectStreamCreate(0); test_sessions_[0]->interval_timer_->invokeCallback(); // the jitter is 40% of 5000, so should be 2000 EXPECT_CALL(*test_sessions_[0]->interval_timer_, - enableTimer(std::chrono::milliseconds(5000 + i % 2000))); + enableTimer(std::chrono::milliseconds(5000 + i % 2000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respond(0, "200", false, false, true, true); } @@ -751,22 +752,22 @@ TEST_F(HttpHealthCheckerImplTest, SuccessIntervalJitterPercent) { cluster_->info_->stats().upstream_cx_total_.inc(); expectSessionCreate(); expectStreamCreate(0); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); health_checker_->start(); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_, _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respond(0, "200", false, false, true, true); EXPECT_EQ(Host::Health::Healthy, cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->health()); for (int i = 0; i < 50000; i += 239) { EXPECT_CALL(random_, random()).WillOnce(Return(i)); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); expectStreamCreate(0); test_sessions_[0]->interval_timer_->invokeCallback(); // the jitter is 40% of 1000, so should be 400 EXPECT_CALL(*test_sessions_[0]->interval_timer_, - enableTimer(std::chrono::milliseconds(1000 + i % 400))); + enableTimer(std::chrono::milliseconds(1000 + i % 400), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respond(0, "200", false, false, true, true); } @@ -781,13 +782,14 @@ TEST_F(HttpHealthCheckerImplTest, SuccessWithSpurious100Continue) { cluster_->info_->stats().upstream_cx_total_.inc(); expectSessionCreate(); expectStreamCreate(0); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); health_checker_->start(); EXPECT_CALL(runtime_.snapshot_, getInteger("health_check.max_interval", _)); EXPECT_CALL(runtime_.snapshot_, getInteger("health_check.min_interval", _)) .WillOnce(Return(45000)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(45000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, + enableTimer(std::chrono::milliseconds(45000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); std::unique_ptr continue_headers( @@ -808,13 +810,14 @@ TEST_F(HttpHealthCheckerImplTest, SuccessWithSpuriousMetadata) { cluster_->info_->stats().upstream_cx_total_.inc(); expectSessionCreate(); expectStreamCreate(0); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); health_checker_->start(); EXPECT_CALL(runtime_.snapshot_, getInteger("health_check.max_interval", _)); EXPECT_CALL(runtime_.snapshot_, getInteger("health_check.min_interval", _)) .WillOnce(Return(45000)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(45000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, + enableTimer(std::chrono::milliseconds(45000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); std::unique_ptr metadata_map(new Http::MetadataMap()); @@ -837,19 +840,21 @@ TEST_F(HttpHealthCheckerImplTest, SuccessWithMultipleHosts) { cluster_->info_->stats().upstream_cx_total_.inc(); expectSessionCreate(); expectStreamCreate(0); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); expectSessionCreate(); expectStreamCreate(1); - EXPECT_CALL(*test_sessions_[1]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[1]->timeout_timer_, enableTimer(_, _)); health_checker_->start(); EXPECT_CALL(runtime_.snapshot_, getInteger("health_check.max_interval", _)).Times(2); EXPECT_CALL(runtime_.snapshot_, getInteger("health_check.min_interval", _)) .Times(2) .WillRepeatedly(Return(45000)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(45000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, + enableTimer(std::chrono::milliseconds(45000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); - EXPECT_CALL(*test_sessions_[1]->interval_timer_, enableTimer(std::chrono::milliseconds(45000))); + EXPECT_CALL(*test_sessions_[1]->interval_timer_, + enableTimer(std::chrono::milliseconds(45000), _)); EXPECT_CALL(*test_sessions_[1]->timeout_timer_, disableTimer()); respond(0, "200", false, false, true); respond(1, "200", false, false, true); @@ -870,19 +875,21 @@ TEST_F(HttpHealthCheckerImplTest, SuccessWithMultipleHostSets) { cluster_->info_->stats().upstream_cx_total_.inc(); expectSessionCreate(); expectStreamCreate(0); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); expectSessionCreate(); expectStreamCreate(1); - EXPECT_CALL(*test_sessions_[1]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[1]->timeout_timer_, enableTimer(_, _)); health_checker_->start(); EXPECT_CALL(runtime_.snapshot_, getInteger("health_check.max_interval", _)).Times(2); EXPECT_CALL(runtime_.snapshot_, getInteger("health_check.min_interval", _)) .Times(2) .WillRepeatedly(Return(45000)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(45000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, + enableTimer(std::chrono::milliseconds(45000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); - EXPECT_CALL(*test_sessions_[1]->interval_timer_, enableTimer(std::chrono::milliseconds(45000))); + EXPECT_CALL(*test_sessions_[1]->interval_timer_, + enableTimer(std::chrono::milliseconds(45000), _)); EXPECT_CALL(*test_sessions_[1]->timeout_timer_, disableTimer()); respond(0, "200", false, false, true); respond(1, "200", false, false, true); @@ -924,7 +931,7 @@ TEST_F(HttpHealthCheckerImplTest, ZeroRetryInterval) { cluster_->info_->stats().upstream_cx_total_.inc(); expectSessionCreate(); expectStreamCreate(0); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); EXPECT_CALL(test_sessions_[0]->request_encoder_, encodeHeaders(_, true)) .WillOnce(Invoke([&](const Http::HeaderMap& headers, bool) { EXPECT_EQ(headers.Host()->value().getStringView(), host); @@ -936,7 +943,7 @@ TEST_F(HttpHealthCheckerImplTest, ZeroRetryInterval) { EXPECT_CALL(runtime_.snapshot_, getInteger("health_check.max_interval", _)).WillOnce(Return(0)); EXPECT_CALL(runtime_.snapshot_, getInteger("health_check.min_interval", _)).WillOnce(Return(0)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(1))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(1), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); absl::optional health_checked_cluster("locations-production-iad"); respond(0, "200", false, false, true, false, health_checked_cluster); @@ -957,7 +964,7 @@ TEST_F(HttpHealthCheckerImplTest, SuccessServiceCheck) { cluster_->info_->stats().upstream_cx_total_.inc(); expectSessionCreate(); expectStreamCreate(0); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); EXPECT_CALL(test_sessions_[0]->request_encoder_, encodeHeaders(_, true)) .WillOnce(Invoke([&](const Http::HeaderMap& headers, bool) { EXPECT_EQ(headers.Host()->value().getStringView(), host); @@ -970,7 +977,8 @@ TEST_F(HttpHealthCheckerImplTest, SuccessServiceCheck) { EXPECT_CALL(runtime_.snapshot_, getInteger("health_check.max_interval", _)); EXPECT_CALL(runtime_.snapshot_, getInteger("health_check.min_interval", _)) .WillOnce(Return(45000)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(45000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, + enableTimer(std::chrono::milliseconds(45000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); absl::optional health_checked_cluster("locations-production-iad"); respond(0, "200", false, false, true, false, health_checked_cluster); @@ -992,7 +1000,7 @@ TEST_F(HttpHealthCheckerImplTest, SuccessServiceCheckWithCustomHostValue) { cluster_->info_->stats().upstream_cx_total_.inc(); expectSessionCreate(); expectStreamCreate(0); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); EXPECT_CALL(test_sessions_[0]->request_encoder_, encodeHeaders(_, true)) .WillOnce(Invoke([&](const Http::HeaderMap& headers, bool) { EXPECT_EQ(headers.Host()->value().getStringView(), host); @@ -1003,7 +1011,8 @@ TEST_F(HttpHealthCheckerImplTest, SuccessServiceCheckWithCustomHostValue) { EXPECT_CALL(runtime_.snapshot_, getInteger("health_check.max_interval", _)); EXPECT_CALL(runtime_.snapshot_, getInteger("health_check.min_interval", _)) .WillOnce(Return(45000)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(45000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, + enableTimer(std::chrono::milliseconds(45000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); absl::optional health_checked_cluster("locations-production-iad"); respond(0, "200", false, false, true, false, health_checked_cluster); @@ -1053,7 +1062,7 @@ TEST_F(HttpHealthCheckerImplTest, SuccessServiceCheckWithAdditionalHeaders) { cluster_->info_->stats().upstream_cx_total_.inc(); expectSessionCreate(); expectStreamCreate(0); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); EXPECT_CALL(test_sessions_[0]->request_encoder_, encodeHeaders(_, true)) .WillRepeatedly(Invoke([&](const Http::HeaderMap& headers, bool) { EXPECT_EQ(headers.get(header_ok)->value().getStringView(), value_ok); @@ -1079,13 +1088,14 @@ TEST_F(HttpHealthCheckerImplTest, SuccessServiceCheckWithAdditionalHeaders) { EXPECT_CALL(runtime_.snapshot_, getInteger("health_check.max_interval", _)); EXPECT_CALL(runtime_.snapshot_, getInteger("health_check.min_interval", _)) .WillOnce(Return(45000)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(45000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, + enableTimer(std::chrono::milliseconds(45000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); absl::optional health_checked_cluster("locations-production-iad"); respond(0, "200", false, false, true, false, health_checked_cluster); EXPECT_EQ(Host::Health::Healthy, cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->health()); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); expectStreamCreate(0); test_sessions_[0]->interval_timer_->invokeCallback(); } @@ -1110,7 +1120,7 @@ TEST_F(HttpHealthCheckerImplTest, SuccessServiceCheckWithoutUserAgent) { cluster_->info_->stats().upstream_cx_total_.inc(); expectSessionCreate(); expectStreamCreate(0); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); EXPECT_CALL(test_sessions_[0]->request_encoder_, encodeHeaders(_, true)) .WillRepeatedly(Invoke( [&](const Http::HeaderMap& headers, bool) { EXPECT_EQ(headers.UserAgent(), nullptr); })); @@ -1119,13 +1129,14 @@ TEST_F(HttpHealthCheckerImplTest, SuccessServiceCheckWithoutUserAgent) { EXPECT_CALL(runtime_.snapshot_, getInteger("health_check.max_interval", _)); EXPECT_CALL(runtime_.snapshot_, getInteger("health_check.min_interval", _)) .WillOnce(Return(45000)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(45000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, + enableTimer(std::chrono::milliseconds(45000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); absl::optional health_checked_cluster("locations-production-iad"); respond(0, "200", false, false, true, false, health_checked_cluster); EXPECT_EQ(Host::Health::Healthy, cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->health()); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); expectStreamCreate(0); test_sessions_[0]->interval_timer_->invokeCallback(); } @@ -1144,13 +1155,14 @@ TEST_F(HttpHealthCheckerImplTest, ServiceDoesNotMatchFail) { cluster_->info_->stats().upstream_cx_total_.inc(); expectSessionCreate(); expectStreamCreate(0); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); health_checker_->start(); EXPECT_CALL(runtime_.snapshot_, getInteger("health_check.max_interval", _)); EXPECT_CALL(runtime_.snapshot_, getInteger("health_check.min_interval", _)) .WillOnce(Return(45000)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(45000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, + enableTimer(std::chrono::milliseconds(45000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); absl::optional health_checked_cluster("api-production-iad"); respond(0, "200", false, false, true, false, health_checked_cluster); @@ -1174,13 +1186,14 @@ TEST_F(HttpHealthCheckerImplTest, ServiceNotPresentInResponseFail) { cluster_->info_->stats().upstream_cx_total_.inc(); expectSessionCreate(); expectStreamCreate(0); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); health_checker_->start(); EXPECT_CALL(runtime_.snapshot_, getInteger("health_check.max_interval", _)); EXPECT_CALL(runtime_.snapshot_, getInteger("health_check.min_interval", _)) .WillOnce(Return(45000)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(45000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, + enableTimer(std::chrono::milliseconds(45000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respond(0, "200", false, false, true, false); EXPECT_TRUE(cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->healthFlagGet( @@ -1201,13 +1214,14 @@ TEST_F(HttpHealthCheckerImplTest, ServiceCheckRuntimeOff) { cluster_->info_->stats().upstream_cx_total_.inc(); expectSessionCreate(); expectStreamCreate(0); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); health_checker_->start(); EXPECT_CALL(runtime_.snapshot_, getInteger("health_check.max_interval", _)); EXPECT_CALL(runtime_.snapshot_, getInteger("health_check.min_interval", _)) .WillOnce(Return(45000)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(45000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, + enableTimer(std::chrono::milliseconds(45000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); absl::optional health_checked_cluster("api-production-iad"); respond(0, "200", false, false, true, false, health_checked_cluster); @@ -1230,10 +1244,10 @@ TEST_F(HttpHealthCheckerImplTest, SuccessNoTraffic) { makeTestHost(cluster_->info_, "tcp://127.0.0.1:80")}; expectSessionCreate(); expectStreamCreate(0); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); health_checker_->start(); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(5000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(5000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respond(0, "200", false, false, true, true); EXPECT_EQ(Host::Health::Healthy, cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->health()); @@ -1247,7 +1261,7 @@ TEST_F(HttpHealthCheckerImplTest, SuccessStartFailedSuccessFirst) { Host::HealthFlag::FAILED_ACTIVE_HC); expectSessionCreate(); expectStreamCreate(0); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); health_checker_->start(); // Test fast success immediately moves us to healthy. @@ -1255,7 +1269,7 @@ TEST_F(HttpHealthCheckerImplTest, SuccessStartFailedSuccessFirst) { EXPECT_CALL(*event_logger_, logAddHealthy(_, _, true)); EXPECT_CALL(runtime_.snapshot_, getInteger("health_check.max_interval", _)).WillOnce(Return(500)); EXPECT_CALL(runtime_.snapshot_, getInteger("health_check.min_interval", _)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(500))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(500), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respond(0, "200", false); EXPECT_EQ(Host::Health::Healthy, cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->health()); @@ -1278,7 +1292,7 @@ TEST_F(HttpHealthCheckerImplTest, HttpFailRemoveHostInCallbackNoClose) { makeTestHost(cluster_->info_, "tcp://127.0.0.1:80")}; expectSessionCreate(); expectStreamCreate(0); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); health_checker_->start(); EXPECT_CALL(*this, onHostStatus(_, HealthTransition::Changed)) @@ -1287,7 +1301,7 @@ TEST_F(HttpHealthCheckerImplTest, HttpFailRemoveHostInCallbackNoClose) { cluster_->prioritySet().runUpdateCallbacks(0, {}, {host}); })); EXPECT_CALL(*event_logger_, logEjectUnhealthy(_, _, _)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_)).Times(0); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_, _)).Times(0); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()).Times(0); EXPECT_CALL(*event_logger_, logUnhealthy(_, _, _, true)); respond(0, "503", false); @@ -1300,7 +1314,7 @@ TEST_F(HttpHealthCheckerImplTest, HttpFailRemoveHostInCallbackClose) { makeTestHost(cluster_->info_, "tcp://127.0.0.1:80")}; expectSessionCreate(); expectStreamCreate(0); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); health_checker_->start(); EXPECT_CALL(*this, onHostStatus(_, HealthTransition::Changed)) @@ -1309,7 +1323,7 @@ TEST_F(HttpHealthCheckerImplTest, HttpFailRemoveHostInCallbackClose) { cluster_->prioritySet().runUpdateCallbacks(0, {}, {host}); })); EXPECT_CALL(*event_logger_, logEjectUnhealthy(_, _, _)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_)).Times(0); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_, _)).Times(0); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()).Times(0); EXPECT_CALL(*event_logger_, logUnhealthy(_, _, _, true)); respond(0, "503", true); @@ -1321,12 +1335,12 @@ TEST_F(HttpHealthCheckerImplTest, HttpFail) { makeTestHost(cluster_->info_, "tcp://127.0.0.1:80")}; expectSessionCreate(); expectStreamCreate(0); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); health_checker_->start(); EXPECT_CALL(*this, onHostStatus(_, HealthTransition::Changed)); EXPECT_CALL(*event_logger_, logEjectUnhealthy(_, _, _)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_, _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); EXPECT_CALL(*event_logger_, logUnhealthy(_, _, _, true)); respond(0, "503", false); @@ -1337,12 +1351,12 @@ TEST_F(HttpHealthCheckerImplTest, HttpFail) { EXPECT_EQ(cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->getActiveHealthFailureType(), Host::ActiveHealthFailureType::UNHEALTHY); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); expectStreamCreate(0); test_sessions_[0]->interval_timer_->invokeCallback(); EXPECT_CALL(*this, onHostStatus(_, HealthTransition::ChangePending)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_, _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respond(0, "200", false); EXPECT_TRUE(cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->healthFlagGet( @@ -1350,13 +1364,13 @@ TEST_F(HttpHealthCheckerImplTest, HttpFail) { EXPECT_EQ(Host::Health::Unhealthy, cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->health()); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); expectStreamCreate(0); test_sessions_[0]->interval_timer_->invokeCallback(); EXPECT_CALL(*this, onHostStatus(_, HealthTransition::Changed)); EXPECT_CALL(*event_logger_, logAddHealthy(_, _, false)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_, _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respond(0, "200", false); EXPECT_EQ(Host::Health::Healthy, cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->health()); @@ -1368,12 +1382,12 @@ TEST_F(HttpHealthCheckerImplTest, HttpFailLogError) { makeTestHost(cluster_->info_, "tcp://127.0.0.1:80")}; expectSessionCreate(); expectStreamCreate(0); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); health_checker_->start(); EXPECT_CALL(*this, onHostStatus(_, HealthTransition::Changed)); EXPECT_CALL(*event_logger_, logEjectUnhealthy(_, _, _)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_, _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); EXPECT_CALL(*event_logger_, logUnhealthy(_, _, _, true)); respond(0, "503", false); @@ -1384,13 +1398,13 @@ TEST_F(HttpHealthCheckerImplTest, HttpFailLogError) { EXPECT_EQ(cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->getActiveHealthFailureType(), Host::ActiveHealthFailureType::UNHEALTHY); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); expectStreamCreate(0); test_sessions_[0]->interval_timer_->invokeCallback(); // logUnhealthy is called with first_check == false EXPECT_CALL(*this, onHostStatus(_, HealthTransition::Unchanged)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_, _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); EXPECT_CALL(*event_logger_, logUnhealthy(_, _, _, false)); respond(0, "503", false); @@ -1401,12 +1415,12 @@ TEST_F(HttpHealthCheckerImplTest, HttpFailLogError) { EXPECT_EQ(cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->getActiveHealthFailureType(), Host::ActiveHealthFailureType::UNHEALTHY); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); expectStreamCreate(0); test_sessions_[0]->interval_timer_->invokeCallback(); EXPECT_CALL(*this, onHostStatus(_, HealthTransition::ChangePending)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_, _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respond(0, "200", false); EXPECT_TRUE(cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->healthFlagGet( @@ -1414,13 +1428,13 @@ TEST_F(HttpHealthCheckerImplTest, HttpFailLogError) { EXPECT_EQ(Host::Health::Unhealthy, cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->health()); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); expectStreamCreate(0); test_sessions_[0]->interval_timer_->invokeCallback(); EXPECT_CALL(*this, onHostStatus(_, HealthTransition::Changed)); EXPECT_CALL(*event_logger_, logAddHealthy(_, _, false)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_, _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respond(0, "200", false); EXPECT_EQ(Host::Health::Healthy, cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->health()); @@ -1435,23 +1449,23 @@ TEST_F(HttpHealthCheckerImplTest, Disconnect) { makeTestHost(cluster_->info_, "tcp://127.0.0.1:80")}; expectSessionCreate(); expectStreamCreate(0); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); health_checker_->start(); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_, _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); test_sessions_[0]->client_connection_->raiseEvent(Network::ConnectionEvent::RemoteClose); EXPECT_EQ(Host::Health::Healthy, cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->health()); expectClientCreate(0); expectStreamCreate(0); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); test_sessions_[0]->interval_timer_->invokeCallback(); EXPECT_CALL(*this, onHostStatus(cluster_->prioritySet().getMockHostSet(0)->hosts_[0], HealthTransition::Changed)); EXPECT_CALL(*event_logger_, logEjectUnhealthy(_, _, _)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_, _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); test_sessions_[0]->client_connection_->raiseEvent(Network::ConnectionEvent::RemoteClose); EXPECT_TRUE(cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->healthFlagGet( @@ -1466,12 +1480,12 @@ TEST_F(HttpHealthCheckerImplTest, Timeout) { makeTestHost(cluster_->info_, "tcp://127.0.0.1:80")}; expectSessionCreate(); expectStreamCreate(0); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); health_checker_->start(); EXPECT_CALL(*this, onHostStatus(_, HealthTransition::Changed)); EXPECT_CALL(*test_sessions_[0]->client_connection_, close(_)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_, _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); EXPECT_CALL(*event_logger_, logUnhealthy(_, _, _, true)); EXPECT_CALL(*event_logger_, logEjectUnhealthy(_, _, _)); @@ -1491,7 +1505,7 @@ TEST_F(HttpHealthCheckerImplTest, TimeoutThenSuccess) { makeTestHost(cluster_->info_, "tcp://127.0.0.1:80")}; expectSessionCreate(); expectStreamCreate(0); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); health_checker_->start(); // Do a response that is not complete but includes headers. @@ -1502,18 +1516,18 @@ TEST_F(HttpHealthCheckerImplTest, TimeoutThenSuccess) { EXPECT_CALL(*this, onHostStatus(_, HealthTransition::ChangePending)); EXPECT_CALL(*event_logger_, logUnhealthy(_, _, _, true)); EXPECT_CALL(*test_sessions_[0]->client_connection_, close(_)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_, _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); test_sessions_[0]->timeout_timer_->invokeCallback(); EXPECT_EQ(Host::Health::Healthy, cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->health()); expectClientCreate(0); expectStreamCreate(0); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); test_sessions_[0]->interval_timer_->invokeCallback(); EXPECT_CALL(*this, onHostStatus(_, HealthTransition::Unchanged)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_, _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respond(0, "200", false, false, true); EXPECT_EQ(Host::Health::Healthy, cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->health()); @@ -1526,24 +1540,24 @@ TEST_F(HttpHealthCheckerImplTest, TimeoutThenRemoteClose) { makeTestHost(cluster_->info_, "tcp://127.0.0.1:80")}; expectSessionCreate(); expectStreamCreate(0); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); health_checker_->start(); EXPECT_CALL(*this, onHostStatus(_, HealthTransition::ChangePending)); EXPECT_CALL(*test_sessions_[0]->client_connection_, close(_)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_, _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); test_sessions_[0]->timeout_timer_->invokeCallback(); EXPECT_EQ(Host::Health::Healthy, cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->health()); expectClientCreate(0); expectStreamCreate(0); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); test_sessions_[0]->interval_timer_->invokeCallback(); EXPECT_CALL(*this, onHostStatus(_, HealthTransition::Changed)); EXPECT_CALL(*event_logger_, logEjectUnhealthy(_, _, _)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_, _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); test_sessions_[0]->client_connection_->raiseEvent(Network::ConnectionEvent::RemoteClose); EXPECT_TRUE(cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->healthFlagGet( @@ -1562,11 +1576,11 @@ TEST_F(HttpHealthCheckerImplTest, TimeoutAfterDisconnect) { expectSessionCreate(); expectStreamCreate(0); EXPECT_CALL(*event_logger_, logUnhealthy(_, _, _, true)); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)).Times(2); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)).Times(2); health_checker_->start(); EXPECT_CALL(*this, onHostStatus(_, HealthTransition::ChangePending)).Times(1); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_)).Times(2); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_, _)).Times(2); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); for (auto& session : test_sessions_) { session->client_connection_->close(Network::ConnectionCloseType::NoFlush); @@ -1576,7 +1590,7 @@ TEST_F(HttpHealthCheckerImplTest, TimeoutAfterDisconnect) { EXPECT_CALL(*event_logger_, logEjectUnhealthy(_, _, _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); - test_sessions_[0]->timeout_timer_->enableTimer(std::chrono::seconds(10)); + test_sessions_[0]->timeout_timer_->enableTimer(std::chrono::seconds(10), nullptr); test_sessions_[0]->timeout_timer_->invokeCallback(); EXPECT_EQ(Host::Health::Unhealthy, cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->health()); @@ -1590,7 +1604,7 @@ TEST_F(HttpHealthCheckerImplTest, DynamicAddAndRemove) { expectStreamCreate(0); cluster_->prioritySet().getMockHostSet(0)->hosts_ = { makeTestHost(cluster_->info_, "tcp://127.0.0.1:80")}; - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); cluster_->prioritySet().getMockHostSet(0)->runCallbacks( {cluster_->prioritySet().getMockHostSet(0)->hosts_.back()}, {}); @@ -1608,17 +1622,17 @@ TEST_F(HttpHealthCheckerImplTest, ConnectionClose) { makeTestHost(cluster_->info_, "tcp://127.0.0.1:80")}; expectSessionCreate(); expectStreamCreate(0); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); health_checker_->start(); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_, _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respond(0, "200", true); EXPECT_EQ(Host::Health::Healthy, cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->health()); expectClientCreate(0); expectStreamCreate(0); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); test_sessions_[0]->interval_timer_->invokeCallback(); } @@ -1630,17 +1644,17 @@ TEST_F(HttpHealthCheckerImplTest, ProxyConnectionClose) { makeTestHost(cluster_->info_, "tcp://127.0.0.1:80")}; expectSessionCreate(); expectStreamCreate(0); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); health_checker_->start(); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_, _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respond(0, "200", false, true); EXPECT_EQ(Host::Health::Healthy, cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->health()); expectClientCreate(0); expectStreamCreate(0); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); test_sessions_[0]->interval_timer_->invokeCallback(); } @@ -1650,39 +1664,39 @@ TEST_F(HttpHealthCheckerImplTest, HealthCheckIntervals) { makeTestHost(cluster_->info_, "tcp://128.0.0.1:80")}; expectSessionCreate(); expectStreamCreate(0); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); health_checker_->start(); // First check should respect no_traffic_interval setting. EXPECT_CALL(*this, onHostStatus(_, HealthTransition::Unchanged)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(5000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(5000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respond(0, "200", false); cluster_->info_->stats().upstream_cx_total_.inc(); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); // Needed after a response is sent. expectStreamCreate(0); test_sessions_[0]->interval_timer_->invokeCallback(); // Follow up successful checks should respect interval setting. EXPECT_CALL(*this, onHostStatus(_, HealthTransition::Unchanged)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(1000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(1000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respond(0, "200", false); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); // Needed after a response is sent. expectStreamCreate(0); test_sessions_[0]->interval_timer_->invokeCallback(); // Follow up successful checks should respect interval setting. EXPECT_CALL(*this, onHostStatus(_, HealthTransition::Unchanged)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(1000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(1000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respond(0, "200", false); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); // Needed after a response is sent. expectStreamCreate(0); test_sessions_[0]->interval_timer_->invokeCallback(); @@ -1692,33 +1706,33 @@ TEST_F(HttpHealthCheckerImplTest, HealthCheckIntervals) { // check respects "unhealthy_interval". EXPECT_CALL(*this, onHostStatus(_, HealthTransition::Changed)); EXPECT_CALL(*event_logger_, logEjectUnhealthy(_, _, _)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(2000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(2000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respond(0, "503", false); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); // Needed after a response is sent. expectStreamCreate(0); test_sessions_[0]->interval_timer_->invokeCallback(); // Subsequent failing checks should respect unhealthy_interval. EXPECT_CALL(*this, onHostStatus(_, HealthTransition::Unchanged)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(2000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(2000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respond(0, "503", false); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); // Needed after a response is sent. expectStreamCreate(0); test_sessions_[0]->interval_timer_->invokeCallback(); // Subsequent failing checks should respect unhealthy_interval. EXPECT_CALL(*this, onHostStatus(_, HealthTransition::Unchanged)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(2000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(2000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respond(0, "503", false); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); // Needed after a response is sent. expectStreamCreate(0); test_sessions_[0]->interval_timer_->invokeCallback(); @@ -1726,21 +1740,21 @@ TEST_F(HttpHealthCheckerImplTest, HealthCheckIntervals) { // When transitioning to a successful state, checks should respect healthy_edge_interval. Health // state should be delayed pending healthy threshold. EXPECT_CALL(*this, onHostStatus(_, HealthTransition::ChangePending)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(4000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(4000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respond(0, "200", false); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); // Needed after a response is sent. expectStreamCreate(0); test_sessions_[0]->interval_timer_->invokeCallback(); EXPECT_CALL(*this, onHostStatus(_, HealthTransition::ChangePending)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(4000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(4000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respond(0, "200", false); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); // Needed after a response is sent. expectStreamCreate(0); test_sessions_[0]->interval_timer_->invokeCallback(); @@ -1749,22 +1763,22 @@ TEST_F(HttpHealthCheckerImplTest, HealthCheckIntervals) { // the default interval. EXPECT_CALL(*this, onHostStatus(_, HealthTransition::Changed)); EXPECT_CALL(*event_logger_, logAddHealthy(_, _, false)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(1000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(1000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respond(0, "200", false); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); // Needed after a response is sent. expectStreamCreate(0); test_sessions_[0]->interval_timer_->invokeCallback(); // Subsequent checks shouldn't change the state. EXPECT_CALL(*this, onHostStatus(_, HealthTransition::Unchanged)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(1000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(1000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respond(0, "200", false); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); // Needed after a response is sent. expectStreamCreate(0); test_sessions_[0]->interval_timer_->invokeCallback(); @@ -1773,11 +1787,11 @@ TEST_F(HttpHealthCheckerImplTest, HealthCheckIntervals) { // timeout, being a network type failure, should respect unhealthy threshold before changing the // health state. EXPECT_CALL(*this, onHostStatus(_, HealthTransition::ChangePending)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(3000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(3000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); test_sessions_[0]->timeout_timer_->invokeCallback(); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); // Needed after a network timeout. expectClientCreate(0); // Needed after a response is sent. @@ -1785,11 +1799,11 @@ TEST_F(HttpHealthCheckerImplTest, HealthCheckIntervals) { test_sessions_[0]->interval_timer_->invokeCallback(); EXPECT_CALL(*this, onHostStatus(_, HealthTransition::ChangePending)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(3000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(3000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); test_sessions_[0]->timeout_timer_->invokeCallback(); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); // Needed after a network timeout. expectClientCreate(0); // Needed after a response is sent. @@ -1800,11 +1814,11 @@ TEST_F(HttpHealthCheckerImplTest, HealthCheckIntervals) { // reached, health state should also change. EXPECT_CALL(*this, onHostStatus(_, HealthTransition::Changed)); EXPECT_CALL(*event_logger_, logEjectUnhealthy(_, _, _)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(2000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(2000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); test_sessions_[0]->timeout_timer_->invokeCallback(); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); // Needed after a network timeout. expectClientCreate(0); // Needed after a response is sent. @@ -1813,11 +1827,11 @@ TEST_F(HttpHealthCheckerImplTest, HealthCheckIntervals) { // Remaining failing checks shouldn't change the state. EXPECT_CALL(*this, onHostStatus(_, HealthTransition::Unchanged)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(2000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(2000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); test_sessions_[0]->timeout_timer_->invokeCallback(); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); // Needed after a network timeout. expectClientCreate(0); // Needed after a response is sent. @@ -1826,21 +1840,21 @@ TEST_F(HttpHealthCheckerImplTest, HealthCheckIntervals) { // When transitioning to a successful state, checks should respect healthy_edge_interval. EXPECT_CALL(*this, onHostStatus(_, HealthTransition::ChangePending)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(4000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(4000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respond(0, "200", false); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); // Needed after a response is sent. expectStreamCreate(0); test_sessions_[0]->interval_timer_->invokeCallback(); EXPECT_CALL(*this, onHostStatus(_, HealthTransition::ChangePending)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(4000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(4000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respond(0, "200", false); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); // Needed after a response is sent. expectStreamCreate(0); test_sessions_[0]->interval_timer_->invokeCallback(); @@ -1849,18 +1863,18 @@ TEST_F(HttpHealthCheckerImplTest, HealthCheckIntervals) { // the default interval. EXPECT_CALL(*this, onHostStatus(_, HealthTransition::Changed)); EXPECT_CALL(*event_logger_, logAddHealthy(_, _, false)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(1000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(1000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respond(0, "200", false); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); // Needed after a response is sent. expectStreamCreate(0); test_sessions_[0]->interval_timer_->invokeCallback(); // Subsequent checks shouldn't change the state. EXPECT_CALL(*this, onHostStatus(_, HealthTransition::Unchanged)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(1000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(1000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respond(0, "200", false); } @@ -1873,10 +1887,10 @@ TEST_F(HttpHealthCheckerImplTest, RemoteCloseBetweenChecks) { makeTestHost(cluster_->info_, "tcp://127.0.0.1:80")}; expectSessionCreate(); expectStreamCreate(0); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); health_checker_->start(); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_, _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respond(0, "200", false); EXPECT_EQ(Host::Health::Healthy, cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->health()); @@ -1885,10 +1899,10 @@ TEST_F(HttpHealthCheckerImplTest, RemoteCloseBetweenChecks) { expectClientCreate(0); expectStreamCreate(0); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); test_sessions_[0]->interval_timer_->invokeCallback(); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_, _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respond(0, "200", false); EXPECT_EQ(Host::Health::Healthy, cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->health()); @@ -1903,10 +1917,10 @@ TEST_F(HttpHealthCheckerImplTest, DontReuseConnectionBetweenChecks) { makeTestHost(cluster_->info_, "tcp://127.0.0.1:80")}; expectSessionCreate(); expectStreamCreate(0); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); health_checker_->start(); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_, _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respond(0, "200", false); EXPECT_EQ(Host::Health::Healthy, cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->health()); @@ -1916,10 +1930,10 @@ TEST_F(HttpHealthCheckerImplTest, DontReuseConnectionBetweenChecks) { // closes the connection. expectClientCreate(0); expectStreamCreate(0); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); test_sessions_[0]->interval_timer_->invokeCallback(); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_, _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respond(0, "200", false); EXPECT_EQ(Host::Health::Healthy, cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->health()); @@ -1933,10 +1947,10 @@ TEST_F(HttpHealthCheckerImplTest, StreamReachesWatermarkDuringCheck) { makeTestHost(cluster_->info_, "tcp://127.0.0.1:80")}; expectSessionCreate(); expectStreamCreate(0); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); health_checker_->start(); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_, _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); test_sessions_[0]->request_encoder_.stream_.runHighWatermarkCallbacks(); @@ -1954,10 +1968,10 @@ TEST_F(HttpHealthCheckerImplTest, ConnectionReachesWatermarkDuringCheck) { makeTestHost(cluster_->info_, "tcp://127.0.0.1:80")}; expectSessionCreate(); expectStreamCreate(0); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); health_checker_->start(); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(_, _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); test_sessions_[0]->client_connection_->runHighWatermarkCallbacks(); @@ -1982,7 +1996,7 @@ TEST_F(HttpHealthCheckerImplTest, SuccessServiceCheckWithAltPort) { cluster_->info_->stats().upstream_cx_total_.inc(); expectSessionCreate(hosts); expectStreamCreate(0); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); EXPECT_CALL(test_sessions_[0]->request_encoder_, encodeHeaders(_, true)) .WillOnce(Invoke([&](const Http::HeaderMap& headers, bool) { EXPECT_EQ(headers.Host()->value().getStringView(), host); @@ -1993,7 +2007,8 @@ TEST_F(HttpHealthCheckerImplTest, SuccessServiceCheckWithAltPort) { EXPECT_CALL(runtime_.snapshot_, getInteger("health_check.max_interval", _)); EXPECT_CALL(runtime_.snapshot_, getInteger("health_check.min_interval", _)) .WillOnce(Return(45000)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(45000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, + enableTimer(std::chrono::milliseconds(45000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); absl::optional health_checked_cluster("locations-production-iad"); respond(0, "200", false, false, true, false, health_checked_cluster); @@ -2013,19 +2028,21 @@ TEST_F(HttpHealthCheckerImplTest, SuccessWithMultipleHostsAndAltPort) { cluster_->info_->stats().upstream_cx_total_.inc(); expectSessionCreate(hosts); expectStreamCreate(0); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); expectSessionCreate(hosts); expectStreamCreate(1); - EXPECT_CALL(*test_sessions_[1]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[1]->timeout_timer_, enableTimer(_, _)); health_checker_->start(); EXPECT_CALL(runtime_.snapshot_, getInteger("health_check.max_interval", _)).Times(2); EXPECT_CALL(runtime_.snapshot_, getInteger("health_check.min_interval", _)) .Times(2) .WillRepeatedly(Return(45000)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(45000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, + enableTimer(std::chrono::milliseconds(45000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); - EXPECT_CALL(*test_sessions_[1]->interval_timer_, enableTimer(std::chrono::milliseconds(45000))); + EXPECT_CALL(*test_sessions_[1]->interval_timer_, + enableTimer(std::chrono::milliseconds(45000), _)); EXPECT_CALL(*test_sessions_[1]->timeout_timer_, disableTimer()); respond(0, "200", false, false, true); respond(1, "200", false, false, true); @@ -2410,7 +2427,7 @@ TEST_F(TcpHealthCheckerImplTest, Success) { expectSessionCreate(); expectClientCreate(); EXPECT_CALL(*connection_, write(_, _)); - EXPECT_CALL(*timeout_timer_, enableTimer(_)); + EXPECT_CALL(*timeout_timer_, enableTimer(_, _)); health_checker_->start(); connection_->runHighWatermarkCallbacks(); @@ -2418,7 +2435,7 @@ TEST_F(TcpHealthCheckerImplTest, Success) { connection_->raiseEvent(Network::ConnectionEvent::Connected); EXPECT_CALL(*timeout_timer_, disableTimer()); - EXPECT_CALL(*interval_timer_, enableTimer(_)); + EXPECT_CALL(*interval_timer_, enableTimer(_, _)); Buffer::OwnedImpl response; add_uint8(response, 2); read_filter_->onData(response, false); @@ -2434,14 +2451,14 @@ TEST_F(TcpHealthCheckerImplTest, DataWithoutReusingConnection) { expectSessionCreate(); expectClientCreate(); EXPECT_CALL(*connection_, write(_, _)).Times(1); - EXPECT_CALL(*timeout_timer_, enableTimer(_)); + EXPECT_CALL(*timeout_timer_, enableTimer(_, _)); health_checker_->start(); connection_->raiseEvent(Network::ConnectionEvent::Connected); // Expected execution flow when a healthcheck is successful and reuse_connection is false. EXPECT_CALL(*timeout_timer_, disableTimer()); - EXPECT_CALL(*interval_timer_, enableTimer(_)); + EXPECT_CALL(*interval_timer_, enableTimer(_, _)); EXPECT_CALL(*connection_, close(Network::ConnectionCloseType::NoFlush)).Times(1); Buffer::OwnedImpl response; @@ -2463,7 +2480,7 @@ TEST_F(TcpHealthCheckerImplTest, WrongData) { expectSessionCreate(); expectClientCreate(); EXPECT_CALL(*connection_, write(_, _)).Times(1); - EXPECT_CALL(*timeout_timer_, enableTimer(_)); + EXPECT_CALL(*timeout_timer_, enableTimer(_, _)); health_checker_->start(); connection_->raiseEvent(Network::ConnectionEvent::Connected); @@ -2492,7 +2509,7 @@ TEST_F(TcpHealthCheckerImplTest, TimeoutThenRemoteClose) { cluster_->prioritySet().getMockHostSet(0)->hosts_ = { makeTestHost(cluster_->info_, "tcp://127.0.0.1:80")}; EXPECT_CALL(*connection_, write(_, _)); - EXPECT_CALL(*timeout_timer_, enableTimer(_)); + EXPECT_CALL(*timeout_timer_, enableTimer(_, _)); cluster_->prioritySet().getMockHostSet(0)->runCallbacks( {cluster_->prioritySet().getMockHostSet(0)->hosts_.back()}, {}); @@ -2506,7 +2523,7 @@ TEST_F(TcpHealthCheckerImplTest, TimeoutThenRemoteClose) { EXPECT_CALL(*connection_, close(_)); EXPECT_CALL(*event_logger_, logUnhealthy(_, _, _, true)); EXPECT_CALL(*timeout_timer_, disableTimer()); - EXPECT_CALL(*interval_timer_, enableTimer(_)); + EXPECT_CALL(*interval_timer_, enableTimer(_, _)); timeout_timer_->invokeCallback(); EXPECT_EQ(cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->getActiveHealthFailureType(), Host::ActiveHealthFailureType::TIMEOUT); @@ -2514,14 +2531,14 @@ TEST_F(TcpHealthCheckerImplTest, TimeoutThenRemoteClose) { expectClientCreate(); EXPECT_CALL(*connection_, write(_, _)); - EXPECT_CALL(*timeout_timer_, enableTimer(_)); + EXPECT_CALL(*timeout_timer_, enableTimer(_, _)); interval_timer_->invokeCallback(); connection_->raiseEvent(Network::ConnectionEvent::Connected); EXPECT_CALL(*event_logger_, logEjectUnhealthy(_, _, _)); EXPECT_CALL(*timeout_timer_, disableTimer()); - EXPECT_CALL(*interval_timer_, enableTimer(_)); + EXPECT_CALL(*interval_timer_, enableTimer(_, _)); connection_->raiseEvent(Network::ConnectionEvent::RemoteClose); EXPECT_TRUE(cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->healthFlagGet( Host::HealthFlag::FAILED_ACTIVE_HC)); @@ -2530,7 +2547,7 @@ TEST_F(TcpHealthCheckerImplTest, TimeoutThenRemoteClose) { expectClientCreate(); EXPECT_CALL(*connection_, write(_, _)); - EXPECT_CALL(*timeout_timer_, enableTimer(_)); + EXPECT_CALL(*timeout_timer_, enableTimer(_, _)); interval_timer_->invokeCallback(); connection_->raiseEvent(Network::ConnectionEvent::Connected); @@ -2552,7 +2569,7 @@ TEST_F(TcpHealthCheckerImplTest, Timeout) { cluster_->prioritySet().getMockHostSet(0)->hosts_ = { makeTestHost(cluster_->info_, "tcp://127.0.0.1:80")}; EXPECT_CALL(*connection_, write(_, _)); - EXPECT_CALL(*timeout_timer_, enableTimer(_)); + EXPECT_CALL(*timeout_timer_, enableTimer(_, _)); cluster_->prioritySet().getMockHostSet(0)->runCallbacks( {cluster_->prioritySet().getMockHostSet(0)->hosts_.back()}, {}); @@ -2567,7 +2584,7 @@ TEST_F(TcpHealthCheckerImplTest, Timeout) { EXPECT_CALL(*event_logger_, logEjectUnhealthy(_, _, _)); EXPECT_CALL(*event_logger_, logUnhealthy(_, _, _, true)); EXPECT_CALL(*timeout_timer_, disableTimer()); - EXPECT_CALL(*interval_timer_, enableTimer(_)); + EXPECT_CALL(*interval_timer_, enableTimer(_, _)); timeout_timer_->invokeCallback(); EXPECT_EQ(cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->getActiveHealthFailureType(), Host::ActiveHealthFailureType::TIMEOUT); @@ -2586,7 +2603,7 @@ TEST_F(TcpHealthCheckerImplTest, DoubleTimeout) { cluster_->prioritySet().getMockHostSet(0)->hosts_ = { makeTestHost(cluster_->info_, "tcp://127.0.0.1:80")}; EXPECT_CALL(*connection_, write(_, _)); - EXPECT_CALL(*timeout_timer_, enableTimer(_)); + EXPECT_CALL(*timeout_timer_, enableTimer(_, _)); cluster_->prioritySet().getMockHostSet(0)->runCallbacks( {cluster_->prioritySet().getMockHostSet(0)->hosts_.back()}, {}); @@ -2600,7 +2617,7 @@ TEST_F(TcpHealthCheckerImplTest, DoubleTimeout) { EXPECT_CALL(*connection_, close(_)); EXPECT_CALL(*event_logger_, logUnhealthy(_, _, _, true)); EXPECT_CALL(*timeout_timer_, disableTimer()); - EXPECT_CALL(*interval_timer_, enableTimer(_)); + EXPECT_CALL(*interval_timer_, enableTimer(_, _)); timeout_timer_->invokeCallback(); EXPECT_EQ(cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->getActiveHealthFailureType(), Host::ActiveHealthFailureType::TIMEOUT); @@ -2608,7 +2625,7 @@ TEST_F(TcpHealthCheckerImplTest, DoubleTimeout) { expectClientCreate(); EXPECT_CALL(*connection_, write(_, _)); - EXPECT_CALL(*timeout_timer_, enableTimer(_)); + EXPECT_CALL(*timeout_timer_, enableTimer(_, _)); interval_timer_->invokeCallback(); connection_->raiseEvent(Network::ConnectionEvent::Connected); @@ -2616,7 +2633,7 @@ TEST_F(TcpHealthCheckerImplTest, DoubleTimeout) { EXPECT_CALL(*connection_, close(_)); EXPECT_CALL(*event_logger_, logEjectUnhealthy(_, _, _)); EXPECT_CALL(*timeout_timer_, disableTimer()); - EXPECT_CALL(*interval_timer_, enableTimer(_)); + EXPECT_CALL(*interval_timer_, enableTimer(_, _)); timeout_timer_->invokeCallback(); EXPECT_EQ(cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->getActiveHealthFailureType(), Host::ActiveHealthFailureType::TIMEOUT); @@ -2625,7 +2642,7 @@ TEST_F(TcpHealthCheckerImplTest, DoubleTimeout) { expectClientCreate(); EXPECT_CALL(*connection_, write(_, _)); - EXPECT_CALL(*timeout_timer_, enableTimer(_)); + EXPECT_CALL(*timeout_timer_, enableTimer(_, _)); interval_timer_->invokeCallback(); connection_->raiseEvent(Network::ConnectionEvent::Connected); @@ -2646,14 +2663,14 @@ TEST_F(TcpHealthCheckerImplTest, TimeoutWithoutReusingConnection) { expectSessionCreate(); expectClientCreate(); EXPECT_CALL(*connection_, write(_, _)).Times(1); - EXPECT_CALL(*timeout_timer_, enableTimer(_)); + EXPECT_CALL(*timeout_timer_, enableTimer(_, _)); health_checker_->start(); connection_->raiseEvent(Network::ConnectionEvent::Connected); // Expected flow when a healthcheck is successful and reuse_connection is false. EXPECT_CALL(*timeout_timer_, disableTimer()); - EXPECT_CALL(*interval_timer_, enableTimer(_)); + EXPECT_CALL(*interval_timer_, enableTimer(_, _)); EXPECT_CALL(*connection_, close(Network::ConnectionCloseType::NoFlush)).Times(1); Buffer::OwnedImpl response; @@ -2666,14 +2683,14 @@ TEST_F(TcpHealthCheckerImplTest, TimeoutWithoutReusingConnection) { // The healthcheck will run again. expectClientCreate(); EXPECT_CALL(*connection_, write(_, _)); - EXPECT_CALL(*timeout_timer_, enableTimer(_)); + EXPECT_CALL(*timeout_timer_, enableTimer(_, _)); interval_timer_->invokeCallback(); connection_->raiseEvent(Network::ConnectionEvent::Connected); // Expected flow when a healthcheck times out. EXPECT_CALL(*timeout_timer_, disableTimer()); - EXPECT_CALL(*interval_timer_, enableTimer(_)); + EXPECT_CALL(*interval_timer_, enableTimer(_, _)); connection_->raiseEvent(Network::ConnectionEvent::RemoteClose); // The healthcheck is not yet at the unhealthy threshold. EXPECT_FALSE(cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->healthFlagGet( @@ -2687,7 +2704,7 @@ TEST_F(TcpHealthCheckerImplTest, TimeoutWithoutReusingConnection) { // The healthcheck will run again, it should be failing after this attempt. expectClientCreate(); EXPECT_CALL(*connection_, write(_, _)); - EXPECT_CALL(*timeout_timer_, enableTimer(_)); + EXPECT_CALL(*timeout_timer_, enableTimer(_, _)); interval_timer_->invokeCallback(); connection_->raiseEvent(Network::ConnectionEvent::Connected); @@ -2695,7 +2712,7 @@ TEST_F(TcpHealthCheckerImplTest, TimeoutWithoutReusingConnection) { // Expected flow when a healthcheck times out. EXPECT_CALL(*event_logger_, logEjectUnhealthy(_, _, _)); EXPECT_CALL(*timeout_timer_, disableTimer()); - EXPECT_CALL(*interval_timer_, enableTimer(_)); + EXPECT_CALL(*interval_timer_, enableTimer(_, _)); connection_->raiseEvent(Network::ConnectionEvent::RemoteClose); EXPECT_TRUE(cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->healthFlagGet( Host::HealthFlag::FAILED_ACTIVE_HC)); @@ -2716,17 +2733,17 @@ TEST_F(TcpHealthCheckerImplTest, NoData) { expectSessionCreate(); expectClientCreate(); EXPECT_CALL(*connection_, write(_, _)).Times(0); - EXPECT_CALL(*timeout_timer_, enableTimer(_)); + EXPECT_CALL(*timeout_timer_, enableTimer(_, _)); health_checker_->start(); EXPECT_CALL(*connection_, close(_)); EXPECT_CALL(*timeout_timer_, disableTimer()); - EXPECT_CALL(*interval_timer_, enableTimer(_)); + EXPECT_CALL(*interval_timer_, enableTimer(_, _)); connection_->raiseEvent(Network::ConnectionEvent::Connected); expectClientCreate(); EXPECT_CALL(*connection_, write(_, _)).Times(0); - EXPECT_CALL(*timeout_timer_, enableTimer(_)); + EXPECT_CALL(*timeout_timer_, enableTimer(_, _)); interval_timer_->invokeCallback(); } @@ -2739,7 +2756,7 @@ TEST_F(TcpHealthCheckerImplTest, PassiveFailure) { expectSessionCreate(); expectClientCreate(); EXPECT_CALL(*connection_, write(_, _)).Times(0); - EXPECT_CALL(*timeout_timer_, enableTimer(_)); + EXPECT_CALL(*timeout_timer_, enableTimer(_, _)); EXPECT_CALL(*event_logger_, logEjectUnhealthy(_, _, _)); EXPECT_CALL(*event_logger_, logUnhealthy(_, _, _, true)); health_checker_->start(); @@ -2755,7 +2772,7 @@ TEST_F(TcpHealthCheckerImplTest, PassiveFailure) { // A single success should not bring us back to healthy. EXPECT_CALL(*connection_, close(_)); EXPECT_CALL(*timeout_timer_, disableTimer()); - EXPECT_CALL(*interval_timer_, enableTimer(_)); + EXPECT_CALL(*interval_timer_, enableTimer(_, _)); connection_->raiseEvent(Network::ConnectionEvent::Connected); EXPECT_TRUE(cluster_->prioritySet().getMockHostSet(0)->hosts_[0]->healthFlagGet( Host::HealthFlag::FAILED_ACTIVE_HC)); @@ -2777,7 +2794,7 @@ TEST_F(TcpHealthCheckerImplTest, PassiveFailureCrossThreadRemoveHostRace) { expectSessionCreate(); expectClientCreate(); EXPECT_CALL(*connection_, write(_, _)).Times(0); - EXPECT_CALL(*timeout_timer_, enableTimer(_)); + EXPECT_CALL(*timeout_timer_, enableTimer(_, _)); health_checker_->start(); // Do a passive failure. This will not reset the active HC timers. @@ -2806,7 +2823,7 @@ TEST_F(TcpHealthCheckerImplTest, PassiveFailureCrossThreadRemoveClusterRace) { expectSessionCreate(); expectClientCreate(); EXPECT_CALL(*connection_, write(_, _)).Times(0); - EXPECT_CALL(*timeout_timer_, enableTimer(_)); + EXPECT_CALL(*timeout_timer_, enableTimer(_, _)); health_checker_->start(); // Do a passive failure. This will not reset the active HC timers. @@ -2834,13 +2851,13 @@ TEST_F(TcpHealthCheckerImplTest, ConnectionLocalFailure) { expectSessionCreate(); expectClientCreate(); EXPECT_CALL(*connection_, write(_, _)); - EXPECT_CALL(*timeout_timer_, enableTimer(_)); + EXPECT_CALL(*timeout_timer_, enableTimer(_, _)); health_checker_->start(); // Expect the LocalClose to be handled as a health check failure EXPECT_CALL(*event_logger_, logUnhealthy(_, _, _, true)); EXPECT_CALL(*timeout_timer_, disableTimer()); - EXPECT_CALL(*interval_timer_, enableTimer(_)); + EXPECT_CALL(*interval_timer_, enableTimer(_, _)); // Raise a LocalClose that is not triggered by the health monitor itself. // e.g. a failure to setsockopt(). @@ -3092,16 +3109,16 @@ class GrpcHealthCheckerImplTestBase { // Hides timer/stream-related boilerplate of healthcheck start. void expectHealthcheckStart(size_t index) { expectStreamCreate(index); - EXPECT_CALL(*test_sessions_[index]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[index]->timeout_timer_, enableTimer(_, _)); } // Hides timer-related boilerplate of healthcheck stop. void expectHealthcheckStop(size_t index, int interval_ms = 0) { if (interval_ms > 0) { EXPECT_CALL(*test_sessions_[index]->interval_timer_, - enableTimer(std::chrono::milliseconds(interval_ms))); + enableTimer(std::chrono::milliseconds(interval_ms), _)); } else { - EXPECT_CALL(*test_sessions_[index]->interval_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[index]->interval_timer_, enableTimer(_, _)); } EXPECT_CALL(*test_sessions_[index]->timeout_timer_, disableTimer()); } @@ -3532,7 +3549,7 @@ TEST_F(GrpcHealthCheckerImplTest, DynamicAddAndRemove) { expectStreamCreate(0); cluster_->prioritySet().getMockHostSet(0)->hosts_ = { makeTestHost(cluster_->info_, "tcp://127.0.0.1:80")}; - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); cluster_->prioritySet().getMockHostSet(0)->runCallbacks( {cluster_->prioritySet().getMockHostSet(0)->hosts_.back()}, {}); @@ -3548,39 +3565,39 @@ TEST_F(GrpcHealthCheckerImplTest, HealthCheckIntervals) { makeTestHost(cluster_->info_, "tcp://128.0.0.1:80")}; expectSessionCreate(); expectStreamCreate(0); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); health_checker_->start(); // First check should respect no_traffic_interval setting. EXPECT_CALL(*this, onHostStatus(_, HealthTransition::Unchanged)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(5000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(5000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respondServiceStatus(0, grpc::health::v1::HealthCheckResponse::SERVING); cluster_->info_->stats().upstream_cx_total_.inc(); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); // Needed after a response is sent. expectStreamCreate(0); test_sessions_[0]->interval_timer_->invokeCallback(); // Follow up successful checks should respect interval setting. EXPECT_CALL(*this, onHostStatus(_, HealthTransition::Unchanged)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(1000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(1000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respondServiceStatus(0, grpc::health::v1::HealthCheckResponse::SERVING); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); // Needed after a response is sent. expectStreamCreate(0); test_sessions_[0]->interval_timer_->invokeCallback(); // Follow up successful checks should respect interval setting. EXPECT_CALL(*this, onHostStatus(_, HealthTransition::Unchanged)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(1000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(1000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respondServiceStatus(0, grpc::health::v1::HealthCheckResponse::SERVING); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); // Needed after a response is sent. expectStreamCreate(0); test_sessions_[0]->interval_timer_->invokeCallback(); @@ -3590,33 +3607,33 @@ TEST_F(GrpcHealthCheckerImplTest, HealthCheckIntervals) { // check respects "unhealthy_interval". EXPECT_CALL(*this, onHostStatus(_, HealthTransition::Changed)); EXPECT_CALL(*event_logger_, logEjectUnhealthy(_, _, _)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(2000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(2000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respondServiceStatus(0, grpc::health::v1::HealthCheckResponse::NOT_SERVING); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); // Needed after a response is sent. expectStreamCreate(0); test_sessions_[0]->interval_timer_->invokeCallback(); // Subsequent failing checks should respect unhealthy_interval. EXPECT_CALL(*this, onHostStatus(_, HealthTransition::Unchanged)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(2000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(2000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respondServiceStatus(0, grpc::health::v1::HealthCheckResponse::NOT_SERVING); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); // Needed after a response is sent. expectStreamCreate(0); test_sessions_[0]->interval_timer_->invokeCallback(); // Subsequent failing checks should respect unhealthy_interval. EXPECT_CALL(*this, onHostStatus(_, HealthTransition::Unchanged)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(2000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(2000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respondServiceStatus(0, grpc::health::v1::HealthCheckResponse::NOT_SERVING); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); // Needed after a response is sent. expectStreamCreate(0); test_sessions_[0]->interval_timer_->invokeCallback(); @@ -3624,21 +3641,21 @@ TEST_F(GrpcHealthCheckerImplTest, HealthCheckIntervals) { // When transitioning to a successful state, checks should respect healthy_edge_interval. Health // state should be delayed pending healthy threshold. EXPECT_CALL(*this, onHostStatus(_, HealthTransition::ChangePending)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(4000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(4000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respondServiceStatus(0, grpc::health::v1::HealthCheckResponse::SERVING); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); // Needed after a response is sent. expectStreamCreate(0); test_sessions_[0]->interval_timer_->invokeCallback(); EXPECT_CALL(*this, onHostStatus(_, HealthTransition::ChangePending)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(4000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(4000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respondServiceStatus(0, grpc::health::v1::HealthCheckResponse::SERVING); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); // Needed after a response is sent. expectStreamCreate(0); test_sessions_[0]->interval_timer_->invokeCallback(); @@ -3647,22 +3664,22 @@ TEST_F(GrpcHealthCheckerImplTest, HealthCheckIntervals) { // the default interval. EXPECT_CALL(*this, onHostStatus(_, HealthTransition::Changed)); EXPECT_CALL(*event_logger_, logAddHealthy(_, _, false)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(1000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(1000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respondServiceStatus(0, grpc::health::v1::HealthCheckResponse::SERVING); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); // Needed after a response is sent. expectStreamCreate(0); test_sessions_[0]->interval_timer_->invokeCallback(); // Subsequent checks shouldn't change the state. EXPECT_CALL(*this, onHostStatus(_, HealthTransition::Unchanged)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(1000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(1000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respondServiceStatus(0, grpc::health::v1::HealthCheckResponse::SERVING); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); // Needed after a response is sent. expectStreamCreate(0); test_sessions_[0]->interval_timer_->invokeCallback(); @@ -3671,21 +3688,21 @@ TEST_F(GrpcHealthCheckerImplTest, HealthCheckIntervals) { // timeout, being a network type failure, should respect unhealthy threshold before changing the // health state. EXPECT_CALL(*this, onHostStatus(_, HealthTransition::ChangePending)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(3000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(3000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); test_sessions_[0]->timeout_timer_->invokeCallback(); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); // Needed after a response is sent. expectStreamCreate(0); test_sessions_[0]->interval_timer_->invokeCallback(); EXPECT_CALL(*this, onHostStatus(_, HealthTransition::ChangePending)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(3000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(3000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); test_sessions_[0]->timeout_timer_->invokeCallback(); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); // Needed after a response is sent. expectStreamCreate(0); test_sessions_[0]->interval_timer_->invokeCallback(); @@ -3694,43 +3711,43 @@ TEST_F(GrpcHealthCheckerImplTest, HealthCheckIntervals) { // reached, health state should also change. EXPECT_CALL(*this, onHostStatus(_, HealthTransition::Changed)); EXPECT_CALL(*event_logger_, logEjectUnhealthy(_, _, _)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(2000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(2000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); test_sessions_[0]->timeout_timer_->invokeCallback(); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); // Needed after a response is sent. expectStreamCreate(0); test_sessions_[0]->interval_timer_->invokeCallback(); // Remaining failing checks shouldn't change the state. EXPECT_CALL(*this, onHostStatus(_, HealthTransition::Unchanged)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(2000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(2000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); test_sessions_[0]->timeout_timer_->invokeCallback(); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); // Needed after a response is sent. expectStreamCreate(0); test_sessions_[0]->interval_timer_->invokeCallback(); // When transitioning to a successful state, checks should respect healthy_edge_interval. EXPECT_CALL(*this, onHostStatus(_, HealthTransition::ChangePending)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(4000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(4000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respondServiceStatus(0, grpc::health::v1::HealthCheckResponse::SERVING); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); // Needed after a response is sent. expectStreamCreate(0); test_sessions_[0]->interval_timer_->invokeCallback(); EXPECT_CALL(*this, onHostStatus(_, HealthTransition::ChangePending)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(4000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(4000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respondServiceStatus(0, grpc::health::v1::HealthCheckResponse::SERVING); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); // Needed after a response is sent. expectStreamCreate(0); test_sessions_[0]->interval_timer_->invokeCallback(); @@ -3739,18 +3756,18 @@ TEST_F(GrpcHealthCheckerImplTest, HealthCheckIntervals) { // the default interval. EXPECT_CALL(*this, onHostStatus(_, HealthTransition::Changed)); EXPECT_CALL(*event_logger_, logAddHealthy(_, _, false)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(1000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(1000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respondServiceStatus(0, grpc::health::v1::HealthCheckResponse::SERVING); - EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_)); + EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_, _)); // Needed after a response is sent. expectStreamCreate(0); test_sessions_[0]->interval_timer_->invokeCallback(); // Subsequent checks shouldn't change the state. EXPECT_CALL(*this, onHostStatus(_, HealthTransition::Unchanged)); - EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(1000))); + EXPECT_CALL(*test_sessions_[0]->interval_timer_, enableTimer(std::chrono::milliseconds(1000), _)); EXPECT_CALL(*test_sessions_[0]->timeout_timer_, disableTimer()); respondServiceStatus(0, grpc::health::v1::HealthCheckResponse::SERVING); } diff --git a/test/common/upstream/load_stats_reporter_test.cc b/test/common/upstream/load_stats_reporter_test.cc index 05dcdf9f22ee..11a2bdfc9bce 100644 --- a/test/common/upstream/load_stats_reporter_test.cc +++ b/test/common/upstream/load_stats_reporter_test.cc @@ -63,7 +63,7 @@ class LoadStatsReporterTest : public testing::Test { std::copy(cluster_names.begin(), cluster_names.end(), Protobuf::RepeatedPtrFieldBackInserter(response->mutable_clusters())); - EXPECT_CALL(*response_timer_, enableTimer(std::chrono::milliseconds(42000))); + EXPECT_CALL(*response_timer_, enableTimer(std::chrono::milliseconds(42000), _)); load_stats_reporter_->onReceiveMessage(std::move(response)); } @@ -84,7 +84,7 @@ class LoadStatsReporterTest : public testing::Test { // Validate that stream creation results in a timer based retry. TEST_F(LoadStatsReporterTest, StreamCreationFailure) { EXPECT_CALL(*async_client_, startRaw(_, _, _)).WillOnce(Return(nullptr)); - EXPECT_CALL(*retry_timer_, enableTimer(_)); + EXPECT_CALL(*retry_timer_, enableTimer(_, _)); createLoadStatsReporter(); EXPECT_CALL(*async_client_, startRaw(_, _, _)).WillOnce(Return(&async_stream_)); expectSendMessage({}); @@ -98,13 +98,13 @@ TEST_F(LoadStatsReporterTest, TestPubSub) { deliverLoadStatsResponse({"foo"}); EXPECT_CALL(async_stream_, sendMessageRaw_(_, _)); - EXPECT_CALL(*response_timer_, enableTimer(std::chrono::milliseconds(42000))); + EXPECT_CALL(*response_timer_, enableTimer(std::chrono::milliseconds(42000), _)); response_timer_cb_(); deliverLoadStatsResponse({"bar"}); EXPECT_CALL(async_stream_, sendMessageRaw_(_, _)); - EXPECT_CALL(*response_timer_, enableTimer(std::chrono::milliseconds(42000))); + EXPECT_CALL(*response_timer_, enableTimer(std::chrono::milliseconds(42000), _)); response_timer_cb_(); } @@ -135,7 +135,7 @@ TEST_F(LoadStatsReporterTest, ExistingClusters) { Protobuf::util::TimeUtil::MicrosecondsToDuration(1)); expectSendMessage({foo_cluster_stats}); } - EXPECT_CALL(*response_timer_, enableTimer(std::chrono::milliseconds(42000))); + EXPECT_CALL(*response_timer_, enableTimer(std::chrono::milliseconds(42000), _)); response_timer_cb_(); // Some traffic on foo/bar in between previous request and next response. @@ -163,7 +163,7 @@ TEST_F(LoadStatsReporterTest, ExistingClusters) { Protobuf::util::TimeUtil::MicrosecondsToDuration(22)); expectSendMessage({bar_cluster_stats, foo_cluster_stats}); } - EXPECT_CALL(*response_timer_, enableTimer(std::chrono::milliseconds(42000))); + EXPECT_CALL(*response_timer_, enableTimer(std::chrono::milliseconds(42000), _)); response_timer_cb_(); // Some traffic on foo/bar in between previous request and next response. @@ -184,7 +184,7 @@ TEST_F(LoadStatsReporterTest, ExistingClusters) { Protobuf::util::TimeUtil::MicrosecondsToDuration(5)); expectSendMessage({bar_cluster_stats}); } - EXPECT_CALL(*response_timer_, enableTimer(std::chrono::milliseconds(42000))); + EXPECT_CALL(*response_timer_, enableTimer(std::chrono::milliseconds(42000), _)); response_timer_cb_(); // Some traffic on foo/bar in between previous request and next response. @@ -212,7 +212,7 @@ TEST_F(LoadStatsReporterTest, ExistingClusters) { Protobuf::util::TimeUtil::MicrosecondsToDuration(14)); expectSendMessage({bar_cluster_stats, foo_cluster_stats}); } - EXPECT_CALL(*response_timer_, enableTimer(std::chrono::milliseconds(42000))); + EXPECT_CALL(*response_timer_, enableTimer(std::chrono::milliseconds(42000), _)); response_timer_cb_(); } @@ -222,7 +222,7 @@ TEST_F(LoadStatsReporterTest, RemoteStreamClose) { expectSendMessage({}); createLoadStatsReporter(); EXPECT_CALL(*response_timer_, disableTimer()); - EXPECT_CALL(*retry_timer_, enableTimer(_)); + EXPECT_CALL(*retry_timer_, enableTimer(_, _)); load_stats_reporter_->onRemoteClose(Grpc::Status::GrpcStatus::Canceled, ""); EXPECT_CALL(*async_client_, startRaw(_, _, _)).WillOnce(Return(&async_stream_)); expectSendMessage({}); diff --git a/test/common/upstream/logical_dns_cluster_test.cc b/test/common/upstream/logical_dns_cluster_test.cc index e09890e76ebe..b3d36e7c43b4 100644 --- a/test/common/upstream/logical_dns_cluster_test.cc +++ b/test/common/upstream/logical_dns_cluster_test.cc @@ -75,7 +75,7 @@ class LogicalDnsClusterTest : public testing::Test { EXPECT_CALL(membership_updated_, ready()); EXPECT_CALL(initialized_, ready()); - EXPECT_CALL(*resolve_timer_, enableTimer(std::chrono::milliseconds(4000))); + EXPECT_CALL(*resolve_timer_, enableTimer(std::chrono::milliseconds(4000), _)); dns_callback_(TestUtility::makeDnsResponse({"127.0.0.1", "127.0.0.2"})); EXPECT_EQ(1UL, cluster_->prioritySet().hostSetsPerPriority()[0]->hosts().size()); @@ -104,7 +104,7 @@ class LogicalDnsClusterTest : public testing::Test { resolve_timer_->invokeCallback(); // Should not cause any changes. - EXPECT_CALL(*resolve_timer_, enableTimer(_)); + EXPECT_CALL(*resolve_timer_, enableTimer(_, _)); dns_callback_(TestUtility::makeDnsResponse({"127.0.0.1", "127.0.0.2", "127.0.0.3"})); EXPECT_EQ("127.0.0.1:" + std::to_string(expected_hc_port), @@ -136,7 +136,7 @@ class LogicalDnsClusterTest : public testing::Test { resolve_timer_->invokeCallback(); // Should cause a change. - EXPECT_CALL(*resolve_timer_, enableTimer(_)); + EXPECT_CALL(*resolve_timer_, enableTimer(_, _)); dns_callback_(TestUtility::makeDnsResponse({"127.0.0.3", "127.0.0.1", "127.0.0.2"})); EXPECT_EQ("127.0.0.3:" + std::to_string(expected_hc_port), @@ -154,7 +154,7 @@ class LogicalDnsClusterTest : public testing::Test { resolve_timer_->invokeCallback(); // Empty should not cause any change. - EXPECT_CALL(*resolve_timer_, enableTimer(_)); + EXPECT_CALL(*resolve_timer_, enableTimer(_, _)); dns_callback_({}); EXPECT_EQ(logical_host, cluster_->prioritySet().hostSetsPerPriority()[0]->hosts()[0]); @@ -255,7 +255,7 @@ TEST_P(LogicalDnsParamTest, ImmediateResolve) { EXPECT_CALL(*dns_resolver_, resolve("foo.bar.com", std::get<1>(GetParam()), _)) .WillOnce(Invoke([&](const std::string&, Network::DnsLookupFamily, Network::DnsResolver::ResolveCb cb) -> Network::ActiveDnsQuery* { - EXPECT_CALL(*resolve_timer_, enableTimer(_)); + EXPECT_CALL(*resolve_timer_, enableTimer(_, _)); cb(TestUtility::makeDnsResponse(std::get<2>(GetParam()))); return nullptr; })); diff --git a/test/common/upstream/original_dst_cluster_test.cc b/test/common/upstream/original_dst_cluster_test.cc index eccedcc9437c..3c6546f472f7 100644 --- a/test/common/upstream/original_dst_cluster_test.cc +++ b/test/common/upstream/original_dst_cluster_test.cc @@ -167,7 +167,7 @@ TEST_F(OriginalDstClusterTest, CleanupInterval) { EXPECT_CALL(initialized_, ready()); EXPECT_CALL(membership_updated_, ready()).Times(0); - EXPECT_CALL(*cleanup_timer_, enableTimer(std::chrono::milliseconds(1000))); + EXPECT_CALL(*cleanup_timer_, enableTimer(std::chrono::milliseconds(1000), _)); setupFromYaml(yaml); EXPECT_EQ(0UL, cluster_->prioritySet().hostSetsPerPriority()[0]->hosts().size()); @@ -184,7 +184,7 @@ TEST_F(OriginalDstClusterTest, NoContext) { EXPECT_CALL(initialized_, ready()); EXPECT_CALL(membership_updated_, ready()).Times(0); - EXPECT_CALL(*cleanup_timer_, enableTimer(_)); + EXPECT_CALL(*cleanup_timer_, enableTimer(_, _)); setupFromYaml(yaml); EXPECT_EQ(0UL, cluster_->prioritySet().hostSetsPerPriority()[0]->hosts().size()); @@ -241,7 +241,7 @@ TEST_F(OriginalDstClusterTest, Membership) { )EOF"; EXPECT_CALL(initialized_, ready()); - EXPECT_CALL(*cleanup_timer_, enableTimer(_)); + EXPECT_CALL(*cleanup_timer_, enableTimer(_, _)); setupFromYaml(yaml); EXPECT_EQ(0UL, cluster_->prioritySet().hostSetsPerPriority()[0]->hosts().size()); @@ -289,7 +289,7 @@ TEST_F(OriginalDstClusterTest, Membership) { // Make host time out, no membership changes happen on the first timeout. ASSERT_EQ(1UL, cluster_->prioritySet().hostSetsPerPriority()[0]->hosts().size()); EXPECT_EQ(true, cluster_->prioritySet().hostSetsPerPriority()[0]->hosts()[0]->used()); - EXPECT_CALL(*cleanup_timer_, enableTimer(_)); + EXPECT_CALL(*cleanup_timer_, enableTimer(_, _)); cleanup_timer_->invokeCallback(); EXPECT_EQ( cluster_hosts, @@ -299,7 +299,7 @@ TEST_F(OriginalDstClusterTest, Membership) { ASSERT_EQ(1UL, cluster_->prioritySet().hostSetsPerPriority()[0]->hosts().size()); EXPECT_EQ(false, cluster_->prioritySet().hostSetsPerPriority()[0]->hosts()[0]->used()); - EXPECT_CALL(*cleanup_timer_, enableTimer(_)); + EXPECT_CALL(*cleanup_timer_, enableTimer(_, _)); EXPECT_CALL(membership_updated_, ready()); cleanup_timer_->invokeCallback(); EXPECT_NE(cluster_hosts, @@ -332,7 +332,7 @@ TEST_F(OriginalDstClusterTest, Membership2) { )EOF"; EXPECT_CALL(initialized_, ready()); - EXPECT_CALL(*cleanup_timer_, enableTimer(_)); + EXPECT_CALL(*cleanup_timer_, enableTimer(_, _)); setupFromYaml(yaml); EXPECT_EQ(0UL, cluster_->prioritySet().hostSetsPerPriority()[0]->hosts().size()); @@ -391,7 +391,7 @@ TEST_F(OriginalDstClusterTest, Membership2) { ASSERT_EQ(2UL, cluster_->prioritySet().hostSetsPerPriority()[0]->hosts().size()); EXPECT_EQ(true, cluster_->prioritySet().hostSetsPerPriority()[0]->hosts()[0]->used()); EXPECT_EQ(true, cluster_->prioritySet().hostSetsPerPriority()[0]->hosts()[1]->used()); - EXPECT_CALL(*cleanup_timer_, enableTimer(_)); + EXPECT_CALL(*cleanup_timer_, enableTimer(_, _)); cleanup_timer_->invokeCallback(); EXPECT_EQ( cluster_hosts, @@ -402,7 +402,7 @@ TEST_F(OriginalDstClusterTest, Membership2) { EXPECT_EQ(false, cluster_->prioritySet().hostSetsPerPriority()[0]->hosts()[0]->used()); EXPECT_EQ(false, cluster_->prioritySet().hostSetsPerPriority()[0]->hosts()[1]->used()); - EXPECT_CALL(*cleanup_timer_, enableTimer(_)); + EXPECT_CALL(*cleanup_timer_, enableTimer(_, _)); EXPECT_CALL(membership_updated_, ready()); cleanup_timer_->invokeCallback(); EXPECT_NE(cluster_hosts, @@ -420,7 +420,7 @@ TEST_F(OriginalDstClusterTest, Connection) { )EOF"; EXPECT_CALL(initialized_, ready()); - EXPECT_CALL(*cleanup_timer_, enableTimer(_)); + EXPECT_CALL(*cleanup_timer_, enableTimer(_, _)); setupFromYaml(yaml); EXPECT_EQ(0UL, cluster_->prioritySet().hostSetsPerPriority()[0]->hosts().size()); @@ -460,7 +460,7 @@ TEST_F(OriginalDstClusterTest, MultipleClusters) { )EOF"; EXPECT_CALL(initialized_, ready()); - EXPECT_CALL(*cleanup_timer_, enableTimer(_)); + EXPECT_CALL(*cleanup_timer_, enableTimer(_, _)); setupFromYaml(yaml); PrioritySetImpl second; @@ -514,7 +514,7 @@ TEST_F(OriginalDstClusterTest, UseHttpHeaderEnabled) { )EOF"; EXPECT_CALL(initialized_, ready()); - EXPECT_CALL(*cleanup_timer_, enableTimer(_)); + EXPECT_CALL(*cleanup_timer_, enableTimer(_, _)); setupFromYaml(yaml); EXPECT_EQ(0UL, cluster_->prioritySet().hostSetsPerPriority()[0]->hosts().size()); @@ -585,7 +585,7 @@ TEST_F(OriginalDstClusterTest, UseHttpHeaderDisabled) { )EOF"; EXPECT_CALL(initialized_, ready()); - EXPECT_CALL(*cleanup_timer_, enableTimer(_)); + EXPECT_CALL(*cleanup_timer_, enableTimer(_, _)); setupFromYaml(yaml); EXPECT_EQ(0UL, cluster_->prioritySet().hostSetsPerPriority()[0]->hosts().size()); diff --git a/test/common/upstream/outlier_detection_impl_test.cc b/test/common/upstream/outlier_detection_impl_test.cc index 6de146f062a7..8c8c51062031 100644 --- a/test/common/upstream/outlier_detection_impl_test.cc +++ b/test/common/upstream/outlier_detection_impl_test.cc @@ -133,7 +133,7 @@ success_rate_stdev_factor: 3000 envoy::api::v2::cluster::OutlierDetection outlier_detection; TestUtility::loadFromYaml(yaml, outlier_detection); - EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(100))); + EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(100), _)); std::shared_ptr detector(DetectorImpl::create( cluster_, outlier_detection, dispatcher_, runtime_, time_system_, event_logger_)); @@ -156,7 +156,7 @@ TEST_F(OutlierDetectorImplTest, DestroyWithActive) { EXPECT_CALL(cluster_.prioritySet(), addMemberUpdateCb(_)); addHosts({"tcp://127.0.0.1:80"}, true); addHosts({"tcp://127.0.0.1:81"}, false); - EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000))); + EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create( cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, event_logger_)); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); @@ -188,7 +188,7 @@ TEST_F(OutlierDetectorImplTest, DestroyWithActive) { TEST_F(OutlierDetectorImplTest, DestroyHostInUse) { EXPECT_CALL(cluster_.prioritySet(), addMemberUpdateCb(_)); addHosts({"tcp://127.0.0.1:80"}); - EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000))); + EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create( cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, event_logger_)); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); @@ -205,7 +205,7 @@ TEST_F(OutlierDetectorImplTest, DestroyHostInUse) { TEST_F(OutlierDetectorImplTest, BasicFlow5xxViaHttpCodes) { EXPECT_CALL(cluster_.prioritySet(), addMemberUpdateCb(_)); addHosts({"tcp://127.0.0.1:80"}); - EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000))); + EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create( cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, event_logger_)); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); @@ -231,7 +231,7 @@ TEST_F(OutlierDetectorImplTest, BasicFlow5xxViaHttpCodes) { // Interval that doesn't bring the host back in. time_system_.setMonotonicTime(std::chrono::milliseconds(9999)); - EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000))); + EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); interval_timer_->invokeCallback(); EXPECT_FALSE(hosts_[0]->outlierDetector().lastUnejectionTime()); @@ -240,7 +240,7 @@ TEST_F(OutlierDetectorImplTest, BasicFlow5xxViaHttpCodes) { EXPECT_CALL(checker_, check(hosts_[0])); EXPECT_CALL(*event_logger_, logUneject(std::static_pointer_cast(hosts_[0]))); - EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000))); + EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); interval_timer_->invokeCallback(); EXPECT_FALSE(hosts_[0]->healthFlagGet(Host::HealthFlag::FAILED_OUTLIER_CHECK)); EXPECT_TRUE(hosts_[0]->outlierDetector().lastUnejectionTime()); @@ -276,7 +276,7 @@ TEST_F(OutlierDetectorImplTest, BasicFlow5xxViaHttpCodes) { TEST_F(OutlierDetectorImplTest, ConnectSuccessWithOptionalHTTP_OK) { EXPECT_CALL(cluster_.prioritySet(), addMemberUpdateCb(_)); addHosts({"tcp://127.0.0.1:80"}); - EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000))); + EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create( cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, event_logger_)); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); @@ -300,7 +300,7 @@ TEST_F(OutlierDetectorImplTest, ConnectSuccessWithOptionalHTTP_OK) { TEST_F(OutlierDetectorImplTest, ExternalOriginEventsNonSplit) { EXPECT_CALL(cluster_.prioritySet(), addMemberUpdateCb(_)); addHosts({"tcp://127.0.0.1:80"}); - EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000))); + EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create( cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, event_logger_)); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); @@ -327,7 +327,7 @@ TEST_F(OutlierDetectorImplTest, ExternalOriginEventsNonSplit) { TEST_F(OutlierDetectorImplTest, BasicFlow5xxViaNonHttpCodes) { EXPECT_CALL(cluster_.prioritySet(), addMemberUpdateCb(_)); addHosts({"tcp://127.0.0.1:80"}); - EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000))); + EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create( cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, event_logger_)); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); @@ -358,7 +358,7 @@ TEST_F(OutlierDetectorImplTest, BasicFlow5xxViaNonHttpCodes) { // Interval that doesn't bring the host back in. time_system_.setMonotonicTime(std::chrono::milliseconds(9999)); - EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000))); + EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); interval_timer_->invokeCallback(); EXPECT_FALSE(hosts_[0]->outlierDetector().lastUnejectionTime()); @@ -367,7 +367,7 @@ TEST_F(OutlierDetectorImplTest, BasicFlow5xxViaNonHttpCodes) { EXPECT_CALL(checker_, check(hosts_[0])); EXPECT_CALL(*event_logger_, logUneject(std::static_pointer_cast(hosts_[0]))); - EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000))); + EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); interval_timer_->invokeCallback(); EXPECT_FALSE(hosts_[0]->healthFlagGet(Host::HealthFlag::FAILED_OUTLIER_CHECK)); EXPECT_TRUE(hosts_[0]->outlierDetector().lastUnejectionTime()); @@ -410,7 +410,7 @@ TEST_F(OutlierDetectorImplTest, BasicFlow5xxViaNonHttpCodes) { TEST_F(OutlierDetectorImplTest, BasicFlowGatewayFailure) { EXPECT_CALL(cluster_.prioritySet(), addMemberUpdateCb(_)); addHosts({"tcp://127.0.0.1:80"}); - EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000))); + EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create( cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, event_logger_)); @@ -449,7 +449,7 @@ TEST_F(OutlierDetectorImplTest, BasicFlowGatewayFailure) { // Interval that doesn't bring the host back in. time_system_.setMonotonicTime(std::chrono::milliseconds(9999)); - EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000))); + EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); interval_timer_->invokeCallback(); EXPECT_FALSE(hosts_[0]->outlierDetector().lastUnejectionTime()); @@ -458,7 +458,7 @@ TEST_F(OutlierDetectorImplTest, BasicFlowGatewayFailure) { EXPECT_CALL(checker_, check(hosts_[0])); EXPECT_CALL(*event_logger_, logUneject(std::static_pointer_cast(hosts_[0]))); - EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000))); + EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); interval_timer_->invokeCallback(); EXPECT_FALSE(hosts_[0]->healthFlagGet(Host::HealthFlag::FAILED_OUTLIER_CHECK)); EXPECT_TRUE(hosts_[0]->outlierDetector().lastUnejectionTime()); @@ -512,7 +512,7 @@ TEST_F(OutlierDetectorImplTest, TimeoutWithHttpCode) { "tcp://127.0.0.1:84", }); - EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000))); + EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create( cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, event_logger_)); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); @@ -536,7 +536,7 @@ TEST_F(OutlierDetectorImplTest, TimeoutWithHttpCode) { EXPECT_CALL(checker_, check(hosts_[0])); EXPECT_CALL(*event_logger_, logUneject(std::static_pointer_cast(hosts_[0]))); - EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000))); + EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); interval_timer_->invokeCallback(); EXPECT_FALSE(hosts_[0]->healthFlagGet(Host::HealthFlag::FAILED_OUTLIER_CHECK)); @@ -581,7 +581,7 @@ TEST_F(OutlierDetectorImplTest, TimeoutWithHttpCode) { TEST_F(OutlierDetectorImplTest, BasicFlowLocalOriginFailure) { EXPECT_CALL(cluster_.prioritySet(), addMemberUpdateCb(_)); addHosts({"tcp://127.0.0.1:80"}, true); - EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000))); + EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create( cluster_, outlier_detection_split_, dispatcher_, runtime_, time_system_, event_logger_)); @@ -610,7 +610,7 @@ TEST_F(OutlierDetectorImplTest, BasicFlowLocalOriginFailure) { // Wait short time - not enough to be unejected time_system_.setMonotonicTime(std::chrono::milliseconds(9999)); - EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000))); + EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); interval_timer_->invokeCallback(); EXPECT_FALSE(hosts_[0]->outlierDetector().lastUnejectionTime()); @@ -619,7 +619,7 @@ TEST_F(OutlierDetectorImplTest, BasicFlowLocalOriginFailure) { EXPECT_CALL(checker_, check(hosts_[0])); EXPECT_CALL(*event_logger_, logUneject(std::static_pointer_cast(hosts_[0]))); - EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000))); + EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); interval_timer_->invokeCallback(); EXPECT_FALSE(hosts_[0]->healthFlagGet(Host::HealthFlag::FAILED_OUTLIER_CHECK)); EXPECT_TRUE(hosts_[0]->outlierDetector().lastUnejectionTime()); @@ -665,7 +665,7 @@ TEST_F(OutlierDetectorImplTest, BasicFlowLocalOriginFailure) { TEST_F(OutlierDetectorImplTest, BasicFlowGatewayFailureAnd5xx) { EXPECT_CALL(cluster_.prioritySet(), addMemberUpdateCb(_)); addHosts({"tcp://127.0.0.1:80"}); - EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000))); + EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create( cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, event_logger_)); @@ -698,7 +698,7 @@ TEST_F(OutlierDetectorImplTest, BasicFlowGatewayFailureAnd5xx) { // Interval that doesn't bring the host back in. time_system_.setMonotonicTime(std::chrono::milliseconds(9999)); - EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000))); + EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); interval_timer_->invokeCallback(); EXPECT_FALSE(hosts_[0]->outlierDetector().lastUnejectionTime()); @@ -707,7 +707,7 @@ TEST_F(OutlierDetectorImplTest, BasicFlowGatewayFailureAnd5xx) { EXPECT_CALL(checker_, check(hosts_[0])); EXPECT_CALL(*event_logger_, logUneject(std::static_pointer_cast(hosts_[0]))); - EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000))); + EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); interval_timer_->invokeCallback(); EXPECT_FALSE(hosts_[0]->healthFlagGet(Host::HealthFlag::FAILED_OUTLIER_CHECK)); EXPECT_TRUE(hosts_[0]->outlierDetector().lastUnejectionTime()); @@ -757,7 +757,7 @@ TEST_F(OutlierDetectorImplTest, BasicFlowGatewayFailureAnd5xx) { TEST_F(OutlierDetectorImplTest, BasicFlowNonHttpCodesExternalOrigin) { EXPECT_CALL(cluster_.prioritySet(), addMemberUpdateCb(_)); addHosts({"tcp://127.0.0.1:80"}); - EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000))); + EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create( cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, event_logger_)); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); @@ -812,7 +812,7 @@ TEST_F(OutlierDetectorImplTest, BasicFlowSuccessRateExternalOrigin) { "tcp://127.0.0.1:84", }); - EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000))); + EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create( cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, event_logger_)); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); @@ -845,7 +845,7 @@ TEST_F(OutlierDetectorImplTest, BasicFlowSuccessRateExternalOrigin) { EXPECT_CALL(*event_logger_, logEject(std::static_pointer_cast(hosts_[4]), _, envoy::data::cluster::v2alpha::OutlierEjectionType::SUCCESS_RATE, true)); - EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000))); + EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); ON_CALL(runtime_.snapshot_, getInteger("outlier_detection.success_rate_stdev_factor", 1900)) .WillByDefault(Return(1900)); interval_timer_->invokeCallback(); @@ -867,7 +867,7 @@ TEST_F(OutlierDetectorImplTest, BasicFlowSuccessRateExternalOrigin) { // Interval that doesn't bring the host back in. time_system_.setMonotonicTime(std::chrono::milliseconds(19999)); - EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000))); + EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); interval_timer_->invokeCallback(); EXPECT_TRUE(hosts_[4]->healthFlagGet(Host::HealthFlag::FAILED_OUTLIER_CHECK)); EXPECT_EQ(1UL, outlier_detection_ejections_active_.value()); @@ -877,7 +877,7 @@ TEST_F(OutlierDetectorImplTest, BasicFlowSuccessRateExternalOrigin) { EXPECT_CALL(checker_, check(hosts_[4])); EXPECT_CALL(*event_logger_, logUneject(std::static_pointer_cast(hosts_[4]))); - EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000))); + EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); interval_timer_->invokeCallback(); EXPECT_FALSE(hosts_[4]->healthFlagGet(Host::HealthFlag::FAILED_OUTLIER_CHECK)); EXPECT_EQ(0UL, outlier_detection_ejections_active_.value()); @@ -900,7 +900,7 @@ TEST_F(OutlierDetectorImplTest, BasicFlowSuccessRateExternalOrigin) { loadRq(hosts_[4], 25, 503); time_system_.setMonotonicTime(std::chrono::milliseconds(60001)); - EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000))); + EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); interval_timer_->invokeCallback(); EXPECT_EQ(0UL, outlier_detection_ejections_active_.value()); EXPECT_EQ(-1, hosts_[4]->outlierDetector().successRate( @@ -916,7 +916,7 @@ TEST_F(OutlierDetectorImplTest, BasicFlowSuccessRateExternalOrigin) { TEST_F(OutlierDetectorImplTest, ExternalOriginEventsWithSplit) { EXPECT_CALL(cluster_.prioritySet(), addMemberUpdateCb(_)); addHosts({"tcp://127.0.0.1:80"}, true); - EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000))); + EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create( cluster_, outlier_detection_split_, dispatcher_, runtime_, time_system_, event_logger_)); @@ -951,7 +951,7 @@ TEST_F(OutlierDetectorImplTest, BasicFlowSuccessRateLocalOrigin) { "tcp://127.0.0.1:84", }); - EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000))); + EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create( cluster_, outlier_detection_split_, dispatcher_, runtime_, time_system_, event_logger_)); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); @@ -979,7 +979,7 @@ TEST_F(OutlierDetectorImplTest, BasicFlowSuccessRateLocalOrigin) { logEject(std::static_pointer_cast(hosts_[4]), _, envoy::data::cluster::v2alpha::OutlierEjectionType::SUCCESS_RATE_LOCAL_ORIGIN, true)); - EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000))); + EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); ON_CALL(runtime_.snapshot_, getInteger("outlier_detection.success_rate_stdev_factor", 1900)) .WillByDefault(Return(1900)); interval_timer_->invokeCallback(); @@ -1001,7 +1001,7 @@ TEST_F(OutlierDetectorImplTest, BasicFlowSuccessRateLocalOrigin) { // Interval that doesn't bring the host back in. time_system_.setMonotonicTime(std::chrono::milliseconds(19999)); - EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000))); + EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); interval_timer_->invokeCallback(); EXPECT_TRUE(hosts_[4]->healthFlagGet(Host::HealthFlag::FAILED_OUTLIER_CHECK)); EXPECT_EQ(1UL, outlier_detection_ejections_active_.value()); @@ -1011,7 +1011,7 @@ TEST_F(OutlierDetectorImplTest, BasicFlowSuccessRateLocalOrigin) { EXPECT_CALL(checker_, check(hosts_[4])); EXPECT_CALL(*event_logger_, logUneject(std::static_pointer_cast(hosts_[4]))); - EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000))); + EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); interval_timer_->invokeCallback(); EXPECT_FALSE(hosts_[4]->healthFlagGet(Host::HealthFlag::FAILED_OUTLIER_CHECK)); EXPECT_EQ(0UL, outlier_detection_ejections_active_.value()); @@ -1030,7 +1030,7 @@ TEST_F(OutlierDetectorImplTest, BasicFlowSuccessRateLocalOrigin) { loadRq(hosts_[4], 25, Result::LOCAL_ORIGIN_CONNECT_FAILED); time_system_.setMonotonicTime(std::chrono::milliseconds(60001)); - EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000))); + EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); interval_timer_->invokeCallback(); EXPECT_EQ(0UL, outlier_detection_ejections_active_.value()); EXPECT_EQ(-1, hosts_[4]->outlierDetector().successRate( @@ -1044,13 +1044,13 @@ TEST_F(OutlierDetectorImplTest, BasicFlowSuccessRateLocalOrigin) { // Validate that empty hosts doesn't crash success rate handling when success_rate_minimum_hosts is // zero. This is a regression test for earlier divide-by-zero behavior. TEST_F(OutlierDetectorImplTest, EmptySuccessRate) { - EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000))); + EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create( cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, event_logger_)); loadRq(hosts_, 200, 503); time_system_.setMonotonicTime(std::chrono::milliseconds(10000)); - EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000))); + EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); ON_CALL(runtime_.snapshot_, getInteger("outlier_detection.success_rate_minimum_hosts", 5)) .WillByDefault(Return(0)); interval_timer_->invokeCallback(); @@ -1059,7 +1059,7 @@ TEST_F(OutlierDetectorImplTest, EmptySuccessRate) { TEST_F(OutlierDetectorImplTest, RemoveWhileEjected) { EXPECT_CALL(cluster_.prioritySet(), addMemberUpdateCb(_)); addHosts({"tcp://127.0.0.1:80"}); - EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000))); + EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create( cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, event_logger_)); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); @@ -1082,14 +1082,14 @@ TEST_F(OutlierDetectorImplTest, RemoveWhileEjected) { EXPECT_EQ(0UL, outlier_detection_ejections_active_.value()); time_system_.setMonotonicTime(std::chrono::milliseconds(9999)); - EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000))); + EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); interval_timer_->invokeCallback(); } TEST_F(OutlierDetectorImplTest, Overflow) { EXPECT_CALL(cluster_.prioritySet(), addMemberUpdateCb(_)); addHosts({"tcp://127.0.0.1:80", "tcp://127.0.0.1:81"}); - EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000))); + EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create( cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, event_logger_)); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); @@ -1118,7 +1118,7 @@ TEST_F(OutlierDetectorImplTest, Overflow) { TEST_F(OutlierDetectorImplTest, NotEnforcing) { EXPECT_CALL(cluster_.prioritySet(), addMemberUpdateCb(_)); addHosts({"tcp://127.0.0.1:80"}); - EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000))); + EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create( cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, event_logger_)); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); @@ -1163,7 +1163,7 @@ TEST_F(OutlierDetectorImplTest, NotEnforcing) { TEST_F(OutlierDetectorImplTest, CrossThreadRemoveRace) { EXPECT_CALL(cluster_.prioritySet(), addMemberUpdateCb(_)); addHosts({"tcp://127.0.0.1:80"}); - EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000))); + EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create( cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, event_logger_)); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); @@ -1185,7 +1185,7 @@ TEST_F(OutlierDetectorImplTest, CrossThreadRemoveRace) { TEST_F(OutlierDetectorImplTest, CrossThreadDestroyRace) { EXPECT_CALL(cluster_.prioritySet(), addMemberUpdateCb(_)); addHosts({"tcp://127.0.0.1:80"}); - EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000))); + EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create( cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, event_logger_)); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); @@ -1208,7 +1208,7 @@ TEST_F(OutlierDetectorImplTest, CrossThreadDestroyRace) { TEST_F(OutlierDetectorImplTest, CrossThreadFailRace) { EXPECT_CALL(cluster_.prioritySet(), addMemberUpdateCb(_)); addHosts({"tcp://127.0.0.1:80"}); - EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000))); + EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create( cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, event_logger_)); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); @@ -1236,7 +1236,7 @@ TEST_F(OutlierDetectorImplTest, CrossThreadFailRace) { TEST_F(OutlierDetectorImplTest, Consecutive_5xxAlreadyEjected) { EXPECT_CALL(cluster_.prioritySet(), addMemberUpdateCb(_)); addHosts({"tcp://127.0.0.1:80"}); - EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000))); + EXPECT_CALL(*interval_timer_, enableTimer(std::chrono::milliseconds(10000), _)); std::shared_ptr detector(DetectorImpl::create( cluster_, empty_outlier_detection_, dispatcher_, runtime_, time_system_, event_logger_)); detector->addChangedStateCb([&](HostSharedPtr host) -> void { checker_.check(host); }); diff --git a/test/common/upstream/upstream_impl_test.cc b/test/common/upstream/upstream_impl_test.cc index f55f2884097a..3bb78af76687 100644 --- a/test/common/upstream/upstream_impl_test.cc +++ b/test/common/upstream/upstream_impl_test.cc @@ -221,7 +221,7 @@ TEST_F(StrictDnsClusterImplTest, ZeroHostsHealthChecker) { EXPECT_CALL(*health_checker, addHostCheckCompleteCb(_)); EXPECT_CALL(initialized, ready()); - EXPECT_CALL(*resolver.timer_, enableTimer(_)); + EXPECT_CALL(*resolver.timer_, enableTimer(_, _)); resolver.dns_callback_({}); EXPECT_EQ(0UL, cluster.prioritySet().hostSetsPerPriority()[0]->hosts().size()); EXPECT_EQ(0UL, cluster.prioritySet().hostSetsPerPriority()[0]->healthyHosts().size()); @@ -301,7 +301,7 @@ TEST_F(StrictDnsClusterImplTest, Basic) { cluster.initialize([] {}); resolver1.expectResolve(*dns_resolver_); - EXPECT_CALL(*resolver1.timer_, enableTimer(std::chrono::milliseconds(4000))); + EXPECT_CALL(*resolver1.timer_, enableTimer(std::chrono::milliseconds(4000), _)); EXPECT_CALL(membership_updated, ready()); resolver1.dns_callback_(TestUtility::makeDnsResponse({"127.0.0.1", "127.0.0.2"})); EXPECT_THAT( @@ -312,7 +312,7 @@ TEST_F(StrictDnsClusterImplTest, Basic) { resolver1.expectResolve(*dns_resolver_); resolver1.timer_->invokeCallback(); - EXPECT_CALL(*resolver1.timer_, enableTimer(std::chrono::milliseconds(4000))); + EXPECT_CALL(*resolver1.timer_, enableTimer(std::chrono::milliseconds(4000), _)); resolver1.dns_callback_(TestUtility::makeDnsResponse({"127.0.0.2", "127.0.0.1"})); EXPECT_THAT( std::list({"127.0.0.1:11001", "127.0.0.2:11001"}), @@ -320,14 +320,14 @@ TEST_F(StrictDnsClusterImplTest, Basic) { resolver1.expectResolve(*dns_resolver_); resolver1.timer_->invokeCallback(); - EXPECT_CALL(*resolver1.timer_, enableTimer(std::chrono::milliseconds(4000))); + EXPECT_CALL(*resolver1.timer_, enableTimer(std::chrono::milliseconds(4000), _)); resolver1.dns_callback_(TestUtility::makeDnsResponse({"127.0.0.2", "127.0.0.1"})); EXPECT_THAT( std::list({"127.0.0.1:11001", "127.0.0.2:11001"}), ContainerEq(hostListToAddresses(cluster.prioritySet().hostSetsPerPriority()[0]->hosts()))); resolver1.timer_->invokeCallback(); - EXPECT_CALL(*resolver1.timer_, enableTimer(std::chrono::milliseconds(4000))); + EXPECT_CALL(*resolver1.timer_, enableTimer(std::chrono::milliseconds(4000), _)); EXPECT_CALL(membership_updated, ready()); resolver1.dns_callback_(TestUtility::makeDnsResponse({"127.0.0.3"})); EXPECT_THAT( @@ -335,7 +335,7 @@ TEST_F(StrictDnsClusterImplTest, Basic) { ContainerEq(hostListToAddresses(cluster.prioritySet().hostSetsPerPriority()[0]->hosts()))); // Make sure we de-dup the same address. - EXPECT_CALL(*resolver2.timer_, enableTimer(std::chrono::milliseconds(4000))); + EXPECT_CALL(*resolver2.timer_, enableTimer(std::chrono::milliseconds(4000), _)); EXPECT_CALL(membership_updated, ready()); resolver2.dns_callback_(TestUtility::makeDnsResponse({"10.0.0.1", "10.0.0.1"})); EXPECT_THAT( @@ -390,7 +390,7 @@ TEST_F(StrictDnsClusterImplTest, HostRemovalActiveHealthSkipped) { cluster.initialize([&]() -> void {}); EXPECT_CALL(*health_checker, addHostCheckCompleteCb(_)); - EXPECT_CALL(*resolver.timer_, enableTimer(_)).Times(2); + EXPECT_CALL(*resolver.timer_, enableTimer(_, _)).Times(2); resolver.dns_callback_(TestUtility::makeDnsResponse({"127.0.0.1", "127.0.0.2"})); // Verify that both endpoints are initially marked with FAILED_ACTIVE_HC, then @@ -443,7 +443,7 @@ TEST_F(StrictDnsClusterImplTest, HostRemovalAfterHcFail) { cluster.initialize([&initialized]() { initialized.ready(); }); EXPECT_CALL(*health_checker, addHostCheckCompleteCb(_)); - EXPECT_CALL(*resolver.timer_, enableTimer(_)).Times(2); + EXPECT_CALL(*resolver.timer_, enableTimer(_, _)).Times(2); resolver.dns_callback_(TestUtility::makeDnsResponse({"127.0.0.1", "127.0.0.2"})); // Verify that both endpoints are initially marked with FAILED_ACTIVE_HC, then @@ -592,7 +592,7 @@ TEST_F(StrictDnsClusterImplTest, LoadAssignmentBasic) { cluster.initialize([] {}); resolver1.expectResolve(*dns_resolver_); - EXPECT_CALL(*resolver1.timer_, enableTimer(std::chrono::milliseconds(4000))); + EXPECT_CALL(*resolver1.timer_, enableTimer(std::chrono::milliseconds(4000), _)); EXPECT_CALL(membership_updated, ready()); resolver1.dns_callback_(TestUtility::makeDnsResponse({"127.0.0.1", "127.0.0.2"})); EXPECT_THAT( @@ -611,7 +611,7 @@ TEST_F(StrictDnsClusterImplTest, LoadAssignmentBasic) { resolver1.expectResolve(*dns_resolver_); resolver1.timer_->invokeCallback(); - EXPECT_CALL(*resolver1.timer_, enableTimer(std::chrono::milliseconds(4000))); + EXPECT_CALL(*resolver1.timer_, enableTimer(std::chrono::milliseconds(4000), _)); resolver1.dns_callback_(TestUtility::makeDnsResponse({"127.0.0.2", "127.0.0.1"})); EXPECT_THAT( std::list({"127.0.0.1:11001", "127.0.0.2:11001"}), @@ -623,7 +623,7 @@ TEST_F(StrictDnsClusterImplTest, LoadAssignmentBasic) { resolver1.expectResolve(*dns_resolver_); resolver1.timer_->invokeCallback(); - EXPECT_CALL(*resolver1.timer_, enableTimer(std::chrono::milliseconds(4000))); + EXPECT_CALL(*resolver1.timer_, enableTimer(std::chrono::milliseconds(4000), _)); resolver1.dns_callback_(TestUtility::makeDnsResponse({"127.0.0.2", "127.0.0.1"})); EXPECT_THAT( std::list({"127.0.0.1:11001", "127.0.0.2:11001"}), @@ -633,7 +633,7 @@ TEST_F(StrictDnsClusterImplTest, LoadAssignmentBasic) { // Since no change for localhost1, we expect no rebuild. EXPECT_EQ(2UL, stats_.counter("cluster.name.update_no_rebuild").value()); - EXPECT_CALL(*resolver2.timer_, enableTimer(std::chrono::milliseconds(4000))); + EXPECT_CALL(*resolver2.timer_, enableTimer(std::chrono::milliseconds(4000), _)); EXPECT_CALL(membership_updated, ready()); resolver2.dns_callback_(TestUtility::makeDnsResponse({"10.0.0.1", "10.0.0.1"})); @@ -642,14 +642,14 @@ TEST_F(StrictDnsClusterImplTest, LoadAssignmentBasic) { resolver1.expectResolve(*dns_resolver_); resolver1.timer_->invokeCallback(); - EXPECT_CALL(*resolver1.timer_, enableTimer(std::chrono::milliseconds(4000))); + EXPECT_CALL(*resolver1.timer_, enableTimer(std::chrono::milliseconds(4000), _)); resolver1.dns_callback_(TestUtility::makeDnsResponse({"127.0.0.2", "127.0.0.1"})); // We again received the same set as before for localhost1. No rebuild this time. EXPECT_EQ(3UL, stats_.counter("cluster.name.update_no_rebuild").value()); resolver1.timer_->invokeCallback(); - EXPECT_CALL(*resolver1.timer_, enableTimer(std::chrono::milliseconds(4000))); + EXPECT_CALL(*resolver1.timer_, enableTimer(std::chrono::milliseconds(4000), _)); EXPECT_CALL(membership_updated, ready()); resolver1.dns_callback_(TestUtility::makeDnsResponse({"127.0.0.3"})); EXPECT_THAT( @@ -657,7 +657,7 @@ TEST_F(StrictDnsClusterImplTest, LoadAssignmentBasic) { ContainerEq(hostListToAddresses(cluster.prioritySet().hostSetsPerPriority()[0]->hosts()))); // Make sure we de-dup the same address. - EXPECT_CALL(*resolver2.timer_, enableTimer(std::chrono::milliseconds(4000))); + EXPECT_CALL(*resolver2.timer_, enableTimer(std::chrono::milliseconds(4000), _)); resolver2.dns_callback_(TestUtility::makeDnsResponse({"10.0.0.1", "10.0.0.1"})); EXPECT_THAT( std::list({"127.0.0.3:11001", "10.0.0.1:11002"}), @@ -670,7 +670,7 @@ TEST_F(StrictDnsClusterImplTest, LoadAssignmentBasic) { cluster.prioritySet().hostSetsPerPriority()[0]->healthyHostsPerLocality().get().size()); // Make sure that we *don't* de-dup between resolve targets. - EXPECT_CALL(*resolver3.timer_, enableTimer(std::chrono::milliseconds(4000))); + EXPECT_CALL(*resolver3.timer_, enableTimer(std::chrono::milliseconds(4000), _)); EXPECT_CALL(membership_updated, ready()); resolver3.dns_callback_(TestUtility::makeDnsResponse({"10.0.0.1"})); @@ -704,11 +704,11 @@ TEST_F(StrictDnsClusterImplTest, LoadAssignmentBasic) { } }); - EXPECT_CALL(*resolver2.timer_, enableTimer(std::chrono::milliseconds(4000))); + EXPECT_CALL(*resolver2.timer_, enableTimer(std::chrono::milliseconds(4000), _)); EXPECT_CALL(membership_updated, ready()); resolver2.dns_callback_(TestUtility::makeDnsResponse({})); - EXPECT_CALL(*resolver3.timer_, enableTimer(std::chrono::milliseconds(4000))); + EXPECT_CALL(*resolver3.timer_, enableTimer(std::chrono::milliseconds(4000), _)); EXPECT_CALL(membership_updated, ready()); resolver3.dns_callback_(TestUtility::makeDnsResponse({})); @@ -789,7 +789,7 @@ TEST_F(StrictDnsClusterImplTest, LoadAssignmentBasicMultiplePriorities) { cluster.initialize([] {}); resolver1.expectResolve(*dns_resolver_); - EXPECT_CALL(*resolver1.timer_, enableTimer(std::chrono::milliseconds(4000))); + EXPECT_CALL(*resolver1.timer_, enableTimer(std::chrono::milliseconds(4000), _)); EXPECT_CALL(membership_updated, ready()); resolver1.dns_callback_(TestUtility::makeDnsResponse({"127.0.0.1", "127.0.0.2"})); EXPECT_THAT( @@ -800,7 +800,7 @@ TEST_F(StrictDnsClusterImplTest, LoadAssignmentBasicMultiplePriorities) { resolver1.expectResolve(*dns_resolver_); resolver1.timer_->invokeCallback(); - EXPECT_CALL(*resolver1.timer_, enableTimer(std::chrono::milliseconds(4000))); + EXPECT_CALL(*resolver1.timer_, enableTimer(std::chrono::milliseconds(4000), _)); resolver1.dns_callback_(TestUtility::makeDnsResponse({"127.0.0.2", "127.0.0.1"})); EXPECT_THAT( std::list({"127.0.0.1:11001", "127.0.0.2:11001"}), @@ -808,14 +808,14 @@ TEST_F(StrictDnsClusterImplTest, LoadAssignmentBasicMultiplePriorities) { resolver1.expectResolve(*dns_resolver_); resolver1.timer_->invokeCallback(); - EXPECT_CALL(*resolver1.timer_, enableTimer(std::chrono::milliseconds(4000))); + EXPECT_CALL(*resolver1.timer_, enableTimer(std::chrono::milliseconds(4000), _)); resolver1.dns_callback_(TestUtility::makeDnsResponse({"127.0.0.2", "127.0.0.1"})); EXPECT_THAT( std::list({"127.0.0.1:11001", "127.0.0.2:11001"}), ContainerEq(hostListToAddresses(cluster.prioritySet().hostSetsPerPriority()[0]->hosts()))); resolver1.timer_->invokeCallback(); - EXPECT_CALL(*resolver1.timer_, enableTimer(std::chrono::milliseconds(4000))); + EXPECT_CALL(*resolver1.timer_, enableTimer(std::chrono::milliseconds(4000), _)); EXPECT_CALL(membership_updated, ready()); resolver1.dns_callback_(TestUtility::makeDnsResponse({"127.0.0.3"})); EXPECT_THAT( @@ -823,7 +823,7 @@ TEST_F(StrictDnsClusterImplTest, LoadAssignmentBasicMultiplePriorities) { ContainerEq(hostListToAddresses(cluster.prioritySet().hostSetsPerPriority()[0]->hosts()))); // Make sure we de-dup the same address. - EXPECT_CALL(*resolver2.timer_, enableTimer(std::chrono::milliseconds(4000))); + EXPECT_CALL(*resolver2.timer_, enableTimer(std::chrono::milliseconds(4000), _)); EXPECT_CALL(membership_updated, ready()); resolver2.dns_callback_(TestUtility::makeDnsResponse({"10.0.0.1", "10.0.0.1"})); EXPECT_THAT( @@ -839,7 +839,7 @@ TEST_F(StrictDnsClusterImplTest, LoadAssignmentBasicMultiplePriorities) { EXPECT_EQ(cluster.info().get(), &host->cluster()); } - EXPECT_CALL(*resolver3.timer_, enableTimer(std::chrono::milliseconds(4000))); + EXPECT_CALL(*resolver3.timer_, enableTimer(std::chrono::milliseconds(4000), _)); EXPECT_CALL(membership_updated, ready()); resolver3.dns_callback_(TestUtility::makeDnsResponse({"192.168.1.1", "192.168.1.2"})); @@ -915,7 +915,7 @@ TEST_F(StrictDnsClusterImplTest, RecordTtlAsDnsRefreshRate) { EXPECT_CALL(membership_updated, ready()); - EXPECT_CALL(*resolver.timer_, enableTimer(std::chrono::milliseconds(5000))); + EXPECT_CALL(*resolver.timer_, enableTimer(std::chrono::milliseconds(5000), _)); resolver.dns_callback_( TestUtility::makeDnsResponse({"192.168.1.1", "192.168.1.2"}, std::chrono::seconds(5))); } @@ -944,7 +944,7 @@ TEST_F(StrictDnsClusterImplTest, DefaultTtlAsDnsRefreshRateWhenResponseEmpty) { std::move(scope), false); cluster.initialize([] {}); - EXPECT_CALL(*resolver.timer_, enableTimer(std::chrono::milliseconds(4000))); + EXPECT_CALL(*resolver.timer_, enableTimer(std::chrono::milliseconds(4000), _)); resolver.dns_callback_(TestUtility::makeDnsResponse({}, std::chrono::seconds(5))); } diff --git a/test/extensions/access_loggers/grpc/grpc_access_log_impl_test.cc b/test/extensions/access_loggers/grpc/grpc_access_log_impl_test.cc index 571d29fe48dd..83ba234f7973 100644 --- a/test/extensions/access_loggers/grpc/grpc_access_log_impl_test.cc +++ b/test/extensions/access_loggers/grpc/grpc_access_log_impl_test.cc @@ -34,7 +34,7 @@ class GrpcAccessLoggerImplTest : public testing::Test { void initLogger(std::chrono::milliseconds buffer_flush_interval_msec, size_t buffer_size_bytes) { timer_ = new Event::MockTimer(&dispatcher_); - EXPECT_CALL(*timer_, enableTimer(buffer_flush_interval_msec)); + EXPECT_CALL(*timer_, enableTimer(buffer_flush_interval_msec, _)); logger_ = std::make_unique(Grpc::RawAsyncClientPtr{async_client_}, log_name_, buffer_flush_interval_msec, buffer_size_bytes, dispatcher_, local_info_); @@ -202,7 +202,7 @@ TEST_F(GrpcAccessLoggerImplTest, Flushing) { initLogger(FlushInterval, 100); // Nothing to do yet. - EXPECT_CALL(*timer_, enableTimer(FlushInterval)); + EXPECT_CALL(*timer_, enableTimer(FlushInterval, _)); timer_->invokeCallback(); envoy::data::accesslog::v2::HTTPAccessLogEntry entry; @@ -227,11 +227,11 @@ TEST_F(GrpcAccessLoggerImplTest, Flushing) { - request: path: /test/path1 )EOF")); - EXPECT_CALL(*timer_, enableTimer(FlushInterval)); + EXPECT_CALL(*timer_, enableTimer(FlushInterval, _)); timer_->invokeCallback(); // Flush on empty message does nothing. - EXPECT_CALL(*timer_, enableTimer(FlushInterval)); + EXPECT_CALL(*timer_, enableTimer(FlushInterval, _)); timer_->invokeCallback(); } diff --git a/test/extensions/clusters/redis/redis_cluster_test.cc b/test/extensions/clusters/redis/redis_cluster_test.cc index 7d6a4967cc8a..cab0c63f34f1 100644 --- a/test/extensions/clusters/redis/redis_cluster_test.cc +++ b/test/extensions/clusters/redis/redis_cluster_test.cc @@ -168,12 +168,12 @@ class RedisClusterTest : public testing::Test, } void expectClusterSlotResponse(NetworkFilters::Common::Redis::RespValuePtr&& response) { - EXPECT_CALL(*resolve_timer_, enableTimer(_)); + EXPECT_CALL(*resolve_timer_, enableTimer(_, _)); pool_callbacks_->onResponse(std::move(response)); } void expectClusterSlotFailure() { - EXPECT_CALL(*resolve_timer_, enableTimer(_)); + EXPECT_CALL(*resolve_timer_, enableTimer(_, _)); pool_callbacks_->onFailure(); } @@ -632,7 +632,7 @@ TEST_F(RedisClusterTest, EmptyDnsResponse) { Event::MockTimer* dns_timer = new NiceMock(&dispatcher_); setupFromV2Yaml(BasicConfig); const std::list resolved_addresses{}; - EXPECT_CALL(*dns_timer, enableTimer(_)); + EXPECT_CALL(*dns_timer, enableTimer(_, _)); expectResolveDiscovery(Network::DnsLookupFamily::V4Only, "foo.bar.com", resolved_addresses); EXPECT_CALL(initialized_, ready()); @@ -643,7 +643,7 @@ TEST_F(RedisClusterTest, EmptyDnsResponse) { EXPECT_EQ(1U, cluster_->info()->stats().update_empty_.value()); // Does not recreate the timer on subsequent DNS resolve calls. - EXPECT_CALL(*dns_timer, enableTimer(_)); + EXPECT_CALL(*dns_timer, enableTimer(_, _)); expectResolveDiscovery(Network::DnsLookupFamily::V4Only, "foo.bar.com", resolved_addresses); dns_timer->invokeCallback(); diff --git a/test/extensions/common/dynamic_forward_proxy/dns_cache_impl_test.cc b/test/extensions/common/dynamic_forward_proxy/dns_cache_impl_test.cc index 7f69ca894a68..0097b254329b 100644 --- a/test/extensions/common/dynamic_forward_proxy/dns_cache_impl_test.cc +++ b/test/extensions/common/dynamic_forward_proxy/dns_cache_impl_test.cc @@ -98,7 +98,7 @@ TEST_F(DnsCacheImplTest, ResolveSuccess) { EXPECT_CALL(update_callbacks_, onDnsHostAddOrUpdate("foo.com", DnsHostInfoEquals("10.0.0.1:80", "foo.com", false))); EXPECT_CALL(callbacks, onLoadDnsCacheComplete()); - EXPECT_CALL(*resolve_timer, enableTimer(std::chrono::milliseconds(60000))); + EXPECT_CALL(*resolve_timer, enableTimer(std::chrono::milliseconds(60000), _)); resolve_cb(TestUtility::makeDnsResponse({"10.0.0.1"})); checkStats(1 /* attempt */, 1 /* success */, 0 /* failure */, 1 /* address changed */, @@ -113,7 +113,7 @@ TEST_F(DnsCacheImplTest, ResolveSuccess) { 1 /* added */, 0 /* removed */, 1 /* num hosts */); // Address does not change. - EXPECT_CALL(*resolve_timer, enableTimer(std::chrono::milliseconds(60000))); + EXPECT_CALL(*resolve_timer, enableTimer(std::chrono::milliseconds(60000), _)); resolve_cb(TestUtility::makeDnsResponse({"10.0.0.1"})); checkStats(2 /* attempt */, 2 /* success */, 0 /* failure */, 1 /* address changed */, @@ -130,7 +130,7 @@ TEST_F(DnsCacheImplTest, ResolveSuccess) { // Address does change. EXPECT_CALL(update_callbacks_, onDnsHostAddOrUpdate("foo.com", DnsHostInfoEquals("10.0.0.2:80", "foo.com", false))); - EXPECT_CALL(*resolve_timer, enableTimer(std::chrono::milliseconds(60000))); + EXPECT_CALL(*resolve_timer, enableTimer(std::chrono::milliseconds(60000), _)); resolve_cb(TestUtility::makeDnsResponse({"10.0.0.2"})); checkStats(3 /* attempt */, 3 /* success */, 0 /* failure */, 2 /* address changed */, @@ -155,7 +155,7 @@ TEST_F(DnsCacheImplTest, Ipv4Address) { update_callbacks_, onDnsHostAddOrUpdate("127.0.0.1", DnsHostInfoEquals("127.0.0.1:80", "127.0.0.1", true))); EXPECT_CALL(callbacks, onLoadDnsCacheComplete()); - EXPECT_CALL(*resolve_timer, enableTimer(std::chrono::milliseconds(60000))); + EXPECT_CALL(*resolve_timer, enableTimer(std::chrono::milliseconds(60000), _)); resolve_cb(TestUtility::makeDnsResponse({"127.0.0.1"})); } @@ -177,7 +177,7 @@ TEST_F(DnsCacheImplTest, Ipv4AddressWithPort) { onDnsHostAddOrUpdate("127.0.0.1:10000", DnsHostInfoEquals("127.0.0.1:10000", "127.0.0.1", true))); EXPECT_CALL(callbacks, onLoadDnsCacheComplete()); - EXPECT_CALL(*resolve_timer, enableTimer(std::chrono::milliseconds(60000))); + EXPECT_CALL(*resolve_timer, enableTimer(std::chrono::milliseconds(60000), _)); resolve_cb(TestUtility::makeDnsResponse({"127.0.0.1"})); } @@ -198,7 +198,7 @@ TEST_F(DnsCacheImplTest, Ipv6Address) { EXPECT_CALL(update_callbacks_, onDnsHostAddOrUpdate("[::1]", DnsHostInfoEquals("[::1]:80", "::1", true))); EXPECT_CALL(callbacks, onLoadDnsCacheComplete()); - EXPECT_CALL(*resolve_timer, enableTimer(std::chrono::milliseconds(60000))); + EXPECT_CALL(*resolve_timer, enableTimer(std::chrono::milliseconds(60000), _)); resolve_cb(TestUtility::makeDnsResponse({"::1"})); } @@ -219,7 +219,7 @@ TEST_F(DnsCacheImplTest, Ipv6AddressWithPort) { EXPECT_CALL(update_callbacks_, onDnsHostAddOrUpdate("[::1]:10000", DnsHostInfoEquals("[::1]:10000", "::1", true))); EXPECT_CALL(callbacks, onLoadDnsCacheComplete()); - EXPECT_CALL(*resolve_timer, enableTimer(std::chrono::milliseconds(60000))); + EXPECT_CALL(*resolve_timer, enableTimer(std::chrono::milliseconds(60000), _)); resolve_cb(TestUtility::makeDnsResponse({"::1"})); } @@ -243,7 +243,7 @@ TEST_F(DnsCacheImplTest, TTL) { EXPECT_CALL(update_callbacks_, onDnsHostAddOrUpdate("foo.com", DnsHostInfoEquals("10.0.0.1:80", "foo.com", false))); EXPECT_CALL(callbacks, onLoadDnsCacheComplete()); - EXPECT_CALL(*resolve_timer, enableTimer(std::chrono::milliseconds(60000))); + EXPECT_CALL(*resolve_timer, enableTimer(std::chrono::milliseconds(60000), _)); resolve_cb(TestUtility::makeDnsResponse({"10.0.0.1"}, std::chrono::seconds(0))); checkStats(1 /* attempt */, 1 /* success */, 0 /* failure */, 1 /* address changed */, @@ -257,7 +257,7 @@ TEST_F(DnsCacheImplTest, TTL) { checkStats(2 /* attempt */, 1 /* success */, 0 /* failure */, 1 /* address changed */, 1 /* added */, 0 /* removed */, 1 /* num hosts */); - EXPECT_CALL(*resolve_timer, enableTimer(std::chrono::milliseconds(60000))); + EXPECT_CALL(*resolve_timer, enableTimer(std::chrono::milliseconds(60000), _)); resolve_cb(TestUtility::makeDnsResponse({"10.0.0.1"})); checkStats(2 /* attempt */, 2 /* success */, 0 /* failure */, 1 /* address changed */, 1 /* added */, 0 /* removed */, 1 /* num hosts */); @@ -300,7 +300,7 @@ TEST_F(DnsCacheImplTest, TTLWithCustomParameters) { EXPECT_CALL(update_callbacks_, onDnsHostAddOrUpdate("foo.com", DnsHostInfoEquals("10.0.0.1:80", "foo.com", false))); EXPECT_CALL(callbacks, onLoadDnsCacheComplete()); - EXPECT_CALL(*resolve_timer, enableTimer(std::chrono::milliseconds(30000))); + EXPECT_CALL(*resolve_timer, enableTimer(std::chrono::milliseconds(30000), _)); resolve_cb(TestUtility::makeDnsResponse({"10.0.0.1"}, std::chrono::seconds(0))); // Re-resolve with ~30s passed. TTL should still be OK at 60s. @@ -308,7 +308,7 @@ TEST_F(DnsCacheImplTest, TTLWithCustomParameters) { EXPECT_CALL(*resolver_, resolve("foo.com", _, _)) .WillOnce(DoAll(SaveArg<2>(&resolve_cb), Return(&resolver_->active_query_))); resolve_timer->invokeCallback(); - EXPECT_CALL(*resolve_timer, enableTimer(std::chrono::milliseconds(30000))); + EXPECT_CALL(*resolve_timer, enableTimer(std::chrono::milliseconds(30000), _)); resolve_cb(TestUtility::makeDnsResponse({"10.0.0.1"})); // Re-resolve with ~30s passed. TTL should expire. @@ -340,7 +340,7 @@ TEST_F(DnsCacheImplTest, InlineResolve) { update_callbacks_, onDnsHostAddOrUpdate("localhost", DnsHostInfoEquals("127.0.0.1:80", "localhost", false))); EXPECT_CALL(callbacks, onLoadDnsCacheComplete()); - EXPECT_CALL(*resolve_timer, enableTimer(std::chrono::milliseconds(60000))); + EXPECT_CALL(*resolve_timer, enableTimer(std::chrono::milliseconds(60000), _)); post_cb(); } diff --git a/test/extensions/filters/http/fault/fault_filter_test.cc b/test/extensions/filters/http/fault/fault_filter_test.cc index e6cbf4ace6b9..038e674c73b3 100644 --- a/test/extensions/filters/http/fault/fault_filter_test.cc +++ b/test/extensions/filters/http/fault/fault_filter_test.cc @@ -142,7 +142,7 @@ class FaultFilterTest : public testing::Test { void expectDelayTimer(uint64_t duration_ms) { timer_ = new Event::MockTimer(&decoder_filter_callbacks_.dispatcher_); - EXPECT_CALL(*timer_, enableTimer(std::chrono::milliseconds(duration_ms))); + EXPECT_CALL(*timer_, enableTimer(std::chrono::milliseconds(duration_ms), _)); EXPECT_CALL(*timer_, disableTimer()); } @@ -766,7 +766,7 @@ TEST_F(FaultFilterTest, TimerResetAfterStreamReset) { SCOPED_TRACE("FixedDelayWithStreamReset"); timer_ = new Event::MockTimer(&decoder_filter_callbacks_.dispatcher_); - EXPECT_CALL(*timer_, enableTimer(std::chrono::milliseconds(5000UL))); + EXPECT_CALL(*timer_, enableTimer(std::chrono::milliseconds(5000UL), _)); EXPECT_CALL(decoder_filter_callbacks_.stream_info_, setResponseFlag(StreamInfo::ResponseFlag::DelayInjected)); @@ -1053,7 +1053,7 @@ TEST_F(FaultFilterRateLimitTest, ResponseRateLimitEnabled) { // Send a small amount of data which should be within limit. Buffer::OwnedImpl data1("hello"); - EXPECT_CALL(*token_timer, enableTimer(std::chrono::milliseconds(0))); + EXPECT_CALL(*token_timer, enableTimer(std::chrono::milliseconds(0), _)); EXPECT_EQ(Http::FilterDataStatus::StopIterationNoBuffer, filter_->encodeData(data1, false)); EXPECT_CALL(encoder_filter_callbacks_, injectEncodedDataToFilterChain(BufferStringEqual("hello"), false)); @@ -1064,11 +1064,11 @@ TEST_F(FaultFilterRateLimitTest, ResponseRateLimitEnabled) { // Send 1152 bytes of data which is 1s + 2 refill cycles of data. EXPECT_CALL(encoder_filter_callbacks_, onEncoderFilterAboveWriteBufferHighWatermark()); - EXPECT_CALL(*token_timer, enableTimer(std::chrono::milliseconds(0))); + EXPECT_CALL(*token_timer, enableTimer(std::chrono::milliseconds(0), _)); Buffer::OwnedImpl data2(std::string(1152, 'a')); EXPECT_EQ(Http::FilterDataStatus::StopIterationNoBuffer, filter_->encodeData(data2, false)); - EXPECT_CALL(*token_timer, enableTimer(std::chrono::milliseconds(63))); + EXPECT_CALL(*token_timer, enableTimer(std::chrono::milliseconds(63), _)); EXPECT_CALL(encoder_filter_callbacks_, onEncoderFilterBelowWriteBufferLowWatermark()); EXPECT_CALL(encoder_filter_callbacks_, injectEncodedDataToFilterChain(BufferStringEqual(std::string(1024, 'a')), false)); @@ -1076,7 +1076,7 @@ TEST_F(FaultFilterRateLimitTest, ResponseRateLimitEnabled) { // Fire timer, also advance time. time_system_.sleep(std::chrono::milliseconds(63)); - EXPECT_CALL(*token_timer, enableTimer(std::chrono::milliseconds(63))); + EXPECT_CALL(*token_timer, enableTimer(std::chrono::milliseconds(63), _)); EXPECT_CALL(encoder_filter_callbacks_, injectEncodedDataToFilterChain(BufferStringEqual(std::string(64, 'a')), false)); token_timer->invokeCallback(); @@ -1087,7 +1087,7 @@ TEST_F(FaultFilterRateLimitTest, ResponseRateLimitEnabled) { // Fire timer, also advance time. time_system_.sleep(std::chrono::milliseconds(63)); - EXPECT_CALL(*token_timer, enableTimer(std::chrono::milliseconds(63))); + EXPECT_CALL(*token_timer, enableTimer(std::chrono::milliseconds(63), _)); EXPECT_CALL(encoder_filter_callbacks_, injectEncodedDataToFilterChain(BufferStringEqual(std::string(64, 'a')), false)); token_timer->invokeCallback(); @@ -1102,7 +1102,7 @@ TEST_F(FaultFilterRateLimitTest, ResponseRateLimitEnabled) { time_system_.sleep(std::chrono::seconds(1)); // Now send 1024 in one shot with end_stream true which should go through and end the stream. - EXPECT_CALL(*token_timer, enableTimer(std::chrono::milliseconds(0))); + EXPECT_CALL(*token_timer, enableTimer(std::chrono::milliseconds(0), _)); Buffer::OwnedImpl data4(std::string(1024, 'c')); EXPECT_EQ(Http::FilterDataStatus::StopIterationNoBuffer, filter_->encodeData(data4, true)); EXPECT_CALL(encoder_filter_callbacks_, diff --git a/test/extensions/filters/http/health_check/health_check_test.cc b/test/extensions/filters/http/health_check/health_check_test.cc index 85f2d242c39d..34df211019b7 100644 --- a/test/extensions/filters/http/health_check/health_check_test.cc +++ b/test/extensions/filters/http/health_check/health_check_test.cc @@ -37,7 +37,7 @@ class HealthCheckFilterTest : public testing::Test { if (caching) { cache_timer_ = new Event::MockTimer(&dispatcher_); - EXPECT_CALL(*cache_timer_, enableTimer(_)); + EXPECT_CALL(*cache_timer_, enableTimer(_, _)); cache_manager_.reset(new HealthCheckCacheManager(dispatcher_, std::chrono::milliseconds(1))); } @@ -359,7 +359,7 @@ TEST_F(HealthCheckFilterCachingTest, All) { filter_->decodeHeaders(request_headers_, true)); // Fire the timer, this should result in the next request going through. - EXPECT_CALL(*cache_timer_, enableTimer(_)); + EXPECT_CALL(*cache_timer_, enableTimer(_, _)); cache_timer_->invokeCallback(); prepareFilter(true); EXPECT_EQ(Http::FilterHeadersStatus::Continue, filter_->decodeHeaders(request_headers_, true)); @@ -393,7 +393,7 @@ TEST_F(HealthCheckFilterCachingTest, DegradedHeader) { filter_->decodeHeaders(request_headers_, true)); // Fire the timer, this should result in the next request going through. - EXPECT_CALL(*cache_timer_, enableTimer(_)); + EXPECT_CALL(*cache_timer_, enableTimer(_, _)); cache_timer_->invokeCallback(); prepareFilter(true); EXPECT_EQ(Http::FilterHeadersStatus::Continue, filter_->decodeHeaders(request_headers_, true)); diff --git a/test/extensions/filters/http/squash/squash_filter_test.cc b/test/extensions/filters/http/squash/squash_filter_test.cc index 0800a51499cb..2cf509c59b5f 100644 --- a/test/extensions/filters/http/squash/squash_filter_test.cc +++ b/test/extensions/filters/http/squash/squash_filter_test.cc @@ -196,7 +196,7 @@ class SquashFilterTest : public testing::Test { expectAsyncClientSend(); - EXPECT_CALL(*attachmentTimeout_timer_, enableTimer(config_->attachmentTimeout())); + EXPECT_CALL(*attachmentTimeout_timer_, enableTimer(config_->attachmentTimeout(), _)); Envoy::Http::TestHeaderMapImpl headers{{":method", "GET"}, {":authority", "www.solo.io"}, @@ -354,7 +354,7 @@ TEST_F(SquashFilterTest, CheckRetryPollingAttachment) { NiceMock* retry_timer; retry_timer = new NiceMock(&filter_callbacks_.dispatcher_); - EXPECT_CALL(*retry_timer, enableTimer(config_->attachmentPollPeriod())); + EXPECT_CALL(*retry_timer, enableTimer(config_->attachmentPollPeriod(), _)); completeGetStatusRequest("attaching"); // Expect the second get attachment request @@ -372,7 +372,7 @@ TEST_F(SquashFilterTest, CheckRetryPollingAttachmentOnFailure) { NiceMock* retry_timer; retry_timer = new NiceMock(&filter_callbacks_.dispatcher_); - EXPECT_CALL(*retry_timer, enableTimer(config_->attachmentPollPeriod())); + EXPECT_CALL(*retry_timer, enableTimer(config_->attachmentPollPeriod(), _)); popPendingCallback()->onFailure(Envoy::Http::AsyncClient::FailureReason::Reset); // Expect the second get attachment request @@ -391,7 +391,7 @@ TEST_F(SquashFilterTest, DestroyedInTheMiddle) { completeCreateRequest(); auto retry_timer = new NiceMock(&filter_callbacks_.dispatcher_); - EXPECT_CALL(*retry_timer, enableTimer(config_->attachmentPollPeriod())); + EXPECT_CALL(*retry_timer, enableTimer(config_->attachmentPollPeriod(), _)); completeGetStatusRequest("attaching"); EXPECT_CALL(*attachmentTimeout_timer_, disableTimer()); @@ -413,7 +413,7 @@ TEST_F(SquashFilterTest, InvalidJsonForGetAttachment) { completeCreateRequest(); auto retry_timer = new NiceMock(&filter_callbacks_.dispatcher_); - EXPECT_CALL(*retry_timer, enableTimer(config_->attachmentPollPeriod())); + EXPECT_CALL(*retry_timer, enableTimer(config_->attachmentPollPeriod(), _)); completeRequest("200", "This is not a JSON object"); } @@ -430,10 +430,9 @@ TEST_F(SquashFilterTest, TimerExpiresInline) { initFilter(); attachmentTimeout_timer_ = new NiceMock(&filter_callbacks_.dispatcher_); - // TODO: this is a really synthetic test as the callback can't actually be called under the stack - // of enableTimer. It'd be good to clean this up. - EXPECT_CALL(*attachmentTimeout_timer_, enableTimer(config_->attachmentTimeout())) - .WillOnce(Invoke([&](const std::chrono::milliseconds&) { + EXPECT_CALL(*attachmentTimeout_timer_, enableTimer(config_->attachmentTimeout(), _)) + .WillOnce(Invoke([&](const std::chrono::milliseconds&, const ScopeTrackedObject* scope) { + attachmentTimeout_timer_->scope_ = scope; attachmentTimeout_timer_->enabled_ = true; // timer expires inline attachmentTimeout_timer_->invokeCallback(); diff --git a/test/extensions/filters/network/client_ssl_auth/client_ssl_auth_test.cc b/test/extensions/filters/network/client_ssl_auth/client_ssl_auth_test.cc index 23b7f9acf6d8..5e50b3769158 100644 --- a/test/extensions/filters/network/client_ssl_auth/client_ssl_auth_test.cc +++ b/test/extensions/filters/network/client_ssl_auth/client_ssl_auth_test.cc @@ -167,7 +167,7 @@ TEST_F(ClientSslAuthFilterTest, Ssl) { filter_callbacks_.connection_.raiseEvent(Network::ConnectionEvent::RemoteClose); // Respond. - EXPECT_CALL(*interval_timer_, enableTimer(_)); + EXPECT_CALL(*interval_timer_, enableTimer(_, _)); Http::MessagePtr message(new Http::ResponseMessageImpl( Http::HeaderMapPtr{new Http::TestHeaderMapImpl{{":status", "200"}}})); message->body() = std::make_unique( @@ -224,7 +224,7 @@ TEST_F(ClientSslAuthFilterTest, Ssl) { interval_timer_->invokeCallback(); // Error response. - EXPECT_CALL(*interval_timer_, enableTimer(_)); + EXPECT_CALL(*interval_timer_, enableTimer(_, _)); message = std::make_unique( Http::HeaderMapPtr{new Http::TestHeaderMapImpl{{":status", "503"}}}); callbacks_->onSuccess(std::move(message)); @@ -234,7 +234,7 @@ TEST_F(ClientSslAuthFilterTest, Ssl) { interval_timer_->invokeCallback(); // Parsing error - EXPECT_CALL(*interval_timer_, enableTimer(_)); + EXPECT_CALL(*interval_timer_, enableTimer(_, _)); message = std::make_unique( Http::HeaderMapPtr{new Http::TestHeaderMapImpl{{":status", "200"}}}); message->body() = std::make_unique("bad_json"); @@ -245,7 +245,7 @@ TEST_F(ClientSslAuthFilterTest, Ssl) { interval_timer_->invokeCallback(); // No response failure. - EXPECT_CALL(*interval_timer_, enableTimer(_)); + EXPECT_CALL(*interval_timer_, enableTimer(_, _)); callbacks_->onFailure(Http::AsyncClient::FailureReason::Reset); // Interval timer fires, cannot obtain async client. @@ -258,7 +258,7 @@ TEST_F(ClientSslAuthFilterTest, Ssl) { Http::HeaderMapPtr{new Http::TestHeaderMapImpl{{":status", "503"}}})}); return nullptr; })); - EXPECT_CALL(*interval_timer_, enableTimer(_)); + EXPECT_CALL(*interval_timer_, enableTimer(_, _)); interval_timer_->invokeCallback(); EXPECT_EQ(4U, stats_store_.counter("auth.clientssl.vpn.update_failure").value()); diff --git a/test/extensions/filters/network/common/redis/client_impl_test.cc b/test/extensions/filters/network/common/redis/client_impl_test.cc index e9d28235610d..a6646c86741a 100644 --- a/test/extensions/filters/network/common/redis/client_impl_test.cc +++ b/test/extensions/filters/network/common/redis/client_impl_test.cc @@ -66,7 +66,7 @@ class RedisClientImplTest : public testing::Test, public Common::Redis::DecoderF connect_or_op_timer_ = new Event::MockTimer(&dispatcher_); flush_timer_ = new Event::MockTimer(&dispatcher_); - EXPECT_CALL(*connect_or_op_timer_, enableTimer(_)); + EXPECT_CALL(*connect_or_op_timer_, enableTimer(_, _)); EXPECT_CALL(*host_, createConnection_(_, _)).WillOnce(Return(conn_info)); EXPECT_CALL(*upstream_connection_, addReadFilter(_)) .WillOnce(SaveArg<0>(&upstream_read_filter_)); @@ -85,7 +85,7 @@ class RedisClientImplTest : public testing::Test, public Common::Redis::DecoderF } void onConnected() { - EXPECT_CALL(*connect_or_op_timer_, enableTimer(_)); + EXPECT_CALL(*connect_or_op_timer_, enableTimer(_, _)); upstream_connection_->raiseEvent(Network::ConnectionEvent::Connected); } @@ -170,7 +170,7 @@ TEST_F(RedisClientImplTest, BatchWithTimerFiring) { Common::Redis::RespValue request1; MockPoolCallbacks callbacks1; EXPECT_CALL(*encoder_, encode(Ref(request1), _)); - EXPECT_CALL(*flush_timer_, enableTimer(_)); + EXPECT_CALL(*flush_timer_, enableTimer(_, _)); PoolRequest* handle1 = client_->makeRequest(request1, callbacks1); EXPECT_NE(nullptr, handle1); @@ -212,7 +212,7 @@ TEST_F(RedisClientImplTest, BatchWithTimerCancelledByBufferFlush) { Common::Redis::RespValue request1; MockPoolCallbacks callbacks1; EXPECT_CALL(*encoder_, encode(Ref(request1), _)); - EXPECT_CALL(*flush_timer_, enableTimer(_)); + EXPECT_CALL(*flush_timer_, enableTimer(_, _)); PoolRequest* handle1 = client_->makeRequest(request1, callbacks1); EXPECT_NE(nullptr, handle1); @@ -232,7 +232,7 @@ TEST_F(RedisClientImplTest, BatchWithTimerCancelledByBufferFlush) { InSequence s; Common::Redis::RespValuePtr response1(new Common::Redis::RespValue()); EXPECT_CALL(callbacks1, onResponse_(Ref(response1))); - EXPECT_CALL(*connect_or_op_timer_, enableTimer(_)); + EXPECT_CALL(*connect_or_op_timer_, enableTimer(_, _)); EXPECT_CALL(host_->outlier_detector_, putResult(Upstream::Outlier::Result::EXT_ORIGIN_REQUEST_SUCCESS, _)); callbacks_->onRespValue(std::move(response1)); @@ -282,7 +282,7 @@ TEST_F(RedisClientImplTest, Basic) { InSequence s; Common::Redis::RespValuePtr response1(new Common::Redis::RespValue()); EXPECT_CALL(callbacks1, onResponse_(Ref(response1))); - EXPECT_CALL(*connect_or_op_timer_, enableTimer(_)); + EXPECT_CALL(*connect_or_op_timer_, enableTimer(_, _)); EXPECT_CALL(host_->outlier_detector_, putResult(Upstream::Outlier::Result::EXT_ORIGIN_REQUEST_SUCCESS, _)); callbacks_->onRespValue(std::move(response1)); @@ -330,7 +330,7 @@ TEST_F(RedisClientImplTest, Cancel) { Common::Redis::RespValuePtr response1(new Common::Redis::RespValue()); EXPECT_CALL(callbacks1, onResponse_(_)).Times(0); - EXPECT_CALL(*connect_or_op_timer_, enableTimer(_)); + EXPECT_CALL(*connect_or_op_timer_, enableTimer(_, _)); EXPECT_CALL(host_->outlier_detector_, putResult(Upstream::Outlier::Result::EXT_ORIGIN_REQUEST_SUCCESS, _)); callbacks_->onRespValue(std::move(response1)); @@ -543,7 +543,7 @@ TEST_F(RedisClientImplTest, OpTimeout) { EXPECT_CALL(*encoder_, encode(Ref(request1), _)); EXPECT_CALL(*flush_timer_, enabled()).WillOnce(Return(false)); - EXPECT_CALL(*connect_or_op_timer_, enableTimer(_)); + EXPECT_CALL(*connect_or_op_timer_, enableTimer(_, _)); handle1 = client_->makeRequest(request1, callbacks1); EXPECT_NE(nullptr, handle1); @@ -596,7 +596,7 @@ TEST_F(RedisClientImplTest, AskRedirection) { // Simulate redirection failure. EXPECT_CALL(callbacks1, onRedirection(Ref(*response1))).WillOnce(Return(false)); EXPECT_CALL(callbacks1, onResponse_(Ref(response1))); - EXPECT_CALL(*connect_or_op_timer_, enableTimer(_)); + EXPECT_CALL(*connect_or_op_timer_, enableTimer(_, _)); EXPECT_CALL(host_->outlier_detector_, putResult(Upstream::Outlier::Result::EXT_ORIGIN_REQUEST_SUCCESS, _)); callbacks_->onRespValue(std::move(response1)); @@ -658,7 +658,7 @@ TEST_F(RedisClientImplTest, MovedRedirection) { // Simulate redirection failure. EXPECT_CALL(callbacks1, onRedirection(Ref(*response1))).WillOnce(Return(false)); EXPECT_CALL(callbacks1, onResponse_(Ref(response1))); - EXPECT_CALL(*connect_or_op_timer_, enableTimer(_)); + EXPECT_CALL(*connect_or_op_timer_, enableTimer(_, _)); EXPECT_CALL(host_->outlier_detector_, putResult(Upstream::Outlier::Result::EXT_ORIGIN_REQUEST_SUCCESS, _)); callbacks_->onRespValue(std::move(response1)); @@ -719,7 +719,7 @@ TEST_F(RedisClientImplTest, AskRedirectionNotEnabled) { response1->asString() = "ASK 1111 10.1.2.3:4321"; // Simulate redirection failure. EXPECT_CALL(callbacks1, onResponse_(Ref(response1))); - EXPECT_CALL(*connect_or_op_timer_, enableTimer(_)); + EXPECT_CALL(*connect_or_op_timer_, enableTimer(_, _)); EXPECT_CALL(host_->outlier_detector_, putResult(Upstream::Outlier::Result::EXT_ORIGIN_REQUEST_SUCCESS, _)); callbacks_->onRespValue(std::move(response1)); @@ -781,7 +781,7 @@ TEST_F(RedisClientImplTest, MovedRedirectionNotEnabled) { // The exact values of the hash slot and IP info are not important. response1->asString() = "MOVED 1111 10.1.2.3:4321"; EXPECT_CALL(callbacks1, onResponse_(Ref(response1))); - EXPECT_CALL(*connect_or_op_timer_, enableTimer(_)); + EXPECT_CALL(*connect_or_op_timer_, enableTimer(_, _)); EXPECT_CALL(host_->outlier_detector_, putResult(Upstream::Outlier::Result::EXT_ORIGIN_REQUEST_SUCCESS, _)); callbacks_->onRespValue(std::move(response1)); diff --git a/test/extensions/filters/network/mongo_proxy/proxy_test.cc b/test/extensions/filters/network/mongo_proxy/proxy_test.cc index 2fb9b66221db..01d0c8082332 100644 --- a/test/extensions/filters/network/mongo_proxy/proxy_test.cc +++ b/test/extensions/filters/network/mongo_proxy/proxy_test.cc @@ -133,7 +133,7 @@ TEST_F(MongoProxyFilterTest, DelayFaults) { Event::MockTimer* delay_timer = new Event::MockTimer(&read_filter_callbacks_.connection_.dispatcher_); - EXPECT_CALL(*delay_timer, enableTimer(std::chrono::milliseconds(10))); + EXPECT_CALL(*delay_timer, enableTimer(std::chrono::milliseconds(10), _)); EXPECT_CALL(*file_, write(_)).Times(AtLeast(1)); EXPECT_CALL(*filter_->decoder_, onData(_)).WillOnce(Invoke([&](Buffer::Instance&) -> void { @@ -551,7 +551,7 @@ TEST_F(MongoProxyFilterTest, ConcurrentQueryWithDrainClose) { .WillByDefault(Return(true)); EXPECT_CALL(drain_decision_, drainClose()).WillOnce(Return(true)); drain_timer = new Event::MockTimer(&read_filter_callbacks_.connection_.dispatcher_); - EXPECT_CALL(*drain_timer, enableTimer(std::chrono::milliseconds(0))); + EXPECT_CALL(*drain_timer, enableTimer(std::chrono::milliseconds(0), _)); filter_->callbacks_->decodeReply(std::move(message)); })); filter_->onWrite(fake_data_, false); @@ -595,7 +595,7 @@ TEST_F(MongoProxyFilterTest, ConnectionDestroyLocal) { Event::MockTimer* delay_timer = new Event::MockTimer(&read_filter_callbacks_.connection_.dispatcher_); - EXPECT_CALL(*delay_timer, enableTimer(std::chrono::milliseconds(10))); + EXPECT_CALL(*delay_timer, enableTimer(std::chrono::milliseconds(10), _)); EXPECT_CALL(*filter_->decoder_, onData(_)).WillOnce(Invoke([&](Buffer::Instance&) -> void { QueryMessagePtr message(new QueryMessageImpl(0, 0)); @@ -619,7 +619,7 @@ TEST_F(MongoProxyFilterTest, ConnectionDestroyRemote) { Event::MockTimer* delay_timer = new Event::MockTimer(&read_filter_callbacks_.connection_.dispatcher_); - EXPECT_CALL(*delay_timer, enableTimer(std::chrono::milliseconds(10))); + EXPECT_CALL(*delay_timer, enableTimer(std::chrono::milliseconds(10), _)); EXPECT_CALL(*filter_->decoder_, onData(_)).WillOnce(Invoke([&](Buffer::Instance&) -> void { QueryMessagePtr message(new QueryMessageImpl(0, 0)); diff --git a/test/extensions/health_checkers/redis/redis_test.cc b/test/extensions/health_checkers/redis/redis_test.cc index f8be7912d129..2d721cacf56d 100644 --- a/test/extensions/health_checkers/redis/redis_test.cc +++ b/test/extensions/health_checkers/redis/redis_test.cc @@ -146,13 +146,13 @@ class RedisHealthCheckerTest void expectExistsRequestCreate() { EXPECT_CALL(*client_, makeRequest(Ref(RedisHealthChecker::existsHealthCheckRequest("")), _)) .WillOnce(DoAll(WithArg<1>(SaveArgAddress(&pool_callbacks_)), Return(&pool_request_))); - EXPECT_CALL(*timeout_timer_, enableTimer(_)); + EXPECT_CALL(*timeout_timer_, enableTimer(_, _)); } void expectPingRequestCreate() { EXPECT_CALL(*client_, makeRequest(Ref(RedisHealthChecker::pingHealthCheckRequest()), _)) .WillOnce(DoAll(WithArg<1>(SaveArgAddress(&pool_callbacks_)), Return(&pool_request_))); - EXPECT_CALL(*timeout_timer_, enableTimer(_)); + EXPECT_CALL(*timeout_timer_, enableTimer(_, _)); } void exerciseStubs() { @@ -204,7 +204,7 @@ TEST_F(RedisHealthCheckerTest, PingAndVariousFailures) { // Success EXPECT_CALL(*timeout_timer_, disableTimer()); - EXPECT_CALL(*interval_timer_, enableTimer(_)); + EXPECT_CALL(*interval_timer_, enableTimer(_, _)); NetworkFilters::Common::Redis::RespValuePtr response( new NetworkFilters::Common::Redis::RespValue()); response->type(NetworkFilters::Common::Redis::RespType::SimpleString); @@ -217,7 +217,7 @@ TEST_F(RedisHealthCheckerTest, PingAndVariousFailures) { // Failure EXPECT_CALL(*event_logger_, logEjectUnhealthy(_, _, _)); EXPECT_CALL(*timeout_timer_, disableTimer()); - EXPECT_CALL(*interval_timer_, enableTimer(_)); + EXPECT_CALL(*interval_timer_, enableTimer(_, _)); response = std::make_unique(); pool_callbacks_->onResponse(std::move(response)); @@ -226,7 +226,7 @@ TEST_F(RedisHealthCheckerTest, PingAndVariousFailures) { // Redis failure via disconnect EXPECT_CALL(*timeout_timer_, disableTimer()); - EXPECT_CALL(*interval_timer_, enableTimer(_)); + EXPECT_CALL(*interval_timer_, enableTimer(_, _)); pool_callbacks_->onFailure(); client_->raiseEvent(Network::ConnectionEvent::RemoteClose); @@ -238,7 +238,7 @@ TEST_F(RedisHealthCheckerTest, PingAndVariousFailures) { EXPECT_CALL(pool_request_, cancel()); EXPECT_CALL(*client_, close()); EXPECT_CALL(*timeout_timer_, disableTimer()); - EXPECT_CALL(*interval_timer_, enableTimer(_)); + EXPECT_CALL(*interval_timer_, enableTimer(_, _)); timeout_timer_->invokeCallback(); expectClientCreate(); @@ -272,7 +272,7 @@ TEST_F(RedisHealthCheckerTest, FailuresLogging) { // Success EXPECT_CALL(*timeout_timer_, disableTimer()); - EXPECT_CALL(*interval_timer_, enableTimer(_)); + EXPECT_CALL(*interval_timer_, enableTimer(_, _)); NetworkFilters::Common::Redis::RespValuePtr response( new NetworkFilters::Common::Redis::RespValue()); response->type(NetworkFilters::Common::Redis::RespType::SimpleString); @@ -286,7 +286,7 @@ TEST_F(RedisHealthCheckerTest, FailuresLogging) { EXPECT_CALL(*event_logger_, logEjectUnhealthy(_, _, _)); EXPECT_CALL(*event_logger_, logUnhealthy(_, _, _, false)); EXPECT_CALL(*timeout_timer_, disableTimer()); - EXPECT_CALL(*interval_timer_, enableTimer(_)); + EXPECT_CALL(*interval_timer_, enableTimer(_, _)); response = std::make_unique(); pool_callbacks_->onResponse(std::move(response)); @@ -296,7 +296,7 @@ TEST_F(RedisHealthCheckerTest, FailuresLogging) { // Fail again EXPECT_CALL(*event_logger_, logUnhealthy(_, _, _, false)); EXPECT_CALL(*timeout_timer_, disableTimer()); - EXPECT_CALL(*interval_timer_, enableTimer(_)); + EXPECT_CALL(*interval_timer_, enableTimer(_, _)); response = std::make_unique(); pool_callbacks_->onResponse(std::move(response)); @@ -332,7 +332,7 @@ TEST_F(RedisHealthCheckerTest, LogInitialFailure) { EXPECT_CALL(*event_logger_, logEjectUnhealthy(_, _, _)); EXPECT_CALL(*event_logger_, logUnhealthy(_, _, _, true)); EXPECT_CALL(*timeout_timer_, disableTimer()); - EXPECT_CALL(*interval_timer_, enableTimer(_)); + EXPECT_CALL(*interval_timer_, enableTimer(_, _)); pool_callbacks_->onFailure(); client_->raiseEvent(Network::ConnectionEvent::RemoteClose); @@ -343,7 +343,7 @@ TEST_F(RedisHealthCheckerTest, LogInitialFailure) { // Success EXPECT_CALL(*event_logger_, logAddHealthy(_, _, false)); EXPECT_CALL(*timeout_timer_, disableTimer()); - EXPECT_CALL(*interval_timer_, enableTimer(_)); + EXPECT_CALL(*interval_timer_, enableTimer(_, _)); NetworkFilters::Common::Redis::RespValuePtr response( new NetworkFilters::Common::Redis::RespValue()); response->type(NetworkFilters::Common::Redis::RespType::SimpleString); @@ -380,7 +380,7 @@ TEST_F(RedisHealthCheckerTest, Exists) { // Success EXPECT_CALL(*timeout_timer_, disableTimer()); - EXPECT_CALL(*interval_timer_, enableTimer(_)); + EXPECT_CALL(*interval_timer_, enableTimer(_, _)); NetworkFilters::Common::Redis::RespValuePtr response( new NetworkFilters::Common::Redis::RespValue()); response->type(NetworkFilters::Common::Redis::RespType::Integer); @@ -393,7 +393,7 @@ TEST_F(RedisHealthCheckerTest, Exists) { // Failure, exists EXPECT_CALL(*event_logger_, logEjectUnhealthy(_, _, _)); EXPECT_CALL(*timeout_timer_, disableTimer()); - EXPECT_CALL(*interval_timer_, enableTimer(_)); + EXPECT_CALL(*interval_timer_, enableTimer(_, _)); response = std::make_unique(); response->type(NetworkFilters::Common::Redis::RespType::Integer); response->asInteger() = 1; @@ -404,7 +404,7 @@ TEST_F(RedisHealthCheckerTest, Exists) { // Failure, no value EXPECT_CALL(*timeout_timer_, disableTimer()); - EXPECT_CALL(*interval_timer_, enableTimer(_)); + EXPECT_CALL(*interval_timer_, enableTimer(_, _)); response = std::make_unique(); pool_callbacks_->onResponse(std::move(response)); @@ -432,7 +432,7 @@ TEST_F(RedisHealthCheckerTest, ExistsRedirected) { // Success with moved redirection EXPECT_CALL(*timeout_timer_, disableTimer()); - EXPECT_CALL(*interval_timer_, enableTimer(_)); + EXPECT_CALL(*interval_timer_, enableTimer(_, _)); NetworkFilters::Common::Redis::RespValue moved_response; moved_response.type(NetworkFilters::Common::Redis::RespType::Error); moved_response.asString() = "MOVED 1111 127.0.0.1:81"; // exact values not important @@ -443,7 +443,7 @@ TEST_F(RedisHealthCheckerTest, ExistsRedirected) { // Success with ask redirection EXPECT_CALL(*timeout_timer_, disableTimer()); - EXPECT_CALL(*interval_timer_, enableTimer(_)); + EXPECT_CALL(*interval_timer_, enableTimer(_, _)); NetworkFilters::Common::Redis::RespValue ask_response; ask_response.type(NetworkFilters::Common::Redis::RespType::Error); ask_response.asString() = "ASK 1111 127.0.0.1:81"; // exact values not important @@ -471,7 +471,7 @@ TEST_F(RedisHealthCheckerTest, NoConnectionReuse) { // The connection will close on success. EXPECT_CALL(*timeout_timer_, disableTimer()); - EXPECT_CALL(*interval_timer_, enableTimer(_)); + EXPECT_CALL(*interval_timer_, enableTimer(_, _)); EXPECT_CALL(*client_, close()); NetworkFilters::Common::Redis::RespValuePtr response( new NetworkFilters::Common::Redis::RespValue()); @@ -486,7 +486,7 @@ TEST_F(RedisHealthCheckerTest, NoConnectionReuse) { // The connection will close on failure. EXPECT_CALL(*event_logger_, logEjectUnhealthy(_, _, _)); EXPECT_CALL(*timeout_timer_, disableTimer()); - EXPECT_CALL(*interval_timer_, enableTimer(_)); + EXPECT_CALL(*interval_timer_, enableTimer(_, _)); EXPECT_CALL(*client_, close()); response = std::make_unique(); pool_callbacks_->onResponse(std::move(response)); @@ -497,7 +497,7 @@ TEST_F(RedisHealthCheckerTest, NoConnectionReuse) { // Redis failure via disconnect, the connection was closed by the other end. EXPECT_CALL(*timeout_timer_, disableTimer()); - EXPECT_CALL(*interval_timer_, enableTimer(_)); + EXPECT_CALL(*interval_timer_, enableTimer(_, _)); pool_callbacks_->onFailure(); client_->raiseEvent(Network::ConnectionEvent::RemoteClose); @@ -509,7 +509,7 @@ TEST_F(RedisHealthCheckerTest, NoConnectionReuse) { EXPECT_CALL(pool_request_, cancel()); EXPECT_CALL(*client_, close()); EXPECT_CALL(*timeout_timer_, disableTimer()); - EXPECT_CALL(*interval_timer_, enableTimer(_)); + EXPECT_CALL(*interval_timer_, enableTimer(_, _)); timeout_timer_->invokeCallback(); expectClientCreate(); diff --git a/test/extensions/tracers/datadog/datadog_tracer_impl_test.cc b/test/extensions/tracers/datadog/datadog_tracer_impl_test.cc index 50e2722f7cfc..cc80f5672c0e 100644 --- a/test/extensions/tracers/datadog/datadog_tracer_impl_test.cc +++ b/test/extensions/tracers/datadog/datadog_tracer_impl_test.cc @@ -48,7 +48,7 @@ class DatadogDriverTest : public testing::Test { if (init_timer) { timer_ = new NiceMock(&tls_.dispatcher_); - EXPECT_CALL(*timer_, enableTimer(std::chrono::milliseconds(900))); + EXPECT_CALL(*timer_, enableTimer(std::chrono::milliseconds(900), _)); } driver_ = std::make_unique(datadog_config, cm_, stats_, tls_, runtime_); @@ -146,7 +146,7 @@ TEST_F(DatadogDriverTest, FlushSpansTimer) { span->finishSpan(); // Timer should be re-enabled. - EXPECT_CALL(*timer_, enableTimer(std::chrono::milliseconds(900))); + EXPECT_CALL(*timer_, enableTimer(std::chrono::milliseconds(900), _)); timer_->invokeCallback(); diff --git a/test/extensions/tracers/lightstep/lightstep_tracer_impl_test.cc b/test/extensions/tracers/lightstep/lightstep_tracer_impl_test.cc index 046bd9596c4b..2514c4d3bf02 100644 --- a/test/extensions/tracers/lightstep/lightstep_tracer_impl_test.cc +++ b/test/extensions/tracers/lightstep/lightstep_tracer_impl_test.cc @@ -60,7 +60,7 @@ class LightStepDriverTest : public testing::Test { if (init_timer) { timer_ = new NiceMock(&tls_.dispatcher_); - EXPECT_CALL(*timer_, enableTimer(std::chrono::milliseconds(1000))); + EXPECT_CALL(*timer_, enableTimer(std::chrono::milliseconds(1000), _)); } driver_ = std::make_unique(lightstep_config, cm_, stats_, tls_, runtime_, @@ -336,7 +336,7 @@ TEST_F(LightStepDriverTest, FlushSpansTimer) { span->finishSpan(); // Timer should be re-enabled. - EXPECT_CALL(*timer_, enableTimer(std::chrono::milliseconds(1000))); + EXPECT_CALL(*timer_, enableTimer(std::chrono::milliseconds(1000), _)); EXPECT_CALL(runtime_.snapshot_, getInteger("tracing.lightstep.request_timeout", 5000U)) .WillOnce(Return(5000U)); EXPECT_CALL(runtime_.snapshot_, getInteger("tracing.lightstep.flush_interval_ms", 1000U)) diff --git a/test/extensions/tracers/zipkin/zipkin_tracer_impl_test.cc b/test/extensions/tracers/zipkin/zipkin_tracer_impl_test.cc index eceef5245fee..b8d18baca67e 100644 --- a/test/extensions/tracers/zipkin/zipkin_tracer_impl_test.cc +++ b/test/extensions/tracers/zipkin/zipkin_tracer_impl_test.cc @@ -49,7 +49,7 @@ class ZipkinDriverTest : public testing::Test { if (init_timer) { timer_ = new NiceMock(&tls_.dispatcher_); - EXPECT_CALL(*timer_, enableTimer(std::chrono::milliseconds(5000))); + EXPECT_CALL(*timer_, enableTimer(std::chrono::milliseconds(5000), _)); } driver_ = std::make_unique(zipkin_config, cm_, stats_, tls_, runtime_, local_info_, @@ -240,7 +240,7 @@ TEST_F(ZipkinDriverTest, FlushSpansTimer) { span->finishSpan(); // Timer should be re-enabled. - EXPECT_CALL(*timer_, enableTimer(std::chrono::milliseconds(5000))); + EXPECT_CALL(*timer_, enableTimer(std::chrono::milliseconds(5000), _)); EXPECT_CALL(runtime_.snapshot_, getInteger("tracing.zipkin.request_timeout", 5000U)) .WillOnce(Return(5000U)); EXPECT_CALL(runtime_.snapshot_, getInteger("tracing.zipkin.flush_interval_ms", 5000U)) diff --git a/test/mocks/event/mocks.cc b/test/mocks/event/mocks.cc index 0cd2f11d33be..af00b66b06c0 100644 --- a/test/mocks/event/mocks.cc +++ b/test/mocks/event/mocks.cc @@ -27,7 +27,11 @@ MockDispatcher::MockDispatcher() { MockDispatcher::~MockDispatcher() = default; MockTimer::MockTimer() { - ON_CALL(*this, enableTimer(_)).WillByDefault(Assign(&enabled_, true)); + ON_CALL(*this, enableTimer(_, _)) + .WillByDefault(Invoke([&](const std::chrono::milliseconds&, const ScopeTrackedObject* scope) { + enabled_ = true; + scope_ = scope; + })); ON_CALL(*this, disableTimer()).WillByDefault(Assign(&enabled_, false)); ON_CALL(*this, enabled()).WillByDefault(ReturnPointee(&enabled_)); } @@ -36,6 +40,7 @@ MockTimer::MockTimer() { // createTimer_(), so to avoid destructing it twice, the MockTimer must have been dynamically // allocated and must not be deleted by it's creator. MockTimer::MockTimer(MockDispatcher* dispatcher) : MockTimer() { + dispatcher_ = dispatcher; EXPECT_CALL(*dispatcher, createTimer_(_)) .WillOnce(DoAll(SaveArg<0>(&callback_), Return(this))) .RetiresOnSaturation(); diff --git a/test/mocks/event/mocks.h b/test/mocks/event/mocks.h index 0e65635e4b08..327214a6903f 100644 --- a/test/mocks/event/mocks.h +++ b/test/mocks/event/mocks.h @@ -17,6 +17,8 @@ #include "envoy/network/transport_socket.h" #include "envoy/ssl/context.h" +#include "common/common/scope_tracker.h" + #include "test/mocks/buffer/mocks.h" #include "test/test_common/test_time.h" @@ -131,14 +133,23 @@ class MockTimer : public Timer { void invokeCallback() { EXPECT_TRUE(enabled_); enabled_ = false; + if (scope_ == nullptr) { + callback_(); + return; + } + ScopeTrackerScopeState scope(scope_, *dispatcher_); + scope_ = nullptr; callback_(); } // Timer MOCK_METHOD0(disableTimer, void()); - MOCK_METHOD1(enableTimer, void(const std::chrono::milliseconds&)); + MOCK_METHOD2(enableTimer, + void(const std::chrono::milliseconds&, const ScopeTrackedObject* scope)); MOCK_METHOD0(enabled, bool()); + MockDispatcher* dispatcher_{}; + const ScopeTrackedObject* scope_{}; bool enabled_{}; private: diff --git a/test/server/connection_handler_test.cc b/test/server/connection_handler_test.cc index 7e4e2e03237c..59d14ffb5e2f 100644 --- a/test/server/connection_handler_test.cc +++ b/test/server/connection_handler_test.cc @@ -601,7 +601,7 @@ TEST_F(ConnectionHandlerTest, ListenerFilterTimeout) { return Network::FilterStatus::StopIteration; })); Event::MockTimer* timeout = new Event::MockTimer(&dispatcher_); - EXPECT_CALL(*timeout, enableTimer(std::chrono::milliseconds(15000))); + EXPECT_CALL(*timeout, enableTimer(std::chrono::milliseconds(15000), _)); Network::MockConnectionSocket* accepted_socket = new NiceMock(); listener_callbacks->onAccept(Network::ConnectionSocketPtr{accepted_socket}, true); Stats::Gauge& downstream_pre_cx_active = @@ -649,7 +649,7 @@ TEST_F(ConnectionHandlerTest, ContinueOnListenerFilterTimeout) { return Network::FilterStatus::StopIteration; })); Event::MockTimer* timeout = new Event::MockTimer(&dispatcher_); - EXPECT_CALL(*timeout, enableTimer(std::chrono::milliseconds(15000))); + EXPECT_CALL(*timeout, enableTimer(std::chrono::milliseconds(15000), _)); Network::MockConnectionSocket* accepted_socket = new NiceMock(); listener_callbacks->onAccept(Network::ConnectionSocketPtr{accepted_socket}, true); Stats::Gauge& downstream_pre_cx_active = @@ -698,7 +698,7 @@ TEST_F(ConnectionHandlerTest, ListenerFilterTimeoutResetOnSuccess) { return Network::FilterStatus::StopIteration; })); Event::MockTimer* timeout = new Event::MockTimer(&dispatcher_); - EXPECT_CALL(*timeout, enableTimer(std::chrono::milliseconds(15000))); + EXPECT_CALL(*timeout, enableTimer(std::chrono::milliseconds(15000), _)); Network::MockConnectionSocket* accepted_socket = new NiceMock(); listener_callbacks->onAccept(Network::ConnectionSocketPtr{accepted_socket}, true); diff --git a/test/server/drain_manager_impl_test.cc b/test/server/drain_manager_impl_test.cc index 58919df1ce7e..0a3076c265c2 100644 --- a/test/server/drain_manager_impl_test.cc +++ b/test/server/drain_manager_impl_test.cc @@ -33,7 +33,7 @@ TEST_F(DrainManagerImplTest, Default) { // Test parent shutdown. Event::MockTimer* shutdown_timer = new Event::MockTimer(&server_.dispatcher_); - EXPECT_CALL(*shutdown_timer, enableTimer(std::chrono::milliseconds(900000))); + EXPECT_CALL(*shutdown_timer, enableTimer(std::chrono::milliseconds(900000), _)); drain_manager.startParentShutdownSequence(); EXPECT_CALL(server_.hot_restart_, sendParentTerminateRequest()); @@ -47,14 +47,14 @@ TEST_F(DrainManagerImplTest, Default) { // Test drain sequence. Event::MockTimer* drain_timer = new Event::MockTimer(&server_.dispatcher_); - EXPECT_CALL(*drain_timer, enableTimer(_)); + EXPECT_CALL(*drain_timer, enableTimer(_, _)); ReadyWatcher drain_complete; drain_manager.startDrainSequence([&drain_complete]() -> void { drain_complete.ready(); }); // 600s which is the default drain time. for (size_t i = 0; i < 599; i++) { if (i < 598) { - EXPECT_CALL(*drain_timer, enableTimer(_)); + EXPECT_CALL(*drain_timer, enableTimer(_, _)); } else { EXPECT_CALL(drain_complete, ready()); } diff --git a/test/test_common/BUILD b/test/test_common/BUILD index c1d4c4f692bf..911ae90a26bd 100644 --- a/test/test_common/BUILD +++ b/test/test_common/BUILD @@ -231,6 +231,7 @@ envoy_cc_test( ":simulated_time_system_lib", ":utility_lib", "//source/common/event:libevent_scheduler_lib", + "//test/mocks/event:event_mocks", ], ) diff --git a/test/test_common/simulated_time_system.cc b/test/test_common/simulated_time_system.cc index c4801ae68bda..43db9e511148 100644 --- a/test/test_common/simulated_time_system.cc +++ b/test/test_common/simulated_time_system.cc @@ -50,8 +50,9 @@ class UnlockGuard { // mechanism used in RealTimeSystem timers is employed for simulated alarms. class SimulatedTimeSystemHelper::Alarm : public Timer { public: - Alarm(SimulatedTimeSystemHelper& time_system, Scheduler& base_scheduler, TimerCb cb) - : base_timer_(base_scheduler.createTimer([this, cb] { runAlarm(cb); })), + Alarm(SimulatedTimeSystemHelper& time_system, Scheduler& base_scheduler, TimerCb cb, + Dispatcher& dispatcher) + : base_timer_(base_scheduler.createTimer([this, cb] { runAlarm(cb); }, dispatcher)), time_system_(time_system), index_(time_system.nextIndex()), armed_(false), pending_(false) { } @@ -59,7 +60,8 @@ class SimulatedTimeSystemHelper::Alarm : public Timer { // Timer void disableTimer() override; - void enableTimer(const std::chrono::milliseconds& duration) override; + void enableTimer(const std::chrono::milliseconds& duration, + const ScopeTrackedObject* scope) override; bool enabled() override { Thread::LockGuard lock(time_system_.mutex_); return armed_ || base_timer_->enabled(); @@ -75,7 +77,8 @@ class SimulatedTimeSystemHelper::Alarm : public Timer { * Activates the timer so it will be run the next time the libevent loop is run, * typically via Dispatcher::run(). */ - void activateLockHeld() EXCLUSIVE_LOCKS_REQUIRED(time_system_.mutex_) { + void activateLockHeld(const ScopeTrackedObject* scope = nullptr) + EXCLUSIVE_LOCKS_REQUIRED(time_system_.mutex_) { ASSERT(armed_); armed_ = false; if (pending_) { @@ -91,7 +94,7 @@ class SimulatedTimeSystemHelper::Alarm : public Timer { // time_system_.mutex_ prior to running libevent, which may delete this. UnlockGuard unlocker(time_system_.mutex_); std::chrono::milliseconds duration = std::chrono::milliseconds::zero(); - base_timer_->enableTimer(duration); + base_timer_->enableTimer(duration, scope); } MonotonicTime time() const EXCLUSIVE_LOCKS_REQUIRED(time_system_.mutex_) { @@ -146,8 +149,9 @@ class SimulatedTimeSystemHelper::SimulatedScheduler : public Scheduler { public: SimulatedScheduler(SimulatedTimeSystemHelper& time_system, Scheduler& base_scheduler) : time_system_(time_system), base_scheduler_(base_scheduler) {} - TimerPtr createTimer(const TimerCb& cb) override { - return std::make_unique(time_system_, base_scheduler_, cb); + TimerPtr createTimer(const TimerCb& cb, Dispatcher& dispatcher) override { + return std::make_unique(time_system_, base_scheduler_, cb, + dispatcher); }; private: @@ -173,13 +177,13 @@ void SimulatedTimeSystemHelper::Alarm::Alarm::disableTimerLockHeld() { } } -void SimulatedTimeSystemHelper::Alarm::Alarm::enableTimer( - const std::chrono::milliseconds& duration) { +void SimulatedTimeSystemHelper::Alarm::Alarm::enableTimer(const std::chrono::milliseconds& duration, + const ScopeTrackedObject* scope) { Thread::LockGuard lock(time_system_.mutex_); disableTimerLockHeld(); armed_ = true; if (duration.count() == 0) { - activateLockHeld(); + activateLockHeld(scope); } else { time_system_.addAlarmLockHeld(this, duration); } diff --git a/test/test_common/simulated_time_system_test.cc b/test/test_common/simulated_time_system_test.cc index 399ee31a87b1..f584c29401d5 100644 --- a/test/test_common/simulated_time_system_test.cc +++ b/test/test_common/simulated_time_system_test.cc @@ -3,6 +3,7 @@ #include "common/event/libevent_scheduler.h" #include "common/event/timer_impl.h" +#include "test/mocks/event/mocks.h" #include "test/test_common/simulated_time_system.h" #include "test/test_common/utility.h" @@ -23,10 +24,12 @@ class SimulatedTimeSystemTest : public testing::Test { void addTask(int64_t delay_ms, char marker) { std::chrono::milliseconds delay(delay_ms); - TimerPtr timer = scheduler_->createTimer([this, marker, delay]() { - output_.append(1, marker); - EXPECT_GE(time_system_.monotonicTime(), start_monotonic_time_ + delay); - }); + TimerPtr timer = scheduler_->createTimer( + [this, marker, delay]() { + output_.append(1, marker); + EXPECT_GE(time_system_.monotonicTime(), start_monotonic_time_ + delay); + }, + dispatcher_); timer->enableTimer(delay); timers_.push_back(std::move(timer)); } @@ -41,6 +44,7 @@ class SimulatedTimeSystemTest : public testing::Test { base_scheduler_.run(Dispatcher::RunType::NonBlock); } + testing::NiceMock dispatcher_; LibeventScheduler base_scheduler_; SimulatedTimeSystem time_system_; SchedulerPtr scheduler_; @@ -71,11 +75,13 @@ TEST_F(SimulatedTimeSystemTest, WaitFor) { }); Thread::CondVar condvar; Thread::MutexBasicLockable mutex; - TimerPtr timer = scheduler_->createTimer([&condvar, &mutex, &done]() { - Thread::LockGuard lock(mutex); - done = true; - condvar.notifyOne(); - }); + TimerPtr timer = scheduler_->createTimer( + [&condvar, &mutex, &done]() { + Thread::LockGuard lock(mutex); + done = true; + condvar.notifyOne(); + }, + dispatcher_); timer->enableTimer(std::chrono::seconds(60)); // Wait 50 simulated seconds of simulated time, which won't be enough to @@ -201,7 +207,7 @@ TEST_F(SimulatedTimeSystemTest, DeleteTime) { TEST_F(SimulatedTimeSystemTest, DuplicateTimer) { // Set one alarm two times to test that pending does not get duplicated.. std::chrono::milliseconds delay(0); - TimerPtr zero_timer = scheduler_->createTimer([this]() { output_.append(1, '2'); }); + TimerPtr zero_timer = scheduler_->createTimer([this]() { output_.append(1, '2'); }, dispatcher_); zero_timer->enableTimer(delay); zero_timer->enableTimer(delay); sleepMsAndLoop(1); @@ -216,11 +222,13 @@ TEST_F(SimulatedTimeSystemTest, DuplicateTimer) { }); Thread::CondVar condvar; Thread::MutexBasicLockable mutex; - TimerPtr timer = scheduler_->createTimer([&condvar, &mutex, &done]() { - Thread::LockGuard lock(mutex); - done = true; - condvar.notifyOne(); - }); + TimerPtr timer = scheduler_->createTimer( + [&condvar, &mutex, &done]() { + Thread::LockGuard lock(mutex); + done = true; + condvar.notifyOne(); + }, + dispatcher_); timer->enableTimer(std::chrono::seconds(10)); { @@ -234,7 +242,7 @@ TEST_F(SimulatedTimeSystemTest, DuplicateTimer) { } TEST_F(SimulatedTimeSystemTest, Enabled) { - TimerPtr timer = scheduler_->createTimer({}); + TimerPtr timer = scheduler_->createTimer({}, dispatcher_); timer->enableTimer(std::chrono::milliseconds(0)); EXPECT_TRUE(timer->enabled()); }