Files
grpc/test/cpp/qps/driver.h
Craig Tiller ccb51eaa23 [latent_see] Add always on latent-see, and a service to drive it (#39781)
Change up latent-see so that it's an always-on thing.

Most of the testing code we've got so far should be updated to use `grpc_core::latent_see::Collect()` - there's a JSON exporter there, and I plan to implement a Fuchsia Trace Format one eventually too (much more compact trace representaton!).

Also added is a service (visibility protected!) that we'll be able to share with partners to allow collecting this data from real systems. That part is strictly opt-in for the moment.

Closes #39781

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/39781 from ctiller:nicety b2e855d9279ee4724961f479ba5c714c823e48a2
PiperOrigin-RevId: 786425381
2025-07-23 14:33:32 -07:00

115 lines
3.4 KiB
C++

//
//
// Copyright 2015 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//
#ifndef GRPC_TEST_CPP_QPS_DRIVER_H
#define GRPC_TEST_CPP_QPS_DRIVER_H
#include <map>
#include <memory>
#include <optional>
#include <string>
#include "src/proto/grpc/testing/control.pb.h"
#include "test/cpp/qps/histogram.h"
#include "test/cpp/util/test_credentials_provider.h" // For kInsecureCredentialsType
namespace grpc {
namespace testing {
class RunScenarioOptions {
public:
// Required parameters, passed to constructor
const grpc::testing::ClientConfig& client_config;
const grpc::testing::ServerConfig& server_config;
// Optional parameters with defaults
size_t num_clients = 1;
size_t num_servers = 1;
int warmup_seconds = 1;
int benchmark_seconds = 3;
int spawn_local_worker_count = -2;
std::string qps_server_target_override;
std::string credential_type = grpc::testing::kInsecureCredentialsType;
std::map<std::string, std::string> per_worker_credential_types = {};
bool run_inproc = false;
int32_t median_latency_collection_interval_millis = 0;
std::optional<std::string> latent_see_directory = std::nullopt;
RunScenarioOptions(const grpc::testing::ClientConfig& client_cfg,
const grpc::testing::ServerConfig& server_cfg)
: client_config(client_cfg), server_config(server_cfg) {}
RunScenarioOptions& set_num_clients(size_t val) {
num_clients = val;
return *this;
}
RunScenarioOptions& set_num_servers(size_t val) {
num_servers = val;
return *this;
}
RunScenarioOptions& set_warmup_seconds(int val) {
warmup_seconds = val;
return *this;
}
RunScenarioOptions& set_benchmark_seconds(int val) {
benchmark_seconds = val;
return *this;
}
RunScenarioOptions& set_spawn_local_worker_count(int val) {
spawn_local_worker_count = val;
return *this;
}
RunScenarioOptions& set_qps_server_target_override(const std::string& val) {
qps_server_target_override = val;
return *this;
}
RunScenarioOptions& set_credential_type(const std::string& val) {
credential_type = val;
return *this;
}
RunScenarioOptions& set_per_worker_credential_types(
const std::map<std::string, std::string>& val) {
per_worker_credential_types = val;
return *this;
}
RunScenarioOptions& set_run_inproc(bool val) {
run_inproc = val;
return *this;
}
RunScenarioOptions& set_median_latency_collection_interval_millis(
int32_t val) {
median_latency_collection_interval_millis = val;
return *this;
}
RunScenarioOptions& set_latent_see_directory(
const std::optional<std::string>& val) {
latent_see_directory = val;
return *this;
}
};
std::unique_ptr<ScenarioResult> RunScenario(const RunScenarioOptions& options);
bool RunQuit(
const std::string& credential_type,
const std::map<std::string, std::string>& per_worker_credential_types);
} // namespace testing
} // namespace grpc
#endif // GRPC_TEST_CPP_QPS_DRIVER_H