aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/qps
diff options
context:
space:
mode:
authorGravatar Yuchen Zeng <zyc@google.com>2017-03-17 13:02:03 -0700
committerGravatar Yuchen Zeng <zyc@google.com>2017-03-17 16:00:17 -0700
commit9bc0d8200ec17ababe4c9cd6134a2cb7465365a6 (patch)
tree14ac57b2410205774b345de360b0886033d7d433 /test/cpp/qps
parentcabb1517e5ac3cdbe59415678d4f0d284f9fabda (diff)
parent40a947ef93aeddca3b606613f628d4d09f094e77 (diff)
Merge remote-tracking branch 'upstream/master' into cares_bazel_rule
Diffstat (limited to 'test/cpp/qps')
-rw-r--r--test/cpp/qps/client.h2
-rw-r--r--test/cpp/qps/client_async.cc4
-rw-r--r--test/cpp/qps/client_sync.cc15
-rw-r--r--test/cpp/qps/driver.h2
-rw-r--r--test/cpp/qps/histogram.h2
-rw-r--r--test/cpp/qps/qps_json_driver.cc1
-rw-r--r--test/cpp/qps/server.h4
-rw-r--r--test/cpp/qps/server_async.cc19
-rw-r--r--test/cpp/qps/server_sync.cc4
9 files changed, 35 insertions, 18 deletions
diff --git a/test/cpp/qps/client.h b/test/cpp/qps/client.h
index baa9304cc2..25a19a5a74 100644
--- a/test/cpp/qps/client.h
+++ b/test/cpp/qps/client.h
@@ -46,7 +46,7 @@
#include <grpc/support/log.h>
#include <grpc/support/time.h>
-#include "src/proto/grpc/testing/payloads.grpc.pb.h"
+#include "src/proto/grpc/testing/payloads.pb.h"
#include "src/proto/grpc/testing/services.grpc.pb.h"
#include "test/cpp/qps/histogram.h"
diff --git a/test/cpp/qps/client_async.cc b/test/cpp/qps/client_async.cc
index 4032039ea1..396d308e2a 100644
--- a/test/cpp/qps/client_async.cc
+++ b/test/cpp/qps/client_async.cc
@@ -112,7 +112,9 @@ class ClientRpcContextUnaryImpl : public ClientRpcContext {
next_state_ = State::RESP_DONE;
return true;
case State::RESP_DONE:
- entry->set_value((UsageTimer::Now() - start_) * 1e9);
+ if (status_.ok()) {
+ entry->set_value((UsageTimer::Now() - start_) * 1e9);
+ }
callback_(status_, &response_, entry);
next_state_ = State::INVALID;
return false;
diff --git a/test/cpp/qps/client_sync.cc b/test/cpp/qps/client_sync.cc
index 498416c64a..a944c45496 100644
--- a/test/cpp/qps/client_sync.cc
+++ b/test/cpp/qps/client_sync.cc
@@ -129,7 +129,9 @@ class SynchronousUnaryClient final : public SynchronousClient {
grpc::ClientContext context;
grpc::Status s =
stub->UnaryCall(&context, request_, &responses_[thread_idx]);
- entry->set_value((UsageTimer::Now() - start) * 1e9);
+ if (s.ok()) {
+ entry->set_value((UsageTimer::Now() - start) * 1e9);
+ }
entry->set_status(s.error_code());
return true;
}
@@ -154,7 +156,7 @@ class SynchronousStreamingClient final : public SynchronousClient {
(*stream)->WritesDone();
Status s = (*stream)->Finish();
if (!s.ok()) {
- gpr_log(GPR_ERROR, "Stream %zu received an error %s", i,
+ gpr_log(GPR_ERROR, "Stream %" PRIuPTR " received an error %s", i,
s.error_message().c_str());
}
}
@@ -170,8 +172,17 @@ class SynchronousStreamingClient final : public SynchronousClient {
if (stream_[thread_idx]->Write(request_) &&
stream_[thread_idx]->Read(&responses_[thread_idx])) {
entry->set_value((UsageTimer::Now() - start) * 1e9);
+ // don't set the status since there isn't one yet
return true;
}
+ stream_[thread_idx]->WritesDone();
+ Status s = stream_[thread_idx]->Finish();
+ // don't set the value since the stream is failed and shouldn't be timed
+ entry->set_status(s.error_code());
+ if (!s.ok()) {
+ gpr_log(GPR_ERROR, "Stream %" PRIuPTR " received an error %s", thread_idx,
+ s.error_message().c_str());
+ }
auto* stub = channels_[thread_idx % channels_.size()].get_stub();
context_[thread_idx].~ClientContext();
new (&context_[thread_idx]) ClientContext();
diff --git a/test/cpp/qps/driver.h b/test/cpp/qps/driver.h
index e72d30a4ef..dd32a16c87 100644
--- a/test/cpp/qps/driver.h
+++ b/test/cpp/qps/driver.h
@@ -36,7 +36,7 @@
#include <memory>
-#include "src/proto/grpc/testing/control.grpc.pb.h"
+#include "src/proto/grpc/testing/control.pb.h"
#include "test/cpp/qps/histogram.h"
namespace grpc {
diff --git a/test/cpp/qps/histogram.h b/test/cpp/qps/histogram.h
index acb415f0a1..470a394301 100644
--- a/test/cpp/qps/histogram.h
+++ b/test/cpp/qps/histogram.h
@@ -35,7 +35,7 @@
#define TEST_QPS_HISTOGRAM_H
#include <grpc/support/histogram.h>
-#include "src/proto/grpc/testing/stats.grpc.pb.h"
+#include "src/proto/grpc/testing/stats.pb.h"
namespace grpc {
namespace testing {
diff --git a/test/cpp/qps/qps_json_driver.cc b/test/cpp/qps/qps_json_driver.cc
index ddaaa7ca75..bd2c1f0ec6 100644
--- a/test/cpp/qps/qps_json_driver.cc
+++ b/test/cpp/qps/qps_json_driver.cc
@@ -31,6 +31,7 @@
*
*/
+#include <iostream>
#include <memory>
#include <set>
diff --git a/test/cpp/qps/server.h b/test/cpp/qps/server.h
index 821d5935be..8fbf37a095 100644
--- a/test/cpp/qps/server.h
+++ b/test/cpp/qps/server.h
@@ -38,8 +38,8 @@
#include <grpc/support/cpu.h>
#include <vector>
-#include "src/proto/grpc/testing/control.grpc.pb.h"
-#include "src/proto/grpc/testing/messages.grpc.pb.h"
+#include "src/proto/grpc/testing/control.pb.h"
+#include "src/proto/grpc/testing/messages.pb.h"
#include "test/core/end2end/data/ssl_test_data.h"
#include "test/core/util/port.h"
#include "test/cpp/qps/usage_timer.h"
diff --git a/test/cpp/qps/server_async.cc b/test/cpp/qps/server_async.cc
index b3a06aeaf5..b58d91eea6 100644
--- a/test/cpp/qps/server_async.cc
+++ b/test/cpp/qps/server_async.cc
@@ -103,24 +103,25 @@ class AsyncQpsServerTest final : public grpc::testing::Server {
server_ = builder.BuildAndStart();
- using namespace std::placeholders;
-
auto process_rpc_bound =
- std::bind(process_rpc, config.payload_config(), _1, _2);
+ std::bind(process_rpc, config.payload_config(), std::placeholders::_1,
+ std::placeholders::_2);
for (int i = 0; i < 15000; i++) {
for (int j = 0; j < num_threads; j++) {
if (request_unary_function) {
- auto request_unary =
- std::bind(request_unary_function, &async_service_, _1, _2, _3,
- srv_cqs_[j].get(), srv_cqs_[j].get(), _4);
+ auto request_unary = std::bind(
+ request_unary_function, &async_service_, std::placeholders::_1,
+ std::placeholders::_2, std::placeholders::_3, srv_cqs_[j].get(),
+ srv_cqs_[j].get(), std::placeholders::_4);
contexts_.emplace_back(
new ServerRpcContextUnaryImpl(request_unary, process_rpc_bound));
}
if (request_streaming_function) {
- auto request_streaming =
- std::bind(request_streaming_function, &async_service_, _1, _2,
- srv_cqs_[j].get(), srv_cqs_[j].get(), _3);
+ auto request_streaming = std::bind(
+ request_streaming_function, &async_service_,
+ std::placeholders::_1, std::placeholders::_2, srv_cqs_[j].get(),
+ srv_cqs_[j].get(), std::placeholders::_3);
contexts_.emplace_back(new ServerRpcContextStreamingImpl(
request_streaming, process_rpc_bound));
}
diff --git a/test/cpp/qps/server_sync.cc b/test/cpp/qps/server_sync.cc
index 8076a4a6b9..f79284d225 100644
--- a/test/cpp/qps/server_sync.cc
+++ b/test/cpp/qps/server_sync.cc
@@ -74,7 +74,9 @@ class BenchmarkServiceImpl final : public BenchmarkService::Service {
return Status(grpc::StatusCode::INTERNAL, "Error creating payload.");
}
}
- stream->Write(response);
+ if (!stream->Write(response)) {
+ return Status(StatusCode::INTERNAL, "Server couldn't respond");
+ }
}
return Status::OK;
}