Skip to content

Commit 73a7bf6

Browse files
author
dubious90
authored
Make the fix_format and check_format scripts work on Nighthawk code (#916)
Fixes #913 Direct changes: - Modified config.yaml to not exclude the current directory, which was excluding all of NH - Overrode some settings in config.yaml to move past some code changes - Filed #914 and #915 to address these overrides in the future - Moved include_dir_order from check_format.sh over to the config.yaml where it now needs to live. Also ran the format script to fix all current code formatting errors. Signed-off-by: Nathan Perry <[email protected]>
1 parent 50dba51 commit 73a7bf6

15 files changed

+183
-109
lines changed

source/adaptive_load/adaptive_load_controller_impl.cc

+4-3
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ absl::StatusOr<BenchmarkResult> AdaptiveLoadControllerImpl::PerformAndAnalyzeNig
144144
command_line_options);
145145
Envoy::SystemTime end_time = time_source_.systemTime();
146146
if (!nighthawk_response_or.ok()) {
147-
ENVOY_LOG_MISC(error, "Nighthawk Service error: {}: {}", nighthawk_response_or.status().raw_code(),
147+
ENVOY_LOG_MISC(error, "Nighthawk Service error: {}: {}",
148+
nighthawk_response_or.status().raw_code(),
148149
nighthawk_response_or.status().message());
149150
return nighthawk_response_or.status();
150151
}
@@ -155,8 +156,8 @@ absl::StatusOr<BenchmarkResult> AdaptiveLoadControllerImpl::PerformAndAnalyzeNig
155156
metrics_evaluator_.AnalyzeNighthawkBenchmark(nighthawk_response, spec,
156157
name_to_custom_plugin_map);
157158
if (!benchmark_result_or.ok()) {
158-
ENVOY_LOG_MISC(error, "Benchmark scoring error: {}: {}", benchmark_result_or.status().raw_code(),
159-
benchmark_result_or.status().message());
159+
ENVOY_LOG_MISC(error, "Benchmark scoring error: {}: {}",
160+
benchmark_result_or.status().raw_code(), benchmark_result_or.status().message());
160161
return benchmark_result_or.status();
161162
}
162163
BenchmarkResult benchmark_result = benchmark_result_or.value();

source/client/output_formatter_impl.cc

+5-4
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,8 @@ CsvOutputFormatterImpl::formatProto(const nighthawk::client::Output& output) con
200200
}
201201
std::string s_percentile = fmt::format("{:.{}g}", p, 8);
202202
ss << fmt::format("{},{},{},{}", s_percentile, percentile.count(),
203-
Envoy::Protobuf::util::TimeUtil::DurationToMicroseconds(percentile.duration()),
203+
Envoy::Protobuf::util::TimeUtil::DurationToMicroseconds(
204+
percentile.duration()),
204205
percentile.has_duration()
205206
? formatProtoDuration(percentile.duration())
206207
: fmt::format("{}", static_cast<int64_t>(percentile.raw_value())),
@@ -210,7 +211,7 @@ CsvOutputFormatterImpl::formatProto(const nighthawk::client::Output& output) con
210211
});
211212
ss << std::endl;
212213
}
213-
214+
214215
// Counters
215216
ss << fmt::format("{},{},{}", "Counter", "Value", "Per second") << std::endl;
216217
for (const nighthawk::client::Counter& counter : result.counters()) {
@@ -226,8 +227,8 @@ CsvOutputFormatterImpl::formatProto(const nighthawk::client::Output& output) con
226227
return ss.str();
227228
}
228229

