Skip to content

Commit

Permalink
Address the last few ambiguous Envoy includes
Browse files Browse the repository at this point in the history
Re-route the last few include that couldn't go via
`external/envoy/...` earler, plus some cleanup.

Needed for envoyproxy#119

This needs envoyproxy/envoy#8045

Signed-off-by: Otto van der Schaaf <[email protected]>
  • Loading branch information
oschaaf committed Aug 27, 2019
1 parent ab230d9 commit 1e0a059
Show file tree
Hide file tree
Showing 19 changed files with 39 additions and 96 deletions.
12 changes: 0 additions & 12 deletions include/nighthawk/client/process.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
#pragma once

#include "envoy/network/address.h"
#include "envoy/stats/store.h"

#include "nighthawk/client/client_worker.h"
#include "nighthawk/client/factories.h"
#include "nighthawk/client/options.h"
#include "nighthawk/client/output_collector.h"
#include "nighthawk/common/statistic.h"
#include "nighthawk/common/uri.h"

#include "external/envoy/source/common/api/api_impl.h"
#include "external/envoy/source/common/common/logger.h"
#include "external/envoy/source/common/event/real_time_system.h"

namespace Nighthawk {
namespace Client {
Expand Down
4 changes: 2 additions & 2 deletions source/client/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,9 @@ envoy_cc_library(
"@envoy//source/common/access_log:access_log_manager_lib_with_external_headers",
"@envoy//source/common/api:api_lib_with_external_headers",
"@envoy//source/common/common:cleanup_lib_with_external_headers",
"@envoy//source/common/common:thread_lib",
"@envoy//source/common/config:utility_lib_with_external_headers",
"@envoy//source/common/event:dispatcher_includes_with_external_headers",
"@envoy//source/common/event:real_time_system_lib_with_external_headers",
"@envoy//source/common/filesystem:filesystem_lib",
"@envoy//source/common/http:context_lib_with_external_headers",
"@envoy//source/common/http:header_map_lib_with_external_headers",
"@envoy//source/common/http:headers_lib_with_external_headers",
Expand All @@ -64,6 +62,8 @@ envoy_cc_library(
"@envoy//source/common/thread_local:thread_local_lib_with_external_headers",
"@envoy//source/common/upstream:cluster_manager_lib_with_external_headers",
"@envoy//source/exe:envoy_common_lib_with_external_headers",
"@envoy//source/exe:platform_header_lib_with_external_headers",
"@envoy//source/exe:platform_impl_lib",
"@envoy//source/exe:process_wide_lib_with_external_headers",
"@envoy//source/extensions/transport_sockets:well_known_names_with_external_headers",
"@envoy//source/extensions/transport_sockets/tls:context_lib_with_external_headers",
Expand Down
3 changes: 0 additions & 3 deletions source/client/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

#include "nighthawk/client/output_collector.h"

#include "external/envoy/source/common/api/api_impl.h"
#include "external/envoy/source/common/common/cleanup.h"
#include "external/envoy/source/common/event/dispatcher_impl.h"
#include "external/envoy/source/common/event/real_time_system.h"
Expand All @@ -20,8 +19,6 @@

#include "api/client/output.pb.h"

#include "common/common/thread_impl.h"
#include "common/filesystem/filesystem_impl.h" // XXX(oschaaf):
#include "common/frequency.h"
#include "common/uri_impl.h"
#include "common/utility.h"
Expand Down
18 changes: 9 additions & 9 deletions source/client/process_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
#include "api/client/options.pb.h"
#include "api/client/output.pb.h"

#include "common/common/thread_impl.h"
#include "common/filesystem/filesystem_impl.h"
#include "common/frequency.h"
#include "common/uri_impl.h"
#include "common/utility.h"
Expand Down Expand Up @@ -69,8 +67,10 @@ class ClusterManagerFactory : public Envoy::Upstream::ProdClusterManagerFactory

ProcessImpl::ProcessImpl(const Options& options, Envoy::Event::TimeSystem& time_system)
: time_system_(time_system), store_factory_(options), stats_allocator_(symbol_table_),
store_root_(stats_allocator_), api_(thread_factory_, store_root_, time_system_, file_system_),
dispatcher_(api_.allocateDispatcher()), cleanup_([this] {
store_root_(stats_allocator_),
api_(std::make_unique<Envoy::Api::Impl>(platform_impl_.threadFactory(), store_root_,
time_system_, platform_impl_.fileSystem())),
dispatcher_(api_->allocateDispatcher()), cleanup_([this] {
store_root_.shutdownThreading();
tls_.shutdownGlobalThreading();
}),
Expand All @@ -80,8 +80,8 @@ ProcessImpl::ProcessImpl(const Options& options, Envoy::Event::TimeSystem& time_
{}, Envoy::Network::Utility::getLocalAddress(Envoy::Network::Address::IpVersion::v4),
"nighthawk_service_zone", "nighthawk_service_cluster", "nighthawk_service_node")),
secret_manager_(config_tracker_), http_context_(store_root_.symbolTable()),
singleton_manager_(std::make_unique<Envoy::Singleton::ManagerImpl>(api_.threadFactory())),
access_log_manager_(std::chrono::milliseconds(1000), api_, *dispatcher_, fakelock_,
singleton_manager_(std::make_unique<Envoy::Singleton::ManagerImpl>(api_->threadFactory())),
access_log_manager_(std::chrono::milliseconds(1000), *api_, *dispatcher_, access_log_lock_,
store_root_),
init_watcher_("Nighthawk", []() {}), validation_context_(false, false) {
std::string lower = absl::AsciiStrToLower(
Expand Down Expand Up @@ -114,7 +114,7 @@ const std::vector<ClientWorkerPtr>& ProcessImpl::createWorkers(const UriImpl& ur
const auto worker_delay = std::chrono::duration_cast<std::chrono::nanoseconds>(
((inter_worker_delay_usec * worker_number) * 1us));
workers_.push_back(std::make_unique<ClientWorkerImpl>(
api_, tls_, cluster_manager_, benchmark_client_factory_, sequencer_factory_,
*api_, tls_, cluster_manager_, benchmark_client_factory_, sequencer_factory_,
std::make_unique<UriImpl>(uri), store_root_, worker_number,
first_worker_start + worker_delay, prefetch_connections));
worker_number++;
Expand Down Expand Up @@ -268,13 +268,13 @@ bool ProcessImpl::run(OutputCollector& collector) {
runtime_singleton_ = std::make_unique<Envoy::Runtime::ScopedLoaderSingleton>(
Envoy::Runtime::LoaderPtr{new Envoy::Runtime::LoaderImpl(
*dispatcher_, tls_, {}, *local_info_, init_manager_, store_root_, generator_,
Envoy::ProtobufMessage::getStrictValidationVisitor(), api_)});
Envoy::ProtobufMessage::getStrictValidationVisitor(), *api_)});
ssl_context_manager_ =
std::make_unique<Extensions::TransportSockets::Tls::ContextManagerImpl>(time_system_);
cluster_manager_factory_ = std::make_unique<ClusterManagerFactory>(
admin_, Envoy::Runtime::LoaderSingleton::get(), store_root_, tls_, generator_,
dispatcher_->createDnsResolver({}), *ssl_context_manager_, *dispatcher_, *local_info_,
secret_manager_, validation_context_, api_, http_context_, access_log_manager_,
secret_manager_, validation_context_, *api_, http_context_, access_log_manager_,
*singleton_manager_);
cluster_manager_ =
cluster_manager_factory_->clusterManagerFromProto(createBootstrapConfiguration(uri));
Expand Down
12 changes: 5 additions & 7 deletions source/client/process_impl.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include "envoy/api/api.h"
#include "envoy/network/address.h"
#include "envoy/stats/store.h"

Expand All @@ -12,7 +13,6 @@
#include "nighthawk/common/uri.h"

#include "external/envoy/source/common/access_log/access_log_manager_impl.h"
#include "external/envoy/source/common/api/api_impl.h"
#include "external/envoy/source/common/common/logger.h"
#include "external/envoy/source/common/event/real_time_system.h"
#include "external/envoy/source/common/http/context_impl.h"
Expand All @@ -22,12 +22,11 @@
#include "external/envoy/source/common/stats/thread_local_store.h"
#include "external/envoy/source/common/thread_local/thread_local_impl.h"
#include "external/envoy/source/common/upstream/cluster_manager_impl.h"
#include "external/envoy/source/exe/platform_impl.h"
#include "external/envoy/source/exe/process_wide.h"
#include "external/envoy/source/extensions/transport_sockets/tls/context_manager_impl.h"
#include "external/envoy/source/server/config_validation/admin.h"

#include "common/common/thread_impl.h" //XXX(oschaaf):
#include "common/filesystem/filesystem_impl.h"
#include "common/uri_impl.h"

#include "client/benchmark_client_impl.h"
Expand Down Expand Up @@ -65,14 +64,13 @@ class ProcessImpl : public Process, public Envoy::Logger::Loggable<Envoy::Logger
mergeWorkerCounters(const std::vector<ClientWorkerPtr>& workers) const;

Envoy::ProcessWide process_wide_;
Envoy::Thread::ThreadFactoryImplPosix thread_factory_;
Envoy::Filesystem::InstanceImplPosix file_system_;
Envoy::PlatformImpl platform_impl_;
Envoy::Event::TimeSystem& time_system_;
StoreFactoryImpl store_factory_;
Envoy::Stats::SymbolTableImpl symbol_table_;
Envoy::Stats::AllocatorImpl stats_allocator_;
Envoy::Stats::ThreadLocalStoreImpl store_root_;
Envoy::Api::Impl api_;
Envoy::Api::ApiPtr api_;
Envoy::ThreadLocal::InstanceImpl tls_;
Envoy::Event::DispatcherPtr dispatcher_;
std::vector<ClientWorkerPtr> workers_;
Expand All @@ -87,7 +85,7 @@ class ProcessImpl : public Process, public Envoy::Logger::Loggable<Envoy::Logger
Envoy::Server::ConfigTrackerImpl config_tracker_;
Envoy::Secret::SecretManagerImpl secret_manager_;
Envoy::Http::ContextImpl http_context_;
Envoy::Thread::MutexBasicLockable fakelock_;
Envoy::Thread::MutexBasicLockable access_log_lock_;
Envoy::Singleton::ManagerPtr singleton_manager_;
Envoy::AccessLog::AccessLogManagerImpl access_log_manager_;

Expand Down
1 change: 1 addition & 0 deletions source/client/service_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include "external/envoy/source/common/common/logger.h"
#include "external/envoy/source/common/common/thread.h"
#include "external/envoy/source/common/event/real_time_system.h"

#include "nighthawk/client/process.h"

Expand Down
1 change: 0 additions & 1 deletion source/common/sequencer_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "envoy/common/pure.h"
#include "envoy/common/time.h"
#include "envoy/event/dispatcher.h"
#include "envoy/thread/thread.h"

#include "nighthawk/common/platform_util.h"
#include "nighthawk/common/rate_limiter.h"
Expand Down
4 changes: 1 addition & 3 deletions source/common/worker_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
#include "envoy/runtime/runtime.h"
#include "envoy/thread_local/thread_local.h"

using namespace std::chrono_literals;

namespace Nighthawk {

WorkerImpl::WorkerImpl(Envoy::Api::Api& api, Envoy::ThreadLocal::Instance& tls,
Envoy::Stats::Store& store)
: thread_factory_(api.threadFactory()), dispatcher_(api.allocateDispatcher()), tls_(tls),
store_(store), time_source_(api.timeSource()), file_system_(api.fileSystem()) {
store_(store), time_source_(api.timeSource()) {
tls.registerThread(*dispatcher_, false);
}

Expand Down
3 changes: 0 additions & 3 deletions source/common/worker_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

#include "envoy/api/api.h"
#include "envoy/common/time.h"
#include "envoy/filesystem/filesystem.h"
#include "envoy/stats/store.h"
#include "envoy/thread/thread.h"

#include "nighthawk/common/worker.h"

Expand All @@ -31,7 +29,6 @@ class WorkerImpl : virtual public Worker {
Envoy::ThreadLocal::Instance& tls_;
Envoy::Stats::Store& store_;
Envoy::TimeSource& time_source_;
Envoy::Filesystem::Instance& file_system_;

private:
Envoy::Thread::ThreadPtr thread_;
Expand Down
2 changes: 0 additions & 2 deletions source/exe/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ envoy_cc_library(
visibility = ["//visibility:public"],
deps = [
"//source/client:nighthawk_client_lib",
"@envoy//source/common/common:thread_lib",
],
)

Expand All @@ -32,6 +31,5 @@ envoy_cc_library(
visibility = ["//visibility:public"],
deps = [
"//source/client:nighthawk_service_lib",
"@envoy//source/common/common:thread_lib",
],
)
2 changes: 0 additions & 2 deletions test/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ envoy_cc_test(
"//source/client:nighthawk_client_lib",
"//test:nighthawk_mocks",
"@envoy//source/common/api:api_lib",
"@envoy//source/common/filesystem:filesystem_lib",
"@envoy//source/common/stats:isolated_store_lib_with_external_headers",
"@envoy//test/mocks/init:init_mocks",
"@envoy//test/mocks/local_info:local_info_mocks",
Expand Down Expand Up @@ -188,7 +187,6 @@ envoy_cc_test(
deps = [
"//source/common:nighthawk_common_lib",
"//test/test_common:environment_lib",
"@envoy//source/common/filesystem:filesystem_lib",
"@envoy//source/common/protobuf:utility_lib_with_external_headers",
"@envoy//source/common/stats:isolated_store_lib_with_external_headers",
],
Expand Down
13 changes: 4 additions & 9 deletions test/client_worker_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@

#include "envoy/upstream/cluster_manager.h"

#include "external/envoy/source/common/api/api_impl.h"
#include "external/envoy/source/common/runtime/runtime_impl.h"
#include "external/envoy/source/common/stats/isolated_store_impl.h"
#include "external/envoy/test/mocks/init/mocks.h"
#include "external/envoy/test/mocks/local_info/mocks.h"
#include "external/envoy/test/mocks/protobuf/mocks.h"
#include "external/envoy/test/mocks/thread_local/mocks.h"
#include "external/envoy/test/test_common/thread_factory_for_test.h"

#include "common/filesystem/filesystem_impl.h" // XXX(oschaaf):
#include "common/statistic_impl.h"
#include "common/uri_impl.h"

Expand All @@ -30,11 +27,10 @@ namespace Client {
class ClientWorkerTest : public Test {
public:
ClientWorkerTest()
: api_(Envoy::Thread::threadFactoryForTest(), store_, time_system_, file_system_),
thread_id_(std::this_thread::get_id()) {
: api_(Envoy::Api::createApiForTest()), thread_id_(std::this_thread::get_id()) {
loader_ = std::make_unique<Envoy::Runtime::ScopedLoaderSingleton>(Envoy::Runtime::LoaderPtr{
new Envoy::Runtime::LoaderImpl(dispatcher_, tls_, {}, local_info_, init_manager_, store_,
rand_, validation_visitor_, api_)});
rand_, validation_visitor_, *api_)});
benchmark_client_ = new MockBenchmarkClient();
sequencer_ = new MockSequencer();

Expand All @@ -60,7 +56,7 @@ class ClientWorkerTest : public Test {
}

StreamingStatistic statistic_;
Envoy::Api::Impl api_;
Envoy::Api::ApiPtr api_;
std::thread::id thread_id_;
MockOptions options_;
MockBenchmarkClientFactory benchmark_client_factory_;
Expand All @@ -72,7 +68,6 @@ class ClientWorkerTest : public Test {
MockSequencer* sequencer_;
Envoy::Runtime::RandomGeneratorImpl rand_;
NiceMock<Envoy::Event::MockDispatcher> dispatcher_;
Envoy::Filesystem::InstanceImplPosix file_system_;
std::unique_ptr<Envoy::Runtime::ScopedLoaderSingleton> loader_;
NiceMock<Envoy::LocalInfo::MockLocalInfo> local_info_;
Envoy::Init::MockManager init_manager_;
Expand Down Expand Up @@ -106,7 +101,7 @@ TEST_F(ClientWorkerTest, BasicTest) {

int worker_number = 12345;
auto worker = std::make_unique<ClientWorkerImpl>(
api_, tls_, cluster_manager_ptr_, benchmark_client_factory_, sequencer_factory_,
*api_, tls_, cluster_manager_ptr_, benchmark_client_factory_, sequencer_factory_,
std::make_unique<Nighthawk::UriImpl>("http://foo"), store_, worker_number,
time_system_.monotonicTime(), true);

Expand Down
1 change: 0 additions & 1 deletion test/factories_test.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include <chrono>

#include "external/envoy/source/common/api/api_impl.h"
#include "external/envoy/test/mocks/event/mocks.h"
#include "external/envoy/test/mocks/stats/mocks.h"
#include "external/envoy/test/test_common/simulated_time_system.h"
Expand Down
6 changes: 3 additions & 3 deletions test/output_collector_test.cc
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include <chrono>

#include "external/envoy/test/test_common/file_system_for_test.h"
#include "external/envoy/test/test_common/simulated_time_system.h"

#include "api/client/options.pb.h"

#include "common/filesystem/filesystem_impl.h" //XXX(oschaaf)
#include "common/statistic_impl.h"

#include "client/output_collector_impl.h"
Expand Down Expand Up @@ -46,13 +46,13 @@ class OutputCollectorTest : public Test {
collector.addResult("worker_0", statistics_, counters_);
collector.addResult("worker_1", statistics_, counters_);
collector.addResult("global", statistics_, counters_);
EXPECT_EQ(filesystem_.fileReadToEnd(TestEnvironment::runfilesPath(std::string(path))),
EXPECT_EQ(Envoy::Filesystem::fileSystemForTest().fileReadToEnd(
TestEnvironment::runfilesPath(std::string(path))),
collector.toString());
}

nighthawk::client::CommandLineOptions command_line_options_;
Envoy::Event::SimulatedTimeSystem time_system_;
Envoy::Filesystem::InstanceImplPosix filesystem_;
MockOptions options_;
std::vector<StatisticPtr> statistics_;
std::map<std::string, uint64_t> counters_;
Expand Down
9 changes: 1 addition & 8 deletions test/sequencer_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,11 @@
#include "nighthawk/common/exception.h"
#include "nighthawk/common/platform_util.h"

#include "external/envoy/source/common/api/api_impl.h"
#include "external/envoy/source/common/event/dispatcher_impl.h"
#include "external/envoy/source/common/stats/isolated_store_impl.h"
#include "external/envoy/test/mocks/event/mocks.h"
#include "external/envoy/test/test_common/simulated_time_system.h"
#include "external/envoy/test/test_common/thread_factory_for_test.h"

#include "common/common/thread_impl.h"
#include "common/filesystem/filesystem_impl.h"
#include "common/rate_limiter_impl.h"
#include "common/sequencer_impl.h"
#include "common/statistic_impl.h"
Expand All @@ -31,8 +27,7 @@ namespace Nighthawk {
class SequencerTestBase : public Test {
public:
SequencerTestBase()
: api_(Envoy::Thread::threadFactoryForTest(), store_, time_system_, file_system_),
dispatcher_(std::make_unique<Envoy::Event::MockDispatcher>()), frequency_(10_Hz),
: dispatcher_(std::make_unique<Envoy::Event::MockDispatcher>()), frequency_(10_Hz),
interval_(std::chrono::duration_cast<std::chrono::milliseconds>(frequency_.interval())),
sequencer_target_(
std::bind(&SequencerTestBase::callback_test, this, std::placeholders::_1)) {}
Expand All @@ -43,11 +38,9 @@ class SequencerTestBase : public Test {
return true;
}

Envoy::Filesystem::InstanceImplPosix file_system_;
MockPlatformUtil platform_util_;
Envoy::Stats::IsolatedStoreImpl store_;
Envoy::Event::SimulatedTimeSystem time_system_;
Envoy::Api::Impl api_;
std::unique_ptr<Envoy::Event::MockDispatcher> dispatcher_;
int callback_test_count_{0};
const Frequency frequency_;
Expand Down
Loading

0 comments on commit 1e0a059

Please sign in to comment.