aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2015-11-21 09:00:11 -0800
committerGravatar Craig Tiller <ctiller@google.com>2015-11-21 09:00:11 -0800
commitd653b394714b1fa342f0872c8262c8cde5511f4b (patch)
tree91573a209f253d58bb4a8b14d759db7e80167b3a /test
parent860f484f43841d14df61cfeda6ca5e637ed99d19 (diff)
parentceb7318d794b4174e18364f6780a5d20e6249e23 (diff)
Merge github.com:grpc/grpc into better-profile
Diffstat (limited to 'test')
-rw-r--r--test/core/client_config/lb_policies_test.c30
-rw-r--r--test/core/end2end/data/server1_cert.c130
-rw-r--r--test/core/end2end/fixtures/h2_fakesec.c10
-rw-r--r--test/core/end2end/fixtures/h2_oauth2.c20
-rw-r--r--test/core/end2end/fixtures/h2_ssl+poll.c11
-rw-r--r--test/core/end2end/fixtures/h2_ssl.c11
-rw-r--r--test/core/end2end/fixtures/h2_ssl_proxy.c16
-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/call_creds.c32
-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.c341
-rw-r--r--test/core/security/fetch_oauth2.c6
-rw-r--r--test/core/security/oauth2_utils.c7
-rw-r--r--test/core/security/oauth2_utils.h3
-rw-r--r--test/core/security/print_google_default_creds_token.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/reconnect_server.c4
-rw-r--r--test/cpp/client/credentials_test.cc4
-rw-r--r--test/cpp/end2end/async_end2end_test.cc4
-rw-r--r--test/cpp/end2end/client_crash_test.cc2
-rw-r--r--test/cpp/end2end/end2end_test.cc71
-rw-r--r--test/cpp/end2end/generic_end2end_test.cc2
-rw-r--r--test/cpp/end2end/mock_test.cc2
-rw-r--r--test/cpp/end2end/server_crash_test_client.cc2
-rw-r--r--test/cpp/end2end/shutdown_test.cc2
-rw-r--r--test/cpp/end2end/streaming_throughput_test.cc2
-rw-r--r--test/cpp/end2end/thread_stress_test.cc2
-rw-r--r--test/cpp/end2end/zookeeper_test.cc2
-rw-r--r--test/cpp/interop/client_helper.cc14
-rw-r--r--test/cpp/interop/interop_client.cc2
-rw-r--r--test/cpp/interop/metrics_client.cc102
-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.cc76
-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.cc6
-rw-r--r--test/cpp/qps/histogram.h7
-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/report.h4
-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/cli_call_test.cc3
-rw-r--r--test/cpp/util/create_test_channel.cc11
-rw-r--r--test/cpp/util/create_test_channel.h2
-rw-r--r--test/cpp/util/grpc_cli.cc4
-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.proto55
65 files changed, 1427 insertions, 497 deletions
diff --git a/test/core/client_config/lb_policies_test.c b/test/core/client_config/lb_policies_test.c
index e44930ed53..6f218e7f08 100644
--- a/test/core/client_config/lb_policies_test.c
+++ b/test/core/client_config/lb_policies_test.c
@@ -135,9 +135,8 @@ static void kill_server(const servers_fixture *f, size_t i) {
gpr_log(GPR_INFO, "KILLING SERVER %d", i);
GPR_ASSERT(f->servers[i] != NULL);
grpc_server_shutdown_and_notify(f->servers[i], f->cq, tag(10000));
- GPR_ASSERT(
- grpc_completion_queue_pluck(f->cq, tag(10000), n_millis_time(5000), NULL)
- .type == GRPC_OP_COMPLETE);
+ GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(10000), n_millis_time(5000),
+ NULL).type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->servers[i]);
f->servers[i] = NULL;
}
@@ -203,8 +202,8 @@ static void teardown_servers(servers_fixture *f) {
if (f->servers[i] == NULL) continue;
grpc_server_shutdown_and_notify(f->servers[i], f->cq, tag(10000));
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(10000),
- n_millis_time(5000), NULL)
- .type == GRPC_OP_COMPLETE);
+ n_millis_time(5000),
+ NULL).type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->servers[i]);
}
grpc_completion_queue_shutdown(f->cq);
@@ -269,8 +268,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;
@@ -303,8 +302,9 @@ int *perform_request(servers_fixture *f, grpc_channel *client,
grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL));
s_idx = -1;
- while ((ev = grpc_completion_queue_next(f->cq, n_millis_time(s_idx == -1 ? 3000 : 200), NULL))
- .type != GRPC_QUEUE_TIMEOUT) {
+ while ((ev = grpc_completion_queue_next(
+ f->cq, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(1), NULL)).type !=
+ GRPC_QUEUE_TIMEOUT) {
GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
read_tag = ((int)(gpr_intptr)ev.tag);
gpr_log(GPR_DEBUG, "EVENT: success:%d, type:%d, tag:%d iter:%d",
@@ -315,6 +315,7 @@ int *perform_request(servers_fixture *f, grpc_channel *client,
s_idx = read_tag - 1000;
s_valid[s_idx] = 1;
connection_sequence[iter_num] = s_idx;
+ break;
} else if (read_tag == 1) {
gpr_log(GPR_DEBUG, "client timed out");
GPR_ASSERT(ev.success);
@@ -453,6 +454,8 @@ void run_spec(const test_spec *spec) {
int *actual_connection_sequence;
request_data rdata;
servers_fixture *f;
+ grpc_channel_args args;
+ grpc_arg arg;
rdata.call_details =
gpr_malloc(sizeof(grpc_call_details) * spec->num_servers);
f = setup_servers("127.0.0.1", &rdata, spec->num_servers);
@@ -462,7 +465,14 @@ void run_spec(const test_spec *spec) {
f->num_servers, ",", NULL);
gpr_asprintf(&client_hostport, "ipv4:%s?lb_policy=round_robin",
servers_hostports_str);
- client = grpc_insecure_channel_create(client_hostport, NULL, NULL);
+
+ arg.type = GRPC_ARG_INTEGER;
+ arg.key = "grpc.testing.fixed_reconnect_backoff";
+ arg.value.integer = 100;
+ args.num_args = 1;
+ args.args = &arg;
+
+ client = grpc_insecure_channel_create(client_hostport, &args, NULL);
gpr_log(GPR_INFO, "Testing '%s' with servers=%s client=%s", spec->description,
servers_hostports_str, client_hostport);
diff --git a/test/core/end2end/data/server1_cert.c b/test/core/end2end/data/server1_cert.c
index d31f2e2d0e..82d65cf551 100644
--- a/test/core/end2end/data/server1_cert.c
+++ b/test/core/end2end/data/server1_cert.c
@@ -34,82 +34,82 @@
const char test_server1_cert[] = {
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x42, 0x45, 0x47, 0x49, 0x4e, 0x20, 0x43,
0x45, 0x52, 0x54, 0x49, 0x46, 0x49, 0x43, 0x41, 0x54, 0x45, 0x2d, 0x2d,
- 0x2d, 0x2d, 0x2d, 0x0a, 0x4d, 0x49, 0x49, 0x43, 0x6d, 0x7a, 0x43, 0x43,
- 0x41, 0x67, 0x53, 0x67, 0x41, 0x77, 0x49, 0x42, 0x41, 0x67, 0x49, 0x42,
- 0x41, 0x7a, 0x41, 0x4e, 0x42, 0x67, 0x6b, 0x71, 0x68, 0x6b, 0x69, 0x47,
- 0x39, 0x77, 0x30, 0x42, 0x41, 0x51, 0x55, 0x46, 0x41, 0x44, 0x42, 0x57,
+ 0x2d, 0x2d, 0x2d, 0x0a, 0x4d, 0x49, 0x49, 0x43, 0x6e, 0x44, 0x43, 0x43,
+ 0x41, 0x67, 0x57, 0x67, 0x41, 0x77, 0x49, 0x42, 0x41, 0x67, 0x49, 0x42,
+ 0x42, 0x7a, 0x41, 0x4e, 0x42, 0x67, 0x6b, 0x71, 0x68, 0x6b, 0x69, 0x47,
+ 0x39, 0x77, 0x30, 0x42, 0x41, 0x51, 0x73, 0x46, 0x41, 0x44, 0x42, 0x57,
0x4d, 0x51, 0x73, 0x77, 0x43, 0x51, 0x59, 0x44, 0x56, 0x51, 0x51, 0x47,
0x45, 0x77, 0x4a, 0x42, 0x56, 0x54, 0x45, 0x54, 0x0a, 0x4d, 0x42, 0x45,
- 0x47, 0x41, 0x31, 0x55, 0x45, 0x43, 0x41, 0x77, 0x4b, 0x55, 0x32, 0x39,
+ 0x47, 0x41, 0x31, 0x55, 0x45, 0x43, 0x42, 0x4d, 0x4b, 0x55, 0x32, 0x39,
0x74, 0x5a, 0x53, 0x31, 0x54, 0x64, 0x47, 0x46, 0x30, 0x5a, 0x54, 0x45,
- 0x68, 0x4d, 0x42, 0x38, 0x47, 0x41, 0x31, 0x55, 0x45, 0x43, 0x67, 0x77,
+ 0x68, 0x4d, 0x42, 0x38, 0x47, 0x41, 0x31, 0x55, 0x45, 0x43, 0x68, 0x4d,
0x59, 0x53, 0x57, 0x35, 0x30, 0x5a, 0x58, 0x4a, 0x75, 0x5a, 0x58, 0x51,
0x67, 0x56, 0x32, 0x6c, 0x6b, 0x5a, 0x32, 0x6c, 0x30, 0x63, 0x79, 0x42,
0x51, 0x0a, 0x64, 0x48, 0x6b, 0x67, 0x54, 0x48, 0x52, 0x6b, 0x4d, 0x51,
- 0x38, 0x77, 0x44, 0x51, 0x59, 0x44, 0x56, 0x51, 0x51, 0x44, 0x44, 0x41,
+ 0x38, 0x77, 0x44, 0x51, 0x59, 0x44, 0x56, 0x51, 0x51, 0x44, 0x45, 0x77,
0x5a, 0x30, 0x5a, 0x58, 0x4e, 0x30, 0x59, 0x32, 0x45, 0x77, 0x48, 0x68,
- 0x63, 0x4e, 0x4d, 0x54, 0x51, 0x77, 0x4e, 0x7a, 0x49, 0x79, 0x4d, 0x44,
- 0x59, 0x77, 0x4d, 0x44, 0x55, 0x33, 0x57, 0x68, 0x63, 0x4e, 0x4d, 0x6a,
- 0x51, 0x77, 0x4e, 0x7a, 0x45, 0x35, 0x0a, 0x4d, 0x44, 0x59, 0x77, 0x4d,
- 0x44, 0x55, 0x33, 0x57, 0x6a, 0x42, 0x6b, 0x4d, 0x51, 0x73, 0x77, 0x43,
+ 0x63, 0x4e, 0x4d, 0x54, 0x55, 0x78, 0x4d, 0x54, 0x41, 0x30, 0x4d, 0x44,
+ 0x49, 0x79, 0x4d, 0x44, 0x49, 0x30, 0x57, 0x68, 0x63, 0x4e, 0x4d, 0x6a,
+ 0x55, 0x78, 0x4d, 0x54, 0x41, 0x78, 0x0a, 0x4d, 0x44, 0x49, 0x79, 0x4d,
+ 0x44, 0x49, 0x30, 0x57, 0x6a, 0x42, 0x6c, 0x4d, 0x51, 0x73, 0x77, 0x43,
0x51, 0x59, 0x44, 0x56, 0x51, 0x51, 0x47, 0x45, 0x77, 0x4a, 0x56, 0x55,
0x7a, 0x45, 0x52, 0x4d, 0x41, 0x38, 0x47, 0x41, 0x31, 0x55, 0x45, 0x43,
0x42, 0x4d, 0x49, 0x53, 0x57, 0x78, 0x73, 0x61, 0x57, 0x35, 0x76, 0x61,
0x58, 0x4d, 0x78, 0x45, 0x44, 0x41, 0x4f, 0x42, 0x67, 0x4e, 0x56, 0x0a,
0x42, 0x41, 0x63, 0x54, 0x42, 0x30, 0x4e, 0x6f, 0x61, 0x57, 0x4e, 0x68,
- 0x5a, 0x32, 0x38, 0x78, 0x46, 0x44, 0x41, 0x53, 0x42, 0x67, 0x4e, 0x56,
- 0x42, 0x41, 0x6f, 0x54, 0x43, 0x30, 0x64, 0x76, 0x62, 0x32, 0x64, 0x73,
- 0x5a, 0x53, 0x42, 0x4a, 0x62, 0x6d, 0x4d, 0x75, 0x4d, 0x52, 0x6f, 0x77,
- 0x47, 0x41, 0x59, 0x44, 0x56, 0x51, 0x51, 0x44, 0x46, 0x42, 0x45, 0x71,
- 0x4c, 0x6e, 0x52, 0x6c, 0x0a, 0x63, 0x33, 0x51, 0x75, 0x5a, 0x32, 0x39,
- 0x76, 0x5a, 0x32, 0x78, 0x6c, 0x4c, 0x6d, 0x4e, 0x76, 0x62, 0x54, 0x43,
- 0x42, 0x6e, 0x7a, 0x41, 0x4e, 0x42, 0x67, 0x6b, 0x71, 0x68, 0x6b, 0x69,
- 0x47, 0x39, 0x77, 0x30, 0x42, 0x41, 0x51, 0x45, 0x46, 0x41, 0x41, 0x4f,
- 0x42, 0x6a, 0x51, 0x41, 0x77, 0x67, 0x59, 0x6b, 0x43, 0x67, 0x59, 0x45,
- 0x41, 0x34, 0x63, 0x4d, 0x56, 0x4a, 0x79, 0x67, 0x73, 0x0a, 0x4a, 0x55,
- 0x6d, 0x6c, 0x67, 0x4d, 0x4d, 0x7a, 0x67, 0x64, 0x69, 0x30, 0x68, 0x31,
- 0x58, 0x6f, 0x43, 0x52, 0x37, 0x2b, 0x77, 0x77, 0x31, 0x70, 0x6f, 0x70,
- 0x30, 0x34, 0x4f, 0x4d, 0x4d, 0x79, 0x79, 0x37, 0x48, 0x2f, 0x69, 0x30,
- 0x50, 0x4a, 0x32, 0x57, 0x36, 0x59, 0x33, 0x35, 0x2b, 0x62, 0x34, 0x43,
- 0x4d, 0x38, 0x51, 0x72, 0x6b, 0x59, 0x65, 0x45, 0x61, 0x66, 0x55, 0x47,
- 0x44, 0x4f, 0x0a, 0x52, 0x59, 0x58, 0x36, 0x79, 0x56, 0x2f, 0x63, 0x48,
- 0x47, 0x47, 0x73, 0x44, 0x2f, 0x78, 0x30, 0x32, 0x79, 0x65, 0x36, 0x65,
- 0x79, 0x31, 0x55, 0x44, 0x74, 0x6b, 0x47, 0x41, 0x44, 0x2f, 0x6d, 0x70,
- 0x44, 0x45, 0x78, 0x38, 0x59, 0x43, 0x72, 0x6a, 0x41, 0x63, 0x31, 0x56,
- 0x66, 0x76, 0x74, 0x38, 0x46, 0x6b, 0x36, 0x43, 0x6e, 0x31, 0x57, 0x56,
- 0x49, 0x78, 0x56, 0x2f, 0x4a, 0x33, 0x30, 0x0a, 0x33, 0x78, 0x6a, 0x42,
- 0x73, 0x46, 0x67, 0x42, 0x79, 0x51, 0x35, 0x35, 0x52, 0x42, 0x70, 0x31,
- 0x4f, 0x4c, 0x5a, 0x66, 0x56, 0x4c, 0x6f, 0x36, 0x41, 0x6c, 0x65, 0x42,
- 0x44, 0x53, 0x62, 0x63, 0x78, 0x61, 0x45, 0x43, 0x41, 0x77, 0x45, 0x41,
- 0x41, 0x61, 0x4e, 0x72, 0x4d, 0x47, 0x6b, 0x77, 0x43, 0x51, 0x59, 0x44,
- 0x56, 0x52, 0x30, 0x54, 0x42, 0x41, 0x49, 0x77, 0x41, 0x44, 0x41, 0x4c,
- 0x0a, 0x42, 0x67, 0x4e, 0x56, 0x48, 0x51, 0x38, 0x45, 0x42, 0x41, 0x4d,
- 0x43, 0x42, 0x65, 0x41, 0x77, 0x54, 0x77, 0x59, 0x44, 0x56, 0x52, 0x30,
- 0x52, 0x42, 0x45, 0x67, 0x77, 0x52, 0x6f, 0x49, 0x51, 0x4b, 0x69, 0x35,
- 0x30, 0x5a, 0x58, 0x4e, 0x30, 0x4c, 0x6d, 0x64, 0x76, 0x62, 0x32, 0x64,
- 0x73, 0x5a, 0x53, 0x35, 0x6d, 0x63, 0x6f, 0x49, 0x59, 0x64, 0x32, 0x46,
- 0x30, 0x5a, 0x58, 0x4a, 0x36, 0x0a, 0x62, 0x32, 0x39, 0x70, 0x4c, 0x6e,
- 0x52, 0x6c, 0x63, 0x33, 0x51, 0x75, 0x5a, 0x32, 0x39, 0x76, 0x5a, 0x32,
- 0x78, 0x6c, 0x4c, 0x6d, 0x4a, 0x6c, 0x67, 0x68, 0x49, 0x71, 0x4c, 0x6e,
- 0x52, 0x6c, 0x63, 0x33, 0x51, 0x75, 0x65, 0x57, 0x39, 0x31, 0x64, 0x48,
- 0x56, 0x69, 0x5a, 0x53, 0x35, 0x6a, 0x62, 0x32, 0x32, 0x48, 0x42, 0x4d,
- 0x43, 0x6f, 0x41, 0x51, 0x4d, 0x77, 0x44, 0x51, 0x59, 0x4a, 0x0a, 0x4b,
- 0x6f, 0x5a, 0x49, 0x68, 0x76, 0x63, 0x4e, 0x41, 0x51, 0x45, 0x46, 0x42,
- 0x51, 0x41, 0x44, 0x67, 0x59, 0x45, 0x41, 0x4d, 0x32, 0x49, 0x69, 0x30,
- 0x4c, 0x67, 0x54, 0x47, 0x62, 0x4a, 0x31, 0x6a, 0x34, 0x6f, 0x71, 0x58,
- 0x39, 0x62, 0x78, 0x56, 0x63, 0x78, 0x6d, 0x2b, 0x2f, 0x52, 0x35, 0x59,
- 0x66, 0x38, 0x6f, 0x69, 0x30, 0x61, 0x5a, 0x71, 0x54, 0x4a, 0x6c, 0x6e,
- 0x4c, 0x59, 0x53, 0x0a, 0x77, 0x58, 0x63, 0x42, 0x79, 0x6b, 0x78, 0x54,
- 0x78, 0x31, 0x38, 0x31, 0x73, 0x37, 0x57, 0x79, 0x66, 0x4a, 0x34, 0x39,
- 0x57, 0x77, 0x72, 0x59, 0x58, 0x6f, 0x37, 0x38, 0x7a, 0x54, 0x44, 0x41,
- 0x6e, 0x66, 0x31, 0x6d, 0x61, 0x30, 0x66, 0x50, 0x71, 0x33, 0x65, 0x34,
- 0x6d, 0x70, 0x73, 0x70, 0x76, 0x79, 0x6e, 0x64, 0x4c, 0x68, 0x31, 0x61,
- 0x2b, 0x4f, 0x61, 0x72, 0x48, 0x61, 0x31, 0x65, 0x0a, 0x61, 0x54, 0x30,
- 0x44, 0x49, 0x49, 0x59, 0x6b, 0x37, 0x71, 0x65, 0x45, 0x61, 0x31, 0x59,
- 0x63, 0x56, 0x6c, 0x6a, 0x78, 0x32, 0x4b, 0x79, 0x4c, 0x64, 0x30, 0x72,
- 0x31, 0x42, 0x42, 0x41, 0x66, 0x72, 0x77, 0x79, 0x47, 0x61, 0x45, 0x50,
- 0x56, 0x65, 0x4a, 0x51, 0x56, 0x59, 0x57, 0x61, 0x4f, 0x4a, 0x52, 0x55,
- 0x32, 0x77, 0x65, 0x2f, 0x4b, 0x44, 0x34, 0x6f, 0x6a, 0x66, 0x39, 0x73,
- 0x3d, 0x0a, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x45, 0x4e, 0x44, 0x20, 0x43,
+ 0x5a, 0x32, 0x38, 0x78, 0x46, 0x54, 0x41, 0x54, 0x42, 0x67, 0x4e, 0x56,
+ 0x42, 0x41, 0x6f, 0x54, 0x44, 0x45, 0x56, 0x34, 0x59, 0x57, 0x31, 0x77,
+ 0x62, 0x47, 0x55, 0x73, 0x49, 0x45, 0x4e, 0x76, 0x4c, 0x6a, 0x45, 0x61,
+ 0x4d, 0x42, 0x67, 0x47, 0x41, 0x31, 0x55, 0x45, 0x41, 0x78, 0x51, 0x52,
+ 0x4b, 0x69, 0x35, 0x30, 0x0a, 0x5a, 0x58, 0x4e, 0x30, 0x4c, 0x6d, 0x64,
+ 0x76, 0x62, 0x32, 0x64, 0x73, 0x5a, 0x53, 0x35, 0x6a, 0x62, 0x32, 0x30,
+ 0x77, 0x67, 0x5a, 0x38, 0x77, 0x44, 0x51, 0x59, 0x4a, 0x4b, 0x6f, 0x5a,
+ 0x49, 0x68, 0x76, 0x63, 0x4e, 0x41, 0x51, 0x45, 0x42, 0x42, 0x51, 0x41,
+ 0x44, 0x67, 0x59, 0x30, 0x41, 0x4d, 0x49, 0x47, 0x4a, 0x41, 0x6f, 0x47,
+ 0x42, 0x41, 0x4f, 0x48, 0x44, 0x46, 0x53, 0x63, 0x6f, 0x0a, 0x4c, 0x43,
+ 0x56, 0x4a, 0x70, 0x59, 0x44, 0x44, 0x4d, 0x34, 0x48, 0x59, 0x74, 0x49,
+ 0x64, 0x56, 0x36, 0x41, 0x6b, 0x65, 0x2f, 0x73, 0x4d, 0x4e, 0x61, 0x61,
+ 0x4b, 0x64, 0x4f, 0x44, 0x6a, 0x44, 0x4d, 0x73, 0x75, 0x78, 0x2f, 0x34,
+ 0x74, 0x44, 0x79, 0x64, 0x6c, 0x75, 0x6d, 0x4e, 0x2b, 0x66, 0x6d, 0x2b,
+ 0x41, 0x6a, 0x50, 0x45, 0x4b, 0x35, 0x47, 0x48, 0x68, 0x47, 0x6e, 0x31,
+ 0x42, 0x67, 0x0a, 0x7a, 0x6b, 0x57, 0x46, 0x2b, 0x73, 0x6c, 0x66, 0x33,
+ 0x42, 0x78, 0x68, 0x72, 0x41, 0x2f, 0x38, 0x64, 0x4e, 0x73, 0x6e, 0x75,
+ 0x6e, 0x73, 0x74, 0x56, 0x41, 0x37, 0x5a, 0x42, 0x67, 0x41, 0x2f, 0x35,
+ 0x71, 0x51, 0x78, 0x4d, 0x66, 0x47, 0x41, 0x71, 0x34, 0x77, 0x48, 0x4e,
+ 0x56, 0x58, 0x37, 0x37, 0x66, 0x42, 0x5a, 0x4f, 0x67, 0x70, 0x39, 0x56,
+ 0x6c, 0x53, 0x4d, 0x56, 0x66, 0x79, 0x64, 0x0a, 0x39, 0x4e, 0x38, 0x59,
+ 0x77, 0x62, 0x42, 0x59, 0x41, 0x63, 0x6b, 0x4f, 0x65, 0x55, 0x51, 0x61,
+ 0x64, 0x54, 0x69, 0x32, 0x58, 0x31, 0x53, 0x36, 0x4f, 0x67, 0x4a, 0x58,
+ 0x67, 0x51, 0x30, 0x6d, 0x33, 0x4d, 0x57, 0x68, 0x41, 0x67, 0x4d, 0x42,
+ 0x41, 0x41, 0x47, 0x6a, 0x61, 0x7a, 0x42, 0x70, 0x4d, 0x41, 0x6b, 0x47,
+ 0x41, 0x31, 0x55, 0x64, 0x45, 0x77, 0x51, 0x43, 0x4d, 0x41, 0x41, 0x77,
+ 0x0a, 0x43, 0x77, 0x59, 0x44, 0x56, 0x52, 0x30, 0x50, 0x42, 0x41, 0x51,
+ 0x44, 0x41, 0x67, 0x58, 0x67, 0x4d, 0x45, 0x38, 0x47, 0x41, 0x31, 0x55,
+ 0x64, 0x45, 0x51, 0x52, 0x49, 0x4d, 0x45, 0x61, 0x43, 0x45, 0x43, 0x6f,
+ 0x75, 0x64, 0x47, 0x56, 0x7a, 0x64, 0x43, 0x35, 0x6e, 0x62, 0x32, 0x39,
+ 0x6e, 0x62, 0x47, 0x55, 0x75, 0x5a, 0x6e, 0x4b, 0x43, 0x47, 0x48, 0x64,
+ 0x68, 0x64, 0x47, 0x56, 0x79, 0x0a, 0x65, 0x6d, 0x39, 0x76, 0x61, 0x53,
+ 0x35, 0x30, 0x5a, 0x58, 0x4e, 0x30, 0x4c, 0x6d, 0x64, 0x76, 0x62, 0x32,
+ 0x64, 0x73, 0x5a, 0x53, 0x35, 0x69, 0x5a, 0x59, 0x49, 0x53, 0x4b, 0x69,
+ 0x35, 0x30, 0x5a, 0x58, 0x4e, 0x30, 0x4c, 0x6e, 0x6c, 0x76, 0x64, 0x58,
+ 0x52, 0x31, 0x59, 0x6d, 0x55, 0x75, 0x59, 0x32, 0x39, 0x74, 0x68, 0x77,
+ 0x54, 0x41, 0x71, 0x41, 0x45, 0x44, 0x4d, 0x41, 0x30, 0x47, 0x0a, 0x43,
+ 0x53, 0x71, 0x47, 0x53, 0x49, 0x62, 0x33, 0x44, 0x51, 0x45, 0x42, 0x43,
+ 0x77, 0x55, 0x41, 0x41, 0x34, 0x47, 0x42, 0x41, 0x4a, 0x46, 0x58, 0x56,
+ 0x69, 0x66, 0x51, 0x4e, 0x75, 0x62, 0x31, 0x4c, 0x55, 0x50, 0x34, 0x4a,
+ 0x6c, 0x6e, 0x58, 0x35, 0x6c, 0x58, 0x4e, 0x6c, 0x6f, 0x38, 0x46, 0x78,
+ 0x5a, 0x32, 0x61, 0x31, 0x32, 0x41, 0x46, 0x51, 0x73, 0x2b, 0x62, 0x7a,
+ 0x6f, 0x4a, 0x36, 0x0a, 0x68, 0x4d, 0x30, 0x34, 0x34, 0x45, 0x44, 0x6a,
+ 0x71, 0x79, 0x78, 0x55, 0x71, 0x53, 0x62, 0x56, 0x65, 0x50, 0x4b, 0x30,
+ 0x6e, 0x69, 0x33, 0x77, 0x31, 0x66, 0x48, 0x51, 0x42, 0x35, 0x72, 0x59,
+ 0x39, 0x79, 0x59, 0x43, 0x35, 0x66, 0x38, 0x47, 0x37, 0x61, 0x71, 0x71,
+ 0x54, 0x59, 0x31, 0x51, 0x4f, 0x68, 0x6f, 0x55, 0x6b, 0x38, 0x5a, 0x54,
+ 0x53, 0x54, 0x52, 0x70, 0x6e, 0x6b, 0x54, 0x68, 0x0a, 0x79, 0x34, 0x6a,
+ 0x6a, 0x64, 0x76, 0x54, 0x5a, 0x65, 0x4c, 0x44, 0x56, 0x42, 0x6c, 0x75,
+ 0x65, 0x5a, 0x55, 0x54, 0x44, 0x52, 0x6d, 0x79, 0x32, 0x66, 0x65, 0x59,
+ 0x35, 0x61, 0x5a, 0x49, 0x55, 0x31, 0x38, 0x76, 0x46, 0x44, 0x4b, 0x30,
+ 0x38, 0x64, 0x54, 0x47, 0x30, 0x41, 0x38, 0x37, 0x70, 0x70, 0x70, 0x75,
+ 0x76, 0x31, 0x4c, 0x4e, 0x49, 0x52, 0x33, 0x6c, 0x6f, 0x76, 0x65, 0x55,
+ 0x38, 0x0a, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x45, 0x4e, 0x44, 0x20, 0x43,
0x45, 0x52, 0x54, 0x49, 0x46, 0x49, 0x43, 0x41, 0x54, 0x45, 0x2d, 0x2d,
0x2d, 0x2d, 0x2d, 0x0a, 0x00};
diff --git a/test/core/end2end/fixtures/h2_fakesec.c b/test/core/end2end/fixtures/h2_fakesec.c
index 3e64cc08e8..bc009e1df1 100644
--- a/test/core/end2end/fixtures/h2_fakesec.c
+++ b/test/core/end2end/fixtures/h2_fakesec.c
@@ -73,14 +73,14 @@ static void process_auth_failure(void *state, grpc_auth_context *ctx,
cb(user_data, NULL, 0, NULL, 0, GRPC_STATUS_UNAUTHENTICATED, NULL);
}
-static void chttp2_init_client_secure_fullstack(grpc_end2end_test_fixture *f,
- grpc_channel_args *client_args,
- grpc_credentials *creds) {
+static void chttp2_init_client_secure_fullstack(
+ grpc_end2end_test_fixture *f, grpc_channel_args *client_args,
+ grpc_channel_credentials *creds) {
fullstack_secure_fixture_data *ffd = f->fixture_data;
f->client =
grpc_secure_channel_create(creds, ffd->localaddr, client_args, NULL);
GPR_ASSERT(f->client != NULL);
- grpc_credentials_release(creds);
+ grpc_channel_credentials_release(creds);
}
static void chttp2_init_server_secure_fullstack(
@@ -106,7 +106,7 @@ void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture *f) {
static void chttp2_init_client_fake_secure_fullstack(
grpc_end2end_test_fixture *f, grpc_channel_args *client_args) {
- grpc_credentials *fake_ts_creds =
+ grpc_channel_credentials *fake_ts_creds =
grpc_fake_transport_security_credentials_create();
chttp2_init_client_secure_fullstack(f, client_args, fake_ts_creds);
}
diff --git a/test/core/end2end/fixtures/h2_oauth2.c b/test/core/end2end/fixtures/h2_oauth2.c
index 10db6c2c6a..7a34cc67d8 100644
--- a/test/core/end2end/fixtures/h2_oauth2.c
+++ b/test/core/end2end/fixtures/h2_oauth2.c
@@ -118,14 +118,14 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack(
return f;
}
-static void chttp2_init_client_secure_fullstack(grpc_end2end_test_fixture *f,
- grpc_channel_args *client_args,
- grpc_credentials *creds) {
+static void chttp2_init_client_secure_fullstack(
+ grpc_end2end_test_fixture *f, grpc_channel_args *client_args,
+ grpc_channel_credentials *creds) {
fullstack_secure_fixture_data *ffd = f->fixture_data;
f->client =
grpc_secure_channel_create(creds, ffd->localaddr, client_args, NULL);
GPR_ASSERT(f->client != NULL);
- grpc_credentials_release(creds);
+ grpc_channel_credentials_release(creds);
}
static void chttp2_init_server_secure_fullstack(
@@ -151,12 +151,12 @@ void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture *f) {
static void chttp2_init_client_simple_ssl_with_oauth2_secure_fullstack(
grpc_end2end_test_fixture *f, grpc_channel_args *client_args) {
- grpc_credentials *ssl_creds =
+ grpc_channel_credentials *ssl_creds =
grpc_ssl_credentials_create(test_root_cert, NULL, NULL);
- grpc_credentials *oauth2_creds =
+ grpc_call_credentials *oauth2_creds =
grpc_md_only_test_credentials_create("Authorization", oauth2_md, 1);
- grpc_credentials *ssl_oauth2_creds =
- grpc_composite_credentials_create(ssl_creds, oauth2_creds, NULL);
+ grpc_channel_credentials *ssl_oauth2_creds =
+ grpc_composite_channel_credentials_create(ssl_creds, oauth2_creds, NULL);
grpc_arg ssl_name_override = {GRPC_ARG_STRING,
GRPC_SSL_TARGET_NAME_OVERRIDE_ARG,
{"foo.test.google.fr"}};
@@ -164,8 +164,8 @@ static void chttp2_init_client_simple_ssl_with_oauth2_secure_fullstack(
grpc_channel_args_copy_and_add(client_args, &ssl_name_override, 1);
chttp2_init_client_secure_fullstack(f, new_client_args, ssl_oauth2_creds);
grpc_channel_args_destroy(new_client_args);
- grpc_credentials_release(ssl_creds);
- grpc_credentials_release(oauth2_creds);
+ grpc_channel_credentials_release(ssl_creds);
+ grpc_call_credentials_release(oauth2_creds);
}
static int fail_server_auth_check(grpc_channel_args *server_args) {
diff --git a/test/core/end2end/fixtures/h2_ssl+poll.c b/test/core/end2end/fixtures/h2_ssl+poll.c
index c2f41f4886..37e1758f00 100644
--- a/test/core/end2end/fixtures/h2_ssl+poll.c
+++ b/test/core/end2end/fixtures/h2_ssl+poll.c
@@ -76,14 +76,14 @@ static void process_auth_failure(void *state, grpc_auth_context *ctx,
cb(user_data, NULL, 0, NULL, 0, GRPC_STATUS_UNAUTHENTICATED, NULL);
}
-static void chttp2_init_client_secure_fullstack(grpc_end2end_test_fixture *f,
- grpc_channel_args *client_args,
- grpc_credentials *creds) {
+static void chttp2_init_client_secure_fullstack(
+ grpc_end2end_test_fixture *f, grpc_channel_args *client_args,
+ grpc_channel_credentials *creds) {
fullstack_secure_fixture_data *ffd = f->fixture_data;
f->client =
grpc_secure_channel_create(creds, ffd->localaddr, client_args, NULL);
GPR_ASSERT(f->client != NULL);
- grpc_credentials_release(creds);
+ grpc_channel_credentials_release(creds);
}
static void chttp2_init_server_secure_fullstack(
@@ -109,7 +109,8 @@ void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture *f) {
static void chttp2_init_client_simple_ssl_secure_fullstack(
grpc_end2end_test_fixture *f, grpc_channel_args *client_args) {
- grpc_credentials *ssl_creds = grpc_ssl_credentials_create(NULL, NULL, NULL);
+ grpc_channel_credentials *ssl_creds =
+ grpc_ssl_credentials_create(NULL, NULL, NULL);
grpc_arg ssl_name_override = {GRPC_ARG_STRING,
GRPC_SSL_TARGET_NAME_OVERRIDE_ARG,
{"foo.test.google.fr"}};
diff --git a/test/core/end2end/fixtures/h2_ssl.c b/test/core/end2end/fixtures/h2_ssl.c
index 896c60c507..f5a006bd08 100644
--- a/test/core/end2end/fixtures/h2_ssl.c
+++ b/test/core/end2end/fixtures/h2_ssl.c
@@ -76,14 +76,14 @@ static void process_auth_failure(void *state, grpc_auth_context *ctx,
cb(user_data, NULL, 0, NULL, 0, GRPC_STATUS_UNAUTHENTICATED, NULL);
}
-static void chttp2_init_client_secure_fullstack(grpc_end2end_test_fixture *f,
- grpc_channel_args *client_args,
- grpc_credentials *creds) {
+static void chttp2_init_client_secure_fullstack(
+ grpc_end2end_test_fixture *f, grpc_channel_args *client_args,
+ grpc_channel_credentials *creds) {
fullstack_secure_fixture_data *ffd = f->fixture_data;
f->client =
grpc_secure_channel_create(creds, ffd->localaddr, client_args, NULL);
GPR_ASSERT(f->client != NULL);
- grpc_credentials_release(creds);
+ grpc_channel_credentials_release(creds);
}
static void chttp2_init_server_secure_fullstack(
@@ -109,7 +109,8 @@ void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture *f) {
static void chttp2_init_client_simple_ssl_secure_fullstack(
grpc_end2end_test_fixture *f, grpc_channel_args *client_args) {
- grpc_credentials *ssl_creds = grpc_ssl_credentials_create(NULL, NULL, NULL);
+ grpc_channel_credentials *ssl_creds =
+ grpc_ssl_credentials_create(NULL, NULL, NULL);
grpc_arg ssl_name_override = {GRPC_ARG_STRING,
GRPC_SSL_TARGET_NAME_OVERRIDE_ARG,
{"foo.test.google.fr"}};
diff --git a/test/core/end2end/fixtures/h2_ssl_proxy.c b/test/core/end2end/fixtures/h2_ssl_proxy.c
index 413a8b84cd..7233cdbe2d 100644
--- a/test/core/end2end/fixtures/h2_ssl_proxy.c
+++ b/test/core/end2end/fixtures/h2_ssl_proxy.c
@@ -66,7 +66,8 @@ static grpc_server *create_proxy_server(const char *port) {
static grpc_channel *create_proxy_client(const char *target) {
grpc_channel *channel;
- grpc_credentials *ssl_creds = grpc_ssl_credentials_create(NULL, NULL, NULL);
+ grpc_channel_credentials *ssl_creds =
+ grpc_ssl_credentials_create(NULL, NULL, NULL);
grpc_arg ssl_name_override = {GRPC_ARG_STRING,
GRPC_SSL_TARGET_NAME_OVERRIDE_ARG,
{"foo.test.google.fr"}};
@@ -74,7 +75,7 @@ static grpc_channel *create_proxy_client(const char *target) {
client_args.num_args = 1;
client_args.args = &ssl_name_override;
channel = grpc_secure_channel_create(ssl_creds, target, &client_args, NULL);
- grpc_credentials_release(ssl_creds);
+ grpc_channel_credentials_release(ssl_creds);
return channel;
}
@@ -104,15 +105,15 @@ static void process_auth_failure(void *state, grpc_auth_context *ctx,
cb(user_data, NULL, 0, NULL, 0, GRPC_STATUS_UNAUTHENTICATED, NULL);
}
-static void chttp2_init_client_secure_fullstack(grpc_end2end_test_fixture *f,
- grpc_channel_args *client_args,
- grpc_credentials *creds) {
+static void chttp2_init_client_secure_fullstack(
+ grpc_end2end_test_fixture *f, grpc_channel_args *client_args,
+ grpc_channel_credentials *creds) {
fullstack_secure_fixture_data *ffd = f->fixture_data;
f->client = grpc_secure_channel_create(
creds, grpc_end2end_proxy_get_client_target(ffd->proxy), client_args,
NULL);
GPR_ASSERT(f->client != NULL);
- grpc_credentials_release(creds);
+ grpc_channel_credentials_release(creds);
}
static void chttp2_init_server_secure_fullstack(
@@ -138,7 +139,8 @@ void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture *f) {
static void chttp2_init_client_simple_ssl_secure_fullstack(
grpc_end2end_test_fixture *f, grpc_channel_args *client_args) {
- grpc_credentials *ssl_creds = grpc_ssl_credentials_create(NULL, NULL, NULL);
+ grpc_channel_credentials *ssl_creds =
+ grpc_ssl_credentials_create(NULL, NULL, NULL);
grpc_arg ssl_name_override = {GRPC_ARG_STRING,
GRPC_SSL_TARGET_NAME_OVERRIDE_ARG,
{"foo.test.google.fr"}};
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/call_creds.c b/test/core/end2end/tests/call_creds.c
index 4aeade1336..bbfad21b62 100644
--- a/test/core/end2end/tests/call_creds.c
+++ b/test/core/end2end/tests/call_creds.c
@@ -132,27 +132,6 @@ static void print_auth_context(int is_client, const grpc_auth_context *ctx) {
}
}
-static void test_call_creds_failure(grpc_end2end_test_config config) {
- grpc_call *c;
- grpc_credentials *creds = NULL;
- grpc_end2end_test_fixture f =
- begin_test(config, "test_call_creds_failure", 0);
- gpr_timespec deadline = five_seconds_time();
- c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq,
- "/foo", "foo.test.google.fr", deadline, NULL);
- GPR_ASSERT(c);
-
- /* Try with credentials unfit to be set on a call (channel creds). */
- creds = grpc_fake_transport_security_credentials_create();
- GPR_ASSERT(grpc_call_set_credentials(c, creds) != GRPC_CALL_OK);
- grpc_credentials_release(creds);
-
- grpc_call_destroy(c);
-
- end_test(&f);
- config.tear_down_data(&f);
-}
-
static void request_response_with_payload_and_call_creds(
const char *test_name, grpc_end2end_test_config config,
override_mode mode) {
@@ -180,7 +159,7 @@ static void request_response_with_payload_and_call_creds(
char *details = NULL;
size_t details_capacity = 0;
int was_cancelled = 2;
- grpc_credentials *creds = NULL;
+ grpc_call_credentials *creds = NULL;
grpc_auth_context *s_auth_context = NULL;
grpc_auth_context *c_auth_context = NULL;
@@ -197,7 +176,7 @@ static void request_response_with_payload_and_call_creds(
case NONE:
break;
case OVERRIDE:
- grpc_credentials_release(creds);
+ grpc_call_credentials_release(creds);
creds = grpc_google_iam_credentials_create(overridden_iam_token,
overridden_iam_selector, NULL);
GPR_ASSERT(creds != NULL);
@@ -207,7 +186,7 @@ static void request_response_with_payload_and_call_creds(
GPR_ASSERT(grpc_call_set_credentials(c, NULL) == GRPC_CALL_OK);
break;
}
- grpc_credentials_release(creds);
+ grpc_call_credentials_release(creds);
grpc_metadata_array_init(&initial_metadata_recv);
grpc_metadata_array_init(&trailing_metadata_recv);
@@ -412,7 +391,7 @@ static void test_request_with_server_rejecting_client_creds(
gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world");
grpc_byte_buffer *request_payload =
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
- grpc_credentials *creds;
+ grpc_call_credentials *creds;
f = begin_test(config, "test_request_with_server_rejecting_client_creds", 1);
cqv = cq_verifier_create(f.cq);
@@ -424,7 +403,7 @@ static void test_request_with_server_rejecting_client_creds(
creds = grpc_google_iam_credentials_create(iam_token, iam_selector, NULL);
GPR_ASSERT(creds != NULL);
GPR_ASSERT(grpc_call_set_credentials(c, creds) == GRPC_CALL_OK);
- grpc_credentials_release(creds);
+ grpc_call_credentials_release(creds);
grpc_metadata_array_init(&initial_metadata_recv);
grpc_metadata_array_init(&trailing_metadata_recv);
@@ -490,7 +469,6 @@ static void test_request_with_server_rejecting_client_creds(
void grpc_end2end_tests(grpc_end2end_test_config config) {
if (config.feature_mask & FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS) {
- test_call_creds_failure(config);
test_request_response_with_payload_and_call_creds(config);
test_request_response_with_payload_and_overridden_call_creds(config);
test_request_response_with_payload_and_deleted_call_creds(config);
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..997969d3cc
--- /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 5c1e0f4b94..4cfef7be78 100644
--- a/test/core/security/credentials_test.c
+++ b/test/core/security/credentials_test.c
@@ -50,11 +50,24 @@
#include <openssl/rsa.h>
+/* -- Mock channel credentials. -- */
+
+static grpc_channel_credentials *grpc_mock_channel_credentials_create(
+ const grpc_channel_credentials_vtable *vtable) {
+ grpc_channel_credentials *c = gpr_malloc(sizeof(*c));
+ memset(c, 0, sizeof(*c));
+ c->type = "mock";
+ c->vtable = vtable;
+ gpr_ref_init(&c->refcount, 1);
+ return c;
+}
+
+/* -- Constants. -- */
+
static const char test_google_iam_authorization_token[] = "blahblahblhahb";
static const char test_google_iam_authority_selector[] = "respectmyauthoritah";
static const char test_oauth2_bearer_token[] =
"Bearer blaaslkdjfaslkdfasdsfasf";
-static const char test_root_cert[] = "I am the root!";
/* This JSON key was generated with the GCE console and revoked immediately.
The identifiers have been changed as well.
@@ -113,6 +126,8 @@ static const char test_signed_jwt[] =
static const char test_service_url[] = "https://foo.com/foo.v1";
static const char other_test_service_url[] = "https://bar.com/bar.v1";
+/* -- Utils. -- */
+
static char *test_json_key_str(void) {
size_t result_len = strlen(test_json_key_str_part1) +
strlen(test_json_key_str_part2) +
@@ -141,6 +156,8 @@ static grpc_httpcli_response http_response(int status, const char *body) {
return response;
}
+/* -- Tests. -- */
+
static void test_empty_md_store(void) {
grpc_credentials_md_store *store = grpc_credentials_md_store_create(0);
GPR_ASSERT(store->num_entries == 0);
@@ -219,7 +236,7 @@ static void test_oauth2_token_fetcher_creds_parsing_ok(void) {
GPR_ASSERT(token_lifetime.tv_sec == 3599);
GPR_ASSERT(token_lifetime.tv_nsec == 0);
GPR_ASSERT(token_md->num_entries == 1);
- GPR_ASSERT(gpr_slice_str_cmp(token_md->entries[0].key, "Authorization") == 0);
+ GPR_ASSERT(gpr_slice_str_cmp(token_md->entries[0].key, "authorization") == 0);
GPR_ASSERT(gpr_slice_str_cmp(token_md->entries[0].value,
"Bearer ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_") ==
0);
@@ -319,7 +336,7 @@ static void check_google_iam_metadata(grpc_exec_ctx *exec_ctx, void *user_data,
grpc_credentials_md *md_elems,
size_t num_md,
grpc_credentials_status status) {
- grpc_credentials *c = (grpc_credentials *)user_data;
+ grpc_call_credentials *c = (grpc_call_credentials *)user_data;
expected_md emd[] = {{GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY,
test_google_iam_authorization_token},
{GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY,
@@ -327,19 +344,17 @@ static void check_google_iam_metadata(grpc_exec_ctx *exec_ctx, void *user_data,
GPR_ASSERT(status == GRPC_CREDENTIALS_OK);
GPR_ASSERT(num_md == 2);
check_metadata(emd, md_elems, num_md);
- grpc_credentials_unref(c);
+ grpc_call_credentials_unref(c);
}
static void test_google_iam_creds(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_credentials *creds = grpc_google_iam_credentials_create(
+ grpc_call_credentials *creds = grpc_google_iam_credentials_create(
test_google_iam_authorization_token, test_google_iam_authority_selector,
NULL);
- GPR_ASSERT(grpc_credentials_has_request_metadata(creds));
- GPR_ASSERT(grpc_credentials_has_request_metadata_only(creds));
- grpc_credentials_get_request_metadata(&exec_ctx, creds, NULL,
- test_service_url,
- check_google_iam_metadata, creds);
+ grpc_call_credentials_get_request_metadata(&exec_ctx, creds, NULL,
+ test_service_url,
+ check_google_iam_metadata, creds);
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -348,81 +363,58 @@ static void check_access_token_metadata(grpc_exec_ctx *exec_ctx,
grpc_credentials_md *md_elems,
size_t num_md,
grpc_credentials_status status) {
- grpc_credentials *c = (grpc_credentials *)user_data;
+ grpc_call_credentials *c = (grpc_call_credentials *)user_data;
expected_md emd[] = {{GRPC_AUTHORIZATION_METADATA_KEY, "Bearer blah"}};
GPR_ASSERT(status == GRPC_CREDENTIALS_OK);
GPR_ASSERT(num_md == 1);
check_metadata(emd, md_elems, num_md);
- grpc_credentials_unref(c);
+ grpc_call_credentials_unref(c);
}
static void test_access_token_creds(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_credentials *creds = grpc_access_token_credentials_create("blah", NULL);
- GPR_ASSERT(grpc_credentials_has_request_metadata(creds));
- GPR_ASSERT(grpc_credentials_has_request_metadata_only(creds));
- GPR_ASSERT(strcmp(creds->type, GRPC_CREDENTIALS_TYPE_OAUTH2) == 0);
- grpc_credentials_get_request_metadata(&exec_ctx, creds, NULL,
- test_service_url,
- check_access_token_metadata, creds);
- grpc_exec_ctx_finish(&exec_ctx);
-}
-
-static void check_ssl_oauth2_composite_metadata(
- grpc_exec_ctx *exec_ctx, void *user_data, grpc_credentials_md *md_elems,
- size_t num_md, grpc_credentials_status status) {
- grpc_credentials *c = (grpc_credentials *)user_data;
- expected_md emd[] = {
- {GRPC_AUTHORIZATION_METADATA_KEY, test_oauth2_bearer_token}};
- GPR_ASSERT(status == GRPC_CREDENTIALS_OK);
- GPR_ASSERT(num_md == 1);
- check_metadata(emd, md_elems, num_md);
- grpc_credentials_unref(c);
-}
-
-static void test_ssl_oauth2_composite_creds(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_credentials *ssl_creds =
- grpc_ssl_credentials_create(test_root_cert, NULL, NULL);
- const grpc_credentials_array *creds_array;
- grpc_credentials *oauth2_creds = grpc_md_only_test_credentials_create(
- "Authorization", test_oauth2_bearer_token, 0);
- grpc_credentials *composite_creds =
- grpc_composite_credentials_create(ssl_creds, oauth2_creds, NULL);
- grpc_credentials_unref(ssl_creds);
- grpc_credentials_unref(oauth2_creds);
- GPR_ASSERT(strcmp(composite_creds->type, GRPC_CREDENTIALS_TYPE_COMPOSITE) ==
- 0);
- GPR_ASSERT(grpc_credentials_has_request_metadata(composite_creds));
- GPR_ASSERT(!grpc_credentials_has_request_metadata_only(composite_creds));
- creds_array = grpc_composite_credentials_get_credentials(composite_creds);
- GPR_ASSERT(creds_array->num_creds == 2);
- GPR_ASSERT(strcmp(creds_array->creds_array[0]->type,
- GRPC_CREDENTIALS_TYPE_SSL) == 0);
- GPR_ASSERT(strcmp(creds_array->creds_array[1]->type,
- GRPC_CREDENTIALS_TYPE_OAUTH2) == 0);
- grpc_credentials_get_request_metadata(
- &exec_ctx, composite_creds, NULL, test_service_url,
- check_ssl_oauth2_composite_metadata, composite_creds);
+ grpc_call_credentials *creds =
+ grpc_access_token_credentials_create("blah", NULL);
+ GPR_ASSERT(strcmp(creds->type, GRPC_CALL_CREDENTIALS_TYPE_OAUTH2) == 0);
+ grpc_call_credentials_get_request_metadata(
+ &exec_ctx, creds, NULL, test_service_url, check_access_token_metadata,
+ creds);
grpc_exec_ctx_finish(&exec_ctx);
}
-void test_ssl_fake_transport_security_composite_creds_failure(void) {
- grpc_credentials *ssl_creds = grpc_ssl_credentials_create(NULL, NULL, NULL);
- grpc_credentials *fake_transport_security_creds =
- grpc_fake_transport_security_credentials_create();
-
- /* 2 connector credentials: should not work. */
- GPR_ASSERT(grpc_composite_credentials_create(
- ssl_creds, fake_transport_security_creds, NULL) == NULL);
- grpc_credentials_unref(ssl_creds);
- grpc_credentials_unref(fake_transport_security_creds);
-}
-
-static void check_ssl_oauth2_google_iam_composite_metadata(
+static grpc_security_status check_channel_oauth2_create_security_connector(
+ grpc_channel_credentials *c, grpc_call_credentials *call_creds,
+ const char *target, const grpc_channel_args *args,
+ grpc_channel_security_connector **sc, grpc_channel_args **new_args) {
+ GPR_ASSERT(strcmp(c->type, "mock") == 0);
+ GPR_ASSERT(call_creds != NULL);
+ GPR_ASSERT(strcmp(call_creds->type, GRPC_CALL_CREDENTIALS_TYPE_OAUTH2) == 0);
+ return GRPC_SECURITY_OK;
+}
+
+static void test_channel_oauth2_composite_creds(void) {
+ grpc_channel_args *new_args;
+ grpc_channel_credentials_vtable vtable = {
+ NULL, check_channel_oauth2_create_security_connector};
+ grpc_channel_credentials *channel_creds =
+ grpc_mock_channel_credentials_create(&vtable);
+ 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_channel_credentials_release(channel_creds);
+ grpc_call_credentials_release(oauth2_creds);
+ GPR_ASSERT(grpc_channel_credentials_create_security_connector(
+ channel_oauth2_creds, NULL, NULL, NULL, &new_args) ==
+ GRPC_SECURITY_OK);
+ grpc_channel_credentials_release(channel_oauth2_creds);
+}
+
+static void check_oauth2_google_iam_composite_metadata(
grpc_exec_ctx *exec_ctx, void *user_data, grpc_credentials_md *md_elems,
size_t num_md, grpc_credentials_status status) {
- grpc_credentials *c = (grpc_credentials *)user_data;
+ grpc_call_credentials *c = (grpc_call_credentials *)user_data;
expected_md emd[] = {
{GRPC_AUTHORIZATION_METADATA_KEY, test_oauth2_bearer_token},
{GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY,
@@ -432,51 +424,90 @@ static void check_ssl_oauth2_google_iam_composite_metadata(
GPR_ASSERT(status == GRPC_CREDENTIALS_OK);
GPR_ASSERT(num_md == 3);
check_metadata(emd, md_elems, num_md);
- grpc_credentials_unref(c);
+ grpc_call_credentials_unref(c);
}
-static void test_ssl_oauth2_google_iam_composite_creds(void) {
+static void test_oauth2_google_iam_composite_creds(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_credentials *ssl_creds =
- grpc_ssl_credentials_create(test_root_cert, NULL, NULL);
- const grpc_credentials_array *creds_array;
- grpc_credentials *oauth2_creds = grpc_md_only_test_credentials_create(
- "Authorization", test_oauth2_bearer_token, 0);
- grpc_credentials *aux_creds =
- grpc_composite_credentials_create(ssl_creds, oauth2_creds, NULL);
- grpc_credentials *google_iam_creds = grpc_google_iam_credentials_create(
+ const grpc_call_credentials_array *creds_array;
+ grpc_call_credentials *oauth2_creds = grpc_md_only_test_credentials_create(
+ "authorization", test_oauth2_bearer_token, 0);
+ grpc_call_credentials *google_iam_creds = grpc_google_iam_credentials_create(
test_google_iam_authorization_token, test_google_iam_authority_selector,
NULL);
- grpc_credentials *composite_creds =
- grpc_composite_credentials_create(aux_creds, google_iam_creds, NULL);
- grpc_credentials_unref(ssl_creds);
- grpc_credentials_unref(oauth2_creds);
- grpc_credentials_unref(aux_creds);
- grpc_credentials_unref(google_iam_creds);
- GPR_ASSERT(strcmp(composite_creds->type, GRPC_CREDENTIALS_TYPE_COMPOSITE) ==
- 0);
- GPR_ASSERT(grpc_credentials_has_request_metadata(composite_creds));
- GPR_ASSERT(!grpc_credentials_has_request_metadata_only(composite_creds));
- creds_array = grpc_composite_credentials_get_credentials(composite_creds);
- GPR_ASSERT(creds_array->num_creds == 3);
+ grpc_call_credentials *composite_creds =
+ 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(
+ strcmp(composite_creds->type, GRPC_CALL_CREDENTIALS_TYPE_COMPOSITE) == 0);
+ creds_array =
+ grpc_composite_call_credentials_get_credentials(composite_creds);
+ GPR_ASSERT(creds_array->num_creds == 2);
GPR_ASSERT(strcmp(creds_array->creds_array[0]->type,
- GRPC_CREDENTIALS_TYPE_SSL) == 0);
+ GRPC_CALL_CREDENTIALS_TYPE_OAUTH2) == 0);
GPR_ASSERT(strcmp(creds_array->creds_array[1]->type,
- GRPC_CREDENTIALS_TYPE_OAUTH2) == 0);
- GPR_ASSERT(strcmp(creds_array->creds_array[2]->type,
- GRPC_CREDENTIALS_TYPE_IAM) == 0);
- grpc_credentials_get_request_metadata(
+ GRPC_CALL_CREDENTIALS_TYPE_IAM) == 0);
+ grpc_call_credentials_get_request_metadata(
&exec_ctx, composite_creds, NULL, test_service_url,
- check_ssl_oauth2_google_iam_composite_metadata, composite_creds);
+ check_oauth2_google_iam_composite_metadata, composite_creds);
grpc_exec_ctx_finish(&exec_ctx);
}
+static grpc_security_status
+check_channel_oauth2_google_iam_create_security_connector(
+ grpc_channel_credentials *c, grpc_call_credentials *call_creds,
+ const char *target, const grpc_channel_args *args,
+ grpc_channel_security_connector **sc, grpc_channel_args **new_args) {
+ const grpc_call_credentials_array *creds_array;
+ GPR_ASSERT(strcmp(c->type, "mock") == 0);
+ GPR_ASSERT(call_creds != NULL);
+ GPR_ASSERT(strcmp(call_creds->type, GRPC_CALL_CREDENTIALS_TYPE_COMPOSITE) ==
+ 0);
+ creds_array = grpc_composite_call_credentials_get_credentials(call_creds);
+ GPR_ASSERT(strcmp(creds_array->creds_array[0]->type,
+ GRPC_CALL_CREDENTIALS_TYPE_OAUTH2) == 0);
+ GPR_ASSERT(strcmp(creds_array->creds_array[1]->type,
+ GRPC_CALL_CREDENTIALS_TYPE_IAM) == 0);
+ return GRPC_SECURITY_OK;
+}
+
+static void test_channel_oauth2_google_iam_composite_creds(void) {
+ grpc_channel_args *new_args;
+ grpc_channel_credentials_vtable vtable = {
+ NULL, check_channel_oauth2_google_iam_create_security_connector};
+ grpc_channel_credentials *channel_creds =
+ grpc_mock_channel_credentials_create(&vtable);
+ 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_call_credentials *google_iam_creds = grpc_google_iam_credentials_create(
+ test_google_iam_authorization_token, test_google_iam_authority_selector,
+ NULL);
+ grpc_channel_credentials *channel_oauth2_iam_creds =
+ grpc_composite_channel_credentials_create(channel_oauth2_creds,
+ google_iam_creds, NULL);
+ grpc_channel_credentials_release(channel_creds);
+ grpc_call_credentials_release(oauth2_creds);
+ grpc_channel_credentials_release(channel_oauth2_creds);
+ grpc_call_credentials_release(google_iam_creds);
+
+ GPR_ASSERT(grpc_channel_credentials_create_security_connector(
+ channel_oauth2_iam_creds, NULL, NULL, NULL, &new_args) ==
+ GRPC_SECURITY_OK);
+
+ grpc_channel_credentials_release(channel_oauth2_iam_creds);
+}
+
static void on_oauth2_creds_get_metadata_success(
grpc_exec_ctx *exec_ctx, void *user_data, grpc_credentials_md *md_elems,
size_t num_md, grpc_credentials_status status) {
GPR_ASSERT(status == GRPC_CREDENTIALS_OK);
GPR_ASSERT(num_md == 1);
- GPR_ASSERT(gpr_slice_str_cmp(md_elems[0].key, "Authorization") == 0);
+ GPR_ASSERT(gpr_slice_str_cmp(md_elems[0].key, "authorization") == 0);
GPR_ASSERT(gpr_slice_str_cmp(md_elems[0].value,
"Bearer ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_") ==
0);
@@ -545,15 +576,13 @@ static int httpcli_get_should_not_be_called(
static void test_compute_engine_creds_success(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_credentials *compute_engine_creds =
+ grpc_call_credentials *compute_engine_creds =
grpc_google_compute_engine_credentials_create(NULL);
- GPR_ASSERT(grpc_credentials_has_request_metadata(compute_engine_creds));
- GPR_ASSERT(grpc_credentials_has_request_metadata_only(compute_engine_creds));
/* First request: http get should be called. */
grpc_httpcli_set_override(compute_engine_httpcli_get_success_override,
httpcli_post_should_not_be_called);
- grpc_credentials_get_request_metadata(
+ grpc_call_credentials_get_request_metadata(
&exec_ctx, compute_engine_creds, NULL, test_service_url,
on_oauth2_creds_get_metadata_success, (void *)test_user_data);
grpc_exec_ctx_flush(&exec_ctx);
@@ -561,27 +590,25 @@ static void test_compute_engine_creds_success(void) {
/* Second request: the cached token should be served directly. */
grpc_httpcli_set_override(httpcli_get_should_not_be_called,
httpcli_post_should_not_be_called);
- grpc_credentials_get_request_metadata(
+ grpc_call_credentials_get_request_metadata(
&exec_ctx, compute_engine_creds, NULL, test_service_url,
on_oauth2_creds_get_metadata_success, (void *)test_user_data);
grpc_exec_ctx_finish(&exec_ctx);
- grpc_credentials_unref(compute_engine_creds);
+ grpc_call_credentials_unref(compute_engine_creds);
grpc_httpcli_set_override(NULL, NULL);
}
static void test_compute_engine_creds_failure(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_credentials *compute_engine_creds =
+ grpc_call_credentials *compute_engine_creds =
grpc_google_compute_engine_credentials_create(NULL);
grpc_httpcli_set_override(compute_engine_httpcli_get_failure_override,
httpcli_post_should_not_be_called);
- GPR_ASSERT(grpc_credentials_has_request_metadata(compute_engine_creds));
- GPR_ASSERT(grpc_credentials_has_request_metadata_only(compute_engine_creds));
- grpc_credentials_get_request_metadata(
+ grpc_call_credentials_get_request_metadata(
&exec_ctx, compute_engine_creds, NULL, test_service_url,
on_oauth2_creds_get_metadata_failure, (void *)test_user_data);
- grpc_credentials_unref(compute_engine_creds);
+ grpc_call_credentials_unref(compute_engine_creds);
grpc_httpcli_set_override(NULL, NULL);
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -631,16 +658,14 @@ static int refresh_token_httpcli_post_failure(
static void test_refresh_token_creds_success(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_credentials *refresh_token_creds =
+ grpc_call_credentials *refresh_token_creds =
grpc_google_refresh_token_credentials_create(test_refresh_token_str,
NULL);
- GPR_ASSERT(grpc_credentials_has_request_metadata(refresh_token_creds));
- GPR_ASSERT(grpc_credentials_has_request_metadata_only(refresh_token_creds));
/* First request: http get should be called. */
grpc_httpcli_set_override(httpcli_get_should_not_be_called,
refresh_token_httpcli_post_success);
- grpc_credentials_get_request_metadata(
+ grpc_call_credentials_get_request_metadata(
&exec_ctx, refresh_token_creds, NULL, test_service_url,
on_oauth2_creds_get_metadata_success, (void *)test_user_data);
grpc_exec_ctx_flush(&exec_ctx);
@@ -648,29 +673,27 @@ static void test_refresh_token_creds_success(void) {
/* Second request: the cached token should be served directly. */
grpc_httpcli_set_override(httpcli_get_should_not_be_called,
httpcli_post_should_not_be_called);
- grpc_credentials_get_request_metadata(
+ grpc_call_credentials_get_request_metadata(
&exec_ctx, refresh_token_creds, NULL, test_service_url,
on_oauth2_creds_get_metadata_success, (void *)test_user_data);
grpc_exec_ctx_flush(&exec_ctx);
- grpc_credentials_unref(refresh_token_creds);
+ grpc_call_credentials_unref(refresh_token_creds);
grpc_httpcli_set_override(NULL, NULL);
grpc_exec_ctx_finish(&exec_ctx);
}
static void test_refresh_token_creds_failure(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_credentials *refresh_token_creds =
+ grpc_call_credentials *refresh_token_creds =
grpc_google_refresh_token_credentials_create(test_refresh_token_str,
NULL);
grpc_httpcli_set_override(httpcli_get_should_not_be_called,
refresh_token_httpcli_post_failure);
- GPR_ASSERT(grpc_credentials_has_request_metadata(refresh_token_creds));
- GPR_ASSERT(grpc_credentials_has_request_metadata_only(refresh_token_creds));
- grpc_credentials_get_request_metadata(
+ grpc_call_credentials_get_request_metadata(
&exec_ctx, refresh_token_creds, NULL, test_service_url,
on_oauth2_creds_get_metadata_failure, (void *)test_user_data);
- grpc_credentials_unref(refresh_token_creds);
+ grpc_call_credentials_unref(refresh_token_creds);
grpc_httpcli_set_override(NULL, NULL);
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -730,7 +753,7 @@ static void on_jwt_creds_get_metadata_success(grpc_exec_ctx *exec_ctx,
gpr_asprintf(&expected_md_value, "Bearer %s", test_signed_jwt);
GPR_ASSERT(status == GRPC_CREDENTIALS_OK);
GPR_ASSERT(num_md == 1);
- GPR_ASSERT(gpr_slice_str_cmp(md_elems[0].key, "Authorization") == 0);
+ GPR_ASSERT(gpr_slice_str_cmp(md_elems[0].key, "authorization") == 0);
GPR_ASSERT(gpr_slice_str_cmp(md_elems[0].value, expected_md_value) == 0);
GPR_ASSERT(user_data != NULL);
GPR_ASSERT(strcmp((const char *)user_data, test_user_data) == 0);
@@ -751,15 +774,13 @@ static void on_jwt_creds_get_metadata_failure(grpc_exec_ctx *exec_ctx,
static void test_jwt_creds_success(void) {
char *json_key_string = test_json_key_str();
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_credentials *jwt_creds =
+ grpc_call_credentials *jwt_creds =
grpc_service_account_jwt_access_credentials_create(
json_key_string, grpc_max_auth_token_lifetime, NULL);
- GPR_ASSERT(grpc_credentials_has_request_metadata(jwt_creds));
- GPR_ASSERT(grpc_credentials_has_request_metadata_only(jwt_creds));
/* First request: jwt_encode_and_sign should be called. */
grpc_jwt_encode_and_sign_set_override(encode_and_sign_jwt_success);
- grpc_credentials_get_request_metadata(
+ grpc_call_credentials_get_request_metadata(
&exec_ctx, jwt_creds, NULL, test_service_url,
on_jwt_creds_get_metadata_success, (void *)test_user_data);
grpc_exec_ctx_flush(&exec_ctx);
@@ -767,7 +788,7 @@ static void test_jwt_creds_success(void) {
/* Second request: the cached token should be served directly. */
grpc_jwt_encode_and_sign_set_override(
encode_and_sign_jwt_should_not_be_called);
- grpc_credentials_get_request_metadata(
+ grpc_call_credentials_get_request_metadata(
&exec_ctx, jwt_creds, NULL, test_service_url,
on_jwt_creds_get_metadata_success, (void *)test_user_data);
grpc_exec_ctx_flush(&exec_ctx);
@@ -775,32 +796,30 @@ static void test_jwt_creds_success(void) {
/* Third request: Different service url so jwt_encode_and_sign should be
called again (no caching). */
grpc_jwt_encode_and_sign_set_override(encode_and_sign_jwt_success);
- grpc_credentials_get_request_metadata(
+ grpc_call_credentials_get_request_metadata(
&exec_ctx, jwt_creds, NULL, other_test_service_url,
on_jwt_creds_get_metadata_success, (void *)test_user_data);
grpc_exec_ctx_flush(&exec_ctx);
gpr_free(json_key_string);
- grpc_credentials_unref(jwt_creds);
+ grpc_call_credentials_unref(jwt_creds);
grpc_jwt_encode_and_sign_set_override(NULL);
}
static void test_jwt_creds_signing_failure(void) {
char *json_key_string = test_json_key_str();
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_credentials *jwt_creds =
+ grpc_call_credentials *jwt_creds =
grpc_service_account_jwt_access_credentials_create(
json_key_string, grpc_max_auth_token_lifetime, NULL);
- GPR_ASSERT(grpc_credentials_has_request_metadata(jwt_creds));
- GPR_ASSERT(grpc_credentials_has_request_metadata_only(jwt_creds));
grpc_jwt_encode_and_sign_set_override(encode_and_sign_jwt_failure);
- grpc_credentials_get_request_metadata(
+ grpc_call_credentials_get_request_metadata(
&exec_ctx, jwt_creds, NULL, test_service_url,
on_jwt_creds_get_metadata_failure, (void *)test_user_data);
gpr_free(json_key_string);
- grpc_credentials_unref(jwt_creds);
+ grpc_call_credentials_unref(jwt_creds);
grpc_jwt_encode_and_sign_set_override(NULL);
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -818,52 +837,39 @@ static void set_google_default_creds_env_var_with_file_contents(
gpr_free(creds_file_name);
}
-static grpc_credentials *composite_inner_creds(grpc_credentials *creds,
- const char *inner_creds_type) {
- size_t i;
- grpc_composite_credentials *composite;
- GPR_ASSERT(strcmp(creds->type, GRPC_CREDENTIALS_TYPE_COMPOSITE) == 0);
- composite = (grpc_composite_credentials *)creds;
- for (i = 0; i < composite->inner.num_creds; i++) {
- grpc_credentials *c = composite->inner.creds_array[i];
- if (strcmp(c->type, inner_creds_type) == 0) return c;
- }
- GPR_ASSERT(0); /* Not found. */
-}
-
static void test_google_default_creds_auth_key(void) {
grpc_service_account_jwt_access_credentials *jwt;
- grpc_credentials *creds;
+ grpc_composite_channel_credentials *creds;
char *json_key = test_json_key_str();
grpc_flush_cached_google_default_credentials();
set_google_default_creds_env_var_with_file_contents(
"json_key_google_default_creds", json_key);
gpr_free(json_key);
- creds = grpc_google_default_credentials_create();
+ creds = (grpc_composite_channel_credentials *)
+ grpc_google_default_credentials_create();
GPR_ASSERT(creds != NULL);
- jwt = (grpc_service_account_jwt_access_credentials *)composite_inner_creds(
- creds, GRPC_CREDENTIALS_TYPE_JWT);
+ jwt = (grpc_service_account_jwt_access_credentials *)creds->call_creds;
GPR_ASSERT(
strcmp(jwt->key.client_id,
"777-abaslkan11hlb6nmim3bpspl31ud.apps.googleusercontent.com") ==
0);
- grpc_credentials_unref(creds);
+ grpc_channel_credentials_unref(&creds->base);
gpr_setenv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR, ""); /* Reset. */
}
static void test_google_default_creds_access_token(void) {
grpc_google_refresh_token_credentials *refresh;
- grpc_credentials *creds;
+ grpc_composite_channel_credentials *creds;
grpc_flush_cached_google_default_credentials();
set_google_default_creds_env_var_with_file_contents(
"refresh_token_google_default_creds", test_refresh_token_str);
- creds = grpc_google_default_credentials_create();
+ creds = (grpc_composite_channel_credentials *)
+ grpc_google_default_credentials_create();
GPR_ASSERT(creds != NULL);
- refresh = (grpc_google_refresh_token_credentials *)composite_inner_creds(
- creds, GRPC_CREDENTIALS_TYPE_OAUTH2);
+ refresh = (grpc_google_refresh_token_credentials *)creds->call_creds;
GPR_ASSERT(strcmp(refresh->refresh_token.client_id,
"32555999999.apps.googleusercontent.com") == 0);
- grpc_credentials_unref(creds);
+ grpc_channel_credentials_unref(&creds->base);
gpr_setenv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR, ""); /* Reset. */
}
@@ -935,7 +941,7 @@ static void plugin_destroy(void *state) {
}
static void test_metadata_plugin_success(void) {
- grpc_credentials *creds;
+ grpc_call_credentials *creds;
plugin_state state = PLUGIN_INITIAL_STATE;
grpc_metadata_credentials_plugin plugin;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
@@ -946,17 +952,17 @@ static void test_metadata_plugin_success(void) {
creds = grpc_metadata_credentials_create_from_plugin(plugin, NULL);
GPR_ASSERT(state == PLUGIN_INITIAL_STATE);
- grpc_credentials_get_request_metadata(
+ grpc_call_credentials_get_request_metadata(
&exec_ctx, creds, NULL, test_service_url,
on_plugin_metadata_received_success, NULL);
GPR_ASSERT(state == PLUGIN_GET_METADATA_CALLED_STATE);
- grpc_credentials_release(creds);
+ grpc_call_credentials_release(creds);
GPR_ASSERT(state == PLUGIN_DESTROY_CALLED_STATE);
grpc_exec_ctx_finish(&exec_ctx);
}
static void test_metadata_plugin_failure(void) {
- grpc_credentials *creds;
+ grpc_call_credentials *creds;
plugin_state state = PLUGIN_INITIAL_STATE;
grpc_metadata_credentials_plugin plugin;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
@@ -967,11 +973,11 @@ static void test_metadata_plugin_failure(void) {
creds = grpc_metadata_credentials_create_from_plugin(plugin, NULL);
GPR_ASSERT(state == PLUGIN_INITIAL_STATE);
- grpc_credentials_get_request_metadata(
+ grpc_call_credentials_get_request_metadata(
&exec_ctx, creds, NULL, test_service_url,
on_plugin_metadata_received_failure, NULL);
GPR_ASSERT(state == PLUGIN_GET_METADATA_CALLED_STATE);
- grpc_credentials_release(creds);
+ grpc_call_credentials_release(creds);
GPR_ASSERT(state == PLUGIN_DESTROY_CALLED_STATE);
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -993,8 +999,9 @@ int main(int argc, char **argv) {
test_oauth2_token_fetcher_creds_parsing_missing_token_lifetime();
test_google_iam_creds();
test_access_token_creds();
- test_ssl_oauth2_composite_creds();
- test_ssl_oauth2_google_iam_composite_creds();
+ test_channel_oauth2_composite_creds();
+ test_oauth2_google_iam_composite_creds();
+ test_channel_oauth2_google_iam_composite_creds();
test_compute_engine_creds_success();
test_compute_engine_creds_failure();
test_refresh_token_creds_success();
diff --git a/test/core/security/fetch_oauth2.c b/test/core/security/fetch_oauth2.c
index 764d8da9b6..ee1178cbdd 100644
--- a/test/core/security/fetch_oauth2.c
+++ b/test/core/security/fetch_oauth2.c
@@ -46,7 +46,7 @@
#include "src/core/support/file.h"
#include "test/core/security/oauth2_utils.h"
-static grpc_credentials *create_refresh_token_creds(
+static grpc_call_credentials *create_refresh_token_creds(
const char *json_refresh_token_file_path) {
int success;
gpr_slice refresh_token =
@@ -60,7 +60,7 @@ static grpc_credentials *create_refresh_token_creds(
}
int main(int argc, char **argv) {
- grpc_credentials *creds = NULL;
+ grpc_call_credentials *creds = NULL;
char *json_key_file_path = NULL;
char *json_refresh_token_file_path = NULL;
char *token = NULL;
@@ -115,7 +115,7 @@ int main(int argc, char **argv) {
printf("Got token: %s.\n", token);
gpr_free(token);
}
- grpc_credentials_release(creds);
+ grpc_call_credentials_release(creds);
gpr_cmdline_destroy(cl);
grpc_shutdown();
return 0;
diff --git a/test/core/security/oauth2_utils.c b/test/core/security/oauth2_utils.c
index f99d170592..fcfe8a6377 100644
--- a/test/core/security/oauth2_utils.c
+++ b/test/core/security/oauth2_utils.c
@@ -75,7 +75,8 @@ static void on_oauth2_response(grpc_exec_ctx *exec_ctx, void *user_data,
static void do_nothing(grpc_exec_ctx *exec_ctx, void *unused, int success) {}
-char *grpc_test_fetch_oauth2_token_with_credentials(grpc_credentials *creds) {
+char *grpc_test_fetch_oauth2_token_with_credentials(
+ grpc_call_credentials *creds) {
oauth2_request request;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_closure do_nothing_closure;
@@ -84,8 +85,8 @@ char *grpc_test_fetch_oauth2_token_with_credentials(grpc_credentials *creds) {
grpc_closure_init(&do_nothing_closure, do_nothing, NULL);
- grpc_credentials_get_request_metadata(&exec_ctx, creds, &request.pollset, "",
- on_oauth2_response, &request);
+ grpc_call_credentials_get_request_metadata(&exec_ctx, creds, &request.pollset,
+ "", on_oauth2_response, &request);
grpc_exec_ctx_finish(&exec_ctx);
diff --git a/test/core/security/oauth2_utils.h b/test/core/security/oauth2_utils.h
index 8082351b8a..b35fe7987f 100644
--- a/test/core/security/oauth2_utils.h
+++ b/test/core/security/oauth2_utils.h
@@ -42,7 +42,8 @@ extern "C" {
/* Fetch oauth2 access token with a credentials object. Does not take ownership.
Returns NULL on a failure. The caller should call gpr_free on the token. */
-char *grpc_test_fetch_oauth2_token_with_credentials(grpc_credentials *creds);
+char *grpc_test_fetch_oauth2_token_with_credentials(
+ grpc_call_credentials *creds);
#ifdef __cplusplus
}
diff --git a/test/core/security/print_google_default_creds_token.c b/test/core/security/print_google_default_creds_token.c
index f207e05794..eb63724715 100644
--- a/test/core/security/print_google_default_creds_token.c
+++ b/test/core/security/print_google_default_creds_token.c
@@ -72,7 +72,7 @@ int main(int argc, char **argv) {
int result = 0;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
synchronizer sync;
- grpc_credentials *creds = NULL;
+ grpc_channel_credentials *creds = NULL;
char *service_url = "https://test.foo.google.com/Foo";
gpr_cmdline *cl = gpr_cmdline_create("print_google_default_creds_token");
gpr_cmdline_add_string(cl, "service_url",
@@ -91,9 +91,9 @@ int main(int argc, char **argv) {
grpc_pollset_init(&sync.pollset);
sync.is_done = 0;
- grpc_credentials_get_request_metadata(&exec_ctx, creds, &sync.pollset,
- service_url, on_metadata_response,
- &sync);
+ grpc_call_credentials_get_request_metadata(
+ &exec_ctx, ((grpc_composite_channel_credentials *)creds)->call_creds,
+ &sync.pollset, service_url, on_metadata_response, &sync);
gpr_mu_lock(GRPC_POLLSET_MU(&sync.pollset));
while (!sync.is_done) {
@@ -107,7 +107,7 @@ int main(int argc, char **argv) {
}
gpr_mu_unlock(GRPC_POLLSET_MU(&sync.pollset));
- grpc_credentials_release(creds);
+ grpc_channel_credentials_release(creds);
end:
gpr_cmdline_destroy(cl);
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/reconnect_server.c b/test/core/util/reconnect_server.c
index ee481ef674..c064fb32c6 100644
--- a/test/core/util/reconnect_server.c
+++ b/test/core/util/reconnect_server.c
@@ -113,6 +113,7 @@ void reconnect_server_init(reconnect_server *server) {
void reconnect_server_start(reconnect_server *server, int port) {
struct sockaddr_in addr;
+ grpc_tcp_listener *listener;
int port_added;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
@@ -121,8 +122,9 @@ void reconnect_server_start(reconnect_server *server, int port) {
memset(&addr.sin_addr, 0, sizeof(addr.sin_addr));
server->tcp_server = grpc_tcp_server_create();
- port_added =
+ 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/client/credentials_test.cc b/test/cpp/client/credentials_test.cc
index 743ad065d1..418a54439a 100644
--- a/test/cpp/client/credentials_test.cc
+++ b/test/cpp/client/credentials_test.cc
@@ -46,8 +46,8 @@ class CredentialsTest : public ::testing::Test {
};
TEST_F(CredentialsTest, InvalidGoogleRefreshToken) {
- std::shared_ptr<Credentials> bad1 = GoogleRefreshTokenCredentials("");
- EXPECT_EQ(static_cast<Credentials*>(nullptr), bad1.get());
+ std::shared_ptr<CallCredentials> bad1 = GoogleRefreshTokenCredentials("");
+ EXPECT_EQ(static_cast<CallCredentials*>(nullptr), bad1.get());
}
} // namespace testing
diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc
index cfb6c21edc..74290c36d2 100644
--- a/test/cpp/end2end/async_end2end_test.cc
+++ b/test/cpp/end2end/async_end2end_test.cc
@@ -199,7 +199,7 @@ class AsyncEnd2endTest : public ::testing::TestWithParam<bool> {
void ResetStub() {
std::shared_ptr<Channel> channel =
- CreateChannel(server_address_.str(), InsecureCredentials());
+ CreateChannel(server_address_.str(), InsecureChannelCredentials());
stub_ = grpc::cpp::test::util::TestService::NewStub(channel);
}
@@ -749,7 +749,7 @@ TEST_P(AsyncEnd2endTest, ServerCheckDone) {
TEST_P(AsyncEnd2endTest, UnimplementedRpc) {
std::shared_ptr<Channel> channel =
- CreateChannel(server_address_.str(), InsecureCredentials());
+ CreateChannel(server_address_.str(), InsecureChannelCredentials());
std::unique_ptr<grpc::cpp::test::util::UnimplementedService::Stub> stub;
stub = grpc::cpp::test::util::UnimplementedService::NewStub(channel);
EchoRequest send_request;
diff --git a/test/cpp/end2end/client_crash_test.cc b/test/cpp/end2end/client_crash_test.cc
index 058e696166..116785bbf2 100644
--- a/test/cpp/end2end/client_crash_test.cc
+++ b/test/cpp/end2end/client_crash_test.cc
@@ -74,7 +74,7 @@ class CrashTest : public ::testing::Test {
}));
GPR_ASSERT(server_);
return grpc::cpp::test::util::TestService::NewStub(
- CreateChannel(addr, InsecureCredentials()));
+ CreateChannel(addr, InsecureChannelCredentials()));
}
void KillServer() { server_.reset(); }
diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc
index c5c7185026..6da933302c 100644
--- a/test/cpp/end2end/end2end_test.cc
+++ b/test/cpp/end2end/end2end_test.cc
@@ -146,13 +146,13 @@ class TestAuthMetadataProcessor : public AuthMetadataProcessor {
TestAuthMetadataProcessor(bool is_blocking) : is_blocking_(is_blocking) {}
- std::shared_ptr<Credentials> GetCompatibleClientCreds() {
+ std::shared_ptr<CallCredentials> GetCompatibleClientCreds() {
return MetadataCredentialsFromPlugin(
std::unique_ptr<MetadataCredentialsPlugin>(
new TestMetadataCredentialsPlugin(kGoodGuy, is_blocking_, true)));
}
- std::shared_ptr<Credentials> GetIncompatibleClientCreds() {
+ std::shared_ptr<CallCredentials> GetIncompatibleClientCreds() {
return MetadataCredentialsFromPlugin(
std::unique_ptr<MetadataCredentialsPlugin>(
new TestMetadataCredentialsPlugin("Mr Hyde", is_blocking_, true)));
@@ -407,7 +407,7 @@ class End2endTest : public ::testing::TestWithParam<TestScenario> {
}
EXPECT_TRUE(is_server_started_);
ChannelArguments args;
- auto channel_creds = InsecureCredentials();
+ auto channel_creds = InsecureChannelCredentials();
if (GetParam().use_tls) {
SslCredentialsOptions ssl_opts = {test_root_cert, "", ""};
args.SetSslTargetNameOverride("foo.test.google.fr");
@@ -429,7 +429,7 @@ class End2endTest : public ::testing::TestWithParam<TestScenario> {
builder.RegisterService(proxy_service_.get());
proxy_server_ = builder.BuildAndStart();
- channel_ = CreateChannel(proxyaddr.str(), InsecureCredentials());
+ channel_ = CreateChannel(proxyaddr.str(), InsecureChannelCredentials());
}
stub_ = grpc::cpp::test::util::TestService::NewStub(channel_);
@@ -575,6 +575,18 @@ void CancelRpc(ClientContext* context, int delay_us, TestServiceImpl* service) {
context->TryCancel();
}
+TEST_P(End2endTest, CancelRpcBeforeStart) {
+ ResetStub();
+ EchoRequest request;
+ EchoResponse response;
+ ClientContext context;
+ request.set_message("hello");
+ context.TryCancel();
+ Status s = stub_->Echo(&context, request, &response);
+ EXPECT_EQ("", response.message());
+ EXPECT_EQ(grpc::StatusCode::CANCELLED, s.error_code());
+}
+
// Client cancels request stream after sending two messages
TEST_P(End2endTest, ClientCancelsRequestStream) {
ResetStub();
@@ -751,7 +763,8 @@ TEST_P(End2endTest, ChannelStateTimeout) {
std::ostringstream server_address;
server_address << "127.0.0.1:" << port;
// Channel to non-existing server
- auto channel = CreateChannel(server_address.str(), InsecureCredentials());
+ auto channel =
+ CreateChannel(server_address.str(), InsecureChannelCredentials());
// Start IDLE
EXPECT_EQ(GRPC_CHANNEL_IDLE, channel->GetState(true));
@@ -971,33 +984,6 @@ TEST_P(SecureEnd2endTest, SimpleRpcWithHost) {
EXPECT_TRUE(s.ok());
}
-// rpc and stream should fail on bad credentials.
-TEST_P(SecureEnd2endTest, BadCredentials) {
- std::shared_ptr<Credentials> bad_creds = GoogleRefreshTokenCredentials("");
- EXPECT_EQ(static_cast<Credentials*>(nullptr), bad_creds.get());
- std::shared_ptr<Channel> channel =
- CreateChannel(server_address_.str(), bad_creds);
- std::unique_ptr<grpc::cpp::test::util::TestService::Stub> stub(
- grpc::cpp::test::util::TestService::NewStub(channel));
- EchoRequest request;
- EchoResponse response;
- ClientContext context;
- request.set_message("Hello");
-
- Status s = stub->Echo(&context, request, &response);
- EXPECT_EQ("", response.message());
- EXPECT_FALSE(s.ok());
- EXPECT_EQ(StatusCode::INVALID_ARGUMENT, s.error_code());
- EXPECT_EQ("Invalid credentials.", s.error_message());
-
- ClientContext context2;
- auto stream = stub->BidiStream(&context2);
- s = stream->Finish();
- EXPECT_FALSE(s.ok());
- EXPECT_EQ(StatusCode::INVALID_ARGUMENT, s.error_code());
- EXPECT_EQ("Invalid credentials.", s.error_message());
-}
-
bool MetadataContains(
const std::multimap<grpc::string_ref, grpc::string_ref>& metadata,
const grpc::string& key, const grpc::string& value) {
@@ -1055,7 +1041,7 @@ TEST_P(SecureEnd2endTest, SetPerCallCredentials) {
EchoRequest request;
EchoResponse response;
ClientContext context;
- std::shared_ptr<Credentials> creds =
+ std::shared_ptr<CallCredentials> creds =
GoogleIAMCredentials("fake_token", "fake_selector");
context.set_credentials(creds);
request.set_message("Hello");
@@ -1072,30 +1058,15 @@ TEST_P(SecureEnd2endTest, SetPerCallCredentials) {
"fake_selector"));
}
-TEST_P(SecureEnd2endTest, InsecurePerCallCredentials) {
- ResetStub();
- EchoRequest request;
- EchoResponse response;
- ClientContext context;
- std::shared_ptr<Credentials> creds = InsecureCredentials();
- context.set_credentials(creds);
- request.set_message("Hello");
- request.mutable_param()->set_echo_metadata(true);
-
- Status s = stub_->Echo(&context, request, &response);
- EXPECT_EQ(StatusCode::CANCELLED, s.error_code());
- EXPECT_EQ("Failed to set credentials to rpc.", s.error_message());
-}
-
TEST_P(SecureEnd2endTest, OverridePerCallCredentials) {
ResetStub();
EchoRequest request;
EchoResponse response;
ClientContext context;
- std::shared_ptr<Credentials> creds1 =
+ std::shared_ptr<CallCredentials> creds1 =
GoogleIAMCredentials("fake_token1", "fake_selector1");
context.set_credentials(creds1);
- std::shared_ptr<Credentials> creds2 =
+ std::shared_ptr<CallCredentials> creds2 =
GoogleIAMCredentials("fake_token2", "fake_selector2");
context.set_credentials(creds2);
request.set_message("Hello");
diff --git a/test/cpp/end2end/generic_end2end_test.cc b/test/cpp/end2end/generic_end2end_test.cc
index 6a46916728..082119d6d5 100644
--- a/test/cpp/end2end/generic_end2end_test.cc
+++ b/test/cpp/end2end/generic_end2end_test.cc
@@ -120,7 +120,7 @@ class GenericEnd2endTest : public ::testing::Test {
void ResetStub() {
std::shared_ptr<Channel> channel =
- CreateChannel(server_address_.str(), InsecureCredentials());
+ CreateChannel(server_address_.str(), InsecureChannelCredentials());
generic_stub_.reset(new GenericStub(channel));
}
diff --git a/test/cpp/end2end/mock_test.cc b/test/cpp/end2end/mock_test.cc
index 80057d893e..bd34cfba67 100644
--- a/test/cpp/end2end/mock_test.cc
+++ b/test/cpp/end2end/mock_test.cc
@@ -244,7 +244,7 @@ class MockTest : public ::testing::Test {
void ResetStub() {
std::shared_ptr<Channel> channel =
- CreateChannel(server_address_.str(), InsecureCredentials());
+ CreateChannel(server_address_.str(), InsecureChannelCredentials());
stub_ = grpc::cpp::test::util::TestService::NewStub(channel);
}
diff --git a/test/cpp/end2end/server_crash_test_client.cc b/test/cpp/end2end/server_crash_test_client.cc
index 17869362c2..2baefcbf42 100644
--- a/test/cpp/end2end/server_crash_test_client.cc
+++ b/test/cpp/end2end/server_crash_test_client.cc
@@ -58,7 +58,7 @@ using namespace gflags;
int main(int argc, char** argv) {
ParseCommandLineFlags(&argc, &argv, true);
auto stub = grpc::cpp::test::util::TestService::NewStub(
- grpc::CreateChannel(FLAGS_address, grpc::InsecureCredentials()));
+ grpc::CreateChannel(FLAGS_address, grpc::InsecureChannelCredentials()));
EchoRequest request;
EchoResponse response;
diff --git a/test/cpp/end2end/shutdown_test.cc b/test/cpp/end2end/shutdown_test.cc
index 0549bb8b5f..b1b18b2a7f 100644
--- a/test/cpp/end2end/shutdown_test.cc
+++ b/test/cpp/end2end/shutdown_test.cc
@@ -93,7 +93,7 @@ class ShutdownTest : public ::testing::Test {
void ResetStub() {
string target = "dns:localhost:" + to_string(port_);
- channel_ = CreateChannel(target, InsecureCredentials());
+ channel_ = CreateChannel(target, InsecureChannelCredentials());
stub_ = grpc::cpp::test::util::TestService::NewStub(channel_);
}
diff --git a/test/cpp/end2end/streaming_throughput_test.cc b/test/cpp/end2end/streaming_throughput_test.cc
index d4ab1486cc..b7e103a1ae 100644
--- a/test/cpp/end2end/streaming_throughput_test.cc
+++ b/test/cpp/end2end/streaming_throughput_test.cc
@@ -160,7 +160,7 @@ class End2endTest : public ::testing::Test {
void ResetStub() {
std::shared_ptr<Channel> channel =
- CreateChannel(server_address_.str(), InsecureCredentials());
+ CreateChannel(server_address_.str(), InsecureChannelCredentials());
stub_ = grpc::cpp::test::util::TestService::NewStub(channel);
}
diff --git a/test/cpp/end2end/thread_stress_test.cc b/test/cpp/end2end/thread_stress_test.cc
index 75a07d89c5..fb82b96135 100644
--- a/test/cpp/end2end/thread_stress_test.cc
+++ b/test/cpp/end2end/thread_stress_test.cc
@@ -190,7 +190,7 @@ class End2endTest : public ::testing::Test {
void ResetStub() {
std::shared_ptr<Channel> channel =
- CreateChannel(server_address_.str(), InsecureCredentials());
+ CreateChannel(server_address_.str(), InsecureChannelCredentials());
stub_ = grpc::cpp::test::util::TestService::NewStub(channel);
}
diff --git a/test/cpp/end2end/zookeeper_test.cc b/test/cpp/end2end/zookeeper_test.cc
index d4c7f0489f..e88c0f9c68 100644
--- a/test/cpp/end2end/zookeeper_test.cc
+++ b/test/cpp/end2end/zookeeper_test.cc
@@ -157,7 +157,7 @@ class ZookeeperTest : public ::testing::Test {
void ResetStub() {
string target = "zookeeper://" + zookeeper_address_ + "/test";
- channel_ = CreateChannel(target, InsecureCredentials());
+ channel_ = CreateChannel(target, InsecureChannelCredentials());
stub_ = std::move(grpc::cpp::test::util::TestService::NewStub(channel_));
}
diff --git a/test/cpp/interop/client_helper.cc b/test/cpp/interop/client_helper.cc
index 61b46d25aa..5caf0f2d1d 100644
--- a/test/cpp/interop/client_helper.cc
+++ b/test/cpp/interop/client_helper.cc
@@ -76,11 +76,11 @@ grpc::string GetServiceAccountJsonKey() {
}
grpc::string GetOauth2AccessToken() {
- std::shared_ptr<Credentials> creds = GoogleComputeEngineCredentials();
- SecureCredentials* secure_creds =
- dynamic_cast<SecureCredentials*>(creds.get());
+ std::shared_ptr<CallCredentials> creds = GoogleComputeEngineCredentials();
+ SecureCallCredentials* secure_creds =
+ dynamic_cast<SecureCallCredentials*>(creds.get());
GPR_ASSERT(secure_creds != nullptr);
- grpc_credentials* c_creds = secure_creds->GetRawCreds();
+ grpc_call_credentials* c_creds = secure_creds->GetRawCreds();
char* token = grpc_test_fetch_oauth2_token_with_credentials(c_creds);
GPR_ASSERT(token != nullptr);
gpr_log(GPR_INFO, "Get raw oauth2 access token: %s", token);
@@ -98,13 +98,13 @@ std::shared_ptr<Channel> CreateChannelForTestCase(
FLAGS_server_port);
if (test_case == "compute_engine_creds") {
- std::shared_ptr<Credentials> creds;
+ std::shared_ptr<CallCredentials> creds;
GPR_ASSERT(FLAGS_use_tls);
creds = GoogleComputeEngineCredentials();
return CreateTestChannel(host_port, FLAGS_server_host_override,
FLAGS_use_tls, !FLAGS_use_test_ca, creds);
} else if (test_case == "jwt_token_creds") {
- std::shared_ptr<Credentials> creds;
+ std::shared_ptr<CallCredentials> creds;
GPR_ASSERT(FLAGS_use_tls);
grpc::string json_key = GetServiceAccountJsonKey();
std::chrono::seconds token_lifetime = std::chrono::hours(1);
@@ -114,7 +114,7 @@ std::shared_ptr<Channel> CreateChannelForTestCase(
FLAGS_use_tls, !FLAGS_use_test_ca, creds);
} else if (test_case == "oauth2_auth_token") {
grpc::string raw_token = GetOauth2AccessToken();
- std::shared_ptr<Credentials> creds = AccessTokenCredentials(raw_token);
+ std::shared_ptr<CallCredentials> creds = AccessTokenCredentials(raw_token);
return CreateTestChannel(host_port, FLAGS_server_host_override,
FLAGS_use_tls, !FLAGS_use_test_ca, creds);
} else {
diff --git a/test/cpp/interop/interop_client.cc b/test/cpp/interop/interop_client.cc
index 46a5255e4c..6340007fa4 100644
--- a/test/cpp/interop/interop_client.cc
+++ b/test/cpp/interop/interop_client.cc
@@ -244,7 +244,7 @@ void InteropClient::DoPerRpcCreds(const grpc::string& json_key) {
ClientContext context;
std::chrono::seconds token_lifetime = std::chrono::hours(1);
- std::shared_ptr<Credentials> creds =
+ std::shared_ptr<CallCredentials> creds =
ServiceAccountJWTAccessCredentials(json_key, token_lifetime.count());
context.set_credentials(creds);
diff --git a/test/cpp/interop/metrics_client.cc b/test/cpp/interop/metrics_client.cc
new file mode 100644
index 0000000000..5d60a84203
--- /dev/null
+++ b/test/cpp/interop/metrics_client.cc
@@ -0,0 +1,102 @@
+/*
+ *
+ * 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 f8c55cf795..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 InsecureCredentials()
- std::shared_ptr<Channel> channel(
- CreateChannel(server_address, InsecureCredentials()));
- 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 5d1419728e..7e926a1a56 100644
--- a/test/cpp/interop/stress_test.cc
+++ b/test/cpp/interop/stress_test.cc
@@ -41,10 +41,19 @@
#include <grpc/support/time.h>
#include <grpc++/create_channel.h>
#include <grpc++/grpc++.h>
+#include <grpc++/impl/thd.h>
#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"
@@ -61,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"
@@ -78,16 +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::thread;
-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<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(
- 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 2c6247deea..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;
@@ -162,7 +162,7 @@ std::unique_ptr<ScenarioResult> RunScenario(
auto* servers = new ServerData[num_servers];
for (size_t i = 0; i < num_servers; i++) {
servers[i].stub = WorkerService::NewStub(
- CreateChannel(workers[i], InsecureCredentials()));
+ CreateChannel(workers[i], InsecureChannelCredentials()));
ServerArgs args;
result_server_config = server_config;
*args.mutable_setup() = server_config;
@@ -189,7 +189,7 @@ std::unique_ptr<ScenarioResult> RunScenario(
auto* clients = new ClientData[num_clients];
for (size_t i = 0; i < num_clients; i++) {
clients[i].stub = WorkerService::NewStub(
- CreateChannel(workers[i + num_servers], InsecureCredentials()));
+ CreateChannel(workers[i + num_servers], InsecureChannelCredentials()));
ClientArgs args;
result_client_config = client_config;
*args.mutable_setup() = client_config;
diff --git a/test/cpp/qps/histogram.h b/test/cpp/qps/histogram.h
index 35527d2a2c..b45c769a77 100644
--- a/test/cpp/qps/histogram.h
+++ b/test/cpp/qps/histogram.h
@@ -42,7 +42,9 @@ 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 +75,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..0479e1aff4 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/report.h b/test/cpp/qps/report.h
index 78779231d3..5caf3fe69a 100644
--- a/test/cpp/qps/report.h
+++ b/test/cpp/qps/report.h
@@ -115,8 +115,8 @@ class PerfDbReporter : public Reporter {
test_name_(test_name),
sys_info_(sys_info),
tag_(tag) {
- perf_db_client_.init(
- grpc::CreateChannel(server_address, grpc::InsecureCredentials()));
+ perf_db_client_.init(grpc::CreateChannel(
+ server_address, grpc::InsecureChannelCredentials()));
}
~PerfDbReporter() GRPC_OVERRIDE { SendData(); };
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/cli_call_test.cc b/test/cpp/util/cli_call_test.cc
index 9c8d59987e..32cd8e4103 100644
--- a/test/cpp/util/cli_call_test.cc
+++ b/test/cpp/util/cli_call_test.cc
@@ -89,7 +89,8 @@ class CliCallTest : public ::testing::Test {
void TearDown() GRPC_OVERRIDE { server_->Shutdown(); }
void ResetStub() {
- channel_ = CreateChannel(server_address_.str(), InsecureCredentials());
+ channel_ =
+ CreateChannel(server_address_.str(), InsecureChannelCredentials());
stub_ = grpc::cpp::test::util::TestService::NewStub(channel_);
}
diff --git a/test/cpp/util/create_test_channel.cc b/test/cpp/util/create_test_channel.cc
index f0d5bfc7eb..0cd9f9e767 100644
--- a/test/cpp/util/create_test_channel.cc
+++ b/test/cpp/util/create_test_channel.cc
@@ -58,13 +58,14 @@ namespace grpc {
std::shared_ptr<Channel> CreateTestChannel(
const grpc::string& server, const grpc::string& override_hostname,
bool enable_ssl, bool use_prod_roots,
- const std::shared_ptr<Credentials>& creds) {
+ const std::shared_ptr<CallCredentials>& creds) {
ChannelArguments channel_args;
if (enable_ssl) {
const char* roots_certs = use_prod_roots ? "" : test_root_cert;
SslCredentialsOptions ssl_opts = {roots_certs, "", ""};
- std::shared_ptr<Credentials> channel_creds = SslCredentials(ssl_opts);
+ std::shared_ptr<ChannelCredentials> channel_creds =
+ SslCredentials(ssl_opts);
if (!server.empty() && !override_hostname.empty()) {
channel_args.SetSslTargetNameOverride(override_hostname);
@@ -72,11 +73,11 @@ std::shared_ptr<Channel> CreateTestChannel(
const grpc::string& connect_to =
server.empty() ? override_hostname : server;
if (creds.get()) {
- channel_creds = CompositeCredentials(creds, channel_creds);
+ channel_creds = CompositeChannelCredentials(channel_creds, creds);
}
return CreateCustomChannel(connect_to, channel_creds, channel_args);
} else {
- return CreateChannel(server, InsecureCredentials());
+ return CreateChannel(server, InsecureChannelCredentials());
}
}
@@ -84,7 +85,7 @@ std::shared_ptr<Channel> CreateTestChannel(
const grpc::string& server, const grpc::string& override_hostname,
bool enable_ssl, bool use_prod_roots) {
return CreateTestChannel(server, override_hostname, enable_ssl,
- use_prod_roots, std::shared_ptr<Credentials>());
+ use_prod_roots, std::shared_ptr<CallCredentials>());
}
// Shortcut for end2end and interop tests.
diff --git a/test/cpp/util/create_test_channel.h b/test/cpp/util/create_test_channel.h
index a4750689a0..b50d653de3 100644
--- a/test/cpp/util/create_test_channel.h
+++ b/test/cpp/util/create_test_channel.h
@@ -51,7 +51,7 @@ std::shared_ptr<Channel> CreateTestChannel(
std::shared_ptr<Channel> CreateTestChannel(
const grpc::string& server, const grpc::string& override_hostname,
bool enable_ssl, bool use_prod_roots,
- const std::shared_ptr<Credentials>& creds);
+ const std::shared_ptr<CallCredentials>& creds);
} // namespace grpc
diff --git a/test/cpp/util/grpc_cli.cc b/test/cpp/util/grpc_cli.cc
index 334b6efb6a..3f40b242fc 100644
--- a/test/cpp/util/grpc_cli.cc
+++ b/test/cpp/util/grpc_cli.cc
@@ -148,9 +148,9 @@ int main(int argc, char** argv) {
std::stringstream input_stream;
input_stream << input_file.rdbuf();
- std::shared_ptr<grpc::Credentials> creds;
+ std::shared_ptr<grpc::ChannelCredentials> creds;
if (!FLAGS_enable_ssl) {
- creds = grpc::InsecureCredentials();
+ creds = grpc::InsecureChannelCredentials();
} else {
if (FLAGS_use_auth) {
creds = grpc::GoogleDefaultCredentials();
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..6b045b3119 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..14740eb65d
--- /dev/null
+++ b/test/proto/metrics.proto
@@ -0,0 +1,55 @@
+
+// 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);
+}