aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/cpp')
-rw-r--r--test/cpp/codegen/BUILD28
-rw-r--r--test/cpp/common/BUILD54
-rw-r--r--test/cpp/end2end/BUILD130
-rw-r--r--test/cpp/end2end/async_end2end_test.cc3
-rw-r--r--test/cpp/end2end/client_crash_test.cc3
-rw-r--r--test/cpp/end2end/end2end_test.cc3
-rw-r--r--test/cpp/end2end/filter_end2end_test.cc3
-rw-r--r--test/cpp/end2end/generic_end2end_test.cc3
-rw-r--r--test/cpp/end2end/health_service_end2end_test.cc3
-rw-r--r--test/cpp/end2end/hybrid_end2end_test.cc3
-rw-r--r--test/cpp/end2end/mock_test.cc3
-rw-r--r--test/cpp/end2end/proto_server_reflection_test.cc3
-rw-r--r--test/cpp/end2end/round_robin_end2end_test.cc3
-rw-r--r--test/cpp/end2end/server_builder_plugin_test.cc3
-rw-r--r--test/cpp/end2end/server_crash_test.cc3
-rw-r--r--test/cpp/end2end/shutdown_test.cc4
-rw-r--r--test/cpp/end2end/streaming_throughput_test.cc4
-rw-r--r--test/cpp/end2end/test_service_impl.cc4
-rw-r--r--test/cpp/end2end/thread_stress_test.cc3
-rw-r--r--test/cpp/microbenchmarks/BUILD39
-rw-r--r--test/cpp/microbenchmarks/bm_cq_multiple_threads.cc16
-rw-r--r--test/cpp/microbenchmarks/fullstack_fixtures.h14
-rw-r--r--test/cpp/qps/BUILD41
-rw-r--r--test/cpp/qps/client.h15
-rw-r--r--test/cpp/qps/client_async.cc8
-rw-r--r--test/cpp/qps/client_sync.cc1
-rw-r--r--test/cpp/qps/driver.cc7
-rw-r--r--test/cpp/qps/qps_json_driver.cc1
-rw-r--r--test/cpp/qps/report.cc21
-rw-r--r--test/cpp/qps/report.h7
-rw-r--r--test/cpp/qps/server.h14
-rw-r--r--test/cpp/qps/server_async.cc8
-rw-r--r--test/cpp/util/BUILD65
33 files changed, 396 insertions, 124 deletions
diff --git a/test/cpp/codegen/BUILD b/test/cpp/codegen/BUILD
index 43d133fc34..f974e63eb4 100644
--- a/test/cpp/codegen/BUILD
+++ b/test/cpp/codegen/BUILD
@@ -29,37 +29,45 @@
licenses(["notice"]) # 3-clause BSD
-cc_test(
+load("//bazel:grpc_build_system.bzl", "grpc_cc_test")
+
+grpc_cc_test(
name = "codegen_test_full",
srcs = ["codegen_test_full.cc"],
deps = [
"//:grpc++",
- "//external:gtest",
"//test/core/util:gpr_test_util",
],
+ external_deps = [
+ "gtest",
+ ],
)
-cc_test(
+grpc_cc_test(
name = "codegen_test_minimal",
srcs = ["codegen_test_minimal.cc"],
deps = [
"//:grpc++",
- "//external:gtest",
"//test/core/util:gpr_test_util",
],
+ external_deps = [
+ "gtest",
+ ],
)
-cc_test(
+grpc_cc_test(
name = "proto_utils_test",
srcs = ["proto_utils_test.cc"],
deps = [
"//:grpc++",
- "//external:gtest",
"//test/core/util:gpr_test_util",
],
+ external_deps = [
+ "gtest",
+ ],
)
-cc_test(
+grpc_cc_test(
name = "golden_file_test",
srcs = ["golden_file_test.cc"],
args = ["--generated_file_path=$(GENDIR)/src/proto/grpc/testing/"],
@@ -69,9 +77,11 @@ cc_test(
],
deps = [
"//:grpc++",
- "//external:gflags",
- "//external:gtest",
"//src/proto/grpc/testing:compiler_test_proto",
"//test/core/util:gpr_test_util",
],
+ external_deps = [
+ "gtest",
+ "gflags",
+ ],
)
diff --git a/test/cpp/common/BUILD b/test/cpp/common/BUILD
index 48ad583981..c8b3e46f5f 100644
--- a/test/cpp/common/BUILD
+++ b/test/cpp/common/BUILD
@@ -29,32 +29,66 @@
licenses(["notice"]) # 3-clause BSD
-cc_test(
+load("//bazel:grpc_build_system.bzl", "grpc_cc_test")
+
+grpc_cc_test(
name = "alarm_cpp_test",
srcs = ["alarm_cpp_test.cc"],
- deps = ["//:grpc++", "//external:gtest", "//test/core/util:gpr_test_util"],
+ deps = [
+ "//:grpc++",
+ "//test/core/util:gpr_test_util",
+ ],
+ external_deps = [
+ "gtest",
+ ],
)
-cc_test(
+grpc_cc_test(
name = "auth_property_iterator_test",
srcs = ["auth_property_iterator_test.cc"],
- deps = ["//:grpc++", "//external:gtest", "//test/core/util:gpr_test_util", "//test/cpp/util:test_util"],
+ deps = [
+ "//:grpc++",
+ "//test/core/util:gpr_test_util",
+ "//test/cpp/util:test_util",
+ ],
+ external_deps = [
+ "gtest",
+ ],
)
-cc_test(
+grpc_cc_test(
name = "channel_arguments_test",
srcs = ["channel_arguments_test.cc"],
- deps = ["//:grpc++", "//external:gtest", "//test/core/util:gpr_test_util"],
+ deps = [
+ "//:grpc++",
+ "//test/core/util:gpr_test_util",
+ ],
+ external_deps = [
+ "gtest",
+ ],
)
-cc_test(
+grpc_cc_test(
name = "channel_filter_test",
srcs = ["channel_filter_test.cc"],
- deps = ["//:grpc++", "//external:gtest", "//test/core/util:gpr_test_util"],
+ deps = [
+ "//:grpc++",
+ "//test/core/util:gpr_test_util",
+ ],
+ external_deps = [
+ "gtest",
+ ],
)
-cc_test(
+grpc_cc_test(
name = "secure_auth_context_test",
srcs = ["secure_auth_context_test.cc"],
- deps = ["//:grpc++", "//external:gtest", "//test/core/util:gpr_test_util", "//test/cpp/util:test_util"],
+ deps = [
+ "//:grpc++",
+ "//test/core/util:gpr_test_util",
+ "//test/cpp/util:test_util",
+ ],
+ external_deps = [
+ "gtest",
+ ],
)
diff --git a/test/cpp/end2end/BUILD b/test/cpp/end2end/BUILD
index e867493fb9..9b691a83e0 100644
--- a/test/cpp/end2end/BUILD
+++ b/test/cpp/end2end/BUILD
@@ -29,25 +29,30 @@
licenses(["notice"]) # 3-clause BSD
-cc_library(
+load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test")
+
+package(default_visibility=["//visibility:public"]) # Allows external users to implement end2end tests.
+
+grpc_cc_library(
name = "test_service_impl",
srcs = ["test_service_impl.cc"],
hdrs = ["test_service_impl.h"],
deps = [
- "//external:gtest",
"//src/proto/grpc/testing:echo_proto",
"//test/cpp/util:test_util",
],
+ external_deps = [
+ "gtest",
+ ],
)
-cc_test(
+grpc_cc_test(
name = "async_end2end_test",
srcs = ["async_end2end_test.cc"],
deps = [
"//:gpr",
"//:grpc",
"//:grpc++",
- "//external:gtest",
"//src/proto/grpc/health/v1:health_proto",
"//src/proto/grpc/testing:echo_messages_proto",
"//src/proto/grpc/testing:echo_proto",
@@ -56,16 +61,18 @@ cc_test(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
+ external_deps = [
+ "gtest",
+ ],
)
-cc_test(
+grpc_cc_test(
name = "client_crash_test",
srcs = ["client_crash_test.cc"],
deps = [
"//:gpr",
"//:grpc",
"//:grpc++",
- "//external:gtest",
"//src/proto/grpc/testing:echo_messages_proto",
"//src/proto/grpc/testing:echo_proto",
"//src/proto/grpc/testing/duplicate:echo_duplicate_proto",
@@ -73,17 +80,18 @@ cc_test(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
+ external_deps = [
+ "gtest",
+ ],
)
-cc_test(
+grpc_cc_test(
name = "client_crash_test_server",
srcs = ["client_crash_test_server.cc"],
deps = [
"//:gpr",
"//:grpc",
"//:grpc++",
- "//external:gflags",
- "//external:gtest",
"//src/proto/grpc/testing:echo_messages_proto",
"//src/proto/grpc/testing:echo_proto",
"//src/proto/grpc/testing/duplicate:echo_duplicate_proto",
@@ -91,17 +99,21 @@ cc_test(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
+ external_deps = [
+ "gflags",
+ "gtest",
+ ],
)
-cc_test(
- name = "end2end_test",
+grpc_cc_library(
+ name = "end2end_test_lib",
srcs = ["end2end_test.cc"],
+ testonly = True,
deps = [
":test_service_impl",
"//:gpr",
"//:grpc",
"//:grpc++",
- "//external:gtest",
"//src/proto/grpc/testing:echo_messages_proto",
"//src/proto/grpc/testing:echo_proto",
"//src/proto/grpc/testing/duplicate:echo_duplicate_proto",
@@ -109,16 +121,25 @@ cc_test(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
+ external_deps = [
+ "gtest",
+ ],
)
-cc_test(
+grpc_cc_test(
+ name = "end2end_test",
+ deps = [
+ ":end2end_test_lib"
+ ],
+)
+
+grpc_cc_test(
name = "filter_end2end_test",
srcs = ["filter_end2end_test.cc"],
deps = [
"//:gpr",
"//:grpc",
"//:grpc++",
- "//external:gtest",
"//src/proto/grpc/testing:echo_messages_proto",
"//src/proto/grpc/testing:echo_proto",
"//src/proto/grpc/testing/duplicate:echo_duplicate_proto",
@@ -126,16 +147,18 @@ cc_test(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
+ external_deps = [
+ "gtest",
+ ],
)
-cc_test(
+grpc_cc_test(
name = "generic_end2end_test",
srcs = ["generic_end2end_test.cc"],
deps = [
"//:gpr",
"//:grpc",
"//:grpc++",
- "//external:gtest",
"//src/proto/grpc/testing:echo_messages_proto",
"//src/proto/grpc/testing:echo_proto",
"//src/proto/grpc/testing/duplicate:echo_duplicate_proto",
@@ -143,9 +166,12 @@ cc_test(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
+ external_deps = [
+ "gtest",
+ ],
)
-cc_test(
+grpc_cc_test(
name = "hybrid_end2end_test",
srcs = ["hybrid_end2end_test.cc"],
deps = [
@@ -153,7 +179,6 @@ cc_test(
"//:gpr",
"//:grpc",
"//:grpc++",
- "//external:gtest",
"//src/proto/grpc/testing:echo_messages_proto",
"//src/proto/grpc/testing:echo_proto",
"//src/proto/grpc/testing/duplicate:echo_duplicate_proto",
@@ -161,16 +186,19 @@ cc_test(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
+ external_deps = [
+ "gtest",
+ ],
)
-cc_test(
+grpc_cc_test(
name = "mock_test",
srcs = ["mock_test.cc"],
deps = [
"//:gpr",
"//:grpc",
"//:grpc++",
- "//external:gtest",
+ "//:grpc++_test",
"//src/proto/grpc/testing:echo_messages_proto",
"//src/proto/grpc/testing:echo_proto",
"//src/proto/grpc/testing/duplicate:echo_duplicate_proto",
@@ -178,9 +206,12 @@ cc_test(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
+ external_deps = [
+ "gtest",
+ ],
)
-cc_test(
+grpc_cc_test(
name = "round_robin_end2end_test",
srcs = ["round_robin_end2end_test.cc"],
deps = [
@@ -188,7 +219,6 @@ cc_test(
"//:gpr",
"//:grpc",
"//:grpc++",
- "//external:gtest",
"//src/proto/grpc/testing:echo_messages_proto",
"//src/proto/grpc/testing:echo_proto",
"//src/proto/grpc/testing/duplicate:echo_duplicate_proto",
@@ -196,10 +226,12 @@ cc_test(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
+ external_deps = [
+ "gtest",
+ ],
)
-
-cc_test(
+grpc_cc_test(
name = "grpclb_end2end_test",
srcs = ["grpclb_end2end_test.cc"],
deps = [
@@ -207,7 +239,6 @@ cc_test(
"//:gpr",
"//:grpc",
"//:grpc++",
- "//external:gtest",
"//src/proto/grpc/lb/v1:load_balancer_proto",
"//src/proto/grpc/testing:echo_messages_proto",
"//src/proto/grpc/testing:echo_proto",
@@ -217,9 +248,12 @@ cc_test(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
+ external_deps = [
+ "gtest",
+ ],
)
-cc_test(
+grpc_cc_test(
name = "proto_server_reflection_test",
srcs = ["proto_server_reflection_test.cc"],
deps = [
@@ -228,8 +262,6 @@ cc_test(
"//:grpc",
"//:grpc++",
"//:grpc++_reflection",
- "//external:gflags",
- "//external:gtest",
"//src/proto/grpc/testing:echo_messages_proto",
"//src/proto/grpc/testing:echo_proto",
"//src/proto/grpc/testing/duplicate:echo_duplicate_proto",
@@ -238,9 +270,13 @@ cc_test(
"//test/cpp/util:grpc++_proto_reflection_desc_db",
"//test/cpp/util:test_util",
],
+ external_deps = [
+ "gtest",
+ "gflags",
+ ],
)
-cc_test(
+grpc_cc_test(
name = "server_builder_plugin_test",
srcs = ["server_builder_plugin_test.cc"],
deps = [
@@ -248,7 +284,6 @@ cc_test(
"//:gpr",
"//:grpc",
"//:grpc++",
- "//external:gtest",
"//src/proto/grpc/testing:echo_messages_proto",
"//src/proto/grpc/testing:echo_proto",
"//src/proto/grpc/testing/duplicate:echo_duplicate_proto",
@@ -256,16 +291,18 @@ cc_test(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
+ external_deps = [
+ "gtest",
+ ],
)
-cc_test(
+grpc_cc_test(
name = "server_crash_test",
srcs = ["server_crash_test.cc"],
deps = [
"//:gpr",
"//:grpc",
"//:grpc++",
- "//external:gtest",
"//src/proto/grpc/testing:echo_messages_proto",
"//src/proto/grpc/testing:echo_proto",
"//src/proto/grpc/testing/duplicate:echo_duplicate_proto",
@@ -273,17 +310,18 @@ cc_test(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
+ external_deps = [
+ "gtest",
+ ],
)
-cc_test(
+grpc_cc_test(
name = "server_crash_test_client",
srcs = ["server_crash_test_client.cc"],
deps = [
"//:gpr",
"//:grpc",
"//:grpc++",
- "//external:gflags",
- "//external:gtest",
"//src/proto/grpc/testing:echo_messages_proto",
"//src/proto/grpc/testing:echo_proto",
"//src/proto/grpc/testing/duplicate:echo_duplicate_proto",
@@ -291,16 +329,19 @@ cc_test(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
+ external_deps = [
+ "gflags",
+ "gtest",
+ ],
)
-cc_test(
+grpc_cc_test(
name = "shutdown_test",
srcs = ["shutdown_test.cc"],
deps = [
"//:gpr",
"//:grpc",
"//:grpc++",
- "//external:gtest",
"//src/proto/grpc/testing:echo_messages_proto",
"//src/proto/grpc/testing:echo_proto",
"//src/proto/grpc/testing/duplicate:echo_duplicate_proto",
@@ -308,16 +349,18 @@ cc_test(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
+ external_deps = [
+ "gtest",
+ ],
)
-cc_test(
+grpc_cc_test(
name = "streaming_throughput_test",
srcs = ["streaming_throughput_test.cc"],
deps = [
"//:gpr",
"//:grpc",
"//:grpc++",
- "//external:gtest",
"//src/proto/grpc/testing:echo_messages_proto",
"//src/proto/grpc/testing:echo_proto",
"//src/proto/grpc/testing/duplicate:echo_duplicate_proto",
@@ -325,16 +368,18 @@ cc_test(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
+ external_deps = [
+ "gtest",
+ ],
)
-cc_test(
+grpc_cc_test(
name = "thread_stress_test",
srcs = ["thread_stress_test.cc"],
deps = [
"//:gpr",
"//:grpc",
"//:grpc++",
- "//external:gtest",
"//src/proto/grpc/testing:echo_messages_proto",
"//src/proto/grpc/testing:echo_proto",
"//src/proto/grpc/testing/duplicate:echo_duplicate_proto",
@@ -342,4 +387,7 @@ cc_test(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
+ external_deps = [
+ "gtest",
+ ],
)
diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc
index cc3958bf13..8d59cbb7e0 100644
--- a/test/cpp/end2end/async_end2end_test.cc
+++ b/test/cpp/end2end/async_end2end_test.cc
@@ -47,7 +47,6 @@
#include <grpc/support/thd.h>
#include <grpc/support/time.h>
#include <grpc/support/tls.h>
-#include <gtest/gtest.h>
#include "src/core/lib/iomgr/port.h"
#include "src/proto/grpc/health/v1/health.grpc.pb.h"
@@ -58,6 +57,8 @@
#include "test/cpp/util/string_ref_helper.h"
#include "test/cpp/util/test_credentials_provider.h"
+#include <gtest/gtest.h>
+
#ifdef GRPC_POSIX_SOCKET
#include "src/core/lib/iomgr/ev_posix.h"
#endif
diff --git a/test/cpp/end2end/client_crash_test.cc b/test/cpp/end2end/client_crash_test.cc
index 966c04b0e3..0ea520925f 100644
--- a/test/cpp/end2end/client_crash_test.cc
+++ b/test/cpp/end2end/client_crash_test.cc
@@ -41,7 +41,6 @@
#include <grpc/support/log.h>
#include <grpc/support/thd.h>
#include <grpc/support/time.h>
-#include <gtest/gtest.h>
#include "src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h"
#include "src/proto/grpc/testing/echo.grpc.pb.h"
@@ -49,6 +48,8 @@
#include "test/core/util/test_config.h"
#include "test/cpp/util/subprocess.h"
+#include <gtest/gtest.h>
+
using grpc::testing::EchoRequest;
using grpc::testing::EchoResponse;
using std::chrono::system_clock;
diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc
index df71777e4b..9a9e81853f 100644
--- a/test/cpp/end2end/end2end_test.cc
+++ b/test/cpp/end2end/end2end_test.cc
@@ -48,7 +48,6 @@
#include <grpc/support/log.h>
#include <grpc/support/thd.h>
#include <grpc/support/time.h>
-#include <gtest/gtest.h>
#include "src/core/lib/security/credentials/credentials.h"
#include "src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h"
@@ -59,6 +58,8 @@
#include "test/cpp/util/string_ref_helper.h"
#include "test/cpp/util/test_credentials_provider.h"
+#include <gtest/gtest.h>
+
using grpc::testing::EchoRequest;
using grpc::testing::EchoResponse;
using grpc::testing::kTlsCredentialsType;
diff --git a/test/cpp/end2end/filter_end2end_test.cc b/test/cpp/end2end/filter_end2end_test.cc
index 2f873eeaa8..5589e2fddc 100644
--- a/test/cpp/end2end/filter_end2end_test.cc
+++ b/test/cpp/end2end/filter_end2end_test.cc
@@ -48,7 +48,6 @@
#include <grpc/grpc.h>
#include <grpc/support/thd.h>
#include <grpc/support/time.h>
-#include <gtest/gtest.h>
#include "src/cpp/common/channel_filter.h"
#include "src/proto/grpc/testing/echo.grpc.pb.h"
@@ -56,6 +55,8 @@
#include "test/core/util/test_config.h"
#include "test/cpp/util/byte_buffer_proto_helper.h"
+#include <gtest/gtest.h>
+
using grpc::testing::EchoRequest;
using grpc::testing::EchoResponse;
using std::chrono::system_clock;
diff --git a/test/cpp/end2end/generic_end2end_test.cc b/test/cpp/end2end/generic_end2end_test.cc
index 2c9f5e38e6..281c58efad 100644
--- a/test/cpp/end2end/generic_end2end_test.cc
+++ b/test/cpp/end2end/generic_end2end_test.cc
@@ -46,13 +46,14 @@
#include <grpc/grpc.h>
#include <grpc/support/thd.h>
#include <grpc/support/time.h>
-#include <gtest/gtest.h>
#include "src/proto/grpc/testing/echo.grpc.pb.h"
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
#include "test/cpp/util/byte_buffer_proto_helper.h"
+#include <gtest/gtest.h>
+
using grpc::testing::EchoRequest;
using grpc::testing::EchoResponse;
using std::chrono::system_clock;
diff --git a/test/cpp/end2end/health_service_end2end_test.cc b/test/cpp/end2end/health_service_end2end_test.cc
index 3d51007857..c320c78697 100644
--- a/test/cpp/end2end/health_service_end2end_test.cc
+++ b/test/cpp/end2end/health_service_end2end_test.cc
@@ -46,7 +46,6 @@
#include <grpc++/server_context.h>
#include <grpc/grpc.h>
#include <grpc/support/log.h>
-#include <gtest/gtest.h>
#include "src/proto/grpc/health/v1/health.grpc.pb.h"
#include "src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h"
@@ -55,6 +54,8 @@
#include "test/core/util/test_config.h"
#include "test/cpp/end2end/test_service_impl.h"
+#include <gtest/gtest.h>
+
using grpc::health::v1::Health;
using grpc::health::v1::HealthCheckRequest;
using grpc::health::v1::HealthCheckResponse;
diff --git a/test/cpp/end2end/hybrid_end2end_test.cc b/test/cpp/end2end/hybrid_end2end_test.cc
index a4ba76fed1..1cd515a23b 100644
--- a/test/cpp/end2end/hybrid_end2end_test.cc
+++ b/test/cpp/end2end/hybrid_end2end_test.cc
@@ -42,7 +42,6 @@
#include <grpc++/server_builder.h>
#include <grpc++/server_context.h>
#include <grpc/grpc.h>
-#include <gtest/gtest.h>
#include "src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h"
#include "src/proto/grpc/testing/echo.grpc.pb.h"
@@ -51,6 +50,8 @@
#include "test/cpp/end2end/test_service_impl.h"
#include "test/cpp/util/byte_buffer_proto_helper.h"
+#include <gtest/gtest.h>
+
namespace grpc {
namespace testing {
diff --git a/test/cpp/end2end/mock_test.cc b/test/cpp/end2end/mock_test.cc
index 7e330063ed..3a82b3a5d6 100644
--- a/test/cpp/end2end/mock_test.cc
+++ b/test/cpp/end2end/mock_test.cc
@@ -45,7 +45,6 @@
#include <grpc/support/log.h>
#include <grpc/support/thd.h>
#include <grpc/support/time.h>
-#include <gtest/gtest.h>
#include <grpc++/test/mock_stream.h>
@@ -55,6 +54,8 @@
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
+#include <gtest/gtest.h>
+
#include <iostream>
using namespace std;
diff --git a/test/cpp/end2end/proto_server_reflection_test.cc b/test/cpp/end2end/proto_server_reflection_test.cc
index 8b9688d200..25cb0d5f73 100644
--- a/test/cpp/end2end/proto_server_reflection_test.cc
+++ b/test/cpp/end2end/proto_server_reflection_test.cc
@@ -41,7 +41,6 @@
#include <grpc++/server_builder.h>
#include <grpc++/server_context.h>
#include <grpc/grpc.h>
-#include <gtest/gtest.h>
#include "src/proto/grpc/testing/echo.grpc.pb.h"
#include "test/core/util/port.h"
@@ -49,6 +48,8 @@
#include "test/cpp/end2end/test_service_impl.h"
#include "test/cpp/util/proto_reflection_descriptor_database.h"
+#include <gtest/gtest.h>
+
namespace grpc {
namespace testing {
diff --git a/test/cpp/end2end/round_robin_end2end_test.cc b/test/cpp/end2end/round_robin_end2end_test.cc
index cc340b96b3..f8e3cc06c0 100644
--- a/test/cpp/end2end/round_robin_end2end_test.cc
+++ b/test/cpp/end2end/round_robin_end2end_test.cc
@@ -44,13 +44,14 @@
#include <grpc/support/log.h>
#include <grpc/support/thd.h>
#include <grpc/support/time.h>
-#include <gtest/gtest.h>
#include "src/proto/grpc/testing/echo.grpc.pb.h"
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
#include "test/cpp/end2end/test_service_impl.h"
+#include <gtest/gtest.h>
+
using grpc::testing::EchoRequest;
using grpc::testing::EchoResponse;
using std::chrono::system_clock;
diff --git a/test/cpp/end2end/server_builder_plugin_test.cc b/test/cpp/end2end/server_builder_plugin_test.cc
index 1b6f4ce37d..81b747a7af 100644
--- a/test/cpp/end2end/server_builder_plugin_test.cc
+++ b/test/cpp/end2end/server_builder_plugin_test.cc
@@ -45,13 +45,14 @@
#include <grpc++/server_builder.h>
#include <grpc++/server_context.h>
#include <grpc/grpc.h>
-#include <gtest/gtest.h>
#include "src/proto/grpc/testing/echo.grpc.pb.h"
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
#include "test/cpp/end2end/test_service_impl.h"
+#include <gtest/gtest.h>
+
#define PLUGIN_NAME "TestServerBuilderPlugin"
namespace grpc {
diff --git a/test/cpp/end2end/server_crash_test.cc b/test/cpp/end2end/server_crash_test.cc
index b1f9216055..4b7041aebe 100644
--- a/test/cpp/end2end/server_crash_test.cc
+++ b/test/cpp/end2end/server_crash_test.cc
@@ -41,7 +41,6 @@
#include <grpc/support/log.h>
#include <grpc/support/thd.h>
#include <grpc/support/time.h>
-#include <gtest/gtest.h>
#include "src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h"
#include "src/proto/grpc/testing/echo.grpc.pb.h"
@@ -49,6 +48,8 @@
#include "test/core/util/test_config.h"
#include "test/cpp/util/subprocess.h"
+#include <gtest/gtest.h>
+
using grpc::testing::EchoRequest;
using grpc::testing::EchoResponse;
using std::chrono::system_clock;
diff --git a/test/cpp/end2end/shutdown_test.cc b/test/cpp/end2end/shutdown_test.cc
index bd68e851d3..63b397dd1c 100644
--- a/test/cpp/end2end/shutdown_test.cc
+++ b/test/cpp/end2end/shutdown_test.cc
@@ -33,8 +33,6 @@
#include <thread>
-#include <gtest/gtest.h>
-
#include <grpc++/channel.h>
#include <grpc++/client_context.h>
#include <grpc++/create_channel.h>
@@ -51,6 +49,8 @@
#include "test/core/util/test_config.h"
#include "test/cpp/util/test_credentials_provider.h"
+#include <gtest/gtest.h>
+
using grpc::testing::EchoRequest;
using grpc::testing::EchoResponse;
diff --git a/test/cpp/end2end/streaming_throughput_test.cc b/test/cpp/end2end/streaming_throughput_test.cc
index 302583766b..ec5b83d1da 100644
--- a/test/cpp/end2end/streaming_throughput_test.cc
+++ b/test/cpp/end2end/streaming_throughput_test.cc
@@ -35,8 +35,6 @@
#include <mutex>
#include <thread>
-#include <gtest/gtest.h>
-
#include <grpc++/channel.h>
#include <grpc++/client_context.h>
#include <grpc++/create_channel.h>
@@ -56,6 +54,8 @@
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
+#include <gtest/gtest.h>
+
using grpc::testing::EchoRequest;
using grpc::testing::EchoResponse;
using std::chrono::system_clock;
diff --git a/test/cpp/end2end/test_service_impl.cc b/test/cpp/end2end/test_service_impl.cc
index b473dd1f52..5411b35f16 100644
--- a/test/cpp/end2end/test_service_impl.cc
+++ b/test/cpp/end2end/test_service_impl.cc
@@ -40,11 +40,11 @@
#include <grpc++/server_context.h>
#include <grpc/support/log.h>
-#include <gtest/gtest.h>
-
#include "src/proto/grpc/testing/echo.grpc.pb.h"
#include "test/cpp/util/string_ref_helper.h"
+#include <gtest/gtest.h>
+
using std::chrono::system_clock;
namespace grpc {
diff --git a/test/cpp/end2end/thread_stress_test.cc b/test/cpp/end2end/thread_stress_test.cc
index d353f9894b..defa7894ff 100644
--- a/test/cpp/end2end/thread_stress_test.cc
+++ b/test/cpp/end2end/thread_stress_test.cc
@@ -43,7 +43,6 @@
#include <grpc/grpc.h>
#include <grpc/support/thd.h>
#include <grpc/support/time.h>
-#include <gtest/gtest.h>
#include "src/core/lib/surface/api_trace.h"
#include "src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h"
@@ -51,6 +50,8 @@
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
+#include <gtest/gtest.h>
+
using grpc::testing::EchoRequest;
using grpc::testing::EchoResponse;
using std::chrono::system_clock;
diff --git a/test/cpp/microbenchmarks/BUILD b/test/cpp/microbenchmarks/BUILD
index 208ac6d794..3a968a020a 100644
--- a/test/cpp/microbenchmarks/BUILD
+++ b/test/cpp/microbenchmarks/BUILD
@@ -29,14 +29,17 @@
licenses(["notice"]) # 3-clause BSD
-cc_test(
+load("//bazel:grpc_build_system.bzl", "grpc_cc_test", "grpc_cc_library")
+
+grpc_cc_test(
name = "noop-benchmark",
srcs = ["noop-benchmark.cc"],
- linkopts = ["-pthread"],
- deps = ["//external:benchmark"],
+ external_deps = [
+ "benchmark",
+ ],
)
-cc_library(
+grpc_cc_library(
name = "helpers",
srcs = ["helpers.cc"],
hdrs = [
@@ -44,64 +47,68 @@ cc_library(
"fullstack_fixtures.h",
"helpers.h",
],
- linkopts = ["-pthread"],
deps = [
"//:grpc++",
- "//external:benchmark",
"//src/proto/grpc/testing:echo_proto",
"//test/core/util:grpc_test_util",
],
+ external_deps = [
+ "benchmark",
+ ],
)
-cc_test(
+grpc_cc_test(
name = "bm_closure",
srcs = ["bm_closure.cc"],
deps = [":helpers"],
)
-cc_test(
+grpc_cc_test(
name = "bm_cq",
srcs = ["bm_cq.cc"],
deps = [":helpers"],
)
-cc_test(
+grpc_cc_test(
name = "bm_cq_multiple_threads",
srcs = ["bm_cq_multiple_threads.cc"],
deps = [":helpers"],
)
-cc_test(
+grpc_cc_test(
name = "bm_error",
srcs = ["bm_error.cc"],
deps = [":helpers"],
)
-cc_test(
+grpc_cc_test(
name = "bm_fullstack_streaming_ping_pong",
srcs = ["bm_fullstack_streaming_ping_pong.cc"],
deps = [":helpers"],
)
-cc_test(
+grpc_cc_test(
name = "bm_fullstack_streaming_pump",
srcs = ["bm_fullstack_streaming_pump.cc"],
deps = [":helpers"],
)
-cc_test(
+grpc_cc_test(
name = "bm_fullstack_trickle",
srcs = ["bm_fullstack_trickle.cc"],
- deps = [":helpers", "//external:gflags"],
+ deps = [":helpers"],
+ external_deps = [
+ "gflags",
+ ],
)
-cc_test(
+grpc_cc_test(
name = "bm_fullstack_unary_ping_pong",
srcs = ["bm_fullstack_unary_ping_pong.cc"],
deps = [":helpers"],
)
-cc_test(
+grpc_cc_test(
name = "bm_metadata",
srcs = ["bm_metadata.cc"],
deps = [":helpers"],
diff --git a/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc b/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc
index 0d267da723..704f255d5f 100644
--- a/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc
+++ b/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc
@@ -81,10 +81,16 @@ static void cq_done_cb(grpc_exec_ctx* exec_ctx, void* done_arg,
gpr_free(cq_completion);
}
-/* Queues a completion tag. ZERO polling overhead */
+/* Queues a completion tag if deadline is > 0.
+ * Does nothing if deadline is 0 (i.e gpr_time_0(GPR_CLOCK_MONOTONIC)) */
static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* ps,
grpc_pollset_worker** worker, gpr_timespec now,
gpr_timespec deadline) {
+ if (gpr_time_cmp(deadline, gpr_time_0(GPR_CLOCK_MONOTONIC)) == 0) {
+ gpr_log(GPR_ERROR, "no-op");
+ return GRPC_ERROR_NONE;
+ }
+
gpr_mu_unlock(&ps->mu);
grpc_cq_begin_op(g_cq, g_tag);
grpc_cq_end_op(exec_ctx, g_cq, g_tag, GRPC_ERROR_NONE, cq_done_cb, NULL,
@@ -115,6 +121,14 @@ static void setup() {
static void teardown() {
grpc_completion_queue_shutdown(g_cq);
+
+ /* Drain any events */
+ gpr_timespec deadline = gpr_time_0(GPR_CLOCK_MONOTONIC);
+ while (grpc_completion_queue_next(g_cq, deadline, NULL).type !=
+ GRPC_QUEUE_SHUTDOWN) {
+ /* Do nothing */
+ }
+
grpc_completion_queue_destroy(g_cq);
}
diff --git a/test/cpp/microbenchmarks/fullstack_fixtures.h b/test/cpp/microbenchmarks/fullstack_fixtures.h
index 98aca1c346..aa71c2ae3f 100644
--- a/test/cpp/microbenchmarks/fullstack_fixtures.h
+++ b/test/cpp/microbenchmarks/fullstack_fixtures.h
@@ -100,6 +100,12 @@ class FullstackFixture : public BaseFixture {
}
}
+ void AddToLabel(std::ostream& out, benchmark::State& state) {
+ BaseFixture::AddToLabel(out, state);
+ out << " polls/iter:"
+ << (double)grpc_get_cq_poll_num(this->cq()->cq()) / state.iterations();
+ }
+
ServerCompletionQueue* cq() { return cq_.get(); }
std::shared_ptr<Channel> channel() { return channel_; }
@@ -212,6 +218,12 @@ class EndpointPairFixture : public BaseFixture {
}
}
+ void AddToLabel(std::ostream& out, benchmark::State& state) {
+ BaseFixture::AddToLabel(out, state);
+ out << " polls/iter:"
+ << (double)grpc_get_cq_poll_num(this->cq()->cq()) / state.iterations();
+ }
+
ServerCompletionQueue* cq() { return cq_.get(); }
std::shared_ptr<Channel> channel() { return channel_; }
@@ -245,7 +257,7 @@ class InProcessCHTTP2 : public EndpointPairFixture {
void AddToLabel(std::ostream& out, benchmark::State& state) {
EndpointPairFixture::AddToLabel(out, state);
out << " writes/iter:"
- << ((double)stats_.num_writes / (double)state.iterations());
+ << (double)stats_.num_writes / (double)state.iterations();
}
private:
diff --git a/test/cpp/qps/BUILD b/test/cpp/qps/BUILD
index 6492b63ec3..c6a1fd2fce 100644
--- a/test/cpp/qps/BUILD
+++ b/test/cpp/qps/BUILD
@@ -29,14 +29,17 @@
licenses(["notice"]) # 3-clause BSD
-cc_library(
+load("//bazel:grpc_build_system.bzl", "grpc_cc_test", "grpc_cc_library", "grpc_cc_binary")
+
+grpc_cc_library(
name = "parse_json",
srcs = ["parse_json.cc"],
hdrs = ["parse_json.h"],
deps = ["//:grpc++"],
+ external_deps = ["protobuf"],
)
-cc_library(
+grpc_cc_library(
name = "qps_worker_impl",
srcs = [
"client_async.cc",
@@ -56,7 +59,6 @@ cc_library(
":usage_timer",
"//:grpc",
"//:grpc++",
- "//external:gtest",
"//src/proto/grpc/testing:control_proto",
"//src/proto/grpc/testing:payloads_proto",
"//src/proto/grpc/testing:services_proto",
@@ -65,9 +67,12 @@ cc_library(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
+ external_deps = [
+ "gtest",
+ ],
)
-cc_library(
+grpc_cc_library(
name = "driver_impl",
srcs = [
"driver.cc",
@@ -90,7 +95,7 @@ cc_library(
],
)
-cc_library(
+grpc_cc_library(
name = "benchmark_config",
srcs = [
"benchmark_config.cc",
@@ -102,12 +107,14 @@ cc_library(
":driver_impl",
":histogram",
"//:grpc++",
- "//external:gflags",
"//src/proto/grpc/testing:control_proto",
],
+ external_deps = [
+ "gflags",
+ ],
)
-cc_library(
+grpc_cc_library(
name = "histogram",
hdrs = [
"histogram.h",
@@ -116,13 +123,13 @@ cc_library(
deps = ["//:gpr"],
)
-cc_library(
+grpc_cc_library(
name = "interarrival",
hdrs = ["interarrival.h"],
deps = ["//:grpc++"],
)
-cc_binary(
+grpc_cc_binary(
name = "json_run_localhost",
srcs = ["json_run_localhost.cc"],
deps = [
@@ -133,7 +140,7 @@ cc_binary(
],
)
-cc_test(
+grpc_cc_test(
name = "qps_interarrival_test",
srcs = ["qps_interarrival_test.cc"],
deps = [
@@ -142,18 +149,20 @@ cc_test(
],
)
-cc_binary(
+grpc_cc_binary(
name = "qps_json_driver",
srcs = ["qps_json_driver.cc"],
deps = [
":benchmark_config",
":driver_impl",
"//:grpc++",
- "//external:gflags",
+ ],
+ external_deps = [
+ "gflags",
],
)
-cc_test(
+grpc_cc_test(
name = "qps_openloop_test",
srcs = ["qps_openloop_test.cc"],
deps = [
@@ -163,7 +172,7 @@ cc_test(
],
)
-cc_test(
+grpc_cc_test(
name = "secure_sync_unary_ping_pong_test",
srcs = ["secure_sync_unary_ping_pong_test.cc"],
deps = [
@@ -173,14 +182,14 @@ cc_test(
],
)
-cc_library(
+grpc_cc_library(
name = "usage_timer",
srcs = ["usage_timer.cc"],
hdrs = ["usage_timer.h"],
deps = ["//:gpr"],
)
-cc_binary(
+grpc_cc_binary(
name = "qps_worker",
srcs = ["worker.cc"],
deps = [
diff --git a/test/cpp/qps/client.h b/test/cpp/qps/client.h
index c3197eb622..5ae6b54f89 100644
--- a/test/cpp/qps/client.h
+++ b/test/cpp/qps/client.h
@@ -46,6 +46,7 @@
#include <grpc/support/log.h>
#include <grpc/support/time.h>
+#include "src/core/lib/surface/completion_queue.h"
#include "src/proto/grpc/testing/payloads.pb.h"
#include "src/proto/grpc/testing/services.grpc.pb.h"
@@ -150,7 +151,8 @@ class Client {
Client()
: timer_(new UsageTimer),
interarrival_timer_(),
- started_requests_(false) {
+ started_requests_(false),
+ last_reset_poll_count_(0) {
gpr_event_init(&start_requests_);
}
virtual ~Client() {}
@@ -162,6 +164,8 @@ class Client {
MaybeStartRequests();
+ int cur_poll_count = GetPollCount();
+ int poll_count = cur_poll_count - last_reset_poll_count_;
if (reset) {
std::vector<Histogram> to_merge(threads_.size());
std::vector<StatusHistogram> to_merge_status(threads_.size());
@@ -176,6 +180,7 @@ class Client {
MergeStatusHistogram(to_merge_status[i], &statuses);
}
timer_result = timer->Mark();
+ last_reset_poll_count_ = cur_poll_count;
} else {
// merge snapshots of each thread histogram
for (size_t i = 0; i < threads_.size(); i++) {
@@ -195,6 +200,7 @@ class Client {
stats.set_time_elapsed(timer_result.wall);
stats.set_time_system(timer_result.system);
stats.set_time_user(timer_result.user);
+ stats.set_cq_poll_count(poll_count);
return stats;
}
@@ -209,6 +215,11 @@ class Client {
}
}
+ virtual int GetPollCount() {
+ // For sync client.
+ return 0;
+ }
+
protected:
bool closed_loop_;
gpr_atm thread_pool_done_;
@@ -351,6 +362,8 @@ class Client {
gpr_event start_requests_;
bool started_requests_;
+ int last_reset_poll_count_;
+
void MaybeStartRequests() {
if (!started_requests_) {
started_requests_ = true;
diff --git a/test/cpp/qps/client_async.cc b/test/cpp/qps/client_async.cc
index 82c3356f02..6b8f736813 100644
--- a/test/cpp/qps/client_async.cc
+++ b/test/cpp/qps/client_async.cc
@@ -205,6 +205,14 @@ class AsyncClient : public ClientImpl<StubType, RequestType> {
}
}
+ int GetPollCount() override {
+ int count = 0;
+ for (auto cq = cli_cqs_.begin(); cq != cli_cqs_.end(); cq++) {
+ count += grpc_get_cq_poll_num((*cq)->cq());
+ }
+ return count;
+ }
+
protected:
const int num_async_threads_;
diff --git a/test/cpp/qps/client_sync.cc b/test/cpp/qps/client_sync.cc
index 9075033bd4..f35713280a 100644
--- a/test/cpp/qps/client_sync.cc
+++ b/test/cpp/qps/client_sync.cc
@@ -48,7 +48,6 @@
#include <grpc/support/host_port.h>
#include <grpc/support/log.h>
#include <grpc/support/time.h>
-#include <gtest/gtest.h>
#include "src/core/lib/profiling/timers.h"
#include "src/proto/grpc/testing/services.grpc.pb.h"
diff --git a/test/cpp/qps/driver.cc b/test/cpp/qps/driver.cc
index 74fe3662c1..ace5028876 100644
--- a/test/cpp/qps/driver.cc
+++ b/test/cpp/qps/driver.cc
@@ -112,6 +112,8 @@ static deque<string> get_workers(const string& env_name) {
static double WallTime(ClientStats s) { return s.time_elapsed(); }
static double SystemTime(ClientStats s) { return s.time_system(); }
static double UserTime(ClientStats s) { return s.time_user(); }
+static double CliPollCount(ClientStats s) { return s.cq_poll_count(); }
+static double SvrPollCount(ServerStats s) { return s.cq_poll_count(); }
static double ServerWallTime(ServerStats s) { return s.time_elapsed(); }
static double ServerSystemTime(ServerStats s) { return s.time_system(); }
static double ServerUserTime(ServerStats s) { return s.time_user(); }
@@ -180,6 +182,11 @@ static void postprocess_scenario_result(ScenarioResult* result) {
result->mutable_summary()->set_failed_requests_per_second(failures /
time_estimate);
}
+
+ result->mutable_summary()->set_client_polls_per_request(
+ sum(result->client_stats(), CliPollCount) / histogram.Count());
+ result->mutable_summary()->set_server_polls_per_request(
+ sum(result->server_stats(), SvrPollCount) / histogram.Count());
}
std::unique_ptr<ScenarioResult> RunScenario(
diff --git a/test/cpp/qps/qps_json_driver.cc b/test/cpp/qps/qps_json_driver.cc
index a906137474..f00f771ea0 100644
--- a/test/cpp/qps/qps_json_driver.cc
+++ b/test/cpp/qps/qps_json_driver.cc
@@ -94,6 +94,7 @@ static std::unique_ptr<ScenarioResult> RunAndReport(const Scenario& scenario,
GetReporter()->ReportLatency(*result);
GetReporter()->ReportTimes(*result);
GetReporter()->ReportCpuUsage(*result);
+ GetReporter()->ReportPollCount(*result);
for (int i = 0; *success && i < result->client_success_size(); i++) {
*success = result->client_success(i);
diff --git a/test/cpp/qps/report.cc b/test/cpp/qps/report.cc
index a9130bf5d4..8bb4c9a3a5 100644
--- a/test/cpp/qps/report.cc
+++ b/test/cpp/qps/report.cc
@@ -80,6 +80,12 @@ void CompositeReporter::ReportCpuUsage(const ScenarioResult& result) {
}
}
+void CompositeReporter::ReportPollCount(const ScenarioResult& result) {
+ for (size_t i = 0; i < reporters_.size(); ++i) {
+ reporters_[i]->ReportPollCount(result);
+ }
+}
+
void GprLogReporter::ReportQPS(const ScenarioResult& result) {
gpr_log(GPR_INFO, "QPS: %.1f", result.summary().qps());
if (result.summary().failed_requests_per_second() > 0) {
@@ -121,6 +127,13 @@ void GprLogReporter::ReportCpuUsage(const ScenarioResult& result) {
result.summary().server_cpu_usage());
}
+void GprLogReporter::ReportPollCount(const ScenarioResult& result) {
+ gpr_log(GPR_INFO, "Client Polls per Request: %.2f",
+ result.summary().client_polls_per_request());
+ gpr_log(GPR_INFO, "Server Polls per Request: %.2f",
+ result.summary().server_polls_per_request());
+}
+
void JsonReporter::ReportQPS(const ScenarioResult& result) {
grpc::string json_string =
SerializeJson(result, "type.googleapis.com/grpc.testing.ScenarioResult");
@@ -145,6 +158,10 @@ void JsonReporter::ReportCpuUsage(const ScenarioResult& result) {
// NOP - all reporting is handled by ReportQPS.
}
+void JsonReporter::ReportPollCount(const ScenarioResult& result) {
+ // NOP - all reporting is handled by ReportQPS.
+}
+
void RpcReporter::ReportQPS(const ScenarioResult& result) {
grpc::ClientContext context;
grpc::Status status;
@@ -177,5 +194,9 @@ void RpcReporter::ReportCpuUsage(const ScenarioResult& result) {
// NOP - all reporting is handled by ReportQPS.
}
+void RpcReporter::ReportPollCount(const ScenarioResult& result) {
+ // NOP - all reporting is handled by ReportQPS.
+}
+
} // namespace testing
} // namespace grpc
diff --git a/test/cpp/qps/report.h b/test/cpp/qps/report.h
index 1749be98c6..621fa7cb00 100644
--- a/test/cpp/qps/report.h
+++ b/test/cpp/qps/report.h
@@ -76,6 +76,9 @@ class Reporter {
/** Reports server cpu usage. */
virtual void ReportCpuUsage(const ScenarioResult& result) = 0;
+ /** Reports client and server poll usage inside completion queue. */
+ virtual void ReportPollCount(const ScenarioResult& result) = 0;
+
private:
const string name_;
};
@@ -93,6 +96,7 @@ class CompositeReporter : public Reporter {
void ReportLatency(const ScenarioResult& result) override;
void ReportTimes(const ScenarioResult& result) override;
void ReportCpuUsage(const ScenarioResult& result) override;
+ void ReportPollCount(const ScenarioResult& result) override;
private:
std::vector<std::unique_ptr<Reporter> > reporters_;
@@ -109,6 +113,7 @@ class GprLogReporter : public Reporter {
void ReportLatency(const ScenarioResult& result) override;
void ReportTimes(const ScenarioResult& result) override;
void ReportCpuUsage(const ScenarioResult& result) override;
+ void ReportPollCount(const ScenarioResult& result) override;
};
/** Dumps the report to a JSON file. */
@@ -123,6 +128,7 @@ class JsonReporter : public Reporter {
void ReportLatency(const ScenarioResult& result) override;
void ReportTimes(const ScenarioResult& result) override;
void ReportCpuUsage(const ScenarioResult& result) override;
+ void ReportPollCount(const ScenarioResult& result) override;
const string report_file_;
};
@@ -138,6 +144,7 @@ class RpcReporter : public Reporter {
void ReportLatency(const ScenarioResult& result) override;
void ReportTimes(const ScenarioResult& result) override;
void ReportCpuUsage(const ScenarioResult& result) override;
+ void ReportPollCount(const ScenarioResult& result) override;
std::unique_ptr<ReportQpsScenarioService::Stub> stub_;
};
diff --git a/test/cpp/qps/server.h b/test/cpp/qps/server.h
index 8fbf37a095..a03dd1a695 100644
--- a/test/cpp/qps/server.h
+++ b/test/cpp/qps/server.h
@@ -38,6 +38,7 @@
#include <grpc/support/cpu.h>
#include <vector>
+#include "src/core/lib/surface/completion_queue.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"
@@ -49,7 +50,8 @@ namespace testing {
class Server {
public:
- explicit Server(const ServerConfig& config) : timer_(new UsageTimer) {
+ explicit Server(const ServerConfig& config)
+ : timer_(new UsageTimer), last_reset_poll_count_(0) {
cores_ = gpr_cpu_num_cores();
if (config.port()) {
port_ = config.port();
@@ -62,10 +64,13 @@ class Server {
ServerStats Mark(bool reset) {
UsageTimer::Result timer_result;
+ int cur_poll_count = GetPollCount();
+ int poll_count = cur_poll_count - last_reset_poll_count_;
if (reset) {
std::unique_ptr<UsageTimer> timer(new UsageTimer);
timer.swap(timer_);
timer_result = timer->Mark();
+ last_reset_poll_count_ = cur_poll_count;
} else {
timer_result = timer_->Mark();
}
@@ -76,6 +81,7 @@ class Server {
stats.set_time_user(timer_result.user);
stats.set_total_cpu_time(timer_result.total_cpu_time);
stats.set_idle_cpu_time(timer_result.idle_cpu_time);
+ stats.set_cq_poll_count(poll_count);
return stats;
}
@@ -106,10 +112,16 @@ class Server {
}
}
+ virtual int GetPollCount() {
+ // For sync server.
+ return 0;
+ }
+
private:
int port_;
int cores_;
std::unique_ptr<UsageTimer> timer_;
+ int last_reset_poll_count_;
};
std::unique_ptr<Server> CreateSynchronousServer(const ServerConfig& config);
diff --git a/test/cpp/qps/server_async.cc b/test/cpp/qps/server_async.cc
index 84f1579c2f..3403ffd326 100644
--- a/test/cpp/qps/server_async.cc
+++ b/test/cpp/qps/server_async.cc
@@ -186,6 +186,14 @@ class AsyncQpsServerTest final : public grpc::testing::Server {
shutdown_thread.join();
}
+ int GetPollCount() override {
+ int count = 0;
+ for (auto cq = srv_cqs_.begin(); cq != srv_cqs_.end(); cq++) {
+ count += grpc_get_cq_poll_num((*cq)->cq());
+ }
+ return count;
+ }
+
private:
void ShutdownThreadFunc() {
// TODO (vpai): Remove this deadline and allow Shutdown to finish properly
diff --git a/test/cpp/util/BUILD b/test/cpp/util/BUILD
index 9dde22b4d1..453e9b6c0f 100644
--- a/test/cpp/util/BUILD
+++ b/test/cpp/util/BUILD
@@ -29,16 +29,20 @@
licenses(["notice"]) # 3-clause BSD
+load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_binary")
+
+package(default_visibility = ["//visibility:public"])
+
# The following builds a shared-object to confirm that grpc++_unsecure
# builds properly. Build-only is sufficient here
-cc_binary(
+grpc_cc_binary(
name = "testso.so",
srcs = [],
linkshared = 1,
deps = ["//:grpc++_unsecure"],
)
-cc_library(
+grpc_cc_library(
name = "test_config",
srcs = [
"test_config_cc.cc",
@@ -46,14 +50,15 @@ cc_library(
hdrs = [
"test_config.h",
],
- visibility = ["//test:__subpackages__"],
+ external_deps = [
+ "gflags",
+ ],
deps = [
"//:gpr",
- "//external:gflags",
],
)
-cc_library(
+grpc_cc_library(
name = "grpc++_proto_reflection_desc_db",
srcs = [
"proto_reflection_descriptor_database.cc",
@@ -61,14 +66,13 @@ cc_library(
hdrs = [
"proto_reflection_descriptor_database.h",
],
- visibility = ["//test:__subpackages__"],
deps = [
"//:grpc++_config_proto",
"//src/proto/grpc/reflection/v1alpha:reflection_proto",
],
)
-cc_library(
+grpc_cc_library(
name = "test_util",
srcs = [
"byte_buffer_proto_helper.cc",
@@ -84,12 +88,57 @@ cc_library(
"subprocess.h",
"test_credentials_provider.h",
],
- visibility = ["//test:__subpackages__"],
deps = [
"//:grpc++",
"//test/core/end2end:ssl_test_data",
"//test/core/util:gpr_test_util",
],
+ external_deps = [
+ "protobuf",
+ ],
+)
+
+grpc_cc_library(
+ name = "grpc_cli_libs",
+ srcs = [
+ "cli_call.cc",
+ "cli_credentials.cc",
+ "grpc_tool.cc",
+ "proto_file_parser.cc",
+ "service_describer.cc",
+ ],
+ hdrs = [
+ "cli_call.h",
+ "cli_credentials.h",
+ "config_grpc_cli.h",
+ "grpc_tool.h",
+ "proto_file_parser.h",
+ "service_describer.h",
+ ],
+ deps = [
+ "//:grpc++",
+ "//src/proto/grpc/reflection/v1alpha:reflection_proto",
+ ":grpc++_proto_reflection_desc_db",
+ ],
+ external_deps = [
+ "gflags",
+ "protobuf",
+ "protobuf_clib",
+ ],
+)
+
+grpc_cc_library(
+ name = "metrics_server_lib",
+ srcs = [
+ "metrics_server.cc",
+ ],
+ hdrs = [
+ "metrics_server.h",
+ ],
+ deps = [
+ "//src/proto/grpc/testing:metrics_proto",
+ "//:grpc++",
+ ],
)
cc_test(