aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorGravatar yang-g <yangg@google.com>2015-11-20 17:01:57 -0800
committerGravatar yang-g <yangg@google.com>2015-11-20 17:01:57 -0800
commit3ff9727a373e5e8819b9db288df99f8d7f68270e (patch)
treeaf8c81a2ffbb00977643a424a0ee9db48b08f6fe /test
parent71b962634eceacae336b1c706829e4ad9621b397 (diff)
parent4dd8f43970f59b062433c5bb48388a78c0c09984 (diff)
merge with head
Diffstat (limited to 'test')
-rw-r--r--test/core/client_config/lb_policies_test.c4
-rw-r--r--test/core/end2end/fixtures/proxy.c6
-rwxr-xr-xtest/core/end2end/gen_build_yaml.py14
-rw-r--r--test/core/end2end/tests/cancel_with_status.c3
-rw-r--r--test/core/end2end/tests/hpack_size.c446
-rw-r--r--test/core/end2end/tests/negative_deadline.c3
-rw-r--r--test/core/network_benchmarks/low_level_ping_pong.c8
-rw-r--r--test/core/security/credentials_test.c10
-rw-r--r--test/core/surface/byte_buffer_reader_test.c4
-rw-r--r--test/core/transport/chttp2/hpack_parser_test.c6
-rw-r--r--test/core/transport/chttp2/hpack_table_test.c27
-rw-r--r--test/core/util/test_tcp_server.c5
-rw-r--r--test/cpp/interop/metrics_client.cc103
-rw-r--r--test/cpp/interop/stress_interop_client.cc44
-rw-r--r--test/cpp/interop/stress_interop_client.h13
-rw-r--r--test/cpp/interop/stress_test.cc74
-rw-r--r--test/cpp/qps/async_streaming_ping_pong_test.cc1
-rw-r--r--test/cpp/qps/async_unary_ping_pong_test.cc1
-rw-r--r--test/cpp/qps/client.h46
-rw-r--r--test/cpp/qps/driver.cc2
-rw-r--r--test/cpp/qps/histogram.h8
-rw-r--r--test/cpp/qps/qps_driver.cc6
-rw-r--r--test/cpp/qps/qps_openloop_test.cc1
-rw-r--r--test/cpp/qps/qps_test.cc1
-rw-r--r--test/cpp/qps/qps_test_with_poll.cc1
-rw-r--r--test/cpp/qps/secure_sync_unary_ping_pong_test.cc1
-rw-r--r--test/cpp/qps/server_async.cc2
-rw-r--r--test/cpp/qps/server_sync.cc2
-rw-r--r--test/cpp/qps/sync_streaming_ping_pong_test.cc1
-rw-r--r--test/cpp/qps/sync_unary_ping_pong_test.cc1
-rw-r--r--test/cpp/util/metrics_server.cc119
-rw-r--r--test/cpp/util/metrics_server.h100
-rw-r--r--test/proto/benchmarks/control.proto24
-rw-r--r--test/proto/benchmarks/services.proto14
-rw-r--r--test/proto/benchmarks/stats.proto17
-rw-r--r--test/proto/metrics.proto56
36 files changed, 1067 insertions, 107 deletions
diff --git a/test/core/client_config/lb_policies_test.c b/test/core/client_config/lb_policies_test.c
index 0218b8f07f..5aa8140e08 100644
--- a/test/core/client_config/lb_policies_test.c
+++ b/test/core/client_config/lb_policies_test.c
@@ -269,8 +269,8 @@ int *perform_request(servers_fixture *f, grpc_channel *client,
memset(s_valid, 0, f->num_servers * sizeof(int));
c = grpc_channel_create_call(client, NULL, GRPC_PROPAGATE_DEFAULTS, f->cq,
- "/foo", "foo.test.google.fr", gpr_inf_future(GPR_CLOCK_REALTIME),
- NULL);
+ "/foo", "foo.test.google.fr",
+ gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
GPR_ASSERT(c);
completed_client = 0;
diff --git a/test/core/end2end/fixtures/proxy.c b/test/core/end2end/fixtures/proxy.c
index 1090ad667d..434e75dd15 100644
--- a/test/core/end2end/fixtures/proxy.c
+++ b/test/core/end2end/fixtures/proxy.c
@@ -146,7 +146,6 @@ void grpc_end2end_proxy_destroy(grpc_end2end_proxy *proxy) {
}
static void unrefpc(proxy_call *pc, const char *reason) {
- gpr_log(GPR_DEBUG, "PROXY UNREF %s", reason);
if (gpr_unref(&pc->refs)) {
grpc_call_destroy(pc->c2p);
grpc_call_destroy(pc->p2s);
@@ -158,10 +157,7 @@ static void unrefpc(proxy_call *pc, const char *reason) {
}
}
-static void refpc(proxy_call *pc, const char *reason) {
- gpr_log(GPR_DEBUG, "PROXY REF %s", reason);
- gpr_ref(&pc->refs);
-}
+static void refpc(proxy_call *pc, const char *reason) { gpr_ref(&pc->refs); }
static void on_c2p_sent_initial_metadata(void *arg, int success) {
proxy_call *pc = arg;
diff --git a/test/core/end2end/gen_build_yaml.py b/test/core/end2end/gen_build_yaml.py
index 38d3b2218a..33687b8cd4 100755
--- a/test/core/end2end/gen_build_yaml.py
+++ b/test/core/end2end/gen_build_yaml.py
@@ -37,8 +37,8 @@ import collections
import hashlib
-FixtureOptions = collections.namedtuple('FixtureOptions', 'fullstack includes_proxy dns_resolver secure platforms ci_mac')
-default_unsecure_fixture_options = FixtureOptions(True, False, True, False, ['windows', 'linux', 'mac', 'posix'], True)
+FixtureOptions = collections.namedtuple('FixtureOptions', 'fullstack includes_proxy dns_resolver secure platforms ci_mac tracing')
+default_unsecure_fixture_options = FixtureOptions(True, False, True, False, ['windows', 'linux', 'mac', 'posix'], True, False)
socketpair_unsecure_fixture_options = default_unsecure_fixture_options._replace(fullstack=False, dns_resolver=False)
default_secure_fixture_options = default_unsecure_fixture_options._replace(secure=True)
uds_fixture_options = default_unsecure_fixture_options._replace(dns_resolver=False, platforms=['linux', 'mac', 'posix'])
@@ -54,7 +54,7 @@ END2END_FIXTURES = {
'h2_proxy': default_unsecure_fixture_options._replace(includes_proxy=True, ci_mac=False),
'h2_sockpair_1byte': socketpair_unsecure_fixture_options._replace(ci_mac=False),
'h2_sockpair': socketpair_unsecure_fixture_options._replace(ci_mac=False),
- 'h2_sockpair+trace': socketpair_unsecure_fixture_options,
+ 'h2_sockpair+trace': socketpair_unsecure_fixture_options._replace(tracing=True),
'h2_ssl': default_secure_fixture_options,
'h2_ssl+poll': default_secure_fixture_options._replace(platforms=['linux']),
'h2_ssl_proxy': default_secure_fixture_options._replace(includes_proxy=True, ci_mac=False),
@@ -63,8 +63,8 @@ END2END_FIXTURES = {
'h2_uds': uds_fixture_options,
}
-TestOptions = collections.namedtuple('TestOptions', 'needs_fullstack needs_dns proxyable flaky secure')
-default_test_options = TestOptions(False, False, True, False, False)
+TestOptions = collections.namedtuple('TestOptions', 'needs_fullstack needs_dns proxyable flaky secure traceable')
+default_test_options = TestOptions(False, False, True, False, False, True)
connectivity_test_options = default_test_options._replace(needs_fullstack=True)
# maps test names to options
@@ -85,6 +85,7 @@ END2END_TESTS = {
'disappearing_server': connectivity_test_options,
'empty_batch': default_test_options,
'graceful_server_shutdown': default_test_options,
+ 'hpack_size': default_test_options._replace(proxyable=False, traceable=False),
'high_initial_seqno': default_test_options,
'invoke_large_request': default_test_options,
'large_metadata': default_test_options,
@@ -117,6 +118,9 @@ def compatible(f, t):
if not END2END_TESTS[t].proxyable:
if END2END_FIXTURES[f].includes_proxy:
return False
+ if not END2END_TESTS[t].traceable:
+ if END2END_FIXTURES[f].tracing:
+ return False
return True
diff --git a/test/core/end2end/tests/cancel_with_status.c b/test/core/end2end/tests/cancel_with_status.c
index eecfa83fa4..2005e5f881 100644
--- a/test/core/end2end/tests/cancel_with_status.c
+++ b/test/core/end2end/tests/cancel_with_status.c
@@ -166,7 +166,8 @@ static void simple_request_body(grpc_end2end_test_fixture f, size_t num_ops) {
cq_verifier_destroy(cqv);
}
-static void test_invoke_simple_request(grpc_end2end_test_config config, size_t num_ops) {
+static void test_invoke_simple_request(grpc_end2end_test_config config,
+ size_t num_ops) {
grpc_end2end_test_fixture f;
f = begin_test(config, "test_invoke_simple_request", NULL, NULL);
diff --git a/test/core/end2end/tests/hpack_size.c b/test/core/end2end/tests/hpack_size.c
new file mode 100644
index 0000000000..297ea8d542
--- /dev/null
+++ b/test/core/end2end/tests/hpack_size.c
@@ -0,0 +1,446 @@
+/*
+ *
+ * Copyright 2015, 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.
+ *
+ */
+
+#include "test/core/end2end/end2end_tests.h"
+
+#include <stdio.h>
+#include <string.h>
+
+#include <grpc/byte_buffer.h>
+#include <grpc/grpc.h>
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
+#include <grpc/support/time.h>
+#include <grpc/support/useful.h>
+
+#include "src/core/support/string.h"
+#include "test/core/end2end/cq_verifier.h"
+
+static void *tag(gpr_intptr t) { return (void *)t; }
+
+const char *hobbits[][2] = {{"Adaldrida", "Brandybuck"},
+ {"Adamanta", "Took"},
+ {"Adalgrim", "Took"},
+ {"Adelard", "Took"},
+ {"Amaranth", "Brandybuck"},
+ {"Andwise", "Roper"},
+ {"Angelica", "Baggins"},
+ {"Asphodel", "Burrows"},
+ {"Balbo", "Baggins"},
+ {"Bandobras", "Took"},
+ {"Belba", "Bolger"},
+ {"Bell", "Gamgee"},
+ {"Belladonna", "Baggins"},
+ {"Berylla", "Baggins"},
+ {"Bilbo", "Baggins"},
+ {"Bilbo", "Gardner"},
+ {"Bill", "Butcher"},
+ {"Bingo", "Baggins"},
+ {"Bodo", "Proudfoot"},
+ {"Bowman", "Cotton"},
+ {"Bungo", "Baggins"},
+ {"Camellia", "Sackville"},
+ {"Carl", "Cotton"},
+ {"Celandine", "Brandybuck"},
+ {"Chica", "Baggins"},
+ {"Daddy", "Twofoot"},
+ {"Daisy", "Boffin"},
+ {"Diamond", "Took"},
+ {"Dinodas", "Brandybuck"},
+ {"Doderic", "Brandybuck"},
+ {"Dodinas", "Brandybuck"},
+ {"Donnamira", "Boffin"},
+ {"Dora", "Baggins"},
+ {"Drogo", "Baggins"},
+ {"Dudo", "Baggins"},
+ {"Eglantine", "Took"},
+ {"Elanor", "Fairbairn"},
+ {"Elfstan", "Fairbairn"},
+ {"Esmeralda", "Brandybuck"},
+ {"Estella", "Brandybuck"},
+ {"Everard", "Took"},
+ {"Falco", "Chubb-Baggins"},
+ {"Faramir", "Took"},
+ {"Farmer", "Maggot"},
+ {"Fastolph", "Bolger"},
+ {"Ferdibrand", "Took"},
+ {"Ferdinand", "Took"},
+ {"Ferumbras", "Took"},
+ {"Ferumbras", "Took"},
+ {"Filibert", "Bolger"},
+ {"Firiel", "Fairbairn"},
+ {"Flambard", "Took"},
+ {"Folco", "Boffin"},
+ {"Fortinbras", "Took"},
+ {"Fortinbras", "Took"},
+ {"Fosco", "Baggins"},
+ {"Fredegar", "Bolger"},
+ {"Frodo", "Baggins"},
+ {"Frodo", "Gardner"},
+ {"Gerontius", "Took"},
+ {"Gilly", "Baggins"},
+ {"Goldilocks", "Took"},
+ {"Gorbadoc", "Brandybuck"},
+ {"Gorbulas", "Brandybuck"},
+ {"Gorhendad", "Brandybuck"},
+ {"Gormadoc", "Brandybuck"},
+ {"Griffo", "Boffin"},
+ {"Halfast", "Gamgee"},
+ {"Halfred", "Gamgee"},
+ {"Halfred", "Greenhand"},
+ {"Hanna", "Brandybuck"},
+ {"Hamfast", "Gamgee"},
+ {"Hamfast", "Gardner"},
+ {"Hamson", "Gamgee"},
+ {"Harding", "Gardner"},
+ {"Hilda", "Brandybuck"},
+ {"Hildibrand", "Took"},
+ {"Hildifons", "Took"},
+ {"Hildigard", "Took"},
+ {"Hildigrim", "Took"},
+ {"Hob", "Gammidge"},
+ {"Hob", "Hayward"},
+ {"Hobson", "Gamgee"},
+ {"Holfast", "Gardner"},
+ {"Holman", "Cotton"},
+ {"Holman", "Greenhand"},
+ {"Hugo", "Boffin"},
+ {"Hugo", "Bracegirdle"},
+ {"Ilberic", "Brandybuck"},
+ {"Isembard", "Took"},
+ {"Isembold", "Took"},
+ {"Isengar", "Took"},
+ {"Isengrim", "Took"},
+ {"Isengrim", "Took"},
+ {"Isumbras", "Took"},
+ {"Isumbras", "Took"},
+ {"Jolly", "Cotton"},
+ {"Lalia", "Took"},
+ {"Largo", "Baggins"},
+ {"Laura", "Baggins"},
+ {"Lily", "Goodbody"},
+ {"Lily", "Cotton"},
+ {"Linda", "Proudfoot"},
+ {"Lobelia", "Sackville-Baggins"},
+ {"Longo", "Baggins"},
+ {"Lotho", "Sackville-Baggins"},
+ {"Madoc", "Brandybuck"},
+ {"Malva", "Brandybuck"},
+ {"Marigold", "Cotton"},
+ {"Marmadas", "Brandybuck"},
+ {"Marmadoc", "Brandybuck"},
+ {"Marroc", "Brandybuck"},
+ {"May", "Gamgee"},
+ {"Melilot", "Brandybuck"},
+ {"Menegilda", "Brandybuck"},
+ {"Mentha", "Brandybuck"},
+ {"Meriadoc", "Brandybuck"},
+ {"Merimac", "Brandybuck"},
+ {"Merimas", "Brandybuck"},
+ {"Merry", "Gardner"},
+ {"Milo", "Burrows"},
+ {"Mimosa", "Baggins"},
+ {"Minto", "Burrows"},
+ {"Mirabella", "Brandybuck"},
+ {"Moro", "Burrows"},
+ {"Mosco", "Burrows"},
+ {"Mungo", "Baggins"},
+ {"Myrtle", "Burrows"},
+ {"Odo", "Proudfoot"},
+ {"Odovacar", "Bolger"},
+ {"Olo", "Proudfoot"},
+ {"Orgulas", "Brandybuck"},
+ {"Otho", "Sackville-Baggins"},
+ {"Paladin", "Took"},
+ {"Pansy", "Bolger"},
+ {"Pearl", "Took"},
+ {"Peony", "Burrows"},
+ {"Peregrin", "Took"},
+ {"Pervinca", "Took"},
+ {"Pimpernel", "Took"},
+ {"Pippin", "Gardner"},
+ {"Polo", "Baggins"},
+ {"Ponto", "Baggins"},
+ {"Porto", "Baggins"},
+ {"Posco", "Baggins"},
+ {"Poppy", "Bolger"},
+ {"Primrose", "Gardner"},
+ {"Primula", "Baggins"},
+ {"Prisca", "Bolger"},
+ {"Reginard", "Took"},
+ {"Robin", "Smallburrow"},
+ {"Robin", "Gardner"},
+ {"Rorimac", "Brandybuck"},
+ {"Rosa", "Took"},
+ {"Rosamunda", "Bolger"},
+ {"Rose", "Gardner"},
+ {"Ruby", "Baggins"},
+ {"Ruby", "Gardner"},
+ {"Rudigar", "Bolger"},
+ {"Rufus", "Burrows"},
+ {"Sadoc", "Brandybuck"},
+ {"Salvia", "Bolger"},
+ {"Samwise", "Gamgee"},
+ {"Sancho", "Proudfoot"},
+ {"Saradas", "Brandybuck"},
+ {"Saradoc", "Brandybuck"},
+ {"Seredic", "Brandybuck"},
+ {"Sigismond", "Took"},
+ {"Smeagol", "Gollum"},
+ {"Tanta", "Baggins"},
+ {"Ted", "Sandyman"},
+ {"Tobold", "Hornblower"},
+ {"Togo", "Goodbody"},
+ {"Tolman", "Cotton"},
+ {"Tolman", "Gardner"},
+ {"Widow", "Rumble"},
+ {"Wilcome", "Cotton"},
+ {"Wilcome", "Cotton"},
+ {"Wilibald", "Bolger"},
+ {"Will", "Whitfoot"},
+ {"Wiseman", "Gamwich"}};
+
+const char *dragons[] = {"Ancalagon", "Glaurung", "Scatha",
+ "Smaug the Magnificent"};
+
+static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config,
+ const char *test_name,
+ grpc_channel_args *client_args,
+ grpc_channel_args *server_args) {
+ grpc_end2end_test_fixture f;
+ gpr_log(GPR_INFO, "%s/%s", test_name, config.name);
+ f = config.create_fixture(client_args, server_args);
+ config.init_client(&f, client_args);
+ config.init_server(&f, server_args);
+ return f;
+}
+
+static gpr_timespec n_seconds_time(int n) {
+ return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n);
+}
+
+static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); }
+
+static void drain_cq(grpc_completion_queue *cq) {
+ grpc_event ev;
+ do {
+ ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL);
+ } while (ev.type != GRPC_QUEUE_SHUTDOWN);
+}
+
+static void shutdown_server(grpc_end2end_test_fixture *f) {
+ if (!f->server) return;
+ grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000));
+ GPR_ASSERT(grpc_completion_queue_pluck(
+ f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL)
+ .type == GRPC_OP_COMPLETE);
+ grpc_server_destroy(f->server);
+ f->server = NULL;
+}
+
+static void shutdown_client(grpc_end2end_test_fixture *f) {
+ if (!f->client) return;
+ grpc_channel_destroy(f->client);
+ f->client = NULL;
+}
+
+static void end_test(grpc_end2end_test_fixture *f) {
+ shutdown_server(f);
+ shutdown_client(f);
+
+ grpc_completion_queue_shutdown(f->cq);
+ drain_cq(f->cq);
+ grpc_completion_queue_destroy(f->cq);
+}
+
+static void simple_request_body(grpc_end2end_test_fixture f, size_t index) {
+ grpc_call *c;
+ grpc_call *s;
+ gpr_timespec deadline = five_seconds_time();
+ cq_verifier *cqv = cq_verifier_create(f.cq);
+ grpc_op ops[6];
+ grpc_op *op;
+ grpc_metadata_array initial_metadata_recv;
+ grpc_metadata_array trailing_metadata_recv;
+ grpc_metadata_array request_metadata_recv;
+ grpc_call_details call_details;
+ grpc_status_code status;
+ grpc_call_error error;
+ grpc_metadata extra_metadata[3];
+ char *details = NULL;
+ size_t details_capacity = 0;
+ int was_cancelled = 2;
+
+ memset(extra_metadata, 0, sizeof(extra_metadata));
+ extra_metadata[0].key = "hobbit-first-name";
+ extra_metadata[0].value = hobbits[index % GPR_ARRAY_SIZE(hobbits)][0];
+ extra_metadata[0].value_length = strlen(extra_metadata[0].value);
+ extra_metadata[1].key = "hobbit-second-name";
+ extra_metadata[1].value = hobbits[index % GPR_ARRAY_SIZE(hobbits)][1];
+ extra_metadata[1].value_length = strlen(extra_metadata[1].value);
+ extra_metadata[2].key = "dragon";
+ extra_metadata[2].value = dragons[index % GPR_ARRAY_SIZE(dragons)];
+ extra_metadata[2].value_length = strlen(extra_metadata[2].value);
+
+ c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
+ "/foo", "foo.test.google.fr:1234", deadline,
+ NULL);
+ GPR_ASSERT(c);
+
+ grpc_metadata_array_init(&initial_metadata_recv);
+ grpc_metadata_array_init(&trailing_metadata_recv);
+ grpc_metadata_array_init(&request_metadata_recv);
+ grpc_call_details_init(&call_details);
+
+ op = ops;
+ op->op = GRPC_OP_SEND_INITIAL_METADATA;
+ op->data.send_initial_metadata.count = GPR_ARRAY_SIZE(extra_metadata);
+ op->data.send_initial_metadata.metadata = extra_metadata;
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ op->op = GRPC_OP_RECV_INITIAL_METADATA;
+ op->data.recv_initial_metadata = &initial_metadata_recv;
+ op->flags = 0;
+ op->reserved = NULL;
+ 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->data.recv_status_on_client.status_details_capacity = &details_capacity;
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
+ GPR_ASSERT(GRPC_CALL_OK == error);
+
+ error =
+ grpc_server_request_call(f.server, &s, &call_details,
+ &request_metadata_recv, f.cq, f.cq, tag(101));
+ GPR_ASSERT(GRPC_CALL_OK == error);
+ cq_expect_completion(cqv, tag(101), 1);
+ cq_verify(cqv);
+
+ op = ops;
+ op->op = GRPC_OP_SEND_INITIAL_METADATA;
+ op->data.send_initial_metadata.count = 0;
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
+ op->data.send_status_from_server.trailing_metadata_count = 0;
+ op->data.send_status_from_server.status = GRPC_STATUS_UNIMPLEMENTED;
+ op->data.send_status_from_server.status_details = "xyz";
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
+ op->data.recv_close_on_server.cancelled = &was_cancelled;
+ op->flags = 0;
+ op->reserved = NULL;
+ op++;
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
+ GPR_ASSERT(GRPC_CALL_OK == error);
+
+ cq_expect_completion(cqv, tag(102), 1);
+ cq_expect_completion(cqv, tag(1), 1);
+ cq_verify(cqv);
+
+ GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED);
+ GPR_ASSERT(0 == strcmp(details, "xyz"));
+ GPR_ASSERT(0 == strcmp(call_details.method, "/foo"));
+ GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr:1234"));
+ GPR_ASSERT(was_cancelled == 1);
+
+ gpr_free(details);
+ grpc_metadata_array_destroy(&initial_metadata_recv);
+ grpc_metadata_array_destroy(&trailing_metadata_recv);
+ grpc_metadata_array_destroy(&request_metadata_recv);
+ grpc_call_details_destroy(&call_details);
+
+ grpc_call_destroy(c);
+ grpc_call_destroy(s);
+
+ cq_verifier_destroy(cqv);
+}
+
+static void test_size(grpc_end2end_test_config config, int encode_size,
+ int decode_size) {
+ size_t i;
+ grpc_end2end_test_fixture f;
+ grpc_arg server_arg;
+ grpc_channel_args server_args;
+ grpc_arg client_arg;
+ grpc_channel_args client_args;
+ char *name;
+
+ server_arg.type = GRPC_ARG_INTEGER;
+ server_arg.key = GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_DECODER;
+ server_arg.value.integer = decode_size;
+ server_args.num_args = 1;
+ server_args.args = &server_arg;
+
+ client_arg.type = GRPC_ARG_INTEGER;
+ client_arg.key = GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_ENCODER;
+ client_arg.value.integer = encode_size;
+ client_args.num_args = 1;
+ client_args.args = &client_arg;
+
+ gpr_asprintf(&name, "test_size:e=%d:d=%d", encode_size, decode_size);
+ f = begin_test(config, name, encode_size != 4096 ? &client_args : NULL,
+ decode_size != 4096 ? &server_args : NULL);
+ for (i = 0; i < 4 * GPR_ARRAY_SIZE(hobbits); i++) {
+ simple_request_body(f, i);
+ }
+ end_test(&f);
+ config.tear_down_data(&f);
+ gpr_free(name);
+}
+
+void grpc_end2end_tests(grpc_end2end_test_config config) {
+ static const int interesting_sizes[] = {4096, 0, 100,
+ 1000, 32768, 4 * 1024 * 1024};
+ size_t i, j;
+
+ for (i = 0; i < GPR_ARRAY_SIZE(interesting_sizes); i++) {
+ for (j = 0; j < GPR_ARRAY_SIZE(interesting_sizes); j++) {
+ test_size(config, interesting_sizes[i], interesting_sizes[j]);
+ }
+ }
+}
diff --git a/test/core/end2end/tests/negative_deadline.c b/test/core/end2end/tests/negative_deadline.c
index abcc1ba358..8fe9e7bcc5 100644
--- a/test/core/end2end/tests/negative_deadline.c
+++ b/test/core/end2end/tests/negative_deadline.c
@@ -163,7 +163,8 @@ static void simple_request_body(grpc_end2end_test_fixture f, size_t num_ops) {
cq_verifier_destroy(cqv);
}
-static void test_invoke_simple_request(grpc_end2end_test_config config, size_t num_ops) {
+static void test_invoke_simple_request(grpc_end2end_test_config config,
+ size_t num_ops) {
grpc_end2end_test_fixture f;
f = begin_test(config, "test_invoke_simple_request", NULL, NULL);
diff --git a/test/core/network_benchmarks/low_level_ping_pong.c b/test/core/network_benchmarks/low_level_ping_pong.c
index 7a2d894481..dd1544c27b 100644
--- a/test/core/network_benchmarks/low_level_ping_pong.c
+++ b/test/core/network_benchmarks/low_level_ping_pong.c
@@ -139,7 +139,7 @@ static int poll_read_bytes(int fd, char *buf, size_t read_size, int spin) {
gpr_log(GPR_ERROR, "Read failed: %s", strerror(errno));
return -1;
}
- bytes_read += (size_t) err2;
+ bytes_read += (size_t)err2;
} while (bytes_read < read_size);
return 0;
}
@@ -174,11 +174,11 @@ static int epoll_read_bytes(struct thread_args *args, char *buf, int spin) {
GPR_ASSERT(ev.data.fd == args->fds.read_fd);
do {
do {
- err2 = read(args->fds.read_fd, buf + bytes_read,
- read_size - bytes_read);
+ err2 =
+ read(args->fds.read_fd, buf + bytes_read, read_size - bytes_read);
} while (err2 < 0 && errno == EINTR);
if (errno == EAGAIN) break;
- bytes_read += (size_t) err2;
+ bytes_read += (size_t)err2;
/* TODO(klempner): This should really be doing an extra call after we are
done to ensure we see an EAGAIN */
} while (bytes_read < read_size);
diff --git a/test/core/security/credentials_test.c b/test/core/security/credentials_test.c
index dcb35e5309..4cfef7be78 100644
--- a/test/core/security/credentials_test.c
+++ b/test/core/security/credentials_test.c
@@ -353,8 +353,8 @@ static void test_google_iam_creds(void) {
test_google_iam_authorization_token, test_google_iam_authority_selector,
NULL);
grpc_call_credentials_get_request_metadata(&exec_ctx, creds, NULL,
- test_service_url,
- check_google_iam_metadata, creds);
+ test_service_url,
+ check_google_iam_metadata, creds);
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -436,7 +436,8 @@ static void test_oauth2_google_iam_composite_creds(void) {
test_google_iam_authorization_token, test_google_iam_authority_selector,
NULL);
grpc_call_credentials *composite_creds =
- grpc_composite_call_credentials_create(oauth2_creds, google_iam_creds, NULL);
+ grpc_composite_call_credentials_create(oauth2_creds, google_iam_creds,
+ NULL);
grpc_call_credentials_unref(oauth2_creds);
grpc_call_credentials_unref(google_iam_creds);
GPR_ASSERT(
@@ -481,7 +482,8 @@ static void test_channel_oauth2_google_iam_composite_creds(void) {
grpc_call_credentials *oauth2_creds =
grpc_access_token_credentials_create("blah", NULL);
grpc_channel_credentials *channel_oauth2_creds =
- grpc_composite_channel_credentials_create(channel_creds, oauth2_creds, NULL);
+ grpc_composite_channel_credentials_create(channel_creds, oauth2_creds,
+ NULL);
grpc_call_credentials *google_iam_creds = grpc_google_iam_credentials_create(
test_google_iam_authorization_token, test_google_iam_authority_selector,
NULL);
diff --git a/test/core/surface/byte_buffer_reader_test.c b/test/core/surface/byte_buffer_reader_test.c
index 7f9cd6b62b..6b41698717 100644
--- a/test/core/surface/byte_buffer_reader_test.c
+++ b/test/core/surface/byte_buffer_reader_test.c
@@ -185,8 +185,8 @@ static void test_byte_buffer_from_reader(void) {
}
static void test_readall(void) {
- char* lotsa_as[512];
- char* lotsa_bs[1024];
+ char *lotsa_as[512];
+ char *lotsa_bs[1024];
gpr_slice slices[2];
grpc_byte_buffer *buffer;
grpc_byte_buffer_reader reader;
diff --git a/test/core/transport/chttp2/hpack_parser_test.c b/test/core/transport/chttp2/hpack_parser_test.c
index 3a313375a4..c6b35fba79 100644
--- a/test/core/transport/chttp2/hpack_parser_test.c
+++ b/test/core/transport/chttp2/hpack_parser_test.c
@@ -151,7 +151,8 @@ static void test_vectors(grpc_slice_split_mode mode) {
grpc_chttp2_hpack_parser_destroy(&parser);
grpc_chttp2_hpack_parser_init(&parser, mdctx);
- parser.table.max_bytes = 256;
+ grpc_chttp2_hptbl_set_max_bytes(&parser.table, 256);
+ grpc_chttp2_hptbl_set_current_table_size(&parser.table, 256);
/* D.5.1 */
test_vector(&parser, mode,
"4803 3330 3258 0770 7269 7661 7465 611d"
@@ -184,7 +185,8 @@ static void test_vectors(grpc_slice_split_mode mode) {
grpc_chttp2_hpack_parser_destroy(&parser);
grpc_chttp2_hpack_parser_init(&parser, mdctx);
- parser.table.max_bytes = 256;
+ grpc_chttp2_hptbl_set_max_bytes(&parser.table, 256);
+ grpc_chttp2_hptbl_set_current_table_size(&parser.table, 256);
/* D.6.1 */
test_vector(&parser, mode,
"4882 6402 5885 aec3 771a 4b61 96d0 7abe"
diff --git a/test/core/transport/chttp2/hpack_table_test.c b/test/core/transport/chttp2/hpack_table_test.c
index aa3e273a6c..5eb52d6d9a 100644
--- a/test/core/transport/chttp2/hpack_table_test.c
+++ b/test/core/transport/chttp2/hpack_table_test.c
@@ -143,9 +143,12 @@ static void test_many_additions(void) {
grpc_chttp2_hptbl_init(&tbl, mdctx);
for (i = 0; i < 1000000; i++) {
+ grpc_mdelem *elem;
gpr_asprintf(&key, "K:%d", i);
gpr_asprintf(&value, "VALUE:%d", i);
- grpc_chttp2_hptbl_add(&tbl, grpc_mdelem_from_strings(mdctx, key, value));
+ elem = grpc_mdelem_from_strings(mdctx, key, value);
+ GPR_ASSERT(grpc_chttp2_hptbl_add(&tbl, elem));
+ GRPC_MDELEM_UNREF(elem);
assert_index(&tbl, 1 + GRPC_CHTTP2_LAST_STATIC_ENTRY, key, value);
gpr_free(key);
gpr_free(value);
@@ -173,18 +176,25 @@ static grpc_chttp2_hptbl_find_result find_simple(grpc_chttp2_hptbl *tbl,
static void test_find(void) {
grpc_chttp2_hptbl tbl;
- int i;
+ gpr_uint32 i;
char buffer[32];
grpc_mdctx *mdctx;
+ grpc_mdelem *elem;
grpc_chttp2_hptbl_find_result r;
LOG_TEST("test_find");
mdctx = grpc_mdctx_create();
grpc_chttp2_hptbl_init(&tbl, mdctx);
- grpc_chttp2_hptbl_add(&tbl, grpc_mdelem_from_strings(mdctx, "abc", "xyz"));
- grpc_chttp2_hptbl_add(&tbl, grpc_mdelem_from_strings(mdctx, "abc", "123"));
- grpc_chttp2_hptbl_add(&tbl, grpc_mdelem_from_strings(mdctx, "x", "1"));
+ elem = grpc_mdelem_from_strings(mdctx, "abc", "xyz");
+ GPR_ASSERT(grpc_chttp2_hptbl_add(&tbl, elem));
+ GRPC_MDELEM_UNREF(elem);
+ elem = grpc_mdelem_from_strings(mdctx, "abc", "123");
+ GPR_ASSERT(grpc_chttp2_hptbl_add(&tbl, elem));
+ GRPC_MDELEM_UNREF(elem);
+ elem = grpc_mdelem_from_strings(mdctx, "x", "1");
+ GPR_ASSERT(grpc_chttp2_hptbl_add(&tbl, elem));
+ GRPC_MDELEM_UNREF(elem);
r = find_simple(&tbl, "abc", "123");
GPR_ASSERT(r.index == 2 + GRPC_CHTTP2_LAST_STATIC_ENTRY);
@@ -233,8 +243,9 @@ static void test_find(void) {
/* overflow the string buffer, check find still works */
for (i = 0; i < 10000; i++) {
gpr_ltoa(i, buffer);
- grpc_chttp2_hptbl_add(&tbl,
- grpc_mdelem_from_strings(mdctx, "test", buffer));
+ elem = grpc_mdelem_from_strings(mdctx, "test", buffer);
+ GPR_ASSERT(grpc_chttp2_hptbl_add(&tbl, elem));
+ GRPC_MDELEM_UNREF(elem);
}
r = find_simple(&tbl, "abc", "123");
@@ -250,7 +261,7 @@ static void test_find(void) {
GPR_ASSERT(r.has_value == 1);
for (i = 0; i < tbl.num_ents; i++) {
- int expect = 9999 - i;
+ gpr_uint32 expect = 9999 - i;
gpr_ltoa(expect, buffer);
r = find_simple(&tbl, "test", buffer);
diff --git a/test/core/util/test_tcp_server.c b/test/core/util/test_tcp_server.c
index 0cd9beed80..e78d830058 100644
--- a/test/core/util/test_tcp_server.c
+++ b/test/core/util/test_tcp_server.c
@@ -57,6 +57,7 @@ void test_tcp_server_init(test_tcp_server *server,
void test_tcp_server_start(test_tcp_server *server, int port) {
struct sockaddr_in addr;
+ grpc_tcp_listener *listener;
int port_added;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
@@ -65,8 +66,8 @@ void test_tcp_server_start(test_tcp_server *server, int port) {
memset(&addr.sin_addr, 0, sizeof(addr.sin_addr));
server->tcp_server = grpc_tcp_server_create();
- port_added =
- grpc_tcp_server_add_port(server->tcp_server, &addr, sizeof(addr));
+ listener = grpc_tcp_server_add_port(server->tcp_server, &addr, sizeof(addr));
+ port_added = grpc_tcp_listener_get_port(listener);
GPR_ASSERT(port_added == port);
grpc_tcp_server_start(&exec_ctx, server->tcp_server, server->pollsets, 1,
diff --git a/test/cpp/interop/metrics_client.cc b/test/cpp/interop/metrics_client.cc
new file mode 100644
index 0000000000..1bd2a2fd78
--- /dev/null
+++ b/test/cpp/interop/metrics_client.cc
@@ -0,0 +1,103 @@
+/*
+ *
+ * Copyright 2015, 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.
+ *is % allowed in string
+ */
+
+#include <memory>
+#include <string>
+
+#include <gflags/gflags.h>
+#include <grpc++/grpc++.h>
+
+#include "test/cpp/util/metrics_server.h"
+#include "test/cpp/util/test_config.h"
+#include "test/proto/metrics.grpc.pb.h"
+#include "test/proto/metrics.pb.h"
+
+DEFINE_string(metrics_server_address, "",
+ "The metrics server addresses in the fomrat <hostname>:<port>");
+
+using grpc::testing::EmptyMessage;
+using grpc::testing::GaugeResponse;
+using grpc::testing::MetricsService;
+using grpc::testing::MetricsServiceImpl;
+
+void PrintMetrics(grpc::string& server_address) {
+ gpr_log(GPR_INFO, "creating a channel to %s", server_address.c_str());
+ std::shared_ptr<grpc::Channel> channel(
+ grpc::CreateChannel(server_address, grpc::InsecureChannelCredentials()));
+
+ std::unique_ptr<MetricsService::Stub> stub(MetricsService::NewStub(channel));
+
+ grpc::ClientContext context;
+ EmptyMessage message;
+
+ std::unique_ptr<grpc::ClientReader<GaugeResponse>> reader(
+ stub->GetAllGauges(&context, message));
+
+ GaugeResponse gauge_response;
+ long overall_qps = 0;
+ int idx = 0;
+ while (reader->Read(&gauge_response)) {
+ if (gauge_response.value_case() == GaugeResponse::kLongValue) {
+ gpr_log(GPR_INFO, "Gauge: %d (%s: %ld)", ++idx,
+ gauge_response.name().c_str(), gauge_response.long_value());
+ overall_qps += gauge_response.long_value();
+ } else {
+ gpr_log(GPR_INFO, "Gauge %s is not a long value",
+ gauge_response.name().c_str());
+ }
+ }
+
+ gpr_log(GPR_INFO, "OVERALL: %ld", overall_qps);
+
+ const grpc::Status status = reader->Finish();
+ if (!status.ok()) {
+ gpr_log(GPR_ERROR, "Error in getting metrics from the client");
+ }
+}
+
+int main(int argc, char** argv) {
+ grpc::testing::InitTest(&argc, &argv, true);
+
+ // Make sure server_addresses flag is not empty
+ if (FLAGS_metrics_server_address.empty()) {
+ gpr_log(
+ GPR_ERROR,
+ "Cannot connect to the Metrics server. Please pass the address of the"
+ "metrics server to connect to via the 'metrics_server_address' flag");
+ return 1;
+ }
+
+ PrintMetrics(FLAGS_metrics_server_address);
+
+ return 0;
+}
diff --git a/test/cpp/interop/stress_interop_client.cc b/test/cpp/interop/stress_interop_client.cc
index 3be2571493..5d2951e3ed 100644
--- a/test/cpp/interop/stress_interop_client.cc
+++ b/test/cpp/interop/stress_interop_client.cc
@@ -40,6 +40,7 @@
#include <grpc++/create_channel.h>
#include "test/cpp/interop/interop_client.h"
+#include "test/cpp/util/metrics_server.h"
namespace grpc {
namespace testing {
@@ -81,21 +82,19 @@ TestCaseType WeightedRandomTestSelector::GetNextTest() const {
StressTestInteropClient::StressTestInteropClient(
int test_id, const grpc::string& server_address,
+ std::shared_ptr<Channel> channel,
const WeightedRandomTestSelector& test_selector, long test_duration_secs,
- long sleep_duration_ms)
+ long sleep_duration_ms, long metrics_collection_interval_secs)
: test_id_(test_id),
server_address_(server_address),
+ channel_(channel),
+ interop_client_(new InteropClient(channel, false)),
test_selector_(test_selector),
test_duration_secs_(test_duration_secs),
- sleep_duration_ms_(sleep_duration_ms) {
- // TODO(sreek): This will change once we add support for other tests
- // that won't work with InsecureChannelCredentials()
- std::shared_ptr<Channel> channel(
- CreateChannel(server_address, InsecureChannelCredentials()));
- interop_client_.reset(new InteropClient(channel, false));
-}
+ sleep_duration_ms_(sleep_duration_ms),
+ metrics_collection_interval_secs_(metrics_collection_interval_secs) {}
-void StressTestInteropClient::MainLoop() {
+void StressTestInteropClient::MainLoop(std::shared_ptr<Gauge> qps_gauge) {
gpr_log(GPR_INFO, "Running test %d. ServerAddr: %s", test_id_,
server_address_.c_str());
@@ -104,21 +103,38 @@ void StressTestInteropClient::MainLoop() {
gpr_time_from_seconds(test_duration_secs_, GPR_TIMESPAN));
gpr_timespec current_time = gpr_now(GPR_CLOCK_REALTIME);
+ gpr_timespec next_stat_collection_time = current_time;
+ gpr_timespec collection_interval =
+ gpr_time_from_seconds(metrics_collection_interval_secs_, GPR_TIMESPAN);
+ long num_calls_per_interval = 0;
+
while (test_duration_secs_ < 0 ||
- gpr_time_cmp(current_time, test_end_time) < 0) {
+ gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), test_end_time) < 0) {
// Select the test case to execute based on the weights and execute it
TestCaseType test_case = test_selector_.GetNextTest();
gpr_log(GPR_INFO, "%d - Executing the test case %d", test_id_, test_case);
RunTest(test_case);
+ num_calls_per_interval++;
+
+ // See if its time to collect stats yet
+ current_time = gpr_now(GPR_CLOCK_REALTIME);
+ if (gpr_time_cmp(next_stat_collection_time, current_time) < 0) {
+ qps_gauge->Set(num_calls_per_interval /
+ metrics_collection_interval_secs_);
+
+ num_calls_per_interval = 0;
+ next_stat_collection_time =
+ gpr_time_add(current_time, collection_interval);
+ }
+
// Sleep between successive calls if needed
if (sleep_duration_ms_ > 0) {
- gpr_timespec sleep_time = gpr_time_add(
- current_time, gpr_time_from_millis(sleep_duration_ms_, GPR_TIMESPAN));
+ gpr_timespec sleep_time =
+ gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
+ gpr_time_from_millis(sleep_duration_ms_, GPR_TIMESPAN));
gpr_sleep_until(sleep_time);
}
-
- current_time = gpr_now(GPR_CLOCK_REALTIME);
}
}
diff --git a/test/cpp/interop/stress_interop_client.h b/test/cpp/interop/stress_interop_client.h
index 36261e501f..6fd303d6b7 100644
--- a/test/cpp/interop/stress_interop_client.h
+++ b/test/cpp/interop/stress_interop_client.h
@@ -41,6 +41,7 @@
#include <grpc++/create_channel.h>
#include "test/cpp/interop/interop_client.h"
+#include "test/cpp/util/metrics_server.h"
namespace grpc {
namespace testing {
@@ -84,20 +85,26 @@ class WeightedRandomTestSelector {
class StressTestInteropClient {
public:
StressTestInteropClient(int test_id, const grpc::string& server_address,
+ std::shared_ptr<Channel> channel,
const WeightedRandomTestSelector& test_selector,
- long test_duration_secs, long sleep_duration_ms);
+ long test_duration_secs, long sleep_duration_ms,
+ long metrics_collection_interval_secs);
- void MainLoop(); // The main function. Use this as the thread entry point.
+ // The main function. Use this as the thread entry point.
+ // qps_gauge is the Gauge to record the requests per second metric
+ void MainLoop(std::shared_ptr<Gauge> qps_gauge);
private:
void RunTest(TestCaseType test_case);
int test_id_;
- std::unique_ptr<InteropClient> interop_client_;
const grpc::string& server_address_;
+ std::shared_ptr<Channel> channel_;
+ std::unique_ptr<InteropClient> interop_client_;
const WeightedRandomTestSelector& test_selector_;
long test_duration_secs_;
long sleep_duration_ms_;
+ long metrics_collection_interval_secs_;
};
} // namespace testing
diff --git a/test/cpp/interop/stress_test.cc b/test/cpp/interop/stress_test.cc
index 018f4ab4f7..f6023a4cb3 100644
--- a/test/cpp/interop/stress_test.cc
+++ b/test/cpp/interop/stress_test.cc
@@ -45,7 +45,15 @@
#include "test/cpp/interop/interop_client.h"
#include "test/cpp/interop/stress_interop_client.h"
+#include "test/cpp/util/metrics_server.h"
#include "test/cpp/util/test_config.h"
+#include "test/proto/metrics.grpc.pb.h"
+#include "test/proto/metrics.pb.h"
+
+DEFINE_int32(metrics_port, 8081, "The metrics server port.");
+
+DEFINE_int32(metrics_collection_interval_secs, 5,
+ "How often (in seconds) should metrics be recorded.");
DEFINE_int32(sleep_duration_ms, 0,
"The duration (in millisec) between two"
@@ -62,6 +70,11 @@ DEFINE_string(server_addresses, "localhost:8080",
" \"<name_1>:<port_1>,<name_2>:<port_1>...<name_N>:<port_N>\"\n"
" Note: <name> can be servername or IP address.");
+DEFINE_int32(num_stubs_per_channel, 1,
+ "Number of stubs per each channels to server. This number also "
+ "indicates the max number of parallel RPC calls on each channel "
+ "at any given time.");
+
// TODO(sreek): Add more test cases here in future
DEFINE_string(test_cases, "",
"List of test cases to call along with the"
@@ -79,15 +92,13 @@ DEFINE_string(test_cases, "",
" 'large_unary', 10% of the time and 'empty_stream' the remaining"
" 70% of the time");
-using std::make_pair;
-using std::pair;
-using std::vector;
-
using grpc::testing::kTestCaseList;
+using grpc::testing::MetricsService;
+using grpc::testing::MetricsServiceImpl;
using grpc::testing::StressTestInteropClient;
using grpc::testing::TestCaseType;
-using grpc::testing::WeightedRandomTestSelector;
using grpc::testing::UNKNOWN_TEST;
+using grpc::testing::WeightedRandomTestSelector;
TestCaseType GetTestTypeFromName(const grpc::string& test_name) {
TestCaseType test_case = UNKNOWN_TEST;
@@ -104,7 +115,7 @@ TestCaseType GetTestTypeFromName(const grpc::string& test_name) {
// Converts a string of comma delimited tokens to a vector of tokens
bool ParseCommaDelimitedString(const grpc::string& comma_delimited_str,
- vector<grpc::string>& tokens) {
+ std::vector<grpc::string>& tokens) {
size_t bpos = 0;
size_t epos = grpc::string::npos;
@@ -122,10 +133,10 @@ bool ParseCommaDelimitedString(const grpc::string& comma_delimited_str,
// - Whether parsing was successful (return value)
// - Vector of (test_type_enum, weight) pairs returned via 'tests' parameter
bool ParseTestCasesString(const grpc::string& test_cases,
- vector<pair<TestCaseType, int>>& tests) {
+ std::vector<std::pair<TestCaseType, int>>& tests) {
bool is_success = true;
- vector<grpc::string> tokens;
+ std::vector<grpc::string> tokens;
ParseCommaDelimitedString(test_cases, tokens);
for (auto it = tokens.begin(); it != tokens.end(); it++) {
@@ -153,8 +164,8 @@ bool ParseTestCasesString(const grpc::string& test_cases,
}
// For debugging purposes
-void LogParameterInfo(const vector<grpc::string>& addresses,
- const vector<pair<TestCaseType, int>>& tests) {
+void LogParameterInfo(const std::vector<grpc::string>& addresses,
+ const std::vector<std::pair<TestCaseType, int>>& tests) {
gpr_log(GPR_INFO, "server_addresses: %s", FLAGS_server_addresses.c_str());
gpr_log(GPR_INFO, "test_cases : %s", FLAGS_test_cases.c_str());
gpr_log(GPR_INFO, "sleep_duration_ms: %d", FLAGS_sleep_duration_ms);
@@ -180,7 +191,7 @@ int main(int argc, char** argv) {
srand(time(NULL));
// Parse the server addresses
- vector<grpc::string> server_addresses;
+ std::vector<grpc::string> server_addresses;
ParseCommaDelimitedString(FLAGS_server_addresses, server_addresses);
// Parse test cases and weights
@@ -189,7 +200,7 @@ int main(int argc, char** argv) {
return 1;
}
- vector<pair<TestCaseType, int>> tests;
+ std::vector<std::pair<TestCaseType, int>> tests;
if (!ParseTestCasesString(FLAGS_test_cases, tests)) {
gpr_log(GPR_ERROR, "Error in parsing test cases string %s ",
FLAGS_test_cases.c_str());
@@ -199,23 +210,48 @@ int main(int argc, char** argv) {
LogParameterInfo(server_addresses, tests);
WeightedRandomTestSelector test_selector(tests);
+ MetricsServiceImpl metrics_service;
gpr_log(GPR_INFO, "Starting test(s)..");
- vector<grpc::thread> test_threads;
+ std::vector<grpc::thread> test_threads;
+
int thread_idx = 0;
for (auto it = server_addresses.begin(); it != server_addresses.end(); it++) {
- StressTestInteropClient* client = new StressTestInteropClient(
- ++thread_idx, *it, test_selector, FLAGS_test_duration_secs,
- FLAGS_sleep_duration_ms);
-
- test_threads.emplace_back(
- grpc::thread(&StressTestInteropClient::MainLoop, client));
+ // TODO(sreek): This will change once we add support for other tests
+ // that won't work with InsecureChannelCredentials()
+ std::shared_ptr<grpc::Channel> channel(
+ grpc::CreateChannel(*it, grpc::InsecureChannelCredentials()));
+
+ // Make multiple stubs (as defined by num_stubs_per_channel flag) to use the
+ // same channel. This is to test calling multiple RPC calls in parallel on
+ // each channel.
+ for (int i = 0; i < FLAGS_num_stubs_per_channel; i++) {
+ StressTestInteropClient* client = new StressTestInteropClient(
+ ++thread_idx, *it, channel, test_selector, FLAGS_test_duration_secs,
+ FLAGS_sleep_duration_ms, FLAGS_metrics_collection_interval_secs);
+
+ bool is_already_created;
+ grpc::string metricName =
+ "/stress_test/qps/thread/" + std::to_string(thread_idx);
+ test_threads.emplace_back(grpc::thread(
+ &StressTestInteropClient::MainLoop, client,
+ metrics_service.CreateGauge(metricName, &is_already_created)));
+
+ // The Gauge should not have been already created
+ GPR_ASSERT(!is_already_created);
+ }
}
+ // Start metrics server before waiting for the stress test threads
+ std::unique_ptr<grpc::Server> metrics_server =
+ metrics_service.StartServer(FLAGS_metrics_port);
+
+ // Wait for the stress test threads to complete
for (auto it = test_threads.begin(); it != test_threads.end(); it++) {
it->join();
}
+ metrics_server->Wait();
return 0;
}
diff --git a/test/cpp/qps/async_streaming_ping_pong_test.cc b/test/cpp/qps/async_streaming_ping_pong_test.cc
index 9fef93a70f..0acdf3affb 100644
--- a/test/cpp/qps/async_streaming_ping_pong_test.cc
+++ b/test/cpp/qps/async_streaming_ping_pong_test.cc
@@ -58,6 +58,7 @@ static void RunAsyncStreamingPingPong() {
ServerConfig server_config;
server_config.set_server_type(ASYNC_SERVER);
+ server_config.set_host("localhost");
server_config.set_async_server_threads(1);
const auto result =
diff --git a/test/cpp/qps/async_unary_ping_pong_test.cc b/test/cpp/qps/async_unary_ping_pong_test.cc
index b4ab0e5d59..d21e116171 100644
--- a/test/cpp/qps/async_unary_ping_pong_test.cc
+++ b/test/cpp/qps/async_unary_ping_pong_test.cc
@@ -58,6 +58,7 @@ static void RunAsyncUnaryPingPong() {
ServerConfig server_config;
server_config.set_server_type(ASYNC_SERVER);
+ server_config.set_host("localhost");
server_config.set_async_server_threads(1);
const auto result =
diff --git a/test/cpp/qps/client.h b/test/cpp/qps/client.h
index f4400692fe..b24a90adac 100644
--- a/test/cpp/qps/client.h
+++ b/test/cpp/qps/client.h
@@ -181,29 +181,29 @@ class Client {
std::unique_ptr<RandomDist> random_dist;
switch (load.load_case()) {
- case LoadParams::kClosedLoop:
- // Closed-loop doesn't use random dist at all
- break;
- case LoadParams::kPoisson:
- random_dist.reset(
- new ExpDist(load.poisson().offered_load() / num_threads));
- break;
- case LoadParams::kUniform:
- random_dist.reset(
- new UniformDist(load.uniform().interarrival_lo() * num_threads,
- load.uniform().interarrival_hi() * num_threads));
- break;
- case LoadParams::kDeterm:
- random_dist.reset(
- new DetDist(num_threads / load.determ().offered_load()));
- break;
- case LoadParams::kPareto:
- random_dist.reset(
- new ParetoDist(load.pareto().interarrival_base() * num_threads,
- load.pareto().alpha()));
- break;
- default:
- GPR_ASSERT(false);
+ case LoadParams::kClosedLoop:
+ // Closed-loop doesn't use random dist at all
+ break;
+ case LoadParams::kPoisson:
+ random_dist.reset(
+ new ExpDist(load.poisson().offered_load() / num_threads));
+ break;
+ case LoadParams::kUniform:
+ random_dist.reset(
+ new UniformDist(load.uniform().interarrival_lo() * num_threads,
+ load.uniform().interarrival_hi() * num_threads));
+ break;
+ case LoadParams::kDeterm:
+ random_dist.reset(
+ new DetDist(num_threads / load.determ().offered_load()));
+ break;
+ case LoadParams::kPareto:
+ random_dist.reset(
+ new ParetoDist(load.pareto().interarrival_base() * num_threads,
+ load.pareto().alpha()));
+ break;
+ default:
+ GPR_ASSERT(false);
}
// Set closed_loop_ based on whether or not random_dist is set
diff --git a/test/cpp/qps/driver.cc b/test/cpp/qps/driver.cc
index 67bdcb2f32..20dc65046b 100644
--- a/test/cpp/qps/driver.cc
+++ b/test/cpp/qps/driver.cc
@@ -110,7 +110,7 @@ std::unique_ptr<ScenarioResult> RunScenario(
list<ClientContext> contexts;
// To be added to the result, containing the final configuration used for
- // client and config (incluiding host, etc.)
+ // client and config (including host, etc.)
ClientConfig result_client_config;
ServerConfig result_server_config;
diff --git a/test/cpp/qps/histogram.h b/test/cpp/qps/histogram.h
index 35527d2a2c..4161eac826 100644
--- a/test/cpp/qps/histogram.h
+++ b/test/cpp/qps/histogram.h
@@ -42,7 +42,10 @@ namespace testing {
class Histogram {
public:
- Histogram() : impl_(gpr_histogram_create(0.01, 60e9)) {}
+ // TODO: look into making histogram params not hardcoded for C++
+ Histogram()
+ : impl_(gpr_histogram_create(default_resolution(),
+ default_max_possible())) {}
~Histogram() {
if (impl_) gpr_histogram_destroy(impl_);
}
@@ -73,6 +76,9 @@ class Histogram {
p.sum_of_squares(), p.count());
}
+ static double default_resolution() { return 0.01; }
+ static double default_max_possible() { return 60e9; }
+
private:
Histogram(const Histogram&);
Histogram& operator=(const Histogram&);
diff --git a/test/cpp/qps/qps_driver.cc b/test/cpp/qps/qps_driver.cc
index 4c93a042cf..c7096391e6 100644
--- a/test/cpp/qps/qps_driver.cc
+++ b/test/cpp/qps/qps_driver.cc
@@ -137,8 +137,14 @@ static void QpsDriver() {
// No further load parameters to set up for closed loop
}
+ client_config.mutable_histogram_params()->set_resolution(
+ Histogram::default_resolution());
+ client_config.mutable_histogram_params()->set_max_possible(
+ Histogram::default_max_possible());
+
ServerConfig server_config;
server_config.set_server_type(server_type);
+ server_config.set_host("localhost");
server_config.set_async_server_threads(FLAGS_async_server_threads);
if (FLAGS_secure_test) {
diff --git a/test/cpp/qps/qps_openloop_test.cc b/test/cpp/qps/qps_openloop_test.cc
index dc88c893bb..51df79ef2f 100644
--- a/test/cpp/qps/qps_openloop_test.cc
+++ b/test/cpp/qps/qps_openloop_test.cc
@@ -59,6 +59,7 @@ static void RunQPS() {
ServerConfig server_config;
server_config.set_server_type(ASYNC_SERVER);
+ server_config.set_host("localhost");
server_config.set_async_server_threads(4);
const auto result =
diff --git a/test/cpp/qps/qps_test.cc b/test/cpp/qps/qps_test.cc
index 89b35cfb05..1f87d18137 100644
--- a/test/cpp/qps/qps_test.cc
+++ b/test/cpp/qps/qps_test.cc
@@ -58,6 +58,7 @@ static void RunQPS() {
ServerConfig server_config;
server_config.set_server_type(ASYNC_SERVER);
+ server_config.set_host("localhost");
server_config.set_async_server_threads(8);
const auto result =
diff --git a/test/cpp/qps/qps_test_with_poll.cc b/test/cpp/qps/qps_test_with_poll.cc
index 97da4096ed..dc800092db 100644
--- a/test/cpp/qps/qps_test_with_poll.cc
+++ b/test/cpp/qps/qps_test_with_poll.cc
@@ -62,6 +62,7 @@ static void RunQPS() {
ServerConfig server_config;
server_config.set_server_type(ASYNC_SERVER);
+ server_config.set_host("localhost");
server_config.set_async_server_threads(4);
const auto result =
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 df06f7e471..ce9f02cceb 100644
--- a/test/cpp/qps/secure_sync_unary_ping_pong_test.cc
+++ b/test/cpp/qps/secure_sync_unary_ping_pong_test.cc
@@ -57,6 +57,7 @@ static void RunSynchronousUnaryPingPong() {
ServerConfig server_config;
server_config.set_server_type(SYNC_SERVER);
+ server_config.set_host("localhost");
// Set up security params
SecurityParams security;
diff --git a/test/cpp/qps/server_async.cc b/test/cpp/qps/server_async.cc
index 2d922fa615..c151918ce4 100644
--- a/test/cpp/qps/server_async.cc
+++ b/test/cpp/qps/server_async.cc
@@ -60,7 +60,7 @@ class AsyncQpsServerTest : public Server {
explicit AsyncQpsServerTest(const ServerConfig &config) : Server(config) {
char *server_address = NULL;
- gpr_join_host_port(&server_address, "::", port());
+ gpr_join_host_port(&server_address, config.host().c_str(), port());
ServerBuilder builder;
builder.AddListeningPort(server_address,
diff --git a/test/cpp/qps/server_sync.cc b/test/cpp/qps/server_sync.cc
index a09b174b7e..3a15bec888 100644
--- a/test/cpp/qps/server_sync.cc
+++ b/test/cpp/qps/server_sync.cc
@@ -89,7 +89,7 @@ class SynchronousServer GRPC_FINAL : public grpc::testing::Server {
char* server_address = NULL;
- gpr_join_host_port(&server_address, "::", port());
+ gpr_join_host_port(&server_address, config.host().c_str(), port());
builder.AddListeningPort(server_address,
Server::CreateServerCredentials(config));
gpr_free(server_address);
diff --git a/test/cpp/qps/sync_streaming_ping_pong_test.cc b/test/cpp/qps/sync_streaming_ping_pong_test.cc
index 186afc03f7..dd8c682815 100644
--- a/test/cpp/qps/sync_streaming_ping_pong_test.cc
+++ b/test/cpp/qps/sync_streaming_ping_pong_test.cc
@@ -57,6 +57,7 @@ static void RunSynchronousStreamingPingPong() {
ServerConfig server_config;
server_config.set_server_type(SYNC_SERVER);
+ server_config.set_host("localhost");
const auto result =
RunScenario(client_config, 1, server_config, 1, WARMUP, BENCHMARK, -2);
diff --git a/test/cpp/qps/sync_unary_ping_pong_test.cc b/test/cpp/qps/sync_unary_ping_pong_test.cc
index 25851833a6..2edb33ef01 100644
--- a/test/cpp/qps/sync_unary_ping_pong_test.cc
+++ b/test/cpp/qps/sync_unary_ping_pong_test.cc
@@ -57,6 +57,7 @@ static void RunSynchronousUnaryPingPong() {
ServerConfig server_config;
server_config.set_server_type(SYNC_SERVER);
+ server_config.set_host("localhost");
const auto result =
RunScenario(client_config, 1, server_config, 1, WARMUP, BENCHMARK, -2);
diff --git a/test/cpp/util/metrics_server.cc b/test/cpp/util/metrics_server.cc
new file mode 100644
index 0000000000..426295f9b4
--- /dev/null
+++ b/test/cpp/util/metrics_server.cc
@@ -0,0 +1,119 @@
+/*
+ *
+ * Copyright 2015, 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.
+ *is % allowed in string
+ */
+
+#include "test/cpp/util/metrics_server.h"
+
+#include <grpc++/server_builder.h>
+
+#include "test/proto/metrics.grpc.pb.h"
+#include "test/proto/metrics.pb.h"
+
+namespace grpc {
+namespace testing {
+
+Gauge::Gauge(long initial_val) : val_(initial_val) {}
+
+void Gauge::Set(long new_val) {
+ std::lock_guard<std::mutex> lock(val_mu_);
+ val_ = new_val;
+}
+
+long Gauge::Get() {
+ std::lock_guard<std::mutex> lock(val_mu_);
+ return val_;
+}
+
+grpc::Status MetricsServiceImpl::GetAllGauges(
+ ServerContext* context, const EmptyMessage* request,
+ ServerWriter<GaugeResponse>* writer) {
+ gpr_log(GPR_INFO, "GetAllGauges called");
+
+ std::lock_guard<std::mutex> lock(mu_);
+ for (auto it = gauges_.begin(); it != gauges_.end(); it++) {
+ GaugeResponse resp;
+ resp.set_name(it->first); // Gauge name
+ resp.set_long_value(it->second->Get()); // Gauge value
+ writer->Write(resp);
+ }
+
+ return Status::OK;
+}
+
+grpc::Status MetricsServiceImpl::GetGauge(ServerContext* context,
+ const GaugeRequest* request,
+ GaugeResponse* response) {
+ std::lock_guard<std::mutex> lock(mu_);
+
+ const auto it = gauges_.find(request->name());
+ if (it != gauges_.end()) {
+ response->set_name(it->first);
+ response->set_long_value(it->second->Get());
+ }
+
+ return Status::OK;
+}
+
+std::shared_ptr<Gauge> MetricsServiceImpl::CreateGauge(const grpc::string& name,
+ bool* already_present) {
+ std::lock_guard<std::mutex> lock(mu_);
+
+ std::shared_ptr<Gauge> gauge(new Gauge(0));
+ const auto p = gauges_.emplace(name, gauge);
+
+ // p.first is an iterator pointing to <name, shared_ptr<Gauge>> pair. p.second
+ // is a boolean which is set to 'true' if the Gauge is inserted in the guages_
+ // map and 'false' if it is already present in the map
+ *already_present = !p.second;
+ return p.first->second;
+}
+
+// Starts the metrics server and returns the grpc::Server instance. Call Wait()
+// on the returned server instance.
+std::unique_ptr<grpc::Server> MetricsServiceImpl::StartServer(int port) {
+ gpr_log(GPR_INFO, "Building metrics server..");
+
+ const grpc::string address = "0.0.0.0:" + std::to_string(port);
+
+ ServerBuilder builder;
+ builder.AddListeningPort(address, grpc::InsecureServerCredentials());
+ builder.RegisterService(this);
+
+ std::unique_ptr<grpc::Server> server(builder.BuildAndStart());
+ gpr_log(GPR_INFO, "Metrics server %s started. Ready to receive requests..",
+ address.c_str());
+
+ return server;
+}
+
+} // namespace testing
+} // namespace grpc
diff --git a/test/cpp/util/metrics_server.h b/test/cpp/util/metrics_server.h
new file mode 100644
index 0000000000..edde37dc4c
--- /dev/null
+++ b/test/cpp/util/metrics_server.h
@@ -0,0 +1,100 @@
+/*
+ *
+ * Copyright 2015, 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.
+ *is % allowed in string
+ */
+#ifndef GRPC_TEST_CPP_METRICS_SERVER_H
+#define GRPC_TEST_CPP_METRICS_SERVER_H
+
+#include <map>
+#include <mutex>
+
+#include "test/proto/metrics.grpc.pb.h"
+#include "test/proto/metrics.pb.h"
+
+/*
+ * This implements a Metrics server defined in test/proto/metrics.proto. Any
+ * test service can use this to export Metrics (TODO (sreek): Only Gauges for
+ * now).
+ *
+ * Example:
+ * MetricsServiceImpl metricsImpl;
+ * ..
+ * // Create Gauge(s). Note: Gauges can be created even after calling
+ * // 'StartServer'.
+ * Gauge gauge1 = metricsImpl.CreateGauge("foo",is_present);
+ * // gauge1 can now be used anywhere in the program to set values.
+ * ...
+ * // Create the metrics server
+ * std::unique_ptr<grpc::Server> server = metricsImpl.StartServer(port);
+ * server->Wait(); // Note: This is blocking.
+ */
+namespace grpc {
+namespace testing {
+
+// TODO(sreek): Add support for other types of Gauges like Double, String in
+// future
+class Gauge {
+ public:
+ Gauge(long initial_val);
+ void Set(long new_val);
+ long Get();
+
+ private:
+ long val_;
+ std::mutex val_mu_;
+};
+
+class MetricsServiceImpl GRPC_FINAL : public MetricsService::Service {
+ public:
+ grpc::Status GetAllGauges(ServerContext* context, const EmptyMessage* request,
+ ServerWriter<GaugeResponse>* writer) GRPC_OVERRIDE;
+
+ grpc::Status GetGauge(ServerContext* context, const GaugeRequest* request,
+ GaugeResponse* response) GRPC_OVERRIDE;
+
+ // Create a Gauge with name 'name'. is_present is set to true if the Gauge
+ // is already present in the map.
+ // NOTE: CreateGauge can be called anytime (i.e before or after calling
+ // StartServer).
+ std::shared_ptr<Gauge> CreateGauge(const grpc::string& name,
+ bool* already_present);
+
+ std::unique_ptr<grpc::Server> StartServer(int port);
+
+ private:
+ std::map<string, std::shared_ptr<Gauge>> gauges_;
+ std::mutex mu_;
+};
+
+} // namespace testing
+} // namespace grpc
+
+#endif // GRPC_TEST_CPP_METRICS_SERVER_H
diff --git a/test/proto/benchmarks/control.proto b/test/proto/benchmarks/control.proto
index 966ab78baa..42a5dd0a85 100644
--- a/test/proto/benchmarks/control.proto
+++ b/test/proto/benchmarks/control.proto
@@ -49,7 +49,10 @@ enum RpcType {
STREAMING = 1;
}
+// Parameters of poisson process distribution, which is a good representation
+// of activity coming in from independent identical stationary sources.
message PoissonParams {
+ // The rate of arrivals (a.k.a. lambda parameter of the exp distribution).
double offered_load = 1;
}
@@ -67,6 +70,8 @@ message ParetoParams {
double alpha = 2;
}
+// Once an RPC finishes, immediately start a new one.
+// No configuration parameters needed.
message ClosedLoopParams {
}
@@ -87,16 +92,23 @@ message SecurityParams {
}
message ClientConfig {
+ // List of targets to connect to. At least one target needs to be specified.
repeated string server_targets = 1;
ClientType client_type = 2;
SecurityParams security_params = 3;
+ // How many concurrent RPCs to start for each channel.
+ // For synchronous client, use a separate thread for each outstanding RPC.
int32 outstanding_rpcs_per_channel = 4;
+ // Number of independent client channels to create.
+ // i-th channel will connect to server_target[i % server_targets.size()]
int32 client_channels = 5;
- // only for async client:
+ // Only for async client. Number of threads to use to start/manage RPCs.
int32 async_client_threads = 7;
RpcType rpc_type = 8;
+ // The requested load for the entire client (aggregated over all the threads).
LoadParams load_params = 10;
PayloadConfig payload_config = 11;
+ HistogramParams histogram_params = 12;
}
message ClientStatus {
@@ -105,6 +117,7 @@ message ClientStatus {
// Request current stats
message Mark {
+ // if true, the stats will be reset after taking their snapshot.
bool reset = 1;
}
@@ -118,10 +131,13 @@ message ClientArgs {
message ServerConfig {
ServerType server_type = 1;
SecurityParams security_params = 2;
+ // Host on which to listen.
+ string host = 3;
+ // Port on which to listen. Zero means pick unused port.
int32 port = 4;
- // only for async server
+ // Only for async server. Number of threads used to serve the requests.
int32 async_server_threads = 7;
- // restrict core usage
+ // restrict core usage, currently unused
int32 core_limit = 8;
PayloadConfig payload_config = 9;
}
@@ -135,6 +151,8 @@ message ServerArgs {
message ServerStatus {
ServerStats stats = 1;
+ // the port bound by the server
int32 port = 2;
+ // Number of cores on the server. See gpr_cpu_num_cores.
int32 cores = 3;
}
diff --git a/test/proto/benchmarks/services.proto b/test/proto/benchmarks/services.proto
index 4c2cbabdf8..ff295ed970 100644
--- a/test/proto/benchmarks/services.proto
+++ b/test/proto/benchmarks/services.proto
@@ -47,9 +47,19 @@ service BenchmarkService {
}
service WorkerService {
- // Start server with specified workload
+ // Start server with specified workload.
+ // First request sent specifies the ServerConfig followed by ServerStatus
+ // response. After that, a "Mark" can be sent anytime to request the latest
+ // stats. Closing the stream will initiate shutdown of the test server
+ // and once the shutdown has finished, the OK status is sent to terminate
+ // this RPC.
rpc RunServer(stream ServerArgs) returns (stream ServerStatus);
- // Start client with specified workload
+ // Start client with specified workload.
+ // First request sent specifies the ClientConfig followed by ClientStatus
+ // response. After that, a "Mark" can be sent anytime to request the latest
+ // stats. Closing the stream will initiate shutdown of the test client
+ // and once the shutdown has finished, the OK status is sent to terminate
+ // this RPC.
rpc RunClient(stream ClientArgs) returns (stream ClientStatus);
}
diff --git a/test/proto/benchmarks/stats.proto b/test/proto/benchmarks/stats.proto
index d52144f321..7e02707dbb 100644
--- a/test/proto/benchmarks/stats.proto
+++ b/test/proto/benchmarks/stats.proto
@@ -32,16 +32,24 @@ syntax = "proto3";
package grpc.testing;
message ServerStats {
- // wall clock time
+ // wall clock time change in seconds since last reset
double time_elapsed = 1;
- // user time used by the server process and threads
+ // change in user time (in seconds) used by the server since last reset
double time_user = 2;
- // server time used by the server process and all threads
+ // change in server time (in seconds) used by the server process and all
+ // threads since last reset
double time_system = 3;
}
+// Histogram params based on grpc/support/histogram.c
+message HistogramParams {
+ double resolution = 1; // first bucket is [0, 1 + resolution)
+ double max_possible = 2; // use enough buckets to allow this value
+}
+
+// Histogram data based on grpc/support/histogram.c
message HistogramData {
repeated uint32 bucket = 1;
double min_seen = 2;
@@ -52,7 +60,10 @@ message HistogramData {
}
message ClientStats {
+ // Latency histogram. Data points are in nanoseconds.
HistogramData latencies = 1;
+
+ // See ServerStats for details.
double time_elapsed = 2;
double time_user = 3;
double time_system = 4;
diff --git a/test/proto/metrics.proto b/test/proto/metrics.proto
new file mode 100644
index 0000000000..f5a08e056a
--- /dev/null
+++ b/test/proto/metrics.proto
@@ -0,0 +1,56 @@
+
+// Copyright 2015, 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.
+
+// An integration test service that covers all the method signature permutations
+// of unary/streaming requests/responses.
+syntax = "proto3";
+
+package grpc.testing;
+
+message GaugeResponse {
+ string name = 1;
+ oneof value {
+ int64 long_value = 2;
+ double double_vale = 3;
+ string string_value = 4;
+ }
+}
+
+message GaugeRequest {
+ string name = 1;
+}
+
+message EmptyMessage {
+}
+
+service MetricsService {
+ rpc GetAllGauges(EmptyMessage) returns (stream GaugeResponse);
+ rpc GetGauge(GaugeRequest) returns (GaugeResponse);
+}