aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/qps
diff options
context:
space:
mode:
authorGravatar Guantao Liu <guantaol@google.com>2017-07-14 17:33:19 -0700
committerGravatar Guantao Liu <guantaol@google.com>2017-07-14 17:33:19 -0700
commitac9fdfbc40507a6c5453b171561537ee9cafe61a (patch)
treeeee5bdfcaa3dd5d193504961002f9ff038952608 /test/cpp/qps
parente72b5d6ab8a48181919181b5bdb4327ba263d07f (diff)
Removed unnecessary default values and fixed sanity.
Diffstat (limited to 'test/cpp/qps')
-rw-r--r--test/cpp/qps/BUILD3
-rw-r--r--test/cpp/qps/driver.cc34
-rw-r--r--test/cpp/qps/driver.h6
-rw-r--r--test/cpp/qps/qps_json_driver.cc8
-rw-r--r--test/cpp/qps/qps_openloop_test.cc5
-rw-r--r--test/cpp/qps/qps_worker.cc8
-rw-r--r--test/cpp/qps/qps_worker.h4
-rw-r--r--test/cpp/qps/secure_sync_unary_ping_pong_test.cc5
-rw-r--r--test/cpp/qps/worker.cc6
9 files changed, 40 insertions, 39 deletions
diff --git a/test/cpp/qps/BUILD b/test/cpp/qps/BUILD
index e24aa0cd0a..b3348b76fa 100644
--- a/test/cpp/qps/BUILD
+++ b/test/cpp/qps/BUILD
@@ -149,6 +149,7 @@ grpc_cc_binary(
":driver_impl",
"//:grpc++",
"//test/cpp/util:test_config",
+ "//test/cpp/util:test_util",
],
external_deps = [
"gflags",
@@ -163,6 +164,7 @@ grpc_cc_test(
":driver_impl",
":qps_worker_impl",
"//test/cpp/util:test_config",
+ "//test/cpp/util:test_util",
],
)
@@ -174,6 +176,7 @@ grpc_cc_test(
":driver_impl",
"//:grpc++",
"//test/cpp/util:test_config",
+ "//test/cpp/util:test_util",
],
)
diff --git a/test/cpp/qps/driver.cc b/test/cpp/qps/driver.cc
index bb4e7536e8..88d4d52abc 100644
--- a/test/cpp/qps/driver.cc
+++ b/test/cpp/qps/driver.cc
@@ -175,13 +175,11 @@ static void postprocess_scenario_result(ScenarioResult* result) {
sum(result->server_stats(), SvrPollCount) / histogram.Count());
auto server_queries_per_cpu_sec =
- histogram.Count() /
- (sum(result->server_stats(), ServerSystemTime) +
- sum(result->server_stats(), ServerUserTime));
+ histogram.Count() / (sum(result->server_stats(), ServerSystemTime) +
+ sum(result->server_stats(), ServerUserTime));
auto client_queries_per_cpu_sec =
- histogram.Count() /
- (sum(result->client_stats(), SystemTime) +
- sum(result->client_stats(), UserTime));
+ histogram.Count() / (sum(result->client_stats(), SystemTime) +
+ sum(result->client_stats(), UserTime));
result->mutable_summary()->set_server_queries_per_cpu_sec(
server_queries_per_cpu_sec);
@@ -193,7 +191,8 @@ std::unique_ptr<ScenarioResult> RunScenario(
const ClientConfig& initial_client_config, size_t num_clients,
const ServerConfig& initial_server_config, size_t num_servers,
int warmup_seconds, int benchmark_seconds, int spawn_local_worker_count,
- const char* qps_server_target_override, const char* credential_type) {
+ const grpc::string& qps_server_target_override,
+ const grpc::string& credential_type) {
// Log everything from the driver
gpr_set_log_verbosity(GPR_LOG_SEVERITY_DEBUG);
@@ -266,10 +265,9 @@ std::unique_ptr<ScenarioResult> RunScenario(
for (size_t i = 0; i < num_servers; i++) {
gpr_log(GPR_INFO, "Starting server on %s (worker #%" PRIuPTR ")",
workers[i].c_str(), i);
- servers[i].stub = WorkerService::NewStub(
- CreateChannel(workers[i],
- GetCredentialsProvider()->GetChannelCredentials(
- credential_type, &channel_args)));
+ servers[i].stub = WorkerService::NewStub(CreateChannel(
+ workers[i], GetCredentialsProvider()->GetChannelCredentials(
+ credential_type, &channel_args)));
ServerConfig server_config = initial_server_config;
if (server_config.core_limit() != 0) {
@@ -316,9 +314,8 @@ std::unique_ptr<ScenarioResult> RunScenario(
gpr_log(GPR_INFO, "Starting client on %s (worker #%" PRIuPTR ")",
worker.c_str(), i + num_servers);
clients[i].stub = WorkerService::NewStub(
- CreateChannel(worker,
- GetCredentialsProvider()->GetChannelCredentials(
- credential_type, &channel_args)));
+ CreateChannel(worker, GetCredentialsProvider()->GetChannelCredentials(
+ credential_type, &channel_args)));
ClientConfig per_client_config = client_config;
if (initial_client_config.core_limit() != 0) {
@@ -503,7 +500,7 @@ std::unique_ptr<ScenarioResult> RunScenario(
return result;
}
-bool RunQuit(const char* credential_type) {
+bool RunQuit(const grpc::string& credential_type) {
// Get client, server lists
bool result = true;
auto workers = get_workers("QPS_WORKERS");
@@ -513,10 +510,9 @@ bool RunQuit(const char* credential_type) {
ChannelArguments channel_args;
for (size_t i = 0; i < workers.size(); i++) {
- auto stub = WorkerService::NewStub(
- CreateChannel(workers[i],
- GetCredentialsProvider()->GetChannelCredentials(
- credential_type, &channel_args)));
+ auto stub = WorkerService::NewStub(CreateChannel(
+ workers[i], GetCredentialsProvider()->GetChannelCredentials(
+ credential_type, &channel_args)));
Void dummy;
grpc::ClientContext ctx;
ctx.set_wait_for_ready(true);
diff --git a/test/cpp/qps/driver.h b/test/cpp/qps/driver.h
index ddf75ce587..29f2776d79 100644
--- a/test/cpp/qps/driver.h
+++ b/test/cpp/qps/driver.h
@@ -31,10 +31,10 @@ std::unique_ptr<ScenarioResult> RunScenario(
const grpc::testing::ClientConfig& client_config, size_t num_clients,
const grpc::testing::ServerConfig& server_config, size_t num_servers,
int warmup_seconds, int benchmark_seconds, int spawn_local_worker_count,
- const char* qps_server_target_override = "",
- const char* credential_type = "INSECURE_CREDENTIALS");
+ const grpc::string& qps_server_target_override,
+ const grpc::string& credential_type);
-bool RunQuit(const char* credential_type = "INSECURE_CREDENTIALS");
+bool RunQuit(const grpc::string& credential_type);
} // namespace testing
} // namespace grpc
diff --git a/test/cpp/qps/qps_json_driver.cc b/test/cpp/qps/qps_json_driver.cc
index d4698a7dc2..cca59f64d8 100644
--- a/test/cpp/qps/qps_json_driver.cc
+++ b/test/cpp/qps/qps_json_driver.cc
@@ -31,6 +31,7 @@
#include "test/cpp/qps/parse_json.h"
#include "test/cpp/qps/report.h"
#include "test/cpp/util/test_config.h"
+#include "test/cpp/util/test_credentials_provider.h"
DEFINE_string(scenarios_file, "",
"JSON file containing an array of Scenario objects");
@@ -61,7 +62,7 @@ DEFINE_string(qps_server_target_override, "",
DEFINE_string(json_file_out, "", "File to write the JSON output to.");
-DEFINE_string(credential_type, "INSECURE_CREDENTIALS",
+DEFINE_string(credential_type, grpc::testing::kInsecureCredentialsType,
"Credential type for communication with workers");
namespace grpc {
@@ -75,8 +76,7 @@ static std::unique_ptr<ScenarioResult> RunAndReport(const Scenario& scenario,
scenario.server_config(), scenario.num_servers(),
scenario.warmup_seconds(), scenario.benchmark_seconds(),
scenario.spawn_local_worker_count(),
- FLAGS_qps_server_target_override.c_str(),
- FLAGS_credential_type.c_str());
+ FLAGS_qps_server_target_override, FLAGS_credential_type);
// Amend the result with scenario config. Eventually we should adjust
// RunScenario contract so we don't need to touch the result here.
@@ -190,7 +190,7 @@ static bool QpsDriver() {
} else if (scjson) {
json = FLAGS_scenarios_json.c_str();
} else if (FLAGS_quit) {
- return RunQuit(FLAGS_credential_type.c_str());
+ return RunQuit(FLAGS_credential_type);
}
// Parse into an array of scenarios
diff --git a/test/cpp/qps/qps_openloop_test.cc b/test/cpp/qps/qps_openloop_test.cc
index 2f8a3d75f0..069b3fa076 100644
--- a/test/cpp/qps/qps_openloop_test.cc
+++ b/test/cpp/qps/qps_openloop_test.cc
@@ -25,6 +25,7 @@
#include "test/cpp/qps/driver.h"
#include "test/cpp/qps/report.h"
#include "test/cpp/util/test_config.h"
+#include "test/cpp/util/test_credentials_provider.h"
namespace grpc {
namespace testing {
@@ -48,8 +49,8 @@ static void RunQPS() {
server_config.set_server_type(ASYNC_SERVER);
server_config.set_async_server_threads(8);
- const auto result =
- RunScenario(client_config, 1, server_config, 1, WARMUP, BENCHMARK, -2);
+ const auto result = RunScenario(client_config, 1, server_config, 1, WARMUP,
+ BENCHMARK, -2, "", kInsecureCredentialsType);
GetReporter()->ReportQPSPerCore(*result);
GetReporter()->ReportLatency(*result);
diff --git a/test/cpp/qps/qps_worker.cc b/test/cpp/qps/qps_worker.cc
index 4db4c86824..d20bc1b074 100644
--- a/test/cpp/qps/qps_worker.cc
+++ b/test/cpp/qps/qps_worker.cc
@@ -265,7 +265,7 @@ class WorkerServiceImpl final : public WorkerService::Service {
};
QpsWorker::QpsWorker(int driver_port, int server_port,
- const char* credential_type) {
+ const grpc::string& credential_type) {
impl_.reset(new WorkerServiceImpl(server_port, this));
gpr_atm_rel_store(&done_, static_cast<gpr_atm>(0));
@@ -273,9 +273,9 @@ QpsWorker::QpsWorker(int driver_port, int server_port,
gpr_join_host_port(&server_address, "::", driver_port);
ServerBuilder builder;
- builder.AddListeningPort(server_address,
- GetCredentialsProvider()->GetServerCredentials(
- credential_type));
+ builder.AddListeningPort(
+ server_address,
+ GetCredentialsProvider()->GetServerCredentials(credential_type));
builder.RegisterService(impl_.get());
gpr_free(server_address);
diff --git a/test/cpp/qps/qps_worker.h b/test/cpp/qps/qps_worker.h
index ab5e26a10e..32ff98da9b 100644
--- a/test/cpp/qps/qps_worker.h
+++ b/test/cpp/qps/qps_worker.h
@@ -33,8 +33,8 @@ class WorkerServiceImpl;
class QpsWorker {
public:
- explicit QpsWorker(int driver_port, int server_port = 0,
- const char* credential_type = "INSECURE_CREDENTIALS");
+ explicit QpsWorker(int driver_port, int server_port,
+ const grpc::string& credential_type);
~QpsWorker();
bool Done() const;
diff --git a/test/cpp/qps/secure_sync_unary_ping_pong_test.cc b/test/cpp/qps/secure_sync_unary_ping_pong_test.cc
index 1ee6e37474..137b33ee25 100644
--- a/test/cpp/qps/secure_sync_unary_ping_pong_test.cc
+++ b/test/cpp/qps/secure_sync_unary_ping_pong_test.cc
@@ -24,6 +24,7 @@
#include "test/cpp/qps/driver.h"
#include "test/cpp/qps/report.h"
#include "test/cpp/util/test_config.h"
+#include "test/cpp/util/test_credentials_provider.h"
namespace grpc {
namespace testing {
@@ -51,8 +52,8 @@ static void RunSynchronousUnaryPingPong() {
client_config.mutable_security_params()->CopyFrom(security);
server_config.mutable_security_params()->CopyFrom(security);
- const auto result =
- RunScenario(client_config, 1, server_config, 1, WARMUP, BENCHMARK, -2);
+ const auto result = RunScenario(client_config, 1, server_config, 1, WARMUP,
+ BENCHMARK, -2, "", kInsecureCredentialsType);
GetReporter()->ReportQPS(*result);
GetReporter()->ReportLatency(*result);
diff --git a/test/cpp/qps/worker.cc b/test/cpp/qps/worker.cc
index 7a8036327f..27010b7315 100644
--- a/test/cpp/qps/worker.cc
+++ b/test/cpp/qps/worker.cc
@@ -27,10 +27,11 @@
#include "test/cpp/qps/qps_worker.h"
#include "test/cpp/util/test_config.h"
+#include "test/cpp/util/test_credentials_provider.h"
DEFINE_int32(driver_port, 0, "Port for communication with driver");
DEFINE_int32(server_port, 0, "Port for operation as a server");
-DEFINE_string(credential_type, "INSECURE_CREDENTIALS",
+DEFINE_string(credential_type, grpc::testing::kInsecureCredentialsType,
"Credential type for communication with driver");
static bool got_sigint = false;
@@ -41,8 +42,7 @@ namespace grpc {
namespace testing {
static void RunServer() {
- QpsWorker worker(FLAGS_driver_port, FLAGS_server_port,
- FLAGS_credential_type.c_str());
+ QpsWorker worker(FLAGS_driver_port, FLAGS_server_port, FLAGS_credential_type);
while (!got_sigint && !worker.Done()) {
gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),