229-
std::string CsvOutputFormatterImpl::formatProtoDuration(
230-
const Envoy::ProtobufWkt::Duration& duration) const {
230+
std::string
231+
CsvOutputFormatterImpl::formatProtoDuration(const Envoy::ProtobufWkt::Duration& duration) const {
231232
int64_t microseconds = Envoy::Protobuf::util::TimeUtil::DurationToMicroseconds(duration);
232233
return fmt::format("{}s {:03}ms {:03}us", (microseconds % 1'000'000'000) / 1'000'000,
233234
(microseconds % 1'000'000) / 1'000, microseconds % 1'000);

source/client/output_formatter_impl.h

+7-4
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,20 @@ class CsvOutputFormatterImpl : public OutputFormatterImpl {
6565
/**
6666
* Return name associated with the specified stat id.
6767
*
68-
* @param stat_id id that represents a specific stat. Example: "benchmark_http_client.queue_to_connect"
68+
* @param stat_id id that represents a specific stat. Example:
69+
* "benchmark_http_client.queue_to_connect"
6970
* @return name or description (as string) associated with the specified stat id
7071
*/
7172
static std::string statIdtoFriendlyStatName(absl::string_view stat_id);
7273

7374
private:
7475
/**
75-
* Transforms an Envoy::ProtobufWkt::Duration to a human-readable string in the format of "{}s {:03}ms {:03}us".
76+
* Transforms an Envoy::ProtobufWkt::Duration to a human-readable string in the format of "{}s
77+
* {:03}ms {:03}us".
7678
*
7779
* @param duration the Envoy::ProtobufWkt::Duration& to transform
78-
* @return the human-readable string representation of the specified duration. Example: "11s 033ms 190us"
80+
* @return the human-readable string representation of the specified duration. Example: "11s 033ms
81+
* 190us"
7982
*/
8083
std::string formatProtoDuration(const Envoy::ProtobufWkt::Duration& duration) const;
8184
};
@@ -167,4 +170,4 @@ class FortioPedanticOutputFormatterImpl : public FortioOutputFormatterImpl {
167170
};
168171

169172
} // namespace Client
170-
} // namespace Nighthawk
173+
} // namespace Nighthawk

source/client/process_impl.cc

