Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions include/nighthawk/sink/sink.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ class Sink {
* @return absl::Status Indicates if the operation succeeded or not.
*/
virtual absl::Status
StoreExecutionResultPiece(const ::nighthawk::client::ExecutionResponse& response) const PURE;
StoreExecutionResultPiece(const nighthawk::client::ExecutionResponse& response) const PURE;

/**
* Attempt to load a vector of ExecutionResponse instances associated to an execution id.
*
* @param execution_id Specify an execution_id that the desired set of ExecutionResponse
* instances are tagged with.
* @return absl::StatusOr<std::vector<::nighthawk::client::ExecutionResponse>>.
* @return absl::StatusOr<std::vector<nighthawk::client::ExecutionResponse>>.
* When no fragments are found for the provided execution id, status kNotFound is returned.
*/
virtual absl::StatusOr<std::vector<::nighthawk::client::ExecutionResponse>>
virtual absl::StatusOr<std::vector<nighthawk::client::ExecutionResponse>>
LoadExecutionResult(absl::string_view execution_id) const PURE;
};

Expand Down
2 changes: 1 addition & 1 deletion source/adaptive_load/adaptive_load_client_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ uint32_t AdaptiveLoadClientMain::Run() {
throw Nighthawk::NighthawkException("Unable to parse file \"" + spec_filename_ +
"\" as a text protobuf (type " + spec.GetTypeName() + ")");
}
std::shared_ptr<::grpc::Channel> channel = grpc::CreateChannel(
std::shared_ptr<grpc::Channel> channel = grpc::CreateChannel(
nighthawk_service_address_, use_tls_ ? grpc::SslCredentials(grpc::SslCredentialsOptions())
: grpc::InsecureChannelCredentials());
std::unique_ptr<nighthawk::client::NighthawkService::StubInterface> stub(
Expand Down
2 changes: 1 addition & 1 deletion source/client/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ bool Main::run() {
Envoy::Event::RealTimeSystem time_system; // NO_CHECK_FORMAT(real_time)
ProcessPtr process;
std::unique_ptr<nighthawk::client::NighthawkService::Stub> stub;
std::shared_ptr<::grpc::Channel> channel;
std::shared_ptr<grpc::Channel> channel;

if (options_->nighthawkService() != "") {
UriPtr uri;
Expand Down
2 changes: 1 addition & 1 deletion source/client/options_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ OptionsImpl::OptionsImpl(const nighthawk::client::CommandLineOptions& options) {
request_headers_.push_back(header_string);
}
if (request_options.request_method() !=
::envoy::config::core::v3::RequestMethod::METHOD_UNSPECIFIED) {
envoy::config::core::v3::RequestMethod::METHOD_UNSPECIFIED) {
request_method_ = request_options.request_method();
}
request_body_size_ =
Expand Down
18 changes: 9 additions & 9 deletions source/client/service_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void ServiceImpl::writeResponse(const nighthawk::client::ExecutionResponse& resp
}
}

::grpc::Status ServiceImpl::finishGrpcStream(const bool success, absl::string_view description) {
grpc::Status ServiceImpl::finishGrpcStream(const bool success, absl::string_view description) {
// We may get here while there's still an active future in-flight in the error-paths.
// Allow it to wrap up and put it's response on the stream before finishing the stream.
if (future_.valid()) {
Expand All @@ -75,10 +75,10 @@ ::grpc::Status ServiceImpl::finishGrpcStream(const bool success, absl::string_vi
// TODO(oschaaf): unit-test Process, create MockProcess & use in service_test.cc / client_test.cc
// TODO(oschaaf): should we merge incoming request options with defaults?
// TODO(oschaaf): aggregate the client's logs and forward them in the grpc response.
::grpc::Status ServiceImpl::ExecutionStream(
::grpc::ServerContext* /*context*/,
::grpc::ServerReaderWriter<::nighthawk::client::ExecutionResponse,
::nighthawk::client::ExecutionRequest>* stream) {
grpc::Status ServiceImpl::ExecutionStream(
grpc::ServerContext* /*context*/,
grpc::ServerReaderWriter<nighthawk::client::ExecutionResponse,
nighthawk::client::ExecutionRequest>* stream) {
nighthawk::client::ExecutionRequest request;
stream_ = stream;

Expand Down Expand Up @@ -122,10 +122,10 @@ RequestSourcePtr RequestSourceServiceImpl::createStaticEmptyRequestSource(const
return std::make_unique<StaticRequestSourceImpl>(std::move(header), amount);
}

::grpc::Status RequestSourceServiceImpl::RequestStream(
::grpc::ServerContext* /*context*/,
::grpc::ServerReaderWriter<::nighthawk::request_source::RequestStreamResponse,
::nighthawk::request_source::RequestStreamRequest>* stream) {
grpc::Status RequestSourceServiceImpl::RequestStream(
grpc::ServerContext* /*context*/,
grpc::ServerReaderWriter<nighthawk::request_source::RequestStreamResponse,
nighthawk::request_source::RequestStreamRequest>* stream) {
nighthawk::request_source::RequestStreamRequest request;
bool ok = true;
while (stream->Read(&request)) {
Expand Down
23 changes: 11 additions & 12 deletions source/client/service_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,22 @@ class ServiceImpl final : public nighthawk::client::NighthawkService::Service,
logging_context_ = std::move(logging_context);
}

::grpc::Status ExecutionStream(
::grpc::ServerContext* context,
::grpc::ServerReaderWriter<::nighthawk::client::ExecutionResponse,
::nighthawk::client::ExecutionRequest>* stream) override;
grpc::Status
ExecutionStream(grpc::ServerContext* context,
grpc::ServerReaderWriter<nighthawk::client::ExecutionResponse,
nighthawk::client::ExecutionRequest>* stream) override;

private:
void handleExecutionRequest(const nighthawk::client::ExecutionRequest& request);
void writeResponse(const nighthawk::client::ExecutionResponse& response);
::grpc::Status finishGrpcStream(const bool success, absl::string_view description = "");
grpc::Status finishGrpcStream(const bool success, absl::string_view description = "");

std::unique_ptr<Envoy::Logger::Context> logging_context_;
std::shared_ptr<Envoy::ProcessWide> process_wide_;
Envoy::Event::RealTimeSystem time_system_; // NO_CHECK_FORMAT(real_time)
Envoy::Thread::MutexBasicLockable log_lock_;
::grpc::ServerReaderWriter<::nighthawk::client::ExecutionResponse,
::nighthawk::client::ExecutionRequest>* stream_;
grpc::ServerReaderWriter<nighthawk::client::ExecutionResponse,
nighthawk::client::ExecutionRequest>* stream_;
std::future<void> future_;
// accepted_lock_ and accepted_event_ are used to synchronize the threads
// when starting up a future to service a test, and ensure the code servicing it
Expand All @@ -81,11 +81,10 @@ class RequestSourceServiceImpl final
public Envoy::Logger::Loggable<Envoy::Logger::Id::main> {

public:
::grpc::Status
RequestStream(::grpc::ServerContext* context,
::grpc::ServerReaderWriter<::nighthawk::request_source::RequestStreamResponse,
::nighthawk::request_source::RequestStreamRequest>*
stream) override;
grpc::Status RequestStream(
grpc::ServerContext* context,
grpc::ServerReaderWriter<nighthawk::request_source::RequestStreamResponse,
nighthawk::request_source::RequestStreamRequest>* stream) override;

private:
RequestSourcePtr createStaticEmptyRequestSource(const uint32_t amount);
Expand Down
8 changes: 4 additions & 4 deletions source/common/nighthawk_service_client_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ NighthawkServiceClientImpl::PerformNighthawkBenchmark(
nighthawk::client::ExecutionResponse response;
*request.mutable_start_request()->mutable_options() = command_line_options;

::grpc::ClientContext context;
std::shared_ptr<::grpc::ClientReaderWriterInterface<nighthawk::client::ExecutionRequest,
nighthawk::client::ExecutionResponse>>
grpc::ClientContext context;
std::shared_ptr<grpc::ClientReaderWriterInterface<nighthawk::client::ExecutionRequest,
nighthawk::client::ExecutionResponse>>
stream(nighthawk_service_stub->ExecutionStream(&context));

if (!stream->Write(request)) {
Expand All @@ -32,7 +32,7 @@ NighthawkServiceClientImpl::PerformNighthawkBenchmark(
if (!got_response) {
return absl::InternalError("Nighthawk Service did not send a gRPC response.");
}
::grpc::Status status = stream->Finish();
grpc::Status status = stream->Finish();
if (!status.ok()) {
return absl::Status(static_cast<absl::StatusCode>(status.error_code()), status.error_message());
}
Expand Down
14 changes: 7 additions & 7 deletions source/sink/nighthawk_sink_client_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ absl::StatusOr<nighthawk::StoreExecutionResponse>
NighthawkSinkClientImpl::StoreExecutionResponseStream(
nighthawk::NighthawkSink::StubInterface& nighthawk_sink_stub,
const nighthawk::StoreExecutionRequest& store_execution_request) const {
::grpc::ClientContext context;
::nighthawk::StoreExecutionResponse store_execution_response;
std::shared_ptr<::grpc::ClientWriterInterface<::nighthawk::StoreExecutionRequest>> stream(
grpc::ClientContext context;
nighthawk::StoreExecutionResponse store_execution_response;
std::shared_ptr<grpc::ClientWriterInterface<nighthawk::StoreExecutionRequest>> stream(
nighthawk_sink_stub.StoreExecutionResponseStream(&context, &store_execution_response));
if (!stream->Write(store_execution_request)) {
return absl::UnavailableError("Failed to write request to the Nighthawk Sink gRPC channel.");
} else if (!stream->WritesDone()) {
return absl::InternalError("WritesDone() failed on the Nighthawk Sink gRPC channel.");
}
::grpc::Status status = stream->Finish();
grpc::Status status = stream->Finish();
if (!status.ok()) {
return absl::Status(static_cast<absl::StatusCode>(status.error_code()), status.error_message());
}
Expand All @@ -29,9 +29,9 @@ absl::StatusOr<nighthawk::SinkResponse> NighthawkSinkClientImpl::SinkRequestStre
const nighthawk::SinkRequest& sink_request) const {
nighthawk::SinkResponse response;

::grpc::ClientContext context;
grpc::ClientContext context;
std::shared_ptr<
::grpc::ClientReaderWriterInterface<nighthawk::SinkRequest, nighthawk::SinkResponse>>
grpc::ClientReaderWriterInterface<nighthawk::SinkRequest, nighthawk::SinkResponse>>
stream(nighthawk_sink_stub.SinkRequestStream(&context));

if (!stream->Write(sink_request)) {
Expand Down Expand Up @@ -60,7 +60,7 @@ absl::StatusOr<nighthawk::SinkResponse> NighthawkSinkClientImpl::SinkRequestStre
"Sink Service has started responding with more than one message.");
got_response = true;
}
::grpc::Status status = stream->Finish();
grpc::Status status = stream->Finish();
if (!status.ok()) {
return absl::Status(static_cast<absl::StatusCode>(status.error_code()), status.error_message());
}
Expand Down
8 changes: 4 additions & 4 deletions source/sink/sink_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ absl::Status verifyCanBeUsedAsDirectoryName(absl::string_view s) {
} // namespace

absl::Status FileSinkImpl::StoreExecutionResultPiece(
const ::nighthawk::client::ExecutionResponse& response) const {
const nighthawk::client::ExecutionResponse& response) const {
const std::string& execution_id = response.execution_id();
absl::Status status = verifyCanBeUsedAsDirectoryName(execution_id);
if (!status.ok()) {
Expand Down Expand Up @@ -72,23 +72,23 @@ absl::Status FileSinkImpl::StoreExecutionResultPiece(
return absl::Status();
}

absl::StatusOr<std::vector<::nighthawk::client::ExecutionResponse>>
absl::StatusOr<std::vector<nighthawk::client::ExecutionResponse>>
FileSinkImpl::LoadExecutionResult(absl::string_view execution_id) const {
absl::Status status = verifyCanBeUsedAsDirectoryName(execution_id);
if (!status.ok()) {
return status;
}

std::filesystem::path filesystem_directory_path("/tmp/nh/" + std::string(execution_id) + "/");
std::vector<::nighthawk::client::ExecutionResponse> responses;
std::vector<nighthawk::client::ExecutionResponse> responses;
std::error_code error_code;

for (const auto& it :
std::filesystem::directory_iterator(filesystem_directory_path, error_code)) {
if (error_code.value()) {
break;
}
::nighthawk::client::ExecutionResponse response;
nighthawk::client::ExecutionResponse response;
std::ifstream ifs(it.path(), std::ios_base::binary);
if (!response.ParseFromIstream(&ifs)) {
return absl::Status(absl::StatusCode::kInternal,
Expand Down
4 changes: 2 additions & 2 deletions source/sink/sink_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ namespace Nighthawk {
class FileSinkImpl : public Sink {
public:
absl::Status
StoreExecutionResultPiece(const ::nighthawk::client::ExecutionResponse& response) const override;
absl::StatusOr<std::vector<::nighthawk::client::ExecutionResponse>>
StoreExecutionResultPiece(const nighthawk::client::ExecutionResponse& response) const override;
absl::StatusOr<std::vector<nighthawk::client::ExecutionResponse>>
LoadExecutionResult(absl::string_view id) const override;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ TEST(FakeMetricsPlugin, GetAllSupportedMetricNamesReturnsCorrectValues) {

FakeMetricsPlugin metrics_plugin(config);
EXPECT_THAT(metrics_plugin.GetAllSupportedMetricNames(),
::testing::UnorderedElementsAre("metric1", "metric2"));
testing::UnorderedElementsAre("metric1", "metric2"));
}

TEST(MakeFakeMetricsPluginTypedExtensionConfig, SetsCorrectPluginName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ TEST(FakeStepControllerConfigFactory, ValidateConfigWithBadConfigProtoReturnsErr
}

TEST(FakeStepControllerConfigFactory, ValidateConfigWithAritificialValidationErrorReturnsError) {
const int kExpectedStatusCode = ::grpc::DATA_LOSS;
const int kExpectedStatusCode = grpc::DATA_LOSS;
const std::string kExpectedStatusMessage = "artificial validation error";
FakeStepControllerConfig config;
config.mutable_artificial_validation_failure()->set_code(kExpectedStatusCode);
Expand Down Expand Up @@ -113,7 +113,7 @@ TEST(FakeStepController, GetCurrentCommandLineOptionsReturnsRpsFromConfig) {

TEST(FakeStepController, GetCurrentCommandLineOptionsReturnsArtificialErrorImmediately) {
FakeStepControllerConfig config;
const int kExpectedCode = ::grpc::DEADLINE_EXCEEDED;
const int kExpectedCode = grpc::DEADLINE_EXCEEDED;
const std::string kExpectedMessage = "artificial input setting error";
config.mutable_artificial_input_setting_failure()->set_code(kExpectedCode);
config.mutable_artificial_input_setting_failure()->set_message(kExpectedMessage);
Expand All @@ -129,7 +129,7 @@ TEST(FakeStepController, GetCurrentCommandLineOptionsReturnsArtificialErrorImmed

TEST(FakeStepController, GetCurrentCommandLineOptionsReturnsArtificialErrorAfterCountdown) {
FakeStepControllerConfig config;
const int kExpectedCode = ::grpc::DEADLINE_EXCEEDED;
const int kExpectedCode = grpc::DEADLINE_EXCEEDED;
const std::string kExpectedMessage = "artificial input setting error";
config.mutable_artificial_input_setting_failure()->set_code(kExpectedCode);
config.mutable_artificial_input_setting_failure()->set_message(kExpectedMessage);
Expand Down
34 changes: 17 additions & 17 deletions test/adaptive_load/metrics_plugin_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Nighthawk {
namespace {

class NighthawkStatsEmulatedMetricsPluginFixture
: public ::testing::TestWithParam<std::tuple<std::string, double>> {};
: public testing::TestWithParam<std::tuple<std::string, double>> {};

TEST_P(NighthawkStatsEmulatedMetricsPluginFixture, ComputesCorrectMetric) {
NighthawkStatsEmulatedMetricsPlugin plugin =
Expand All @@ -35,17 +35,17 @@ TEST_P(NighthawkStatsEmulatedMetricsPluginFixture, ComputesCorrectMetric) {

INSTANTIATE_TEST_SUITE_P(
NighthawkStatsEmulatedMetricsPluginValuesTests, NighthawkStatsEmulatedMetricsPluginFixture,
::testing::Values(std::make_tuple<std::string, double>("achieved-rps", 256),
std::make_tuple<std::string, double>("attempted-rps", 1024),
std::make_tuple<std::string, double>("latency-ns-max", 600.0),
std::make_tuple<std::string, double>("latency-ns-mean", 500.0),
std::make_tuple<std::string, double>("latency-ns-mean-plus-1stdev", 511.0),
std::make_tuple<std::string, double>("latency-ns-mean-plus-2stdev", 522.0),
std::make_tuple<std::string, double>("latency-ns-mean-plus-3stdev", 533.0),
std::make_tuple<std::string, double>("latency-ns-min", 400.0),
std::make_tuple<std::string, double>("latency-ns-pstdev", 11.0),
std::make_tuple<std::string, double>("send-rate", 0.25),
std::make_tuple<std::string, double>("success-rate", 0.125)));
testing::Values(std::make_tuple<std::string, double>("achieved-rps", 256),
std::make_tuple<std::string, double>("attempted-rps", 1024),
std::make_tuple<std::string, double>("latency-ns-max", 600.0),
std::make_tuple<std::string, double>("latency-ns-mean", 500.0),
std::make_tuple<std::string, double>("latency-ns-mean-plus-1stdev", 511.0),
std::make_tuple<std::string, double>("latency-ns-mean-plus-2stdev", 522.0),
std::make_tuple<std::string, double>("latency-ns-mean-plus-3stdev", 533.0),
std::make_tuple<std::string, double>("latency-ns-min", 400.0),
std::make_tuple<std::string, double>("latency-ns-pstdev", 11.0),
std::make_tuple<std::string, double>("send-rate", 0.25),
std::make_tuple<std::string, double>("success-rate", 0.125)));

TEST(NighthawkStatsEmulatedMetricsPlugin, ReturnsErrorIfGlobalResultMissing) {
nighthawk::client::Output empty_output;
Expand Down Expand Up @@ -221,11 +221,11 @@ TEST(NighthawkStatsEmulatedMetricsPlugin, ReturnsCorrectSupportedMetricNames) {
NighthawkStatsEmulatedMetricsPlugin plugin = NighthawkStatsEmulatedMetricsPlugin({});
std::vector<std::string> supported_metrics = plugin.GetAllSupportedMetricNames();
EXPECT_THAT(supported_metrics,
::testing::ElementsAre("achieved-rps", "attempted-rps", "latency-ns-max",
"latency-ns-mean", "latency-ns-mean-plus-1stdev",
"latency-ns-mean-plus-2stdev", "latency-ns-mean-plus-3stdev",
"latency-ns-min", "latency-ns-pstdev", "send-rate",
"success-rate"));
testing::ElementsAre("achieved-rps", "attempted-rps", "latency-ns-max",
"latency-ns-mean", "latency-ns-mean-plus-1stdev",
"latency-ns-mean-plus-2stdev", "latency-ns-mean-plus-3stdev",
"latency-ns-min", "latency-ns-pstdev", "send-rate",
"success-rate"));
}

} // namespace
Expand Down
Loading