aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/cpp')
-rw-r--r--test/cpp/grpclb/grpclb_test.cc6
-rw-r--r--test/cpp/interop/BUILD90
-rw-r--r--test/cpp/microbenchmarks/bm_call_create.cc169
3 files changed, 257 insertions, 8 deletions
diff --git a/test/cpp/grpclb/grpclb_test.cc b/test/cpp/grpclb/grpclb_test.cc
index 997a8391eb..a002c7f77d 100644
--- a/test/cpp/grpclb/grpclb_test.cc
+++ b/test/cpp/grpclb/grpclb_test.cc
@@ -310,7 +310,7 @@ static void start_lb_server(server_fixture *sf, int *ports, size_t nports,
gpr_log(GPR_INFO, "LB Server[%s](%s) after tag 204. All done. LB server out",
sf->servers_hostport, sf->balancer_name);
- grpc_call_destroy(s);
+ grpc_call_unref(s);
cq_verifier_destroy(cqv);
@@ -457,7 +457,7 @@ static void start_backend_server(server_fixture *sf) {
gpr_log(GPR_INFO, "Server[%s] DONE. After servicing %d calls",
sf->servers_hostport, sf->num_calls_serviced);
- grpc_call_destroy(s);
+ grpc_call_unref(s);
cq_verifier_destroy(cqv);
grpc_metadata_array_destroy(&request_metadata_recv);
grpc_call_details_destroy(&call_details);
@@ -557,7 +557,7 @@ static void perform_request(client_fixture *cf) {
peer = grpc_call_get_peer(c);
gpr_log(GPR_INFO, "Client DONE WITH SERVER %s ", peer);
- grpc_call_destroy(c);
+ grpc_call_unref(c);
cq_verify_empty_timeout(cqv, 1 /* seconds */);
cq_verifier_destroy(cqv);
diff --git a/test/cpp/interop/BUILD b/test/cpp/interop/BUILD
new file mode 100644
index 0000000000..1a3e8d916f
--- /dev/null
+++ b/test/cpp/interop/BUILD
@@ -0,0 +1,90 @@
+# Copyright 2017, Google Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+licenses(["notice"]) # 3-clause BSD
+
+cc_library(
+ name = "server_helper_lib",
+ srcs = [
+ "server_helper.cc",
+ ],
+ hdrs = [
+ "server_helper.h",
+ ],
+ deps = [
+ "//test/cpp/util:test_util",
+ "//external:gflags",
+ ],
+)
+
+cc_binary(
+ name = "interop_server",
+ srcs = [
+ "interop_server.cc",
+ "interop_server_bootstrap.cc",
+ ],
+ deps = [
+ ":server_helper_lib",
+ "//:grpc++",
+ "//src/proto/grpc/testing:empty_proto",
+ "//src/proto/grpc/testing:messages_proto",
+ "//src/proto/grpc/testing:test_proto",
+ "//test/cpp/util:test_config",
+ ],
+)
+
+cc_library(
+ name = "client_helper_lib",
+ srcs = [
+ "client_helper.cc",
+ "interop_client.cc",
+ ],
+ hdrs = [
+ "client_helper.h",
+ "interop_client.h",
+ ],
+ deps = [
+ "//test/cpp/util:test_util",
+ "//src/proto/grpc/testing:empty_proto",
+ "//src/proto/grpc/testing:messages_proto",
+ "//src/proto/grpc/testing:test_proto",
+ "//test/core/security:oauth2_utils",
+ "//test/cpp/util:test_config",
+ ],
+)
+
+cc_binary(
+ name = "interop_client",
+ srcs = [
+ "client.cc",
+ ],
+ deps = [
+ ":client_helper_lib",
+ ],
+)
diff --git a/test/cpp/microbenchmarks/bm_call_create.cc b/test/cpp/microbenchmarks/bm_call_create.cc
index 8373eead61..18b7566bef 100644
--- a/test/cpp/microbenchmarks/bm_call_create.cc
+++ b/test/cpp/microbenchmarks/bm_call_create.cc
@@ -124,7 +124,7 @@ static void BM_CallCreateDestroy(benchmark::State &state) {
void *method_hdl =
grpc_channel_register_call(fixture.channel(), "/foo/bar", NULL, NULL);
while (state.KeepRunning()) {
- grpc_call_destroy(grpc_channel_create_registered_call(
+ grpc_call_unref(grpc_channel_create_registered_call(
fixture.channel(), NULL, GRPC_PROPAGATE_DEFAULTS, cq, method_hdl,
deadline, NULL));
}
@@ -166,6 +166,165 @@ static void BM_LameChannelCallCreateCpp(benchmark::State &state) {
}
BENCHMARK(BM_LameChannelCallCreateCpp);
+static void do_nothing(void *ignored) {}
+
+static void BM_LameChannelCallCreateCore(benchmark::State &state) {
+ TrackCounters track_counters;
+
+ grpc_channel *channel;
+ grpc_completion_queue *cq;
+ grpc_metadata_array initial_metadata_recv;
+ grpc_metadata_array trailing_metadata_recv;
+ grpc_byte_buffer *response_payload_recv = NULL;
+ grpc_status_code status;
+ grpc_slice details;
+ grpc::testing::EchoRequest send_request;
+ grpc_slice send_request_slice =
+ grpc_slice_new(&send_request, sizeof(send_request), do_nothing);
+
+ channel = grpc_lame_client_channel_create(
+ "localhost:1234", GRPC_STATUS_UNAUTHENTICATED, "blah");
+ cq = grpc_completion_queue_create_for_next(NULL);
+ void *rc = grpc_channel_register_call(
+ channel, "/grpc.testing.EchoTestService/Echo", NULL, NULL);
+ while (state.KeepRunning()) {
+ GPR_TIMER_SCOPE("BenchmarkCycle", 0);
+ grpc_call *call = grpc_channel_create_registered_call(
+ channel, NULL, GRPC_PROPAGATE_DEFAULTS, cq, rc,
+ gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
+ grpc_metadata_array_init(&initial_metadata_recv);
+ grpc_metadata_array_init(&trailing_metadata_recv);
+ grpc_byte_buffer *request_payload_send =
+ grpc_raw_byte_buffer_create(&send_request_slice, 1);
+
+ // Fill in call ops
+ grpc_op ops[6];
+ memset(ops, 0, sizeof(ops));
+ grpc_op *op = ops;
+ op->op = GRPC_OP_SEND_INITIAL_METADATA;
+ op->data.send_initial_metadata.count = 0;
+ op++;
+ op->op = GRPC_OP_SEND_MESSAGE;
+ op->data.send_message.send_message = request_payload_send;
+ op++;
+ op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
+ op++;
+ op->op = GRPC_OP_RECV_INITIAL_METADATA;
+ op->data.recv_initial_metadata.recv_initial_metadata =
+ &initial_metadata_recv;
+ op++;
+ op->op = GRPC_OP_RECV_MESSAGE;
+ op->data.recv_message.recv_message = &response_payload_recv;
+ op++;
+ op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
+ op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
+ op->data.recv_status_on_client.status = &status;
+ op->data.recv_status_on_client.status_details = &details;
+ op++;
+
+ GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(call, ops,
+ (size_t)(op - ops),
+ (void *)1, NULL));
+ grpc_event ev = grpc_completion_queue_next(
+ cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
+ GPR_ASSERT(ev.type != GRPC_QUEUE_SHUTDOWN);
+ GPR_ASSERT(ev.success != 0);
+ grpc_call_unref(call);
+ grpc_byte_buffer_destroy(request_payload_send);
+ grpc_byte_buffer_destroy(response_payload_recv);
+ grpc_metadata_array_destroy(&initial_metadata_recv);
+ grpc_metadata_array_destroy(&trailing_metadata_recv);
+ }
+ grpc_channel_destroy(channel);
+ grpc_completion_queue_destroy(cq);
+ grpc_slice_unref(send_request_slice);
+ track_counters.Finish(state);
+}
+BENCHMARK(BM_LameChannelCallCreateCore);
+
+static void BM_LameChannelCallCreateCoreSeparateBatch(benchmark::State &state) {
+ TrackCounters track_counters;
+
+ grpc_channel *channel;
+ grpc_completion_queue *cq;
+ grpc_metadata_array initial_metadata_recv;
+ grpc_metadata_array trailing_metadata_recv;
+ grpc_byte_buffer *response_payload_recv = NULL;
+ grpc_status_code status;
+ grpc_slice details;
+ grpc::testing::EchoRequest send_request;
+ grpc_slice send_request_slice =
+ grpc_slice_new(&send_request, sizeof(send_request), do_nothing);
+
+ channel = grpc_lame_client_channel_create(
+ "localhost:1234", GRPC_STATUS_UNAUTHENTICATED, "blah");
+ cq = grpc_completion_queue_create_for_next(NULL);
+ void *rc = grpc_channel_register_call(
+ channel, "/grpc.testing.EchoTestService/Echo", NULL, NULL);
+ while (state.KeepRunning()) {
+ GPR_TIMER_SCOPE("BenchmarkCycle", 0);
+ grpc_call *call = grpc_channel_create_registered_call(
+ channel, NULL, GRPC_PROPAGATE_DEFAULTS, cq, rc,
+ gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
+ grpc_metadata_array_init(&initial_metadata_recv);
+ grpc_metadata_array_init(&trailing_metadata_recv);
+ grpc_byte_buffer *request_payload_send =
+ grpc_raw_byte_buffer_create(&send_request_slice, 1);
+
+ // Fill in call ops
+ grpc_op ops[3];
+ memset(ops, 0, sizeof(ops));
+ grpc_op *op = ops;
+ op->op = GRPC_OP_SEND_INITIAL_METADATA;
+ op->data.send_initial_metadata.count = 0;
+ op++;
+ op->op = GRPC_OP_SEND_MESSAGE;
+ op->data.send_message.send_message = request_payload_send;
+ op++;
+ op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
+ op++;
+ GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(call, ops,
+ (size_t)(op - ops),
+ (void *)0, NULL));
+ memset(ops, 0, sizeof(ops));
+ op = ops;
+ op->op = GRPC_OP_RECV_INITIAL_METADATA;
+ op->data.recv_initial_metadata.recv_initial_metadata =
+ &initial_metadata_recv;
+ op++;
+ op->op = GRPC_OP_RECV_MESSAGE;
+ op->data.recv_message.recv_message = &response_payload_recv;
+ op++;
+ op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
+ op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
+ op->data.recv_status_on_client.status = &status;
+ op->data.recv_status_on_client.status_details = &details;
+ op++;
+
+ GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(call, ops,
+ (size_t)(op - ops),
+ (void *)1, NULL));
+ grpc_event ev = grpc_completion_queue_next(
+ cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
+ GPR_ASSERT(ev.type != GRPC_QUEUE_SHUTDOWN);
+ GPR_ASSERT(ev.success == 0);
+ ev = grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME),
+ NULL);
+ GPR_ASSERT(ev.type != GRPC_QUEUE_SHUTDOWN);
+ GPR_ASSERT(ev.success != 0);
+ grpc_call_unref(call);
+ grpc_byte_buffer_destroy(request_payload_send);
+ grpc_byte_buffer_destroy(response_payload_recv);
+ grpc_metadata_array_destroy(&initial_metadata_recv);
+ grpc_metadata_array_destroy(&trailing_metadata_recv);
+ }
+ grpc_channel_destroy(channel);
+ grpc_completion_queue_destroy(cq);
+ grpc_slice_unref(send_request_slice);
+ track_counters.Finish(state);
+}
+BENCHMARK(BM_LameChannelCallCreateCoreSeparateBatch);
+
static void FilterDestroy(grpc_exec_ctx *exec_ctx, void *arg,
grpc_error *error) {
gpr_free(arg);
@@ -560,7 +719,7 @@ static const grpc_channel_filter isolated_call_filter = {
GetPeer,
GetChannelInfo,
"isolated_call_filter"};
-}
+} // namespace isolated_call_filter
class IsolatedCallFixture : public TrackCounters {
public:
@@ -600,7 +759,7 @@ static void BM_IsolatedCall_NoOp(benchmark::State &state) {
grpc_channel_register_call(fixture.channel(), "/foo/bar", NULL, NULL);
while (state.KeepRunning()) {
GPR_TIMER_SCOPE("BenchmarkCycle", 0);
- grpc_call_destroy(grpc_channel_create_registered_call(
+ grpc_call_unref(grpc_channel_create_registered_call(
fixture.channel(), nullptr, GRPC_PROPAGATE_DEFAULTS, fixture.cq(),
method_hdl, deadline, NULL));
}
@@ -645,7 +804,7 @@ static void BM_IsolatedCall_Unary(benchmark::State &state) {
grpc_call_start_batch(call, ops, 6, tag(1), NULL);
grpc_completion_queue_next(fixture.cq(),
gpr_inf_future(GPR_CLOCK_MONOTONIC), NULL);
- grpc_call_destroy(call);
+ grpc_call_unref(call);
}
fixture.Finish(state);
grpc_metadata_array_destroy(&recv_initial_metadata);
@@ -686,7 +845,7 @@ static void BM_IsolatedCall_StreamingSend(benchmark::State &state) {
grpc_completion_queue_next(fixture.cq(),
gpr_inf_future(GPR_CLOCK_MONOTONIC), NULL);
}
- grpc_call_destroy(call);
+ grpc_call_unref(call);
fixture.Finish(state);
grpc_metadata_array_destroy(&recv_initial_metadata);
grpc_metadata_array_destroy(&recv_trailing_metadata);