Skip to content

Commit

Permalink
Changed TestHooks to ListenerHooks (#6642)
Browse files Browse the repository at this point in the history
Change name of class TestHooks to ListenerHooks

Risk Level: Low; name change only.
Testing: Existing tests
Docs Changes: n/a
Release Notes: n/a
Fixes #6641

Signed-off-by: Randy Smith <rdsmith@google.com>
  • Loading branch information
curiouserrandy authored and htuch committed Apr 23, 2019
1 parent 37b4d2d commit 85ae43a
Show file tree
Hide file tree
Showing 17 changed files with 45 additions and 44 deletions.
2 changes: 1 addition & 1 deletion source/exe/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ envoy_cc_library(
"//source/server:drain_manager_lib",
"//source/server:options_lib",
"//source/server:server_lib",
"//source/server:test_hooks_lib",
"//source/server:listener_hooks_lib",
] + select({
"//bazel:windows_x86_64": envoy_windows_extensions(),
"//bazel:linux_ppc": envoy_all_extensions(PPC_SKIP_TARGETS),
Expand Down
9 changes: 5 additions & 4 deletions source/exe/main_common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
#include "server/config_validation/server.h"
#include "server/drain_manager_impl.h"
#include "server/hot_restart_nop_impl.h"
#include "server/listener_hooks.h"
#include "server/options_impl.h"
#include "server/proto_descriptors.h"
#include "server/server.h"
#include "server/test_hooks.h"

#include "absl/strings/str_split.h"

Expand All @@ -43,7 +43,8 @@ Runtime::LoaderPtr ProdComponentFactory::createRuntime(Server::Instance& server,
}

MainCommonBase::MainCommonBase(const OptionsImpl& options, Event::TimeSystem& time_system,
TestHooks& test_hooks, Server::ComponentFactory& component_factory,
ListenerHooks& listener_hooks,
Server::ComponentFactory& component_factory,
std::unique_ptr<Runtime::RandomGenerator>&& random_generator,
Thread::ThreadFactory& thread_factory,
Filesystem::Instance& file_system)
Expand Down Expand Up @@ -83,7 +84,7 @@ MainCommonBase::MainCommonBase(const OptionsImpl& options, Event::TimeSystem& ti
restarter_->statsAllocator());

server_ = std::make_unique<Server::InstanceImpl>(
options_, time_system, local_address, test_hooks, *restarter_, *stats_store_,
options_, time_system, local_address, listener_hooks, *restarter_, *stats_store_,
access_log_lock, component_factory, std::move(random_generator), *tls_, thread_factory_,
file_system_);

Expand Down Expand Up @@ -138,7 +139,7 @@ void MainCommonBase::adminRequest(absl::string_view path_and_query, absl::string

MainCommon::MainCommon(int argc, const char* const* argv)
: options_(argc, argv, &MainCommon::hotRestartVersion, spdlog::level::info),
base_(options_, real_time_system_, default_test_hooks_, prod_component_factory_,
base_(options_, real_time_system_, default_listener_hooks_, prod_component_factory_,
std::make_unique<Runtime::RandomGeneratorImpl>(), platform_impl_.threadFactory(),
platform_impl_.fileSystem()) {}

Expand Down
8 changes: 4 additions & 4 deletions source/exe/main_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

#include "exe/platform_impl.h"

#include "server/listener_hooks.h"
#include "server/options_impl.h"
#include "server/server.h"
#include "server/test_hooks.h"

#ifdef ENVOY_HANDLE_SIGNALS
#include "exe/signal_action.h"
Expand All @@ -34,8 +34,8 @@ class MainCommonBase {
public:
// Consumer must guarantee that all passed references are alive until this object is
// destructed.
MainCommonBase(const OptionsImpl& options, Event::TimeSystem& time_system, TestHooks& test_hooks,
Server::ComponentFactory& component_factory,
MainCommonBase(const OptionsImpl& options, Event::TimeSystem& time_system,
ListenerHooks& listener_hooks, Server::ComponentFactory& component_factory,
std::unique_ptr<Runtime::RandomGenerator>&& random_generator,
Thread::ThreadFactory& thread_factory, Filesystem::Instance& file_system);
~MainCommonBase();
Expand Down Expand Up @@ -121,7 +121,7 @@ class MainCommon {
PlatformImpl platform_impl_;
Envoy::OptionsImpl options_;
Event::RealTimeSystem real_time_system_;
DefaultTestHooks default_test_hooks_;
DefaultListenerHooks default_listener_hooks_;
ProdComponentFactory prod_component_factory_;
MainCommonBase base_;
};
Expand Down
8 changes: 4 additions & 4 deletions source/server/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@ envoy_cc_library(
":configuration_lib",
":connection_handler_lib",
":guarddog_lib",
":listener_hooks_lib",
":listener_manager_lib",
":test_hooks_lib",
":worker_lib",
"//include/envoy/event:dispatcher_interface",
"//include/envoy/event:signal_interface",
Expand Down Expand Up @@ -312,8 +312,8 @@ envoy_cc_library(
)

envoy_cc_library(
name = "test_hooks_lib",
hdrs = ["test_hooks.h"],
name = "listener_hooks_lib",
hdrs = ["listener_hooks.h"],
)

envoy_cc_library(
Expand All @@ -334,7 +334,7 @@ envoy_cc_library(
hdrs = ["worker_impl.h"],
deps = [
":connection_handler_lib",
":test_hooks_lib",
":listener_hooks_lib",
"//include/envoy/api:api_interface",
"//include/envoy/event:dispatcher_interface",
"//include/envoy/event:timer_interface",
Expand Down
10 changes: 5 additions & 5 deletions source/server/test_hooks.h → source/server/listener_hooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ namespace Envoy {
* Hooks in the server to allow for integration testing. The real server just uses an empty
* implementation defined below.
*/
class TestHooks {
class ListenerHooks {
public:
virtual ~TestHooks() {}
virtual ~ListenerHooks() {}

/**
* Called when a worker has added a listener and it is listening.
Expand All @@ -29,11 +29,11 @@ class TestHooks {
};

/**
* Empty implementation of TestHooks.
* Empty implementation of ListenerHooks.
*/
class DefaultTestHooks : public TestHooks {
class DefaultListenerHooks : public ListenerHooks {
public:
// TestHooks
// ListenerHooks
void onWorkerListenerAdded() override {}
void onWorkerListenerRemoved() override {}
void onRuntimeCreated() override {}
Expand Down
8 changes: 4 additions & 4 deletions source/server/server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@
#include "server/configuration_impl.h"
#include "server/connection_handler_impl.h"
#include "server/guarddog_impl.h"
#include "server/test_hooks.h"
#include "server/listener_hooks.h"

namespace Envoy {
namespace Server {

InstanceImpl::InstanceImpl(const Options& options, Event::TimeSystem& time_system,
Network::Address::InstanceConstSharedPtr local_address, TestHooks& hooks,
HotRestart& restarter, Stats::StoreRoot& store,
Network::Address::InstanceConstSharedPtr local_address,
ListenerHooks& hooks, HotRestart& restarter, Stats::StoreRoot& store,
Thread::BasicLockable& access_log_lock,
ComponentFactory& component_factory,
Runtime::RandomGeneratorPtr&& random_generator,
Expand Down Expand Up @@ -200,7 +200,7 @@ InstanceUtil::loadBootstrapConfig(envoy::config::bootstrap::v2::Bootstrap& boots

void InstanceImpl::initialize(const Options& options,
Network::Address::InstanceConstSharedPtr local_address,
ComponentFactory& component_factory, TestHooks& hooks) {
ComponentFactory& component_factory, ListenerHooks& hooks) {
ENVOY_LOG(info, "initializing epoch {} (hot restart version={})", options.restartEpoch(),
restarter_.version());

Expand Down
6 changes: 3 additions & 3 deletions source/server/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@

#include "server/configuration_impl.h"
#include "server/http/admin.h"
#include "server/listener_hooks.h"
#include "server/listener_manager_impl.h"
#include "server/overload_manager_impl.h"
#include "server/test_hooks.h"
#include "server/worker_impl.h"

#include "extensions/transport_sockets/tls/context_manager_impl.h"
Expand Down Expand Up @@ -145,7 +145,7 @@ class InstanceImpl : Logger::Loggable<Logger::Id::main>,
* @throw EnvoyException if initialization fails.
*/
InstanceImpl(const Options& options, Event::TimeSystem& time_system,
Network::Address::InstanceConstSharedPtr local_address, TestHooks& hooks,
Network::Address::InstanceConstSharedPtr local_address, ListenerHooks& hooks,
HotRestart& restarter, Stats::StoreRoot& store,
Thread::BasicLockable& access_log_lock, ComponentFactory& component_factory,
Runtime::RandomGeneratorPtr&& random_generator, ThreadLocal::Instance& tls,
Expand Down Expand Up @@ -202,7 +202,7 @@ class InstanceImpl : Logger::Loggable<Logger::Id::main>,
ProtobufTypes::MessagePtr dumpBootstrapConfig();
void flushStats();
void initialize(const Options& options, Network::Address::InstanceConstSharedPtr local_address,
ComponentFactory& component_factory, TestHooks& hooks);
ComponentFactory& component_factory, ListenerHooks& hooks);
void loadServerFlags(const absl::optional<std::string>& flags_path);
uint64_t numConnections();
void startWorkers();
Expand Down
2 changes: 1 addition & 1 deletion source/server/worker_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ WorkerPtr ProdWorkerFactory::createWorker(OverloadManager& overload_manager) {
overload_manager, api_)};
}

WorkerImpl::WorkerImpl(ThreadLocal::Instance& tls, TestHooks& hooks,
WorkerImpl::WorkerImpl(ThreadLocal::Instance& tls, ListenerHooks& hooks,
Event::DispatcherPtr&& dispatcher, Network::ConnectionHandlerPtr handler,
OverloadManager& overload_manager, Api::Api& api)
: tls_(tls), hooks_(hooks), dispatcher_(std::move(dispatcher)), handler_(std::move(handler)),
Expand Down
10 changes: 5 additions & 5 deletions source/server/worker_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@

#include "common/common/logger.h"

#include "server/test_hooks.h"
#include "server/listener_hooks.h"

namespace Envoy {
namespace Server {

class ProdWorkerFactory : public WorkerFactory, Logger::Loggable<Logger::Id::main> {
public:
ProdWorkerFactory(ThreadLocal::Instance& tls, Api::Api& api, TestHooks& hooks)
ProdWorkerFactory(ThreadLocal::Instance& tls, Api::Api& api, ListenerHooks& hooks)
: tls_(tls), api_(api), hooks_(hooks) {}

// Server::WorkerFactory
Expand All @@ -28,15 +28,15 @@ class ProdWorkerFactory : public WorkerFactory, Logger::Loggable<Logger::Id::mai
private:
ThreadLocal::Instance& tls_;
Api::Api& api_;
TestHooks& hooks_;
ListenerHooks& hooks_;
};

/**
* A server threaded worker that wraps up a worker thread, event loop, etc.
*/
class WorkerImpl : public Worker, Logger::Loggable<Logger::Id::main> {
public:
WorkerImpl(ThreadLocal::Instance& tls, TestHooks& hooks, Event::DispatcherPtr&& dispatcher,
WorkerImpl(ThreadLocal::Instance& tls, ListenerHooks& hooks, Event::DispatcherPtr&& dispatcher,
Network::ConnectionHandlerPtr handler, OverloadManager& overload_manager,
Api::Api& api);

Expand All @@ -54,7 +54,7 @@ class WorkerImpl : public Worker, Logger::Loggable<Logger::Id::main> {
void stopAcceptingConnectionsCb(OverloadActionState state);

ThreadLocal::Instance& tls_;
TestHooks& hooks_;
ListenerHooks& hooks_;
Event::DispatcherPtr dispatcher_;
Network::ConnectionHandlerPtr handler_;
Api::Api& api_;
Expand Down
2 changes: 1 addition & 1 deletion test/integration/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,8 @@ envoy_cc_test_library(
"//source/extensions/transport_sockets/tls:ssl_socket_lib",
"//source/server:connection_handler_lib",
"//source/server:hot_restart_nop_lib",
"//source/server:listener_hooks_lib",
"//source/server:server_lib",
"//source/server:test_hooks_lib",
"//test/common/runtime:utility_lib",
"//test/common/upstream:utility_lib",
"//test/config:utility_lib",
Expand Down
2 changes: 1 addition & 1 deletion test/integration/server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ void IntegrationTestServer::onRuntimeCreated() {

void IntegrationTestServerImpl::createAndRunEnvoyServer(
OptionsImpl& options, Event::TimeSystem& time_system,
Network::Address::InstanceConstSharedPtr local_address, TestHooks& hooks,
Network::Address::InstanceConstSharedPtr local_address, ListenerHooks& hooks,
Thread::BasicLockable& access_log_lock, Server::ComponentFactory& component_factory,
Runtime::RandomGeneratorPtr&& random_generator) {
Stats::FakeSymbolTableImpl symbol_table;
Expand Down
10 changes: 5 additions & 5 deletions test/integration/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
#include "common/common/thread.h"
#include "common/stats/source_impl.h"

#include "server/listener_hooks.h"
#include "server/options_impl.h"
#include "server/server.h"
#include "server/test_hooks.h"

#include "test/integration/server_stats.h"
#include "test/integration/tcp_dump.h"
Expand Down Expand Up @@ -201,7 +201,7 @@ typedef std::unique_ptr<IntegrationTestServer> IntegrationTestServerPtr;
* createAndRunEnvoyServer().
*/
class IntegrationTestServer : public Logger::Loggable<Logger::Id::testing>,
public TestHooks,
public ListenerHooks,
public IntegrationTestServerStats,
public Server::ComponentFactory {
public:
Expand Down Expand Up @@ -263,7 +263,7 @@ class IntegrationTestServer : public Logger::Loggable<Logger::Id::testing>,

std::vector<Stats::GaugeSharedPtr> gauges() override { return stat_store().gauges(); }

// TestHooks
// ListenerHooks
void onWorkerListenerAdded() override;
void onWorkerListenerRemoved() override;

Expand Down Expand Up @@ -293,7 +293,7 @@ class IntegrationTestServer : public Logger::Loggable<Logger::Id::testing>,
// The subclass is also responsible for tearing down this server in its destructor.
virtual void createAndRunEnvoyServer(OptionsImpl& options, Event::TimeSystem& time_system,
Network::Address::InstanceConstSharedPtr local_address,
TestHooks& hooks, Thread::BasicLockable& access_log_lock,
ListenerHooks& hooks, Thread::BasicLockable& access_log_lock,
Server::ComponentFactory& component_factory,
Runtime::RandomGeneratorPtr&& random_generator) PURE;

Expand Down Expand Up @@ -344,7 +344,7 @@ class IntegrationTestServerImpl : public IntegrationTestServer {
private:
void createAndRunEnvoyServer(OptionsImpl& options, Event::TimeSystem& time_system,
Network::Address::InstanceConstSharedPtr local_address,
TestHooks& hooks, Thread::BasicLockable& access_log_lock,
ListenerHooks& hooks, Thread::BasicLockable& access_log_lock,
Server::ComponentFactory& component_factory,
Runtime::RandomGeneratorPtr&& random_generator) override;

Expand Down
4 changes: 2 additions & 2 deletions test/server/server_fuzz_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#include "common/network/address_impl.h"
#include "common/thread_local/thread_local_impl.h"

#include "server/listener_hooks.h"
#include "server/proto_descriptors.h"
#include "server/server.h"
#include "server/test_hooks.h"

#include "test/fuzz/fuzz_runner.h"
#include "test/integration/server.h"
Expand Down Expand Up @@ -54,7 +54,7 @@ makeHermeticPathsAndPorts(Fuzz::PerTestEnvironment& test_env,

DEFINE_PROTO_FUZZER(const envoy::config::bootstrap::v2::Bootstrap& input) {
testing::NiceMock<MockOptions> options;
DefaultTestHooks hooks;
DefaultListenerHooks hooks;
testing::NiceMock<MockHotRestart> restart;
Stats::TestIsolatedStoreImpl stats_store;
Thread::MutexBasicLockable fakelock;
Expand Down
2 changes: 1 addition & 1 deletion test/server/server_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class ServerInstanceImplTest : public testing::TestWithParam<Network::Address::I

Network::Address::IpVersion version_;
testing::NiceMock<MockOptions> options_;
DefaultTestHooks hooks_;
DefaultListenerHooks hooks_;
testing::NiceMock<MockHotRestart> restart_;
std::unique_ptr<ThreadLocal::InstanceImpl> thread_local_;
Stats::TestIsolatedStoreImpl stats_store_;
Expand Down
2 changes: 1 addition & 1 deletion test/server/worker_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class WorkerImplTest : public testing::Test {
NiceMock<MockOverloadManager> overload_manager_;
Api::ApiPtr api_;
Event::DispatcherPtr dispatcher_;
DefaultTestHooks hooks_;
DefaultListenerHooks hooks_;
Event::TimerPtr no_exit_timer_;
WorkerImpl worker_;
};
Expand Down
2 changes: 1 addition & 1 deletion tools/testdata/check_format/header_order.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "server/configuration_impl.h"
#include "server/connection_handler_impl.h"
#include "server/guarddog_impl.h"
#include "server/test_hooks.h"
#include "server/listener_hooks.h"
#include <signal.h>
#include <string>
#include <unordered_set>
Expand Down
2 changes: 1 addition & 1 deletion tools/testdata/check_format/header_order.cc.gold
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include "server/configuration_impl.h"
#include "server/connection_handler_impl.h"
#include "server/guarddog_impl.h"
#include "server/test_hooks.h"
#include "server/listener_hooks.h"

#include "absl/types/optional.h"

Expand Down

0 comments on commit 85ae43a

Please sign in to comment.