diff --git a/include/envoy/api/api.h b/include/envoy/api/api.h index 33373c4023268..26724bc11e742 100644 --- a/include/envoy/api/api.h +++ b/include/envoy/api/api.h @@ -22,10 +22,9 @@ class Api { /** * Allocate a dispatcher. - * @param time_source the time source. * @return Event::DispatcherPtr which is owned by the caller. */ - virtual Event::DispatcherPtr allocateDispatcher(Event::TimeSystem& time_system) PURE; + virtual Event::DispatcherPtr allocateDispatcher() PURE; /** * @return a reference to the ThreadFactory @@ -36,9 +35,15 @@ class Api { * @return a reference to the Filesystem::Instance */ virtual Filesystem::Instance& fileSystem() PURE; + + /** + * @return a reference to the TimeSystem + * TODO(jmarantz): change this to return a TimeSource. + */ + virtual Event::TimeSystem& timeSystem() PURE; }; typedef std::unique_ptr ApiPtr; } // namespace Api -} // namespace Envoy \ No newline at end of file +} // namespace Envoy diff --git a/include/envoy/server/BUILD b/include/envoy/server/BUILD index 934b216b33773..aefef1c978545 100644 --- a/include/envoy/server/BUILD +++ b/include/envoy/server/BUILD @@ -145,6 +145,7 @@ envoy_cc_library( deps = [ ":admin_interface", "//include/envoy/access_log:access_log_interface", + "//include/envoy/api:api_interface", "//include/envoy/http:codes_interface", "//include/envoy/http:context_interface", "//include/envoy/http:filter_interface", diff --git a/source/common/api/api_impl.cc b/source/common/api/api_impl.cc index 4f93d2b0417aa..ab6e1479b56c6 100644 --- a/source/common/api/api_impl.cc +++ b/source/common/api/api_impl.cc @@ -10,17 +10,15 @@ namespace Envoy { namespace Api { Impl::Impl(std::chrono::milliseconds file_flush_interval_msec, - Thread::ThreadFactory& thread_factory, Stats::Store& stats_store) + Thread::ThreadFactory& thread_factory, Stats::Store& stats_store, + Event::TimeSystem& time_system) : thread_factory_(thread_factory), - file_system_(file_flush_interval_msec, thread_factory, stats_store) {} + file_system_(file_flush_interval_msec, thread_factory, stats_store), + time_system_(time_system) {} -Event::DispatcherPtr Impl::allocateDispatcher(Event::TimeSystem& time_system) { - return std::make_unique(time_system, *this); +Event::DispatcherPtr Impl::allocateDispatcher() { + return std::make_unique(*this); } -Thread::ThreadFactory& Impl::threadFactory() { return thread_factory_; } - -Filesystem::Instance& Impl::fileSystem() { return file_system_; } - } // namespace Api } // namespace Envoy diff --git a/source/common/api/api_impl.h b/source/common/api/api_impl.h index 8223e7d90443c..050b18cfca12c 100644 --- a/source/common/api/api_impl.h +++ b/source/common/api/api_impl.h @@ -19,16 +19,18 @@ namespace Api { class Impl : public Api { public: Impl(std::chrono::milliseconds file_flush_interval_msec, Thread::ThreadFactory& thread_factory, - Stats::Store& stats_store); + Stats::Store& stats_store, Event::TimeSystem& time_system); // Api::Api - Event::DispatcherPtr allocateDispatcher(Event::TimeSystem& time_system) override; - Thread::ThreadFactory& threadFactory() override; - Filesystem::Instance& fileSystem() override; + Event::DispatcherPtr allocateDispatcher() override; + Thread::ThreadFactory& threadFactory() override { return thread_factory_; } + Filesystem::Instance& fileSystem() override { return file_system_; } + Event::TimeSystem& timeSystem() override { return time_system_; } private: Thread::ThreadFactory& thread_factory_; Filesystem::InstanceImpl file_system_; + Event::TimeSystem& time_system_; }; } // namespace Api diff --git a/source/common/event/dispatched_thread.h b/source/common/event/dispatched_thread.h index 1f3aaf86c41dc..8ea8d3beeb9b3 100644 --- a/source/common/event/dispatched_thread.h +++ b/source/common/event/dispatched_thread.h @@ -39,8 +39,7 @@ namespace Event { */ class DispatchedThreadImpl : Logger::Loggable { public: - DispatchedThreadImpl(Api::Api& api, TimeSystem& time_system) - : api_(api), dispatcher_(new DispatcherImpl(time_system, api_)) {} + explicit DispatchedThreadImpl(Api::Api& api) : api_(api), dispatcher_(new DispatcherImpl(api_)) {} /** * Start the thread. diff --git a/source/common/event/dispatcher_impl.cc b/source/common/event/dispatcher_impl.cc index ced376e638dc5..9c146ea2f518b 100644 --- a/source/common/event/dispatcher_impl.cc +++ b/source/common/event/dispatcher_impl.cc @@ -26,17 +26,15 @@ namespace Envoy { namespace Event { -DispatcherImpl::DispatcherImpl(TimeSystem& time_system, Api::Api& api) - : DispatcherImpl(time_system, Buffer::WatermarkFactoryPtr{new Buffer::WatermarkBufferFactory}, - api) { +DispatcherImpl::DispatcherImpl(Api::Api& api) + : DispatcherImpl(Buffer::WatermarkFactoryPtr{new Buffer::WatermarkBufferFactory}, api) { // The dispatcher won't work as expected if libevent hasn't been configured to use threads. RELEASE_ASSERT(Libevent::Global::initialized(), ""); } -DispatcherImpl::DispatcherImpl(TimeSystem& time_system, Buffer::WatermarkFactoryPtr&& factory, - Api::Api& api) - : api_(api), time_system_(time_system), buffer_factory_(std::move(factory)), - base_(event_base_new()), scheduler_(time_system_.createScheduler(base_)), +DispatcherImpl::DispatcherImpl(Buffer::WatermarkFactoryPtr&& factory, Api::Api& api) + : api_(api), buffer_factory_(std::move(factory)), base_(event_base_new()), + scheduler_(api.timeSystem().createScheduler(base_)), deferred_delete_timer_(createTimer([this]() -> void { clearDeferredDeleteList(); })), post_timer_(createTimer([this]() -> void { runPostCallbacks(); })), current_to_delete_(&to_delete_1_) { diff --git a/source/common/event/dispatcher_impl.h b/source/common/event/dispatcher_impl.h index c13108809df8d..99306ced0502b 100644 --- a/source/common/event/dispatcher_impl.h +++ b/source/common/event/dispatcher_impl.h @@ -23,8 +23,8 @@ namespace Event { */ class DispatcherImpl : Logger::Loggable, public Dispatcher { public: - explicit DispatcherImpl(TimeSystem& time_system, Api::Api& api); - DispatcherImpl(TimeSystem& time_system, Buffer::WatermarkFactoryPtr&& factory, Api::Api& api); + explicit DispatcherImpl(Api::Api& api); + DispatcherImpl(Buffer::WatermarkFactoryPtr&& factory, Api::Api& api); ~DispatcherImpl(); /** @@ -33,7 +33,7 @@ class DispatcherImpl : Logger::Loggable, public Dispatcher { event_base& base() { return *base_; } // Event::Dispatcher - TimeSystem& timeSystem() override { return time_system_; } + TimeSystem& timeSystem() override { return api_.timeSystem(); } void clearDeferredDeleteList() override; Network::ConnectionPtr createServerConnection(Network::ConnectionSocketPtr&& socket, @@ -70,7 +70,6 @@ class DispatcherImpl : Logger::Loggable, public Dispatcher { bool isThreadSafe() const { return run_tid_ == nullptr || run_tid_->isCurrentThreadId(); } Api::Api& api_; - TimeSystem& time_system_; Thread::ThreadIdPtr run_tid_; Buffer::WatermarkFactoryPtr buffer_factory_; Libevent::BasePtr base_; diff --git a/source/common/router/router.h b/source/common/router/router.h index 291354b0c1978..9fcafdad5b424 100644 --- a/source/common/router/router.h +++ b/source/common/router/router.h @@ -112,7 +112,7 @@ class FilterConfig { context.runtime(), context.random(), std::move(shadow_writer), PROTOBUF_GET_WRAPPED_OR_DEFAULT(config, dynamic_stats, true), config.start_child_span(), config.suppress_envoy_headers(), - context.timeSource(), context.httpContext()) { + context.api().timeSystem(), context.httpContext()) { for (const auto& upstream_log : config.upstream_log()) { upstream_logs_.push_back(AccessLog::AccessLogFactory::fromProto(upstream_log, context)); } diff --git a/source/server/config_validation/api.cc b/source/server/config_validation/api.cc index 14b52e6e8e653..4763d043b4480 100644 --- a/source/server/config_validation/api.cc +++ b/source/server/config_validation/api.cc @@ -6,11 +6,12 @@ namespace Envoy { namespace Api { ValidationImpl::ValidationImpl(std::chrono::milliseconds file_flush_interval_msec, - Thread::ThreadFactory& thread_factory, Stats::Store& stats_store) - : Impl(file_flush_interval_msec, thread_factory, stats_store) {} + Thread::ThreadFactory& thread_factory, Stats::Store& stats_store, + Event::TimeSystem& time_system) + : Impl(file_flush_interval_msec, thread_factory, stats_store, time_system) {} -Event::DispatcherPtr ValidationImpl::allocateDispatcher(Event::TimeSystem& time_system) { - return Event::DispatcherPtr{new Event::ValidationDispatcher(time_system, *this)}; +Event::DispatcherPtr ValidationImpl::allocateDispatcher() { + return Event::DispatcherPtr{new Event::ValidationDispatcher(*this)}; } } // namespace Api diff --git a/source/server/config_validation/api.h b/source/server/config_validation/api.h index b00cd2c81e1c5..ef05bfdc70319 100644 --- a/source/server/config_validation/api.h +++ b/source/server/config_validation/api.h @@ -16,9 +16,10 @@ namespace Api { class ValidationImpl : public Impl { public: ValidationImpl(std::chrono::milliseconds file_flush_interval_msec, - Thread::ThreadFactory& thread_factory, Stats::Store& stats_store); + Thread::ThreadFactory& thread_factory, Stats::Store& stats_store, + Event::TimeSystem& time_system); - Event::DispatcherPtr allocateDispatcher(Event::TimeSystem&) override; + Event::DispatcherPtr allocateDispatcher() override; }; } // namespace Api diff --git a/source/server/config_validation/async_client.cc b/source/server/config_validation/async_client.cc index 9d04323d5fe3a..be388769f8383 100644 --- a/source/server/config_validation/async_client.cc +++ b/source/server/config_validation/async_client.cc @@ -3,8 +3,7 @@ namespace Envoy { namespace Http { -ValidationAsyncClient::ValidationAsyncClient(Event::TimeSystem& time_system, Api::Api& api) - : dispatcher_(time_system, api) {} +ValidationAsyncClient::ValidationAsyncClient(Api::Api& api) : dispatcher_(api) {} AsyncClient::Request* ValidationAsyncClient::send(MessagePtr&&, Callbacks&, const RequestOptions&) { return nullptr; diff --git a/source/server/config_validation/async_client.h b/source/server/config_validation/async_client.h index 29b533c013d3f..026fd01882767 100644 --- a/source/server/config_validation/async_client.h +++ b/source/server/config_validation/async_client.h @@ -19,7 +19,7 @@ namespace Http { */ class ValidationAsyncClient : public AsyncClient { public: - ValidationAsyncClient(Event::TimeSystem& time_system, Api::Api& api); + ValidationAsyncClient(Api::Api& api); // Http::AsyncClient AsyncClient::Request* send(MessagePtr&& request, Callbacks& callbacks, diff --git a/source/server/config_validation/cluster_manager.cc b/source/server/config_validation/cluster_manager.cc index 2978e13d150c2..328921df74804 100644 --- a/source/server/config_validation/cluster_manager.cc +++ b/source/server/config_validation/cluster_manager.cc @@ -29,7 +29,7 @@ ValidationClusterManager::ValidationClusterManager( Server::Admin& admin, Api::Api& api, Http::Context& http_context) : ClusterManagerImpl(bootstrap, factory, stats, tls, runtime, random, local_info, log_manager, main_thread_dispatcher, admin, api, http_context), - async_client_(main_thread_dispatcher.timeSystem(), api) {} + async_client_(api) {} Http::ConnectionPool::Instance* ValidationClusterManager::httpConnPoolForCluster(const std::string&, ResourcePriority, diff --git a/source/server/config_validation/dispatcher.h b/source/server/config_validation/dispatcher.h index a30addebe8a51..8024c9e2591f4 100644 --- a/source/server/config_validation/dispatcher.h +++ b/source/server/config_validation/dispatcher.h @@ -16,7 +16,7 @@ namespace Event { */ class ValidationDispatcher : public DispatcherImpl { public: - ValidationDispatcher(TimeSystem& time_system, Api::Api& api) : DispatcherImpl(time_system, api) {} + ValidationDispatcher(Api::Api& api) : DispatcherImpl(api) {} Network::ClientConnectionPtr createClientConnection(Network::Address::InstanceConstSharedPtr, diff --git a/source/server/config_validation/server.cc b/source/server/config_validation/server.cc index adb4c785db111..b2220e00acb5d 100644 --- a/source/server/config_validation/server.cc +++ b/source/server/config_validation/server.cc @@ -40,9 +40,10 @@ ValidationInstance::ValidationInstance(Options& options, Event::TimeSystem& time Thread::BasicLockable& access_log_lock, ComponentFactory& component_factory, Thread::ThreadFactory& thread_factory) - : options_(options), time_system_(time_system), stats_store_(store), - api_(new Api::ValidationImpl(options.fileFlushIntervalMsec(), thread_factory, store)), - dispatcher_(api_->allocateDispatcher(time_system)), + : options_(options), stats_store_(store), + api_(new Api::ValidationImpl(options.fileFlushIntervalMsec(), thread_factory, store, + time_system)), + dispatcher_(api_->allocateDispatcher()), singleton_manager_(new Singleton::ManagerImpl(api_->threadFactory().currentThreadId())), access_log_manager_(*api_, *dispatcher_, access_log_lock), mutex_tracer_(nullptr) { try { @@ -69,7 +70,7 @@ void ValidationInstance::initialize(Options& options, // be ready to serve, then the config has passed validation. // Handle configuration that needs to take place prior to the main configuration load. envoy::config::bootstrap::v2::Bootstrap bootstrap; - InstanceUtil::loadBootstrapConfig(bootstrap, options, api()); + InstanceUtil::loadBootstrapConfig(bootstrap, options, *api_); Config::Utility::createTagProducer(bootstrap); @@ -81,16 +82,16 @@ void ValidationInstance::initialize(Options& options, Configuration::InitialImpl initial_config(bootstrap); overload_manager_ = std::make_unique(dispatcher(), stats(), threadLocal(), - bootstrap.overload_manager(), api()); - listener_manager_ = std::make_unique(*this, *this, *this, time_system_); + bootstrap.overload_manager(), *api_); + listener_manager_ = std::make_unique(*this, *this, *this); thread_local_.registerThread(*dispatcher_, true); runtime_loader_ = component_factory.createRuntime(*this, initial_config); secret_manager_ = std::make_unique(); ssl_context_manager_ = - std::make_unique(time_system_); + std::make_unique(api_->timeSystem()); cluster_manager_factory_ = std::make_unique( admin(), runtime(), stats(), threadLocal(), random(), dnsResolver(), sslContextManager(), - dispatcher(), localInfo(), *secret_manager_, api(), http_context_, accessLogManager(), + dispatcher(), localInfo(), *secret_manager_, *api_, http_context_, accessLogManager(), singletonManager()); config_.initialize(bootstrap, *this, *cluster_manager_factory_); http_context_.setTracer(config_.httpTracer()); diff --git a/source/server/config_validation/server.h b/source/server/config_validation/server.h index faca12ea8ea6f..c6993a479737c 100644 --- a/source/server/config_validation/server.h +++ b/source/server/config_validation/server.h @@ -92,7 +92,7 @@ class ValidationInstance : Logger::Loggable, Http::Context& httpContext() override { return http_context_; } ThreadLocal::Instance& threadLocal() override { return thread_local_; } const LocalInfo::LocalInfo& localInfo() override { return *local_info_; } - Event::TimeSystem& timeSystem() override { return time_system_; } + Event::TimeSystem& timeSystem() override { return api_->timeSystem(); } Envoy::MutexTracer* mutexTracer() override { return mutex_tracer_; } std::chrono::milliseconds statsFlushInterval() const override { @@ -140,7 +140,6 @@ class ValidationInstance : Logger::Loggable, ComponentFactory& component_factory); Options& options_; - Event::TimeSystem& time_system_; Stats::IsolatedStoreImpl& stats_store_; ThreadLocal::InstanceImpl thread_local_; Api::ApiPtr api_; diff --git a/source/server/guarddog_impl.cc b/source/server/guarddog_impl.cc index ecae1349b9a42..6c0d4a7e54007 100644 --- a/source/server/guarddog_impl.cc +++ b/source/server/guarddog_impl.cc @@ -17,8 +17,8 @@ namespace Envoy { namespace Server { GuardDogImpl::GuardDogImpl(Stats::Scope& stats_scope, const Server::Configuration::Main& config, - Event::TimeSystem& time_system, Api::Api& api) - : time_system_(time_system), miss_timeout_(config.wdMissTimeout()), + Api::Api& api) + : time_system_(api.timeSystem()), miss_timeout_(config.wdMissTimeout()), megamiss_timeout_(config.wdMegaMissTimeout()), kill_timeout_(config.wdKillTimeout()), multi_kill_timeout_(config.wdMultiKillTimeout()), loop_interval_([&]() -> std::chrono::milliseconds { diff --git a/source/server/guarddog_impl.h b/source/server/guarddog_impl.h index 27f50eade9058..a1b228f966937 100644 --- a/source/server/guarddog_impl.h +++ b/source/server/guarddog_impl.h @@ -39,8 +39,7 @@ class GuardDogImpl : public GuardDog { * * See the configuration documentation for details on the timeout settings. */ - GuardDogImpl(Stats::Scope& stats_scope, const Server::Configuration::Main& config, - Event::TimeSystem& time_system, Api::Api& api); + GuardDogImpl(Stats::Scope& stats_scope, const Server::Configuration::Main& config, Api::Api& api); ~GuardDogImpl(); /** diff --git a/source/server/listener_manager_impl.cc b/source/server/listener_manager_impl.cc index 0ea1572e6e550..cd2ae8202e600 100644 --- a/source/server/listener_manager_impl.cc +++ b/source/server/listener_manager_impl.cc @@ -665,9 +665,8 @@ void ListenerImpl::setSocket(const Network::SocketSharedPtr& socket) { ListenerManagerImpl::ListenerManagerImpl(Instance& server, ListenerComponentFactory& listener_factory, - WorkerFactory& worker_factory, TimeSource& time_source) - : server_(server), time_source_(time_source), factory_(listener_factory), - stats_(generateStats(server.stats())), + WorkerFactory& worker_factory) + : server_(server), factory_(listener_factory), stats_(generateStats(server.stats())), config_tracker_entry_(server.admin().getConfigTracker().add( "listeners", [this] { return dumpListenerConfigs(); })) { for (uint32_t i = 0; i < server.options().concurrency(); i++) { diff --git a/source/server/listener_manager_impl.h b/source/server/listener_manager_impl.h index e8a5a87051ffe..fd19d5026eab6 100644 --- a/source/server/listener_manager_impl.h +++ b/source/server/listener_manager_impl.h @@ -104,7 +104,7 @@ struct ListenerManagerStats { class ListenerManagerImpl : public ListenerManager, Logger::Loggable { public: ListenerManagerImpl(Instance& server, ListenerComponentFactory& listener_factory, - WorkerFactory& worker_factory, TimeSource& time_source); + WorkerFactory& worker_factory); void onListenerWarmed(ListenerImpl& listener); @@ -124,7 +124,6 @@ class ListenerManagerImpl : public ListenerManager, Logger::Loggable()), - dispatcher_(api_->allocateDispatcher(time_system)), + dispatcher_(api_->allocateDispatcher()), singleton_manager_(new Singleton::ManagerImpl(api_->threadFactory().currentThreadId())), handler_(new ConnectionHandlerImpl(ENVOY_LOGGER(), *dispatcher_)), random_generator_(std::move(random_generator)), listener_component_factory_(*this), - worker_factory_(thread_local_, *api_, hooks, time_system), + worker_factory_(thread_local_, *api_, hooks), dns_resolver_(dispatcher_->createDnsResolver({})), access_log_manager_(*api_, *dispatcher_, access_log_lock), terminated_(false), mutex_tracer_(options.mutexTracingEnabled() ? &Envoy::MutexTracerImpl::getOrCreateTracer() @@ -288,8 +288,8 @@ void InstanceImpl::initialize(Options& options, bootstrap_.overload_manager(), api()); // Workers get created first so they register for thread local updates. - listener_manager_ = std::make_unique(*this, listener_component_factory_, - worker_factory_, time_system_); + listener_manager_ = + std::make_unique(*this, listener_component_factory_, worker_factory_); // The main thread is also registered for thread local updates so that code that does not care // whether it runs on the main thread or on workers can still use TLS. @@ -348,7 +348,7 @@ void InstanceImpl::initialize(Options& options, // GuardDog (deadlock detection) object and thread setup before workers are // started and before our own run() loop runs. - guard_dog_ = std::make_unique(stats_store_, config_, time_system_, api()); + guard_dog_ = std::make_unique(stats_store_, config_, api()); } void InstanceImpl::startWorkers() { diff --git a/source/server/worker_impl.cc b/source/server/worker_impl.cc index 89f21a31f1c22..660d1ac1cf739 100644 --- a/source/server/worker_impl.cc +++ b/source/server/worker_impl.cc @@ -14,7 +14,7 @@ namespace Envoy { namespace Server { WorkerPtr ProdWorkerFactory::createWorker(OverloadManager& overload_manager) { - Event::DispatcherPtr dispatcher(api_.allocateDispatcher(time_system_)); + Event::DispatcherPtr dispatcher(api_.allocateDispatcher()); return WorkerPtr{new WorkerImpl( tls_, hooks_, std::move(dispatcher), Network::ConnectionHandlerPtr{new ConnectionHandlerImpl(ENVOY_LOGGER(), *dispatcher)}, diff --git a/source/server/worker_impl.h b/source/server/worker_impl.h index 5c0e374fdc250..b59c7356f2134 100644 --- a/source/server/worker_impl.h +++ b/source/server/worker_impl.h @@ -19,9 +19,8 @@ namespace Server { class ProdWorkerFactory : public WorkerFactory, Logger::Loggable { public: - ProdWorkerFactory(ThreadLocal::Instance& tls, Api::Api& api, TestHooks& hooks, - Event::TimeSystem& time_system) - : tls_(tls), api_(api), hooks_(hooks), time_system_(time_system) {} + ProdWorkerFactory(ThreadLocal::Instance& tls, Api::Api& api, TestHooks& hooks) + : tls_(tls), api_(api), hooks_(hooks) {} // Server::WorkerFactory WorkerPtr createWorker(OverloadManager& overload_manager) override; @@ -30,7 +29,6 @@ class ProdWorkerFactory : public WorkerFactory, Logger::Loggable> callbacks_; FilesystemEdsSubscriptionImpl subscription_; diff --git a/test/common/event/BUILD b/test/common/event/BUILD index 2ecbb8a213540..0a5ad582e66b2 100644 --- a/test/common/event/BUILD +++ b/test/common/event/BUILD @@ -17,7 +17,6 @@ envoy_cc_test( "//source/common/event:dispatcher_lib", "//source/common/stats:isolated_store_lib", "//test/mocks:common_lib", - "//test/test_common:test_time_lib", "//test/test_common:utility_lib", ], ) @@ -32,7 +31,6 @@ envoy_cc_test( "//source/common/stats:isolated_store_lib", "//test/mocks:common_lib", "//test/test_common:environment_lib", - "//test/test_common:test_time_lib", "//test/test_common:utility_lib", ], ) diff --git a/test/common/event/dispatched_thread_impl_test.cc b/test/common/event/dispatched_thread_impl_test.cc index 1971ee014621a..fc9ba00435fbd 100644 --- a/test/common/event/dispatched_thread_impl_test.cc +++ b/test/common/event/dispatched_thread_impl_test.cc @@ -10,7 +10,6 @@ #include "test/mocks/server/mocks.h" #include "test/mocks/stats/mocks.h" #include "test/test_common/test_base.h" -#include "test/test_common/test_time.h" #include "test/test_common/utility.h" #include "gmock/gmock.h" @@ -24,14 +23,13 @@ namespace Event { class DispatchedThreadTest : public TestBase { protected: DispatchedThreadTest() - : config_(1000, 1000, 1000, 1000), api_(Api::createApiForTest(fakestats_)), - thread_(*api_, test_time_.timeSystem()), - guard_dog_(fakestats_, config_, test_time_.timeSystem(), *api_) {} + : config_(1000, 1000, 1000, 1000), api_(Api::createApiForTest(fakestats_)), thread_(*api_), + guard_dog_(fakestats_, config_, *api_) {} + + void SetUp() override { thread_.start(guard_dog_); } - void SetUp() { thread_.start(guard_dog_); } NiceMock config_; Stats::IsolatedStoreImpl fakestats_; - DangerousDeprecatedTestTime test_time_; Api::ApiPtr api_; DispatchedThreadImpl thread_; Envoy::Server::GuardDogImpl guard_dog_; diff --git a/test/common/event/dispatcher_impl_test.cc b/test/common/event/dispatcher_impl_test.cc index da48fa793e17c..6677fbfe679d9 100644 --- a/test/common/event/dispatcher_impl_test.cc +++ b/test/common/event/dispatcher_impl_test.cc @@ -9,7 +9,6 @@ #include "test/mocks/common.h" #include "test/test_common/test_base.h" -#include "test/test_common/test_time.h" #include "test/test_common/utility.h" #include "gmock/gmock.h" @@ -32,8 +31,7 @@ TEST(DeferredDeleteTest, DeferredDelete) { InSequence s; Stats::IsolatedStoreImpl stats_store; Api::ApiPtr api = Api::createApiForTest(stats_store); - DangerousDeprecatedTestTime test_time; - DispatcherImpl dispatcher(test_time.timeSystem(), *api); + DispatcherImpl dispatcher(*api); ReadyWatcher watcher1; dispatcher.deferredDelete( @@ -65,8 +63,7 @@ class DispatcherImplTest : public TestBase { protected: DispatcherImplTest() : api_(Api::createApiForTest(stat_store_)), - dispatcher_(std::make_unique(test_time_.timeSystem(), *api_)), - work_finished_(false) { + dispatcher_(std::make_unique(*api_)), work_finished_(false) { dispatcher_thread_ = api_->threadFactory().createThread([this]() { // Must create a keepalive timer to keep the dispatcher from exiting. std::chrono::milliseconds time_interval(500); @@ -83,8 +80,6 @@ class DispatcherImplTest : public TestBase { dispatcher_thread_->join(); } - DangerousDeprecatedTestTime test_time_; - Stats::IsolatedStoreImpl stat_store_; Api::ApiPtr api_; Thread::ThreadPtr dispatcher_thread_; diff --git a/test/common/event/file_event_impl_test.cc b/test/common/event/file_event_impl_test.cc index cb8bec642bf66..d43dbeef0bc40 100644 --- a/test/common/event/file_event_impl_test.cc +++ b/test/common/event/file_event_impl_test.cc @@ -8,7 +8,6 @@ #include "test/mocks/common.h" #include "test/test_common/environment.h" #include "test/test_common/test_base.h" -#include "test/test_common/test_time.h" #include "test/test_common/utility.h" namespace Envoy { @@ -16,8 +15,7 @@ namespace Event { class FileEventImplTest : public TestBase { public: - FileEventImplTest() - : api_(Api::createApiForTest(stats_store_)), dispatcher_(test_time_.timeSystem(), *api_) {} + FileEventImplTest() : api_(Api::createApiForTest(stats_store_)), dispatcher_(*api_) {} void SetUp() override { int rc = socketpair(AF_UNIX, SOCK_DGRAM, 0, fds_); @@ -36,7 +34,6 @@ class FileEventImplTest : public TestBase { int fds_[2]; Stats::IsolatedStoreImpl stats_store_; Api::ApiPtr api_; - DangerousDeprecatedTestTime test_time_; DispatcherImpl dispatcher_; }; @@ -55,10 +52,9 @@ TEST_P(FileEventImplActivateTest, Activate) { } ASSERT_NE(-1, fd); - DangerousDeprecatedTestTime test_time; Stats::IsolatedStoreImpl stats_store; Api::ApiPtr api = Api::createApiForTest(stats_store); - DispatcherImpl dispatcher(test_time.timeSystem(), *api); + DispatcherImpl dispatcher(*api); ReadyWatcher read_event; EXPECT_CALL(read_event, ready()).Times(1); ReadyWatcher write_event; diff --git a/test/common/filesystem/BUILD b/test/common/filesystem/BUILD index 9538338b6614c..c34f8969df993 100644 --- a/test/common/filesystem/BUILD +++ b/test/common/filesystem/BUILD @@ -48,6 +48,5 @@ envoy_cc_test( "//source/common/filesystem:watcher_lib", "//source/common/stats:isolated_store_lib", "//test/test_common:environment_lib", - "//test/test_common:test_time_lib", ], ) diff --git a/test/common/filesystem/watcher_impl_test.cc b/test/common/filesystem/watcher_impl_test.cc index a7ab6895f702f..da6b5fd80cddf 100644 --- a/test/common/filesystem/watcher_impl_test.cc +++ b/test/common/filesystem/watcher_impl_test.cc @@ -8,7 +8,6 @@ #include "test/test_common/environment.h" #include "test/test_common/test_base.h" -#include "test/test_common/test_time.h" #include "test/test_common/utility.h" #include "gmock/gmock.h" @@ -18,12 +17,10 @@ namespace Filesystem { class WatcherImplTest : public TestBase { protected: - WatcherImplTest() - : api_(Api::createApiForTest(stats_store_)), dispatcher_(test_time_.timeSystem(), *api_) {} + WatcherImplTest() : api_(Api::createApiForTest(stats_store_)), dispatcher_(*api_) {} Stats::IsolatedStoreImpl stats_store_; Api::ApiPtr api_; - DangerousDeprecatedTestTime test_time_; Event::DispatcherImpl dispatcher_; }; diff --git a/test/common/grpc/google_async_client_impl_test.cc b/test/common/grpc/google_async_client_impl_test.cc index 761ce43fbd61c..73f69db13b9de 100644 --- a/test/common/grpc/google_async_client_impl_test.cc +++ b/test/common/grpc/google_async_client_impl_test.cc @@ -48,7 +48,7 @@ class EnvoyGoogleAsyncClientImplTest : public TestBase { public: EnvoyGoogleAsyncClientImplTest() : stats_store_(new Stats::IsolatedStoreImpl), api_(Api::createApiForTest(*stats_store_)), - dispatcher_(test_time_.timeSystem(), *api_), scope_(stats_store_), + dispatcher_(*api_), scope_(stats_store_), method_descriptor_(helloworld::Greeter::descriptor()->FindMethodByName("SayHello")) { envoy::api::v2::core::GrpcService config; auto* google_grpc = config.mutable_google_grpc(); diff --git a/test/common/grpc/grpc_client_integration_test_harness.h b/test/common/grpc/grpc_client_integration_test_harness.h index 8776208548073..950c087a163c2 100644 --- a/test/common/grpc/grpc_client_integration_test_harness.h +++ b/test/common/grpc/grpc_client_integration_test_harness.h @@ -218,7 +218,7 @@ class GrpcClientIntegrationTest : public GrpcClientIntegrationParamTest { public: GrpcClientIntegrationTest() : method_descriptor_(helloworld::Greeter::descriptor()->FindMethodByName("SayHello")), - api_(Api::createApiForTest(*stats_store_)), dispatcher_(test_time_.timeSystem(), *api_) {} + api_(Api::createApiForTest(*stats_store_, test_time_.timeSystem())), dispatcher_(*api_) {} virtual void initialize() { if (fake_upstream_ == nullptr) { diff --git a/test/common/http/BUILD b/test/common/http/BUILD index d810ea68df6dc..ff05727d307db 100644 --- a/test/common/http/BUILD +++ b/test/common/http/BUILD @@ -54,7 +54,6 @@ envoy_cc_test( "//test/mocks/upstream:upstream_mocks", "//test/test_common:environment_lib", "//test/test_common:network_utility_lib", - "//test/test_common:test_time_lib", "//test/test_common:utility_lib", ], ) diff --git a/test/common/http/codec_client_test.cc b/test/common/http/codec_client_test.cc index 0871311e6fbb1..6e38d86bea355 100644 --- a/test/common/http/codec_client_test.cc +++ b/test/common/http/codec_client_test.cc @@ -19,7 +19,6 @@ #include "test/test_common/network_utility.h" #include "test/test_common/printers.h" #include "test/test_common/test_base.h" -#include "test/test_common/test_time.h" #include "test/test_common/utility.h" #include "gmock/gmock.h" @@ -60,7 +59,6 @@ class CodecClientTest : public TestBase { ~CodecClientTest() { EXPECT_EQ(0U, client_->numActiveRequests()); } - DangerousDeprecatedTestTime test_time_; Event::MockDispatcher dispatcher_; Network::MockClientConnection* connection_; Http::MockClientConnection* codec_; @@ -262,7 +260,7 @@ TEST_F(CodecClientTest, WatermarkPassthrough) { class CodecNetworkTest : public TestBaseWithParam { public: CodecNetworkTest() : api_(Api::createApiForTest(stats_store_)) { - dispatcher_ = std::make_unique(test_time_.timeSystem(), *api_); + dispatcher_ = std::make_unique(*api_); upstream_listener_ = dispatcher_->createListener(socket_, listener_callbacks_, true, false); Network::ClientConnectionPtr client_connection = dispatcher_->createClientConnection( socket_.localAddress(), source_address_, Network::Test::createRawBufferSocket(), nullptr); @@ -330,7 +328,6 @@ class CodecNetworkTest : public TestBaseWithParam { protected: Stats::IsolatedStoreImpl stats_store_; Api::ApiPtr api_; - DangerousDeprecatedTestTime test_time_; Event::DispatcherPtr dispatcher_; Network::ListenerPtr upstream_listener_; Network::MockListenerCallbacks listener_callbacks_; diff --git a/test/common/http/http1/BUILD b/test/common/http/http1/BUILD index 66da7a23b6e86..e685bff6f3288 100644 --- a/test/common/http/http1/BUILD +++ b/test/common/http/http1/BUILD @@ -45,7 +45,6 @@ envoy_cc_test( "//test/mocks/network:network_mocks", "//test/mocks/runtime:runtime_mocks", "//test/mocks/upstream:upstream_mocks", - "//test/test_common:test_time_lib", "//test/test_common:utility_lib", ], ) diff --git a/test/common/http/http1/conn_pool_test.cc b/test/common/http/http1/conn_pool_test.cc index 40c3994e9688a..ae6152f37eb7b 100644 --- a/test/common/http/http1/conn_pool_test.cc +++ b/test/common/http/http1/conn_pool_test.cc @@ -18,7 +18,6 @@ #include "test/mocks/upstream/mocks.h" #include "test/test_common/printers.h" #include "test/test_common/test_base.h" -#include "test/test_common/test_time.h" #include "test/test_common/utility.h" #include "gmock/gmock.h" @@ -81,8 +80,7 @@ class ConnPoolImplForTest : public ConnPoolImpl { test_client.codec_ = new NiceMock(); test_client.connect_timer_ = new NiceMock(&mock_dispatcher_); std::shared_ptr cluster{new NiceMock()}; - test_client.client_dispatcher_ = - std::make_unique(test_time_.timeSystem(), *api_); + test_client.client_dispatcher_ = std::make_unique(*api_); Network::ClientConnectionPtr connection{test_client.connection_}; test_client.codec_client_ = new CodecClientForTest( std::move(connection), test_client.codec_, @@ -115,7 +113,6 @@ class ConnPoolImplForTest : public ConnPoolImpl { Stats::IsolatedStoreImpl stats_store_; Api::ApiPtr api_; - DangerousDeprecatedTestTime test_time_; Event::MockDispatcher& mock_dispatcher_; NiceMock* mock_upstream_ready_timer_; std::vector test_clients_; diff --git a/test/common/http/http2/BUILD b/test/common/http/http2/BUILD index 436b29f83860d..bb255b0ba9a31 100644 --- a/test/common/http/http2/BUILD +++ b/test/common/http/http2/BUILD @@ -75,7 +75,6 @@ envoy_cc_test( "//test/mocks/network:network_mocks", "//test/mocks/runtime:runtime_mocks", "//test/mocks/upstream:upstream_mocks", - "//test/test_common:test_time_lib", ], ) diff --git a/test/common/http/http2/conn_pool_test.cc b/test/common/http/http2/conn_pool_test.cc index 0402277c88f00..cd318c0fb6735 100644 --- a/test/common/http/http2/conn_pool_test.cc +++ b/test/common/http/http2/conn_pool_test.cc @@ -16,7 +16,6 @@ #include "test/mocks/upstream/mocks.h" #include "test/test_common/printers.h" #include "test/test_common/test_base.h" -#include "test/test_common/test_time.h" #include "gmock/gmock.h" @@ -83,8 +82,7 @@ class Http2ConnPoolImplTest : public TestBase { test_client.connection_ = new NiceMock(); test_client.codec_ = new NiceMock(); test_client.connect_timer_ = new NiceMock(&dispatcher_); - test_client.client_dispatcher_ = - std::make_unique(test_time_.timeSystem(), *api_); + test_client.client_dispatcher_ = std::make_unique(*api_); EXPECT_CALL(dispatcher_, createClientConnection_(_, _, _, _)) .WillOnce(Return(test_client.connection_)); auto cluster = std::make_shared>(); @@ -120,7 +118,6 @@ class Http2ConnPoolImplTest : public TestBase { Stats::IsolatedStoreImpl stats_store_; Api::ApiPtr api_; - DangerousDeprecatedTestTime test_time_; NiceMock dispatcher_; std::shared_ptr cluster_{new NiceMock()}; Upstream::HostSharedPtr host_{Upstream::makeTestHost(cluster_, "tcp://127.0.0.1:80")}; diff --git a/test/common/network/BUILD b/test/common/network/BUILD index 0dc910b23e19a..8b356ed2c997e 100644 --- a/test/common/network/BUILD +++ b/test/common/network/BUILD @@ -64,6 +64,7 @@ envoy_cc_test( "//test/test_common:environment_lib", "//test/test_common:network_utility_lib", "//test/test_common:simulated_time_system_lib", + "//test/test_common:test_time_lib", ], ) @@ -85,7 +86,6 @@ envoy_cc_test( "//test/mocks/network:network_mocks", "//test/test_common:environment_lib", "//test/test_common:network_utility_lib", - "//test/test_common:test_time_lib", "//test/test_common:utility_lib", ], ) @@ -155,7 +155,6 @@ envoy_cc_test( "//test/mocks/server:server_mocks", "//test/test_common:environment_lib", "//test/test_common:network_utility_lib", - "//test/test_common:test_time_lib", "//test/test_common:utility_lib", ], ) diff --git a/test/common/network/connection_impl_test.cc b/test/common/network/connection_impl_test.cc index 9f8667b030829..f00422b5125ca 100644 --- a/test/common/network/connection_impl_test.cc +++ b/test/common/network/connection_impl_test.cc @@ -79,9 +79,9 @@ INSTANTIATE_TEST_SUITE_P(IpVersions, ConnectionImplDeathTest, TEST_P(ConnectionImplDeathTest, BadFd) { Stats::IsolatedStoreImpl stats_store; - Api::ApiPtr api = Api::createApiForTest(stats_store); Event::SimulatedTimeSystem time_system; - Event::DispatcherImpl dispatcher(time_system, *api); + Api::ApiPtr api = Api::createApiForTest(stats_store); + Event::DispatcherImpl dispatcher(*api); IoHandlePtr io_handle = std::make_unique(); EXPECT_DEATH_LOG_TO_STDERR( ConnectionImpl(dispatcher, @@ -96,7 +96,7 @@ class ConnectionImplTest : public TestBaseWithParam { void setUpBasicConnection() { if (dispatcher_.get() == nullptr) { - dispatcher_ = std::make_unique(time_system_, *api_); + dispatcher_ = std::make_unique(*api_); } listener_ = dispatcher_->createListener(socket_, listener_callbacks_, true, false); @@ -159,8 +159,8 @@ class ConnectionImplTest : public TestBaseWithParam { ASSERT(dispatcher_.get() == nullptr); MockBufferFactory* factory = new StrictMock; - dispatcher_ = std::make_unique( - time_system_, Buffer::WatermarkFactoryPtr{factory}, *api_); + dispatcher_ = + std::make_unique(Buffer::WatermarkFactoryPtr{factory}, *api_); // The first call to create a client session will get a MockBuffer. // Other calls for server sessions will by default get a normal OwnedImpl. EXPECT_CALL(*factory, create_(_, _)) @@ -272,7 +272,7 @@ TEST_P(ConnectionImplTest, CloseDuringConnectCallback) { } TEST_P(ConnectionImplTest, ImmediateConnectError) { - dispatcher_ = std::make_unique(time_system_, *api_); + dispatcher_ = std::make_unique(*api_); // Using a broadcast/multicast address as the connection destinations address causes an // immediate error return from connect(). @@ -886,7 +886,7 @@ TEST_P(ConnectionImplTest, BindFailureTest) { source_address_ = Network::Address::InstanceConstSharedPtr{ new Network::Address::Ipv6Instance(address_string, 0)}; } - dispatcher_ = std::make_unique(time_system_, *api_); + dispatcher_ = std::make_unique(*api_); listener_ = dispatcher_->createListener(socket_, listener_callbacks_, true, false); client_connection_ = dispatcher_->createClientConnection( @@ -1574,7 +1574,7 @@ class ReadBufferLimitTest : public ConnectionImplTest { public: void readBufferLimitTest(uint32_t read_buffer_limit, uint32_t expected_chunk_size) { const uint32_t buffer_size = 256 * 1024; - dispatcher_ = std::make_unique(time_system_, *api_); + dispatcher_ = std::make_unique(*api_); listener_ = dispatcher_->createListener(socket_, listener_callbacks_, true, false); client_connection_ = dispatcher_->createClientConnection( @@ -1645,12 +1645,11 @@ TEST_P(ReadBufferLimitTest, SomeLimit) { class TcpClientConnectionImplTest : public TestBaseWithParam { protected: - TcpClientConnectionImplTest() - : api_(Api::createApiForTest(stats_store_)), dispatcher_(time_system_, *api_) {} + TcpClientConnectionImplTest() : api_(Api::createApiForTest(stats_store_)), dispatcher_(*api_) {} Stats::IsolatedStoreImpl stats_store_; - Api::ApiPtr api_; Event::SimulatedTimeSystem time_system_; + Api::ApiPtr api_; Event::DispatcherImpl dispatcher_; }; INSTANTIATE_TEST_SUITE_P(IpVersions, TcpClientConnectionImplTest, @@ -1690,12 +1689,11 @@ TEST_P(TcpClientConnectionImplTest, BadConnectConnRefused) { class PipeClientConnectionImplTest : public TestBase { protected: - PipeClientConnectionImplTest() - : api_(Api::createApiForTest(stats_store_)), dispatcher_(time_system_, *api_) {} + PipeClientConnectionImplTest() : api_(Api::createApiForTest(stats_store_)), dispatcher_(*api_) {} Stats::IsolatedStoreImpl stats_store_; - Api::ApiPtr api_; Event::SimulatedTimeSystem time_system_; + Api::ApiPtr api_; Event::DispatcherImpl dispatcher_; const std::string path_{TestEnvironment::unixDomainSocketPath("foo")}; }; diff --git a/test/common/network/dns_impl_test.cc b/test/common/network/dns_impl_test.cc index 37cf0080bbc20..d5c0403d592d5 100644 --- a/test/common/network/dns_impl_test.cc +++ b/test/common/network/dns_impl_test.cc @@ -27,7 +27,6 @@ #include "test/test_common/network_utility.h" #include "test/test_common/printers.h" #include "test/test_common/test_base.h" -#include "test/test_common/test_time.h" #include "test/test_common/utility.h" #include "ares.h" @@ -325,12 +324,10 @@ class DnsResolverImplPeer { class DnsImplConstructor : public TestBase { protected: - DnsImplConstructor() - : api_(Api::createApiForTest(stats_store_)), dispatcher_(test_time_.timeSystem(), *api_) {} + DnsImplConstructor() : api_(Api::createApiForTest(stats_store_)), dispatcher_(*api_) {} Stats::IsolatedStoreImpl stats_store_; Api::ApiPtr api_; - DangerousDeprecatedTestTime test_time_; Event::DispatcherImpl dispatcher_; }; @@ -407,8 +404,7 @@ TEST_F(DnsImplConstructor, BadCustomResolvers) { class DnsImplTest : public TestBaseWithParam { public: - DnsImplTest() - : api_(Api::createApiForTest(stats_store_)), dispatcher_(test_time_.timeSystem(), *api_) {} + DnsImplTest() : api_(Api::createApiForTest(stats_store_)), dispatcher_(*api_) {} void SetUp() override { resolver_ = dispatcher_.createDnsResolver({}); @@ -441,7 +437,6 @@ class DnsImplTest : public TestBaseWithParam { Stats::IsolatedStoreImpl stats_store_; std::unique_ptr listener_; Api::ApiPtr api_; - DangerousDeprecatedTestTime test_time_; Event::DispatcherImpl dispatcher_; DnsResolverSharedPtr resolver_; }; diff --git a/test/common/network/listener_impl_test.cc b/test/common/network/listener_impl_test.cc index 0e20d0f103635..05592b2072e45 100644 --- a/test/common/network/listener_impl_test.cc +++ b/test/common/network/listener_impl_test.cc @@ -7,7 +7,6 @@ #include "test/test_common/environment.h" #include "test/test_common/network_utility.h" #include "test/test_common/test_base.h" -#include "test/test_common/test_time.h" #include "test/test_common/utility.h" #include "gmock/gmock.h" @@ -24,8 +23,7 @@ static void errorCallbackTest(Address::IpVersion version) { // test in the forked process to avoid confusion when the fork happens. Stats::IsolatedStoreImpl stats_store; Api::ApiPtr api = Api::createApiForTest(stats_store); - DangerousDeprecatedTestTime test_time; - Event::DispatcherImpl dispatcher(test_time.timeSystem(), *api); + Event::DispatcherImpl dispatcher(*api); Network::TcpListenSocket socket(Network::Test::getCanonicalLoopbackAddress(version), nullptr, true); @@ -79,13 +77,12 @@ class ListenerImplTest : public TestBaseWithParam { : version_(GetParam()), alt_address_(Network::Test::findOrCheckFreePort( Network::Test::getCanonicalLoopbackAddress(version_), Address::SocketType::Stream)), - api_(Api::createApiForTest(stats_store_)), dispatcher_(test_time_.timeSystem(), *api_) {} + api_(Api::createApiForTest(stats_store_)), dispatcher_(*api_) {} const Address::IpVersion version_; const Address::InstanceConstSharedPtr alt_address_; Stats::IsolatedStoreImpl stats_store_; Api::ApiPtr api_; - DangerousDeprecatedTestTime test_time_; Event::DispatcherImpl dispatcher_; }; INSTANTIATE_TEST_SUITE_P(IpVersions, ListenerImplTest, diff --git a/test/common/network/udp_listener_impl_test.cc b/test/common/network/udp_listener_impl_test.cc index 6c9e9b1926529..ae2639c7a6c56 100644 --- a/test/common/network/udp_listener_impl_test.cc +++ b/test/common/network/udp_listener_impl_test.cc @@ -36,13 +36,13 @@ class TestUdpListenerImpl : public UdpListenerImpl { } }; -class ListenerImplTest : public TestBaseWithParam { +class UdpListenerImplTest : public TestBaseWithParam { protected: - ListenerImplTest() + UdpListenerImplTest() : version_(GetParam()), alt_address_(Network::Test::findOrCheckFreePort( Network::Test::getCanonicalLoopbackAddress(version_), Address::SocketType::Stream)), - api_(Api::createApiForTest(stats_store_)), dispatcher_(test_time_.timeSystem(), *api_) {} + api_(Api::createApiForTest(stats_store_)), dispatcher_(*api_) {} SocketPtr getSocket(Address::SocketType type, const Address::InstanceConstSharedPtr& address, const Network::Socket::OptionsSharedPtr& options, bool bind) { @@ -120,12 +120,12 @@ class ListenerImplTest : public TestBaseWithParam { DangerousDeprecatedTestTime test_time_; Event::DispatcherImpl dispatcher_; }; -INSTANTIATE_TEST_CASE_P(IpVersions, ListenerImplTest, +INSTANTIATE_TEST_CASE_P(IpVersions, UdpListenerImplTest, testing::ValuesIn(TestEnvironment::getIpVersionsForTest()), TestUtility::ipTestParamsToString); // Test that socket options are set after the listener is setup. -TEST_P(ListenerImplTest, UdpSetListeningSocketOptionsSuccess) { +TEST_P(UdpListenerImplTest, UdpSetListeningSocketOptionsSuccess) { Network::MockListenerCallbacks listener_callbacks; Network::MockConnectionHandler connection_handler; @@ -138,7 +138,7 @@ TEST_P(ListenerImplTest, UdpSetListeningSocketOptionsSuccess) { /** * Tests UDP listener for actual destination and data. */ -TEST_P(ListenerImplTest, UseActualDstUdp) { +TEST_P(UdpListenerImplTest, UseActualDstUdp) { // Setup server socket SocketPtr server_socket = getSocket(Address::SocketType::Datagram, Network::Test::getCanonicalLoopbackAddress(version_), @@ -224,7 +224,7 @@ TEST_P(ListenerImplTest, UseActualDstUdp) { /** * Tests UDP listener for read and write callbacks with actual data. */ -TEST_P(ListenerImplTest, UdpEcho) { +TEST_P(UdpListenerImplTest, UdpEcho) { // Setup server socket SocketPtr server_socket = getSocket(Address::SocketType::Datagram, Network::Test::getCanonicalLoopbackAddress(version_), @@ -358,7 +358,7 @@ TEST_P(ListenerImplTest, UdpEcho) { /** * Tests UDP listener's `enable` and `disable` APIs. */ -TEST_P(ListenerImplTest, UdpListenerEnableDisable) { +TEST_P(UdpListenerImplTest, UdpListenerEnableDisable) { // Setup server socket SocketPtr server_socket = getSocket(Address::SocketType::Datagram, Network::Test::getCanonicalLoopbackAddress(version_), @@ -458,7 +458,7 @@ TEST_P(ListenerImplTest, UdpListenerEnableDisable) { /** * Tests UDP listener's error callback. */ -TEST_P(ListenerImplTest, UdpListenerRecvFromError) { +TEST_P(UdpListenerImplTest, UdpListenerRecvFromError) { // Setup server socket SocketPtr server_socket = getSocket(Address::SocketType::Datagram, Network::Test::getCanonicalLoopbackAddress(version_), diff --git a/test/common/stats/BUILD b/test/common/stats/BUILD index b3d2020e43890..4ceea90e1b3c7 100644 --- a/test/common/stats/BUILD +++ b/test/common/stats/BUILD @@ -151,6 +151,7 @@ envoy_cc_test_binary( "//source/common/stats:thread_local_store_lib", "//source/common/thread_local:thread_local_lib", "//test/test_common:simulated_time_system_lib", + "//test/test_common:test_time_lib", "//test/test_common:utility_lib", ], ) diff --git a/test/common/stats/thread_local_store_speed_test.cc b/test/common/stats/thread_local_store_speed_test.cc index c23bb1e66520f..8eddd256937de 100644 --- a/test/common/stats/thread_local_store_speed_test.cc +++ b/test/common/stats/thread_local_store_speed_test.cc @@ -12,6 +12,7 @@ #include "test/common/stats/stat_test_utility.h" #include "test/test_common/simulated_time_system.h" +#include "test/test_common/test_time.h" #include "test/test_common/utility.h" #include "benchmark/benchmark.h" @@ -20,7 +21,8 @@ namespace Envoy { class ThreadLocalStorePerf { public: - ThreadLocalStorePerf() : store_(options_, heap_alloc_), api_(Api::createApiForTest(store_)) { + ThreadLocalStorePerf() + : store_(options_, heap_alloc_), api_(Api::createApiForTest(store_, time_system_)) { store_.setTagProducer(std::make_unique(stats_config_)); } @@ -37,17 +39,17 @@ class ThreadLocalStorePerf { } void initThreading() { - dispatcher_ = std::make_unique(time_system_, *api_); + dispatcher_ = std::make_unique(*api_); tls_ = std::make_unique(); store_.initializeThreading(*dispatcher_, *tls_); } private: + Event::SimulatedTimeSystem time_system_; Stats::StatsOptionsImpl options_; Stats::HeapStatDataAllocator heap_alloc_; Stats::ThreadLocalStoreImpl store_; Api::ApiPtr api_; - Event::SimulatedTimeSystem time_system_; std::unique_ptr dispatcher_; std::unique_ptr tls_; envoy::config::metrics::v2::StatsConfig stats_config_; diff --git a/test/common/thread_local/BUILD b/test/common/thread_local/BUILD index a1e1de967c805..c1d95410e5ab9 100644 --- a/test/common/thread_local/BUILD +++ b/test/common/thread_local/BUILD @@ -17,6 +17,5 @@ envoy_cc_test( "//source/common/stats:isolated_store_lib", "//source/common/thread_local:thread_local_lib", "//test/mocks/event:event_mocks", - "//test/test_common:test_time_lib", ], ) diff --git a/test/common/thread_local/thread_local_impl_test.cc b/test/common/thread_local/thread_local_impl_test.cc index 49e228030d1a4..99ff8eaa426cf 100644 --- a/test/common/thread_local/thread_local_impl_test.cc +++ b/test/common/thread_local/thread_local_impl_test.cc @@ -4,7 +4,6 @@ #include "common/thread_local/thread_local_impl.h" #include "test/mocks/event/mocks.h" -#include "test/test_common/test_time.h" #include "gmock/gmock.h" @@ -117,11 +116,10 @@ TEST_F(ThreadLocalInstanceImplTest, RunOnAllThreads) { TEST(ThreadLocalInstanceImplDispatcherTest, Dispatcher) { InstanceImpl tls; - DangerousDeprecatedTestTime test_time; Stats::IsolatedStoreImpl stats_store; Api::ApiPtr api = Api::createApiForTest(stats_store); - Event::DispatcherImpl main_dispatcher(test_time.timeSystem(), *api); - Event::DispatcherImpl thread_dispatcher(test_time.timeSystem(), *api); + Event::DispatcherImpl main_dispatcher(*api); + Event::DispatcherImpl thread_dispatcher(*api); tls.registerThread(main_dispatcher, true); tls.registerThread(thread_dispatcher, false); diff --git a/test/common/upstream/hds_test.cc b/test/common/upstream/hds_test.cc index 501aa9aa76929..fc39df03d8784 100644 --- a/test/common/upstream/hds_test.cc +++ b/test/common/upstream/hds_test.cc @@ -46,7 +46,8 @@ class HdsTest : public TestBase { protected: HdsTest() : retry_timer_(new Event::MockTimer()), server_response_timer_(new Event::MockTimer()), - async_client_(new Grpc::MockAsyncClient()), api_(Api::createApiForTest(stats_store_)) { + async_client_(new Grpc::MockAsyncClient()), api_(Api::createApiForTest(stats_store_)), + ssl_context_manager_(api_->timeSystem()) { node_.set_id("hds-node"); } @@ -96,6 +97,7 @@ class HdsTest : public TestBase { return msg; } + Event::SimulatedTimeSystem time_system_; envoy::api::v2::core::Node node_; Event::MockDispatcher dispatcher_; Stats::IsolatedStoreImpl stats_store_; @@ -115,8 +117,8 @@ class HdsTest : public TestBase { Grpc::MockAsyncStream async_stream_; Grpc::MockAsyncClient* async_client_; Runtime::MockLoader runtime_; - Event::SimulatedTimeSystem time_system_; - Extensions::TransportSockets::Tls::ContextManagerImpl ssl_context_manager_{time_system_}; + Api::ApiPtr api_; + Extensions::TransportSockets::Tls::ContextManagerImpl ssl_context_manager_; NiceMock random_; NiceMock log_manager_; NiceMock cm_; @@ -124,7 +126,6 @@ class HdsTest : public TestBase { NiceMock admin_; Singleton::ManagerImpl singleton_manager_{Thread::threadFactoryForTest().currentThreadId()}; NiceMock tls_; - Api::ApiPtr api_; }; // Test that HdsDelegate builds and sends initial message correctly diff --git a/test/config_test/BUILD b/test/config_test/BUILD index 1048b4f8e7840..494341c4b6fd6 100644 --- a/test/config_test/BUILD +++ b/test/config_test/BUILD @@ -44,5 +44,6 @@ envoy_cc_test_library( "//test/mocks/server:server_mocks", "//test/mocks/ssl:ssl_mocks", "//test/test_common:threadsafe_singleton_injector_lib", + "//test/test_common:simulated_time_system_lib", ] + envoy_all_extensions(), ) diff --git a/test/config_test/config_test.cc b/test/config_test/config_test.cc index f7efcaab48630..e9aab4f379564 100644 --- a/test/config_test/config_test.cc +++ b/test/config_test/config_test.cc @@ -106,8 +106,7 @@ class ConfigTest { std::unique_ptr cluster_manager_factory_; NiceMock component_factory_; NiceMock worker_factory_; - Server::ListenerManagerImpl listener_manager_{server_, component_factory_, worker_factory_, - server_.timeSystem()}; + Server::ListenerManagerImpl listener_manager_{server_, component_factory_, worker_factory_}; Runtime::RandomGeneratorImpl random_; NiceMock os_sys_calls_; TestThreadsafeSingletonInjector os_calls{&os_sys_calls_}; diff --git a/test/extensions/filters/http/gzip/gzip_filter_integration_test.cc b/test/extensions/filters/http/gzip/gzip_filter_integration_test.cc index aa56d03ee1e96..edfd1e34cce39 100644 --- a/test/extensions/filters/http/gzip/gzip_filter_integration_test.cc +++ b/test/extensions/filters/http/gzip/gzip_filter_integration_test.cc @@ -9,11 +9,11 @@ namespace Envoy { -class GzipIntegrationTest : public HttpIntegrationTest, +class GzipIntegrationTest : public Event::SimulatedTimeSystem, + public HttpIntegrationTest, public TestBaseWithParam { public: - GzipIntegrationTest() - : HttpIntegrationTest(Http::CodecClient::Type::HTTP1, GetParam(), simTime()) {} + GzipIntegrationTest() : HttpIntegrationTest(Http::CodecClient::Type::HTTP1, GetParam()) {} void SetUp() override { decompressor_.init(window_bits); } void TearDown() override { cleanupUpstreamAndDownstream(); } diff --git a/test/extensions/filters/listener/proxy_protocol/proxy_protocol_test.cc b/test/extensions/filters/listener/proxy_protocol/proxy_protocol_test.cc index 50fae0a437564..cdb8d7c6c126b 100644 --- a/test/extensions/filters/listener/proxy_protocol/proxy_protocol_test.cc +++ b/test/extensions/filters/listener/proxy_protocol/proxy_protocol_test.cc @@ -23,7 +23,6 @@ #include "test/test_common/network_utility.h" #include "test/test_common/printers.h" #include "test/test_common/test_base.h" -#include "test/test_common/test_time.h" #include "test/test_common/threadsafe_singleton_injector.h" #include "test/test_common/utility.h" @@ -50,7 +49,7 @@ class ProxyProtocolTest : public TestBaseWithParam, protected Logger::Loggable { public: ProxyProtocolTest() - : api_(Api::createApiForTest(stats_store_)), dispatcher_(test_time_.timeSystem(), *api_), + : api_(Api::createApiForTest(stats_store_)), dispatcher_(*api_), socket_(Network::Test::getCanonicalLoopbackAddress(GetParam()), nullptr, true), connection_handler_(new Server::ConnectionHandlerImpl(ENVOY_LOGGER(), dispatcher_)), name_("proxy"), filter_chain_(Network::Test::createEmptyFilterChainWithRawBufferSockets()) { @@ -151,7 +150,6 @@ class ProxyProtocolTest : public TestBaseWithParam, Stats::IsolatedStoreImpl stats_store_; Api::ApiPtr api_; - DangerousDeprecatedTestTime test_time_; Event::DispatcherImpl dispatcher_; Network::TcpListenSocket socket_; Network::ConnectionHandlerPtr connection_handler_; @@ -871,7 +869,7 @@ class WildcardProxyProtocolTest : public TestBaseWithParam { public: WildcardProxyProtocolTest() - : api_(Api::createApiForTest(stats_store_)), dispatcher_(test_time_.timeSystem(), *api_), + : api_(Api::createApiForTest(stats_store_)), dispatcher_(*api_), socket_(Network::Test::getAnyAddress(GetParam()), nullptr, true), local_dst_address_(Network::Utility::getAddressWithPort( *Network::Test::getCanonicalLoopbackAddress(GetParam()), @@ -958,7 +956,6 @@ class WildcardProxyProtocolTest : public TestBaseWithParamcreateResourceMonitor(config, context); EXPECT_NE(monitor, nullptr); diff --git a/test/extensions/resource_monitors/injected_resource/injected_resource_monitor_test.cc b/test/extensions/resource_monitors/injected_resource/injected_resource_monitor_test.cc index 5b2c5d862d988..4955ef58bd982 100644 --- a/test/extensions/resource_monitors/injected_resource/injected_resource_monitor_test.cc +++ b/test/extensions/resource_monitors/injected_resource/injected_resource_monitor_test.cc @@ -7,7 +7,6 @@ #include "test/test_common/environment.h" #include "test/test_common/test_base.h" -#include "test/test_common/test_time.h" #include "test/test_common/utility.h" #include "absl/strings/match.h" @@ -46,7 +45,7 @@ class MockedCallbacks : public Server::ResourceMonitor::Callbacks { class InjectedResourceMonitorTest : public TestBase { protected: InjectedResourceMonitorTest() - : api_(Api::createApiForTest(stats_store_)), dispatcher_(test_time_.timeSystem(), *api_), + : api_(Api::createApiForTest(stats_store_)), dispatcher_(*api_), resource_filename_(TestEnvironment::temporaryPath("injected_resource")), file_updater_(resource_filename_), monitor_(createMonitor()) {} @@ -67,7 +66,6 @@ class InjectedResourceMonitorTest : public TestBase { Stats::IsolatedStoreImpl stats_store_; Api::ApiPtr api_; - DangerousDeprecatedTestTime test_time_; Event::DispatcherImpl dispatcher_; const std::string resource_filename_; AtomicFileUpdater file_updater_; diff --git a/test/extensions/transport_sockets/tls/ssl_socket_test.cc b/test/extensions/transport_sockets/tls/ssl_socket_test.cc index 10d4d6e064d44..0be696fe23cad 100644 --- a/test/extensions/transport_sockets/tls/ssl_socket_test.cc +++ b/test/extensions/transport_sockets/tls/ssl_socket_test.cc @@ -183,11 +183,11 @@ void testUtil(const TestUtilOptions& options) { server_tls_context); auto server_cfg = std::make_unique(server_tls_context, server_factory_context); - ContextManagerImpl manager(time_system); + ContextManagerImpl manager(*time_system); ServerSslSocketFactory server_ssl_socket_factory(std::move(server_cfg), manager, server_stats_store, std::vector{}); - Event::DispatcherImpl dispatcher(time_system, *server_api); + Event::DispatcherImpl dispatcher(*server_api); Network::TcpListenSocket socket(Network::Test::getCanonicalLoopbackAddress(options.version()), nullptr, true); Network::MockListenerCallbacks callbacks; @@ -394,7 +394,7 @@ class TestUtilOptionsV2 : public TestUtilOptionsBase { const std::string testUtilV2(const TestUtilOptionsV2& options) { Event::SimulatedTimeSystem time_system; - ContextManagerImpl manager(time_system); + ContextManagerImpl manager(*time_system); std::string new_session = EMPTY_STRING; // SNI-based selection logic isn't happening in SslSocket anymore. @@ -413,7 +413,7 @@ const std::string testUtilV2(const TestUtilOptionsV2& options) { ServerSslSocketFactory server_ssl_socket_factory(std::move(server_cfg), manager, server_stats_store, server_names); - Event::DispatcherImpl dispatcher(time_system, *server_api); + Event::DispatcherImpl dispatcher(*server_api); Network::TcpListenSocket socket(Network::Test::getCanonicalLoopbackAddress(options.version()), nullptr, true); NiceMock callbacks; @@ -588,7 +588,7 @@ void configureServerAndExpiredClientCertificate(envoy::api::v2::Listener& listen class SslSocketTest : public SslCertsTest, public testing::WithParamInterface { protected: - SslSocketTest() : dispatcher_(std::make_unique(time_system_, *api_)) {} + SslSocketTest() : dispatcher_(std::make_unique(*api_)) {} void testClientSessionResumption(const std::string& server_ctx_yaml, const std::string& client_ctx_yaml, bool expect_reuse, @@ -2103,7 +2103,7 @@ void testTicketSessionResumption(const std::string& server_ctx_yaml1, const std::string& client_ctx_yaml, bool expect_reuse, const Network::Address::IpVersion ip_version) { Event::SimulatedTimeSystem time_system; - ContextManagerImpl manager(time_system); + ContextManagerImpl manager(*time_system); Stats::IsolatedStoreImpl server_stats_store; Api::ApiPtr server_api = Api::createApiForTest(server_stats_store); @@ -2131,7 +2131,7 @@ void testTicketSessionResumption(const std::string& server_ctx_yaml1, true); NiceMock callbacks; Network::MockConnectionHandler connection_handler; - Event::DispatcherImpl dispatcher(time_system, *server_api); + Event::DispatcherImpl dispatcher(*server_api); Network::ListenerPtr listener1 = dispatcher.createListener(socket1, callbacks, true, false); Network::ListenerPtr listener2 = dispatcher.createListener(socket2, callbacks, true, false); @@ -2654,7 +2654,7 @@ void SslSocketTest::testClientSessionResumption(const std::string& server_ctx_ya NiceMock callbacks; Network::MockConnectionHandler connection_handler; Api::ApiPtr api = Api::createApiForTest(server_stats_store); - Event::DispatcherImpl dispatcher(time_system_, *server_api); + Event::DispatcherImpl dispatcher(*server_api); Network::ListenerPtr listener = dispatcher.createListener(socket, callbacks, true, false); Network::ConnectionPtr server_connection; @@ -3662,8 +3662,8 @@ class SslReadBufferLimitTest : public SslSocketTest { void singleWriteTest(uint32_t read_buffer_limit, uint32_t bytes_to_write) { MockWatermarkBuffer* client_write_buffer = nullptr; MockBufferFactory* factory = new StrictMock; - dispatcher_ = std::make_unique( - time_system_, Buffer::WatermarkFactoryPtr{factory}, *api_); + dispatcher_ = + std::make_unique(Buffer::WatermarkFactoryPtr{factory}, *api_); // By default, expect 4 buffers to be created - the client and server read and write buffers. EXPECT_CALL(*factory, create_(_, _)) diff --git a/test/integration/echo_integration_test.cc b/test/integration/echo_integration_test.cc index da64a31270779..e91fe26f5ee17 100644 --- a/test/integration/echo_integration_test.cc +++ b/test/integration/echo_integration_test.cc @@ -10,7 +10,7 @@ std::string echo_config; class EchoIntegrationTest : public BaseIntegrationTest, public TestBaseWithParam { public: - EchoIntegrationTest() : BaseIntegrationTest(GetParam(), realTime(), echo_config) {} + EchoIntegrationTest() : BaseIntegrationTest(GetParam(), echo_config) {} // Called once by the gtest framework before any EchoIntegrationTests are run. static void SetUpTestSuite() { diff --git a/test/integration/fake_upstream.cc b/test/integration/fake_upstream.cc index 0a48b7e0c526f..2e9bc4786411b 100644 --- a/test/integration/fake_upstream.cc +++ b/test/integration/fake_upstream.cc @@ -374,7 +374,7 @@ FakeUpstream::FakeUpstream(Network::TransportSocketFactoryPtr&& transport_socket Event::TestTimeSystem& time_system, bool enable_half_close) : http_type_(type), socket_(std::move(listen_socket)), api_(Api::createApiForTest(stats_store_)), time_system_(time_system), - dispatcher_(api_->allocateDispatcher(time_system_)), + dispatcher_(api_->allocateDispatcher()), handler_(new Server::ConnectionHandlerImpl(ENVOY_LOGGER(), *dispatcher_)), allow_unexpected_disconnects_(false), enable_half_close_(enable_half_close), listener_(*this), filter_chain_(Network::Test::createEmptyFilterChain(std::move(transport_socket_factory))) { diff --git a/test/integration/http_integration.cc b/test/integration/http_integration.cc index 3b5eba31906a2..a06b8cc67c03c 100644 --- a/test/integration/http_integration.cc +++ b/test/integration/http_integration.cc @@ -204,9 +204,8 @@ HttpIntegrationTest::makeHttpConnection(Network::ClientConnectionPtr&& conn) { HttpIntegrationTest::HttpIntegrationTest(Http::CodecClient::Type downstream_protocol, Network::Address::IpVersion version, - TestTimeSystemPtr time_system, const std::string& config) - : BaseIntegrationTest(version, std::move(time_system), config), - downstream_protocol_(downstream_protocol) { + const std::string& config) + : BaseIntegrationTest(version, config), downstream_protocol_(downstream_protocol) { // Legacy integration tests expect the default listener to be named "http" for lookupPort calls. config_helper_.renameListener("http"); config_helper_.setClientCodec(typeToCodecType(downstream_protocol_)); diff --git a/test/integration/http_integration.h b/test/integration/http_integration.h index a0d2b0d2bc8a9..743b009f0c049 100644 --- a/test/integration/http_integration.h +++ b/test/integration/http_integration.h @@ -80,7 +80,11 @@ typedef std::unique_ptr IntegrationCodecClientPtr; class HttpIntegrationTest : public BaseIntegrationTest { public: HttpIntegrationTest(Http::CodecClient::Type downstream_protocol, - Network::Address::IpVersion version, TestTimeSystemPtr time_system, + Network::Address::IpVersion version, TestTimeSystemPtr, + const std::string& config = ConfigHelper::HTTP_PROXY_CONFIG) + : HttpIntegrationTest(downstream_protocol, version, config) {} + HttpIntegrationTest(Http::CodecClient::Type downstream_protocol, + Network::Address::IpVersion version, const std::string& config = ConfigHelper::HTTP_PROXY_CONFIG); virtual ~HttpIntegrationTest(); diff --git a/test/integration/http_protocol_integration.h b/test/integration/http_protocol_integration.h index 36d47b7a038e7..2939c795612e1 100644 --- a/test/integration/http_protocol_integration.h +++ b/test/integration/http_protocol_integration.h @@ -48,7 +48,7 @@ class HttpProtocolIntegrationTest : public HttpIntegrationTest, protocolTestParamsToString(const ::testing::TestParamInfo& p); HttpProtocolIntegrationTest() - : HttpIntegrationTest(GetParam().downstream_protocol, GetParam().version, realTime()) {} + : HttpIntegrationTest(GetParam().downstream_protocol, GetParam().version) {} void SetUp() override { setDownstreamProtocol(GetParam().downstream_protocol); diff --git a/test/integration/integration.cc b/test/integration/integration.cc index ac57ca81079dc..6147978f30887 100644 --- a/test/integration/integration.cc +++ b/test/integration/integration.cc @@ -227,20 +227,21 @@ void IntegrationTcpClient::ConnectionCallbacks::onEvent(Network::ConnectionEvent } BaseIntegrationTest::BaseIntegrationTest(Network::Address::IpVersion version, - TestTimeSystemPtr time_system, const std::string& config) + const std::string& config) : api_(Api::createApiForTest(stats_store_)), - mock_buffer_factory_(new NiceMock), time_system_(std::move(time_system)), - dispatcher_(new Event::DispatcherImpl( - *time_system_, Buffer::WatermarkFactoryPtr{mock_buffer_factory_}, *api_)), + mock_buffer_factory_(new NiceMock), + dispatcher_( + new Event::DispatcherImpl(Buffer::WatermarkFactoryPtr{mock_buffer_factory_}, *api_)), version_(version), config_helper_(version, *api_, config), default_log_level_(TestEnvironment::getOptions().logLevel()) { + // This is a hack, but there are situations where we disconnect fake upstream connections and // then we expect the server connection pool to get the disconnect before the next test starts. // This does not always happen. This pause should allow the server to pick up the disconnect // notification and clear the pool connection if necessary. A real fix would require adding fairly // complex test hooks to the server and/or spin waiting on stats, neither of which I think are // necessary right now. - time_system_->sleep(std::chrono::milliseconds(10)); + timeSystem().sleep(std::chrono::milliseconds(10)); ON_CALL(*mock_buffer_factory_, create_(_, _)) .WillByDefault(Invoke([](std::function below_low, std::function above_high) -> Buffer::Instance* { @@ -273,10 +274,10 @@ void BaseIntegrationTest::createUpstreams() { for (uint32_t i = 0; i < fake_upstreams_count_; ++i) { if (autonomous_upstream_) { fake_upstreams_.emplace_back( - new AutonomousUpstream(0, upstream_protocol_, version_, *time_system_)); + new AutonomousUpstream(0, upstream_protocol_, version_, timeSystem())); } else { fake_upstreams_.emplace_back( - new FakeUpstream(0, upstream_protocol_, version_, *time_system_, enable_half_close_)); + new FakeUpstream(0, upstream_protocol_, version_, timeSystem(), enable_half_close_)); } } } @@ -369,7 +370,7 @@ void BaseIntegrationTest::createGeneratedApiTestServer(const std::string& bootst const std::vector& port_names) { test_server_ = IntegrationTestServer::create(bootstrap_path, version_, pre_worker_start_test_steps_, deterministic_, - *time_system_, *api_, defer_listener_finalization_); + timeSystem(), *api_, defer_listener_finalization_); if (config_helper_.bootstrap().static_resources().listeners_size() > 0 && !defer_listener_finalization_) { // Wait for listeners to be created before invoking registerTestServerPorts() below, as that @@ -400,7 +401,7 @@ void BaseIntegrationTest::createTestServer(const std::string& json_path, const std::vector& port_names) { test_server_ = createIntegrationTestServer( TestEnvironment::temporaryFileSubstitute(json_path, port_map_, version_), nullptr, - *time_system_); + timeSystem()); registerTestServerPorts(port_names); } diff --git a/test/integration/integration.h b/test/integration/integration.h index ccd662caf39ec..15a77c66d0b67 100644 --- a/test/integration/integration.h +++ b/test/integration/integration.h @@ -132,20 +132,15 @@ class BaseIntegrationTest : Logger::Loggable { public: using TestTimeSystemPtr = std::unique_ptr; - BaseIntegrationTest(Network::Address::IpVersion version, TestTimeSystemPtr time_system, + BaseIntegrationTest(Network::Address::IpVersion version, const std::string& config = ConfigHelper::HTTP_PROXY_CONFIG); + BaseIntegrationTest(Network::Address::IpVersion version, TestTimeSystemPtr, + const std::string& config = ConfigHelper::HTTP_PROXY_CONFIG) + : BaseIntegrationTest(version, config) {} virtual ~BaseIntegrationTest() {} - /** - * Helper function to create a simulated time integration test during construction. - */ - static TestTimeSystemPtr simTime() { return std::make_unique(); } - - /** - * Helper function to create a wall-clock time integration test during construction. - */ - static TestTimeSystemPtr realTime() { return std::make_unique(); } + static TestTimeSystemPtr realTime() { return TestTimeSystemPtr(); } // Initialize the basic proto configuration, create fake upstreams, and start Envoy. virtual void initialize(); @@ -182,7 +177,7 @@ class BaseIntegrationTest : Logger::Loggable { void createApiTestServer(const ApiFilesystemConfig& api_filesystem_config, const std::vector& port_names); - Event::TestTimeSystem& timeSystem() { return *time_system_; } + Event::TestTimeSystem& timeSystem() { return time_system_; } Stats::IsolatedStoreImpl stats_store_; Api::ApiPtr api_; @@ -210,7 +205,7 @@ class BaseIntegrationTest : Logger::Loggable { } private: - TestTimeSystemPtr time_system_; + Event::GlobalTimeSystem time_system_; public: Event::DispatcherPtr dispatcher_; diff --git a/test/integration/integration_admin_test.cc b/test/integration/integration_admin_test.cc index 0dcdf795a00c1..120f7ebbb45bd 100644 --- a/test/integration/integration_admin_test.cc +++ b/test/integration/integration_admin_test.cc @@ -450,12 +450,12 @@ TEST_F(IntegrationAdminIpv4Ipv6Test, Ipv4Ipv6Listen) { // Testing the behavior of StatsMatcher, which allows/denies the instantiation of stats based on // restrictions on their names. class StatsMatcherIntegrationTest - : public HttpIntegrationTest, + : public Event::SimulatedTimeSystem, + public HttpIntegrationTest, public TestBase, public testing::WithParamInterface { public: - StatsMatcherIntegrationTest() - : HttpIntegrationTest(Http::CodecClient::Type::HTTP1, GetParam(), simTime()) {} + StatsMatcherIntegrationTest() : HttpIntegrationTest(Http::CodecClient::Type::HTTP1, GetParam()) {} void initialize() override { config_helper_.addConfigModifier( diff --git a/test/integration/utility.cc b/test/integration/utility.cc index 5eb7c783cc751..f7d46289ceece 100644 --- a/test/integration/utility.cc +++ b/test/integration/utility.cc @@ -61,9 +61,10 @@ IntegrationUtil::makeSingleRequest(const Network::Address::InstanceConstSharedPt const std::string& host, const std::string& content_type) { NiceMock mock_stats_store; - Api::Impl api(std::chrono::milliseconds(9000), Thread::threadFactoryForTest(), mock_stats_store); Event::GlobalTimeSystem time_system; - Event::DispatcherPtr dispatcher(api.allocateDispatcher(*time_system)); + Api::Impl api(std::chrono::milliseconds(9000), Thread::threadFactoryForTest(), mock_stats_store, + time_system); + Event::DispatcherPtr dispatcher(api.allocateDispatcher()); std::shared_ptr cluster{new NiceMock()}; Upstream::HostDescriptionConstSharedPtr host_description{ Upstream::makeTestHostDescription(cluster, "tcp://127.0.0.1:80")}; @@ -112,7 +113,7 @@ RawConnectionDriver::RawConnectionDriver(uint32_t port, Buffer::Instance& initia Network::Address::IpVersion version) { api_ = Api::createApiForTest(stats_store_); Event::GlobalTimeSystem time_system; - dispatcher_ = api_->allocateDispatcher(*time_system); + dispatcher_ = api_->allocateDispatcher(); callbacks_ = std::make_unique(); client_ = dispatcher_->createClientConnection( Network::Utility::resolveUrl( diff --git a/test/mocks/api/BUILD b/test/mocks/api/BUILD index 6a5be0ab4f1e5..65ae8f1431d8a 100644 --- a/test/mocks/api/BUILD +++ b/test/mocks/api/BUILD @@ -18,6 +18,6 @@ envoy_cc_mock( "//source/common/api:os_sys_calls_lib", "//source/common/common:assert_lib", "//test/mocks/filesystem:filesystem_mocks", - "//test/test_common:test_time_system_interface", + "//test/test_common:test_time_lib", ], ) diff --git a/test/mocks/api/mocks.cc b/test/mocks/api/mocks.cc index 4aab4c9c1759e..27fcb28593c45 100644 --- a/test/mocks/api/mocks.cc +++ b/test/mocks/api/mocks.cc @@ -17,6 +17,10 @@ MockApi::MockApi() { ON_CALL(*this, fileSystem()).WillByDefault(ReturnRef(file_s MockApi::~MockApi() {} +Event::DispatcherPtr MockApi::allocateDispatcher() { + return Event::DispatcherPtr{allocateDispatcher_(timeSystem())}; +} + MockOsSysCalls::MockOsSysCalls() { num_writes_ = num_open_ = 0; } MockOsSysCalls::~MockOsSysCalls() {} diff --git a/test/mocks/api/mocks.h b/test/mocks/api/mocks.h index 31dc57f9fe236..e1d495f83a62d 100644 --- a/test/mocks/api/mocks.h +++ b/test/mocks/api/mocks.h @@ -12,7 +12,7 @@ #include "common/api/os_sys_calls_impl.h" #include "test/mocks/filesystem/mocks.h" -#include "test/test_common/test_time_system.h" +#include "test/test_common/test_time.h" #include "gmock/gmock.h" @@ -25,15 +25,15 @@ class MockApi : public Api { ~MockApi(); // Api::Api - Event::DispatcherPtr allocateDispatcher(Event::TimeSystem& time_system) override { - return Event::DispatcherPtr{allocateDispatcher_(time_system)}; - } + Event::DispatcherPtr allocateDispatcher() override; + Event::TimeSystem& timeSystem() override { return time_system_; } MOCK_METHOD1(allocateDispatcher_, Event::Dispatcher*(Event::TimeSystem&)); MOCK_METHOD0(fileSystem, Filesystem::Instance&()); MOCK_METHOD0(threadFactory, Thread::ThreadFactory&()); testing::NiceMock file_system_; + Event::GlobalTimeSystem time_system_; }; class MockOsSysCalls : public OsSysCallsImpl { diff --git a/test/mocks/server/mocks.cc b/test/mocks/server/mocks.cc index c0ab9e59f422e..ce37f26c1ca02 100644 --- a/test/mocks/server/mocks.cc +++ b/test/mocks/server/mocks.cc @@ -179,6 +179,7 @@ MockFactoryContext::MockFactoryContext() ON_CALL(*this, threadLocal()).WillByDefault(ReturnRef(thread_local_)); ON_CALL(*this, admin()).WillByDefault(ReturnRef(admin_)); ON_CALL(*this, listenerScope()).WillByDefault(ReturnRef(listener_scope_)); + ON_CALL(*this, api()).WillByDefault(ReturnRef(api_)); ON_CALL(*this, timeSource()).WillByDefault(ReturnRef(time_system_)); ON_CALL(*this, overloadManager()).WillByDefault(ReturnRef(overload_manager_)); ON_CALL(*this, api()).WillByDefault(ReturnRef(api_)); diff --git a/test/server/BUILD b/test/server/BUILD index 0ba84d4870b45..813ac24ee5267 100644 --- a/test/server/BUILD +++ b/test/server/BUILD @@ -174,6 +174,7 @@ envoy_cc_test( "//test/test_common:environment_lib", "//test/test_common:registry_lib", "//test/test_common:simulated_time_system_lib", + "//test/test_common:test_time_lib", "//test/test_common:threadsafe_singleton_injector_lib", ], ) @@ -251,7 +252,6 @@ envoy_cc_test( "//test/mocks/network:network_mocks", "//test/mocks/server:server_mocks", "//test/mocks/thread_local:thread_local_mocks", - "//test/test_common:test_time_lib", "//test/test_common:utility_lib", ], ) diff --git a/test/server/config_validation/BUILD b/test/server/config_validation/BUILD index 6015d898495c1..a1e274b2ebd9b 100644 --- a/test/server/config_validation/BUILD +++ b/test/server/config_validation/BUILD @@ -18,7 +18,6 @@ envoy_cc_test( "//source/server/config_validation:dns_lib", "//test/mocks/http:http_mocks", "//test/mocks/upstream:upstream_mocks", - "//test/test_common:test_time_lib", ], ) diff --git a/test/server/config_validation/async_client_test.cc b/test/server/config_validation/async_client_test.cc index 7dfc5e3a6e6b6..dceb4dafafb3e 100644 --- a/test/server/config_validation/async_client_test.cc +++ b/test/server/config_validation/async_client_test.cc @@ -6,7 +6,6 @@ #include "test/mocks/http/mocks.h" #include "test/mocks/upstream/mocks.h" -#include "test/test_common/test_time.h" namespace Envoy { namespace Http { @@ -16,10 +15,9 @@ TEST(ValidationAsyncClientTest, MockedMethods) { MockAsyncClientCallbacks callbacks; MockAsyncClientStreamCallbacks stream_callbacks; - DangerousDeprecatedTestTime test_time; Stats::IsolatedStoreImpl stats_store; Api::ApiPtr api = Api::createApiForTest(stats_store); - ValidationAsyncClient client(test_time.timeSystem(), *api); + ValidationAsyncClient client(*api); EXPECT_EQ(nullptr, client.send(std::move(message), callbacks, AsyncClient::RequestOptions())); EXPECT_EQ(nullptr, client.start(stream_callbacks, AsyncClient::StreamOptions())); } diff --git a/test/server/config_validation/cluster_manager_test.cc b/test/server/config_validation/cluster_manager_test.cc index 86a3d9dd7765d..3b976a80f8271 100644 --- a/test/server/config_validation/cluster_manager_test.cc +++ b/test/server/config_validation/cluster_manager_test.cc @@ -19,7 +19,6 @@ #include "test/mocks/server/mocks.h" #include "test/mocks/thread_local/mocks.h" #include "test/mocks/upstream/mocks.h" -#include "test/test_common/simulated_time_system.h" #include "test/test_common/utility.h" namespace Envoy { @@ -29,12 +28,11 @@ TEST(ValidationClusterManagerTest, MockedMethods) { Stats::IsolatedStoreImpl stats_store; Api::ApiPtr api(Api::createApiForTest(stats_store)); NiceMock runtime; - Event::SimulatedTimeSystem time_system; NiceMock tls; NiceMock random; testing::NiceMock secret_manager; auto dns_resolver = std::make_shared>(); - Extensions::TransportSockets::Tls::ContextManagerImpl ssl_context_manager{time_system}; + Extensions::TransportSockets::Tls::ContextManagerImpl ssl_context_manager{api->timeSystem()}; NiceMock dispatcher; LocalInfo::MockLocalInfo local_info; NiceMock admin; diff --git a/test/server/config_validation/dispatcher_test.cc b/test/server/config_validation/dispatcher_test.cc index 7f7342380e721..db5e41dfcce5f 100644 --- a/test/server/config_validation/dispatcher_test.cc +++ b/test/server/config_validation/dispatcher_test.cc @@ -24,9 +24,10 @@ class ConfigValidation : public TestBaseWithParam { ConfigValidation() { Event::Libevent::Global::initialize(); - validation_ = std::make_unique( - std::chrono::milliseconds(1000), Thread::threadFactoryForTest(), stats_store_); - dispatcher_ = validation_->allocateDispatcher(test_time_.timeSystem()); + validation_ = std::make_unique(std::chrono::milliseconds(1000), + Thread::threadFactoryForTest(), + stats_store_, test_time_.timeSystem()); + dispatcher_ = validation_->allocateDispatcher(); } DangerousDeprecatedTestTime test_time_; diff --git a/test/server/guarddog_impl_test.cc b/test/server/guarddog_impl_test.cc index b2bd21eef329b..c61ac7946f347 100644 --- a/test/server/guarddog_impl_test.cc +++ b/test/server/guarddog_impl_test.cc @@ -26,7 +26,7 @@ namespace Server { class GuardDogTestBase : public TestBase { protected: - GuardDogTestBase() : api_(Api::createApiForTest(stats_store_)) {} + GuardDogTestBase() : api_(Api::createApiForTest(stats_store_, time_system_)) {} Event::SimulatedTimeSystem time_system_; Stats::IsolatedStoreImpl stats_store_; @@ -51,7 +51,7 @@ class GuardDogDeathTest : public GuardDogTestBase { */ void SetupForDeath() { InSequence s; - guard_dog_ = std::make_unique(fakestats_, config_kill_, time_system_, *api_); + guard_dog_ = std::make_unique(fakestats_, config_kill_, *api_); unpet_dog_ = guard_dog_->createWatchDog(api_->threadFactory().currentThreadId()); guard_dog_->forceCheckForTest(); time_system_.sleep(std::chrono::milliseconds(500)); @@ -63,7 +63,7 @@ class GuardDogDeathTest : public GuardDogTestBase { */ void SetupForMultiDeath() { InSequence s; - guard_dog_ = std::make_unique(fakestats_, config_multikill_, time_system_, *api_); + guard_dog_ = std::make_unique(fakestats_, config_multikill_, *api_); auto unpet_dog_ = guard_dog_->createWatchDog(api_->threadFactory().currentThreadId()); guard_dog_->forceCheckForTest(); auto second_dog_ = guard_dog_->createWatchDog(api_->threadFactory().currentThreadId()); @@ -120,7 +120,7 @@ TEST_F(GuardDogAlmostDeadTest, NearDeathTest) { // This ensures that if only one thread surpasses the multiple kill threshold // there is no death. The positive case is covered in MultiKillDeathTest. InSequence s; - GuardDogImpl gd(fakestats_, config_multikill_, time_system_, *api_); + GuardDogImpl gd(fakestats_, config_multikill_, *api_); auto unpet_dog = gd.createWatchDog(api_->threadFactory().currentThreadId()); auto pet_dog = gd.createWatchDog(api_->threadFactory().currentThreadId()); // This part "waits" 600 milliseconds while one dog is touched every 100, and @@ -146,7 +146,7 @@ class GuardDogMissTest : public GuardDogTestBase { TEST_F(GuardDogMissTest, MissTest) { // This test checks the actual collected statistics after doing some timer // advances that should and shouldn't increment the counters. - GuardDogImpl gd(stats_store_, config_miss_, time_system_, *api_); + GuardDogImpl gd(stats_store_, config_miss_, *api_); // We'd better start at 0: EXPECT_EQ(0UL, stats_store_.counter("server.watchdog_miss").value()); auto unpet_dog = gd.createWatchDog(api_->threadFactory().currentThreadId()); @@ -165,7 +165,7 @@ TEST_F(GuardDogMissTest, MissTest) { TEST_F(GuardDogMissTest, MegaMissTest) { // This test checks the actual collected statistics after doing some timer // advances that should and shouldn't increment the counters. - GuardDogImpl gd(stats_store_, config_mega_, time_system_, *api_); + GuardDogImpl gd(stats_store_, config_mega_, *api_); auto unpet_dog = gd.createWatchDog(api_->threadFactory().currentThreadId()); // We'd better start at 0: EXPECT_EQ(0UL, stats_store_.counter("server.watchdog_mega_miss").value()); @@ -185,7 +185,7 @@ TEST_F(GuardDogMissTest, MissCountTest) { // This tests a flake discovered in the MissTest where real timeout or // spurious condition_variable wakeup causes the counter to get incremented // more than it should be. - GuardDogImpl gd(stats_store_, config_miss_, time_system_, *api_); + GuardDogImpl gd(stats_store_, config_miss_, *api_); auto sometimes_pet_dog = gd.createWatchDog(api_->threadFactory().currentThreadId()); // These steps are executed once without ever touching the watchdog. // Then the last step is to touch the watchdog and repeat the steps. @@ -225,27 +225,27 @@ TEST_F(GuardDogMissTest, MissCountTest) { TEST_F(GuardDogTestBase, StartStopTest) { NiceMock stats; NiceMock config(0, 0, 0, 0); - GuardDogImpl gd(stats, config, time_system_, *api_); + GuardDogImpl gd(stats, config, *api_); } TEST_F(GuardDogTestBase, LoopIntervalNoKillTest) { NiceMock stats; NiceMock config(40, 50, 0, 0); - GuardDogImpl gd(stats, config, time_system_, *api_); + GuardDogImpl gd(stats, config, *api_); EXPECT_EQ(gd.loopIntervalForTest(), 40); } TEST_F(GuardDogTestBase, LoopIntervalTest) { NiceMock stats; NiceMock config(100, 90, 1000, 500); - GuardDogImpl gd(stats, config, time_system_, *api_); + GuardDogImpl gd(stats, config, *api_); EXPECT_EQ(gd.loopIntervalForTest(), 90); } TEST_F(GuardDogTestBase, WatchDogThreadIdTest) { NiceMock stats; NiceMock config(100, 90, 1000, 500); - GuardDogImpl gd(stats, config, time_system_, *api_); + GuardDogImpl gd(stats, config, *api_); auto watched_dog = gd.createWatchDog(api_->threadFactory().currentThreadId()); EXPECT_EQ(watched_dog->threadId().debugString(), api_->threadFactory().currentThreadId()->debugString()); diff --git a/test/server/listener_manager_impl_test.cc b/test/server/listener_manager_impl_test.cc index 2da9582823033..616b29e36a53c 100644 --- a/test/server/listener_manager_impl_test.cc +++ b/test/server/listener_manager_impl_test.cc @@ -60,8 +60,7 @@ class ListenerManagerImplTest : public TestBase { ListenerManagerImplTest() : api_(Api::createApiForTest(stats_)) { ON_CALL(server_, api()).WillByDefault(ReturnRef(*api_)); EXPECT_CALL(worker_factory_, createWorker_()).WillOnce(Return(worker_)); - manager_ = std::make_unique(server_, listener_factory_, worker_factory_, - time_system_); + manager_ = std::make_unique(server_, listener_factory_, worker_factory_); } /** diff --git a/test/server/worker_impl_test.cc b/test/server/worker_impl_test.cc index 0be4f48732037..06775542ab02d 100644 --- a/test/server/worker_impl_test.cc +++ b/test/server/worker_impl_test.cc @@ -7,7 +7,6 @@ #include "test/mocks/server/mocks.h" #include "test/mocks/thread_local/mocks.h" #include "test/test_common/test_base.h" -#include "test/test_common/test_time.h" #include "test/test_common/utility.h" using testing::_; @@ -31,12 +30,11 @@ class WorkerImplTest : public TestBase { Stats::IsolatedStoreImpl stats_store_; NiceMock tls_; - DangerousDeprecatedTestTime test_time; Network::MockConnectionHandler* handler_ = new Network::MockConnectionHandler(); NiceMock guard_dog_; NiceMock overload_manager_; Api::ApiPtr api_; - Event::DispatcherImpl* dispatcher_ = new Event::DispatcherImpl(test_time.timeSystem(), *api_); + Event::DispatcherImpl* dispatcher_ = new Event::DispatcherImpl(*api_); DefaultTestHooks hooks_; WorkerImpl worker_{tls_, hooks_, diff --git a/test/test_common/BUILD b/test/test_common/BUILD index 0aa8c4956b797..b314e54f0c13e 100644 --- a/test/test_common/BUILD +++ b/test/test_common/BUILD @@ -90,6 +90,7 @@ envoy_cc_test_library( "abseil_strings", ], deps = [ + ":test_time_lib", "//include/envoy/buffer:buffer_interface", "//include/envoy/http:codec_interface", "//include/envoy/network:address_interface", diff --git a/test/test_common/environment.cc b/test/test_common/environment.cc index 5097558f1ff95..266a9a446676a 100644 --- a/test/test_common/environment.cc +++ b/test/test_common/environment.cc @@ -124,7 +124,7 @@ absl::optional TestEnvironment::getOptionalEnvVar(const std::string std::string TestEnvironment::getCheckedEnvVar(const std::string& var) { auto optional = getOptionalEnvVar(var); - RELEASE_ASSERT(optional.has_value(), ""); + RELEASE_ASSERT(optional.has_value(), var); return optional.value(); } diff --git a/test/test_common/utility.cc b/test/test_common/utility.cc index 4b10d5208c446..e88e7a9d4e539 100644 --- a/test/test_common/utility.cc +++ b/test/test_common/utility.cc @@ -38,6 +38,7 @@ #include "common/filesystem/directory.h" #include "test/test_common/printers.h" +#include "test/test_common/test_time.h" #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" @@ -400,11 +401,27 @@ ThreadFactory& threadFactoryForTest() { namespace Api { +class TimeSystemProvider { +protected: + Event::GlobalTimeSystem global_time_system_; +}; + +class TestImpl : public TimeSystemProvider, public Impl { +public: + TestImpl(std::chrono::milliseconds file_flush_interval_msec, + Thread::ThreadFactory& thread_factory, Stats::Store& stats_store) + : Impl(file_flush_interval_msec, thread_factory, stats_store, global_time_system_) {} +}; + ApiPtr createApiForTest(Stats::Store& stat_store) { + return std::make_unique(std::chrono::milliseconds(1000), Thread::threadFactoryForTest(), + stat_store); +} + +ApiPtr createApiForTest(Stats::Store& stat_store, Event::TimeSystem& time_system) { return std::make_unique(std::chrono::milliseconds(1000), Thread::threadFactoryForTest(), - stat_store); + stat_store, time_system); } } // namespace Api - } // namespace Envoy diff --git a/test/test_common/utility.h b/test/test_common/utility.h index 02726229002c2..c61b49b57a01e 100644 --- a/test/test_common/utility.h +++ b/test/test_common/utility.h @@ -527,6 +527,7 @@ ThreadFactory& threadFactoryForTest(); namespace Api { ApiPtr createApiForTest(Stats::Store& stat_store); +ApiPtr createApiForTest(Stats::Store& stat_store, Event::TimeSystem& time_system); } // namespace Api MATCHER_P(HeaderMapEqualIgnoreOrder, rhs, "") { diff --git a/tools/bootstrap2pb.cc b/tools/bootstrap2pb.cc index fb2b539617995..8b298b3da8c49 100644 --- a/tools/bootstrap2pb.cc +++ b/tools/bootstrap2pb.cc @@ -13,6 +13,7 @@ #include "common/api/api_impl.h" #include "common/common/assert.h" +#include "common/event/real_time_system.h" #include "common/protobuf/utility.h" #include "common/stats/isolated_store_impl.h" @@ -28,8 +29,9 @@ int main(int argc, char** argv) { Envoy::PlatformImpl platform_impl_; Envoy::Stats::IsolatedStoreImpl stats_store; - Envoy::Api::Impl api(std::chrono::milliseconds(1000), platform_impl_.threadFactory(), - stats_store); + Envoy::Event::RealTimeSystem time_system; // NO_CHECK_FORMAT(real_time) + Envoy::Api::Impl api(std::chrono::milliseconds(1000), platform_impl_.threadFactory(), stats_store, + time_system); envoy::config::bootstrap::v2::Bootstrap bootstrap; Envoy::MessageUtil::loadFromFile(argv[1], bootstrap, api); diff --git a/tools/v1_to_bootstrap.cc b/tools/v1_to_bootstrap.cc index 74f5763d87adb..48f8861552898 100644 --- a/tools/v1_to_bootstrap.cc +++ b/tools/v1_to_bootstrap.cc @@ -12,6 +12,7 @@ #include "common/api/api_impl.h" #include "common/config/bootstrap_json.h" +#include "common/event/real_time_system.h" #include "common/json/json_loader.h" #include "common/protobuf/utility.h" #include "common/stats/isolated_store_impl.h" @@ -28,8 +29,9 @@ int main(int argc, char** argv) { Envoy::PlatformImpl platform_impl_; Envoy::Stats::IsolatedStoreImpl stats_store; - Envoy::Api::Impl api(std::chrono::milliseconds(1000), platform_impl_.threadFactory(), - stats_store); + Envoy::Event::RealTimeSystem time_system; // NO_CHECK_FORMAT(real_time) + Envoy::Api::Impl api(std::chrono::milliseconds(1000), platform_impl_.threadFactory(), stats_store, + time_system); envoy::config::bootstrap::v2::Bootstrap bootstrap; auto config_json = Envoy::Json::Factory::loadFromFile(argv[1], api);