+122-51
Original file line numberDiff line numberDiff line change
@@ -103,59 +103,107 @@ class BootstrapFactory : public Envoy::Logger::Loggable<Envoy::Logger::Id::main>
103103
// Implementation of Envoy::Server::Instance. Only methods used by Envoy's code
104104
// when Nighthawk is running are implemented.
105105
class NighthawkServerInstance : public Envoy::Server::Instance {
106-
public:
107-
NighthawkServerInstance(Envoy::Server::Admin& admin, Envoy::Api::Api& api, Envoy::Event::Dispatcher& dispatcher,
106+
public:
107+
NighthawkServerInstance(Envoy::Server::Admin& admin, Envoy::Api::Api& api,
108+
Envoy::Event::Dispatcher& dispatcher,
108109
Envoy::AccessLog::AccessLogManager& log_manager,
109-
Envoy::Server::Options& options,
110-
Envoy::Runtime::Loader& runtime, Envoy::Singleton::Manager& singleton_manager, Envoy::ThreadLocal::Instance& tls,
111-
Envoy::LocalInfo::LocalInfo& local_info) :
112-
admin_(admin), api_(api), dispatcher_(dispatcher), log_manager_(log_manager),
113-
options_(options),
114-
runtime_(runtime), singleton_manager_(singleton_manager), tls_(tls), local_info_(local_info) {}
110+
Envoy::Server::Options& options, Envoy::Runtime::Loader& runtime,
111+
Envoy::Singleton::Manager& singleton_manager,
112+
Envoy::ThreadLocal::Instance& tls,
113+
Envoy::LocalInfo::LocalInfo& local_info)
114+
: admin_(admin), api_(api), dispatcher_(dispatcher), log_manager_(log_manager),
115+
options_(options), runtime_(runtime), singleton_manager_(singleton_manager), tls_(tls),
116+
local_info_(local_info) {}
115117

116118
Envoy::Server::Admin& admin() override { return admin_; }
117119
Envoy::Api::Api& api() override { return api_; }
118-
Envoy::Upstream::ClusterManager& clusterManager() override { PANIC("NighthawkServerInstance::clusterManager not implemented"); }
120+
Envoy::Upstream::ClusterManager& clusterManager() override {
121+
PANIC("NighthawkServerInstance::clusterManager not implemented");
122+
}
119123
const Envoy::Upstream::ClusterManager& clusterManager() const override {
120124
PANIC("NighthawkServerInstance::clusterManager not implemented");
121125
}
122-
Envoy::Ssl::ContextManager& sslContextManager() override { PANIC("NighthawkServerInstance::sslContextManager not implemented"); }
126+
Envoy::Ssl::ContextManager& sslContextManager() override {
127+
PANIC("NighthawkServerInstance::sslContextManager not implemented");
128+
}
123129
Envoy::Event::Dispatcher& dispatcher() override { return dispatcher_; }
124-
Envoy::Network::DnsResolverSharedPtr dnsResolver() override { PANIC("NighthawkServerInstance::dnsResolver not implemented"); }
125-
void drainListeners() override { PANIC("NighthawkServerInstance::drainListeners not implemented"); }
126-
Envoy::Server::DrainManager& drainManager() override { PANIC("NighthawkServerInstance::drainManager not implemented"); }
130+
Envoy::Network::DnsResolverSharedPtr dnsResolver() override {
131+
PANIC("NighthawkServerInstance::dnsResolver not implemented");
132+
}
133+
void drainListeners() override {
134+
PANIC("NighthawkServerInstance::drainListeners not implemented");
135+
}
136+
Envoy::Server::DrainManager& drainManager() override {
137+
PANIC("NighthawkServerInstance::drainManager not implemented");
138+
}
127139
Envoy::AccessLog::AccessLogManager& accessLogManager() override { return log_manager_; }
128-
void failHealthcheck(bool) override { PANIC("NighthawkServerInstance::failHealthcheck not implemented"); }
129-
bool healthCheckFailed() override { PANIC("NighthawkServerInstance::healthCheckFailed not implemented"); }
130-
Envoy::Server::HotRestart& hotRestart() override { PANIC("NighthawkServerInstance::hotRestart not implemented"); }
131-
Envoy::Init::Manager& initManager() override { PANIC("NighthawkServerInstance::initManager not implemented"); }
132-
Envoy::Server::ListenerManager& listenerManager() override { PANIC("NighthawkServerInstance::listenerManager not implemented"); }
133-
Envoy::MutexTracer* mutexTracer() override { PANIC("NighthawkServerInstance::mutexTracer not implemented"); }
134-
Envoy::Server::OverloadManager& overloadManager() override { PANIC("NighthawkServerInstance::overloadManager not implemented"); }
135-
Envoy::Secret::SecretManager& secretManager() override { PANIC("NighthawkServerInstance::secretManager not implemented"); }
140+
void failHealthcheck(bool) override {
141+
PANIC("NighthawkServerInstance::failHealthcheck not implemented");
142+
}
143+
bool healthCheckFailed() override {
144+
PANIC("NighthawkServerInstance::healthCheckFailed not implemented");
145+
}
146+
Envoy::Server::HotRestart& hotRestart() override {
147+
PANIC("NighthawkServerInstance::hotRestart not implemented");
148+
}
149+
Envoy::Init::Manager& initManager() override {
150+
PANIC("NighthawkServerInstance::initManager not implemented");
151+
}
152+
Envoy::Server::ListenerManager& listenerManager() override {
153+
PANIC("NighthawkServerInstance::listenerManager not implemented");
154+
}
155+
Envoy::MutexTracer* mutexTracer() override {
156+
PANIC("NighthawkServerInstance::mutexTracer not implemented");
157+
}
158+
Envoy::Server::OverloadManager& overloadManager() override {
159+
PANIC("NighthawkServerInstance::overloadManager not implemented");
160+
}
161+
Envoy::Secret::SecretManager& secretManager() override {
162+
PANIC("NighthawkServerInstance::secretManager not implemented");
163+
}
136164
const Envoy::Server::Options& options() override { return options_; }
137165
Envoy::Runtime::Loader& runtime() override { return runtime_; }
138-
Envoy::Server::ServerLifecycleNotifier& lifecycleNotifier() override { PANIC("NighthawkServerInstance::lifecycleNotifier not implemented"); }
166+
Envoy::Server::ServerLifecycleNotifier& lifecycleNotifier() override {
167+
PANIC("NighthawkServerInstance::lifecycleNotifier not implemented");
168+
}
139169
void shutdown() override { PANIC("NighthawkServerInstance::shutdown not implemented"); }
140170
bool isShutdown() override { PANIC("NighthawkServerInstance::isShutdown not implemented"); }
141171
void shutdownAdmin() override { PANIC("NighthawkServerInstance::shutdownAdmin not implemented"); }
142172
Envoy::Singleton::Manager& singletonManager() override { return singleton_manager_; }
143-
time_t startTimeCurrentEpoch() override { PANIC("NighthawkServerInstance::startTimeCurrentEpoch not implemented"); }
144-
time_t startTimeFirstEpoch() override { PANIC("NighthawkServerInstance::startTimeFirstEpoch not implemented"); }
173+
time_t startTimeCurrentEpoch() override {
174+
PANIC("NighthawkServerInstance::startTimeCurrentEpoch not implemented");
175+
}
176+
time_t startTimeFirstEpoch() override {
177+
PANIC("NighthawkServerInstance::startTimeFirstEpoch not implemented");
178+
}
145179
Envoy::Stats::Store& stats() override { PANIC("NighthawkServerInstance::stats not implemented"); }
146-
Envoy::Grpc::Context& grpcContext() override { PANIC("NighthawkServerInstance::grpcContext not implemented"); }
147-
Envoy::Http::Context& httpContext() override { PANIC("NighthawkServerInstance::httpContext not implemented"); }
148-
Envoy::Router::Context& routerContext() override { PANIC("NighthawkServerInstance::routerContext not implemented"); }
149-
Envoy::ProcessContextOptRef processContext() override { PANIC("NighthawkServerInstance::processContext not implemented"); }
180+
Envoy::Grpc::Context& grpcContext() override {
181+
PANIC("NighthawkServerInstance::grpcContext not implemented");
182+
}
183+
Envoy::Http::Context& httpContext() override {
184+
PANIC("NighthawkServerInstance::httpContext not implemented");
185+
}
186+
Envoy::Router::Context& routerContext() override {
187+
PANIC("NighthawkServerInstance::routerContext not implemented");
188+
}
189+
Envoy::ProcessContextOptRef processContext() override {
190+
PANIC("NighthawkServerInstance::processContext not implemented");
191+
}
150192
Envoy::ThreadLocal::Instance& threadLocal() override { return tls_; }
151193
Envoy::LocalInfo::LocalInfo& localInfo() const override { return local_info_; }
152-
Envoy::TimeSource& timeSource() override { PANIC("NighthawkServerInstance::timeSource not implemented"); }
194+
Envoy::TimeSource& timeSource() override {
195+
PANIC("NighthawkServerInstance::timeSource not implemented");
196+
}
153197
void flushStats() override { PANIC("NighthawkServerInstance::flushStats not implemented"); }
154198
Envoy::ProtobufMessage::ValidationContext& messageValidationContext() override {
155199
PANIC("NighthawkServerInstance::messageValidationContext not implemented");
156200
}
157-
Envoy::Server::Configuration::StatsConfig& statsConfig() override { PANIC("NighthawkServerInstance::statsConfig not implemented"); }
158-
envoy::config::bootstrap::v3::Bootstrap& bootstrap() override { PANIC("NighthawkServerInstance::bootstrap not implemented"); }
201+
Envoy::Server::Configuration::StatsConfig& statsConfig() override {
202+
PANIC("NighthawkServerInstance::statsConfig not implemented");
203+
}
204+
envoy::config::bootstrap::v3::Bootstrap& bootstrap() override {
205+
PANIC("NighthawkServerInstance::bootstrap not implemented");
206+
}
159207
Envoy::Server::Configuration::ServerFactoryContext& serverFactoryContext() override {
160208
PANIC("NighthawkServerInstance::serverFactoryContext not implemented");
161209
}
@@ -166,12 +214,14 @@ class NighthawkServerInstance : public Envoy::Server::Instance {
166214
void setDefaultTracingConfig(const envoy::config::trace::v3::Tracing&) override {
167215
PANIC("NighthawkServerInstance::setDefaultTracingConfig not implemented");
168216
}
169-
bool enableReusePortDefault() override { PANIC("NighthawkServerInstance::enableReusePortDefault not implemented"); }
217+
bool enableReusePortDefault() override {
218+
PANIC("NighthawkServerInstance::enableReusePortDefault not implemented");
219+
}
170220
void setSinkPredicates(std::unique_ptr<Envoy::Stats::SinkPredicates>&&) override {
171221
PANIC("NighthawkServerInstance::setSinkPredicates not implemented");
172222
}
173223

174-
private:
224+
private:
175225
Envoy::Server::Admin& admin_;
176226
Envoy::Api::Api& api_;
177227
Envoy::Event::Dispatcher& dispatcher_;
@@ -181,12 +231,11 @@ class NighthawkServerInstance : public Envoy::Server::Instance {
181231
Envoy::Singleton::Manager& singleton_manager_;
182232
Envoy::ThreadLocal::Instance& tls_;
183233
Envoy::LocalInfo::LocalInfo& local_info_;
184-
185234
};
186235

187236
// Implementation of Envoy::Server::Configuration::ServerFactoryContext.
188237
class NighthawkServerFactoryContext : public Envoy::Server::Configuration::ServerFactoryContext {
189-
public:
238+
public:
190239
NighthawkServerFactoryContext(Envoy::Server::Instance& server) : server_(server) {}
191240

192241
const Envoy::Server::Options& options() override { return server_.options(); };
@@ -207,46 +256,66 @@ class NighthawkServerFactoryContext : public Envoy::Server::Configuration::Serve
207256
return Envoy::ProtobufMessage::getStrictValidationVisitor();
208257
};
209258

210-
Envoy::Stats::Scope& scope() override { PANIC("NighthawkServerFactoryContext::scope not implemented"); };
259+
Envoy::Stats::Scope& scope() override {
260+
PANIC("NighthawkServerFactoryContext::scope not implemented");
261+
};
211262

212-
Envoy::Stats::Scope& serverScope() override { PANIC("NighthawkServerFactoryContext::serverScope not implemented"); };
263+
Envoy::Stats::Scope& serverScope() override {
264+
PANIC("NighthawkServerFactoryContext::serverScope not implemented");
265+
};
213266

214267
Envoy::ThreadLocal::SlotAllocator& threadLocal() override { return server_.threadLocal(); }
215268

216-
Envoy::Upstream::ClusterManager& clusterManager() override { PANIC("NighthawkServerFactoryContext::clusterManager not implemented"); };
269+
Envoy::Upstream::ClusterManager& clusterManager() override {
270+
PANIC("NighthawkServerFactoryContext::clusterManager not implemented");
271+
};
217272

218273
Envoy::ProtobufMessage::ValidationContext& messageValidationContext() override {
219274
PANIC("NighthawkServerFactoryContext::messageValidationContext not implemented");
220275
};
221276

222-
Envoy::TimeSource& timeSource() override { PANIC("NighthawkServerFactoryContext::timeSource not implemented"); };
277+
Envoy::TimeSource& timeSource() override {
278+
PANIC("NighthawkServerFactoryContext::timeSource not implemented");
279+
};
223280

224-
Envoy::AccessLog::AccessLogManager& accessLogManager() override { return server_.accessLogManager(); }
281+
Envoy::AccessLog::AccessLogManager& accessLogManager() override {
282+
return server_.accessLogManager();
283+
}
225284

226285
Envoy::Server::ServerLifecycleNotifier& lifecycleNotifier() override {
227286
PANIC("NighthawkServerFactoryContext::lifecycleNotifier not implemented");
228287
};
229288

230-
Envoy::Init::Manager& initManager() override { PANIC("NighthawkServerFactoryContext::initManager not implemented"); };
289+
Envoy::Init::Manager& initManager() override {
290+
PANIC("NighthawkServerFactoryContext::initManager not implemented");
291+
};
231292

232-
Envoy::Grpc::Context& grpcContext() override { PANIC("NighthawkServerFactoryContext::grpcContext not implemented"); };
293+
Envoy::Grpc::Context& grpcContext() override {
294+
PANIC("NighthawkServerFactoryContext::grpcContext not implemented");
295+
};
233296

234-
Envoy::Router::Context& routerContext() override { PANIC("NighthawkServerFactoryContext::routerContext not implemented"); };
297+
Envoy::Router::Context& routerContext() override {
298+
PANIC("NighthawkServerFactoryContext::routerContext not implemented");
299+
};
235300

236-
Envoy::Server::DrainManager& drainManager() override { PANIC("NighthawkServerFactoryContext::drainManager not implemented"); };
301+
Envoy::Server::DrainManager& drainManager() override {
302+
PANIC("NighthawkServerFactoryContext::drainManager not implemented");
303+
};
237304

238-
Envoy::Server::Configuration::StatsConfig& statsConfig() override { PANIC("NighthawkServerFactoryContext::statsConfig not implemented"); }
305+
Envoy::Server::Configuration::StatsConfig& statsConfig() override {
306+
PANIC("NighthawkServerFactoryContext::statsConfig not implemented");
307+
}
239308

240-
envoy::config::bootstrap::v3::Bootstrap& bootstrap() override { PANIC("NighthawkServerFactoryContext::bootstrap not implemented"); }
309+
envoy::config::bootstrap::v3::Bootstrap& bootstrap() override {
310+
PANIC("NighthawkServerFactoryContext::bootstrap not implemented");
311+
}
241312

242-
private:
313+
private:
243314
Envoy::Server::Instance& server_;
244315
};
245316

246317
// Disables the hot restart Envoy functionality.
247-
std::string HotRestartDisabled(bool) {
248-
return "hot restart is disabled";
249-
}
318+
std::string HotRestartDisabled(bool) { return "hot restart is disabled"; }
250319

251320
} // namespace
252321

