aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/qps
diff options
context:
space:
mode:
authorGravatar Jan Tattermusch <jtattermusch@google.com>2016-12-21 12:19:14 +0100
committerGravatar Jan Tattermusch <jtattermusch@google.com>2016-12-21 12:20:37 +0100
commit9f89107f1741278d16e2b39651293f5bf77380b7 (patch)
tree3d5c7f46de8e01ccc7103460843106e403684fc4 /test/cpp/qps
parent659ddda0eb532b42830bdba34d6db024ad8c30e3 (diff)
better qps_json_driver message when QPS_WORKERS env is missing
Diffstat (limited to 'test/cpp/qps')
-rw-r--r--test/cpp/qps/driver.cc44
1 files changed, 31 insertions, 13 deletions
diff --git a/test/cpp/qps/driver.cc b/test/cpp/qps/driver.cc
index 3e509e2abd..93ef32db77 100644
--- a/test/cpp/qps/driver.cc
+++ b/test/cpp/qps/driver.cc
@@ -44,6 +44,7 @@
#include <grpc/support/alloc.h>
#include <grpc/support/host_port.h>
#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
#include "src/core/lib/profiling/timers.h"
#include "src/core/lib/support/env.h"
@@ -99,23 +100,36 @@ static std::unordered_map<string, std::deque<int>> get_hosts_and_cores(
return hosts;
}
-static deque<string> get_workers(const string& name) {
- char* env = gpr_getenv(name.c_str());
- if (!env || strlen(env) == 0) return deque<string>();
-
+static deque<string> get_workers(const string& env_name) {
+ char* env = gpr_getenv(env_name.c_str());
+ if (!env) {
+ env = gpr_strdup("");
+ }
deque<string> out;
char* p = env;
- for (;;) {
- char* comma = strchr(p, ',');
- if (comma) {
- out.emplace_back(p, comma);
- p = comma + 1;
- } else {
- out.emplace_back(p);
- gpr_free(env);
- return out;
+ if (strlen(env) != 0) {
+ for (;;) {
+ char* comma = strchr(p, ',');
+ if (comma) {
+ out.emplace_back(p, comma);
+ p = comma + 1;
+ } else {
+ out.emplace_back(p);
+ break;
+ }
}
}
+ if (out.size() == 0) {
+ gpr_log(GPR_ERROR,
+ "Environment variable \"%s\" does not contain a list of QPS "
+ "workers to use. Set it to a comma-separated list of "
+ "hostname:port pairs, starting with hosts that should act as "
+ "servers. E.g. export "
+ "%s=\"serverhost1:1234,clienthost1:1234,clienthost2:1234\"",
+ env_name.c_str(), env_name.c_str());
+ }
+ gpr_free(env);
+ return out;
}
// helpers for postprocess_scenario_result
@@ -241,6 +255,7 @@ std::unique_ptr<ScenarioResult> RunScenario(
workers.push_back(addr);
}
}
+ GPR_ASSERT(workers.size() != 0);
// if num_clients is set to <=0, do dynamic sizing: all workers
// except for servers are clients
@@ -560,6 +575,9 @@ bool RunQuit() {
// Get client, server lists
bool result = true;
auto workers = get_workers("QPS_WORKERS");
+ if (workers.size() == 0) {
+ return false;
+ }
for (size_t i = 0; i < workers.size(); i++) {
auto stub = WorkerService::NewStub(
CreateChannel(workers[i], InsecureChannelCredentials()));