@@ -622,7 +691,9 @@ bool ProcessImpl::runInternal(OutputCollector& collector, const UriPtr& tracing_
622691
std::make_unique<Envoy::Extensions::TransportSockets::Tls::ContextManagerImpl>(
623692
time_system_);
624693

625-
server_ = std::make_unique<NighthawkServerInstance>(admin_, *api_, *dispatcher_, access_log_manager_, envoy_options_, runtime_singleton_->instance(), *singleton_manager_, tls_, *local_info_);
694+
server_ = std::make_unique<NighthawkServerInstance>(
695+
admin_, *api_, *dispatcher_, access_log_manager_, envoy_options_,
696+
runtime_singleton_->instance(), *singleton_manager_, tls_, *local_info_);
626697
server_factory_context_ = std::make_unique<NighthawkServerFactoryContext>(*server_);
627698
cluster_manager_factory_ = std::make_unique<ClusterManagerFactory>(
628699
*server_factory_context_, admin_, Envoy::Runtime::LoaderSingleton::get(), store_root_, tls_,

source/client/stream_decoder.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
#include <memory>
44

5-
#include "fmt/ostream.h"
6-
75
#include "external/envoy/source/common/http/http1/codec_impl.h"
86
#include "external/envoy/source/common/http/utility.h"
97
#include "external/envoy/source/common/network/address_impl.h"
108
#include "external/envoy/source/common/stream_info/stream_info_impl.h"
119
#include "external/envoy/source/extensions/request_id/uuid/config.h"
1210

11+
#include "fmt/ostream.h"
12+
1313
namespace Nighthawk {
1414
namespace Client {
1515

0 commit comments

Comments
 (0)