diff options
author | Sree Kuchibhotla <sreek@google.com> | 2016-04-26 11:27:14 -0700 |
---|---|---|
committer | Sree Kuchibhotla <sreek@google.com> | 2016-04-26 11:27:14 -0700 |
commit | 30499760db987c67fe71839c52c24473a5365e0c (patch) | |
tree | 9b9965393a6346ee9b0b34032349925b366b9532 /src | |
parent | 0b9fdd8adc4b2d167e33a6d39e7ff4a46ef9a65c (diff) | |
parent | c3d869ef5853c4cfad57b7d3694d5260eeb7ce75 (diff) |
Merge branch 'master' into server_channel_affinity
Diffstat (limited to 'src')
88 files changed, 3501 insertions, 1167 deletions
diff --git a/src/boringssl/err_data.c b/src/boringssl/err_data.c index 1a1d950419..d4cc08bd99 100644 --- a/src/boringssl/err_data.c +++ b/src/boringssl/err_data.c @@ -54,30 +54,30 @@ OPENSSL_COMPILE_ASSERT(ERR_LIB_USER == 32, library_values_changed_32); OPENSSL_COMPILE_ASSERT(ERR_NUM_LIBS == 33, library_values_changed_num); const uint32_t kOpenSSLReasonValues[] = { - 0xc3207ba, - 0xc3287d4, - 0xc3307e3, - 0xc3387f3, - 0xc340802, - 0xc34881b, - 0xc350827, - 0xc358844, - 0xc360856, - 0xc368864, - 0xc370874, - 0xc378881, - 0xc380891, - 0xc38889c, - 0xc3908b2, - 0xc3988c1, - 0xc3a08d5, - 0xc3a87c7, + 0xc3207ab, + 0xc3287c5, + 0xc3307d4, + 0xc3387e4, + 0xc3407f3, + 0xc34880c, + 0xc350818, + 0xc358835, + 0xc360847, + 0xc368855, + 0xc370865, + 0xc378872, + 0xc380882, + 0xc38888d, + 0xc3908a3, + 0xc3988b2, + 0xc3a08c6, + 0xc3a87b8, 0xc3b00b0, - 0x10321478, - 0x10329484, - 0x1033149d, - 0x103394b0, - 0x10340de1, + 0x10321484, + 0x10329490, + 0x103314a9, + 0x103394bc, + 0x10340ded, 0x103494cf, 0x103514e4, 0x10359516, @@ -97,7 +97,7 @@ const uint32_t kOpenSSLReasonValues[] = { 0x103c9658, 0x103d166f, 0x103d9682, - 0x103e0b6c, + 0x103e0b5d, 0x103e96b3, 0x103f16c6, 0x103f96e0, @@ -108,87 +108,91 @@ const uint32_t kOpenSSLReasonValues[] = { 0x10421747, 0x1042975b, 0x1043176d, - 0x104385d0, - 0x104408c1, + 0x104385c1, + 0x104408b2, 0x10449782, 0x10451799, 0x104597ae, 0x104617bc, 0x10469695, 0x104714f7, - 0x104787c7, + 0x104787b8, 0x104800b0, - 0x104894c3, - 0x14320b4f, - 0x14328b5d, - 0x14330b6c, - 0x14338b7e, + 0x10488b8c, + 0x14320b40, + 0x14328b4e, + 0x14330b5d, + 0x14338b6f, 0x18320083, - 0x18328e47, - 0x18340e75, - 0x18348e89, - 0x18358ec0, - 0x18368eed, - 0x18370f00, - 0x18378f14, - 0x18380f38, - 0x18388f46, - 0x18390f5c, - 0x18398f70, - 0x183a0f80, - 0x183b0f90, - 0x183b8fa5, - 0x183c8fd0, - 0x183d0fe4, - 0x183d8ff4, - 0x183e0b9b, - 0x183e9001, - 0x183f1013, - 0x183f901e, - 0x1840102e, - 0x1840903f, - 0x18411050, - 0x18419062, - 0x1842108b, - 0x184290bd, - 0x184310cc, - 0x18451135, - 0x1845914b, - 0x18461166, - 0x18468ed8, - 0x184709d9, + 0x18328e53, + 0x18340e81, + 0x18348e95, + 0x18358ecc, + 0x18368ef9, + 0x18370f0c, + 0x18378f20, + 0x18380f44, + 0x18388f52, + 0x18390f68, + 0x18398f7c, + 0x183a0f8c, + 0x183b0f9c, + 0x183b8fb1, + 0x183c8fdc, + 0x183d0ff0, + 0x183d9000, + 0x183e0b98, + 0x183e900d, + 0x183f101f, + 0x183f902a, + 0x1840103a, + 0x1840904b, + 0x1841105c, + 0x1841906e, + 0x18421097, + 0x184290c9, + 0x184310d8, + 0x18451141, + 0x18459157, + 0x18461172, + 0x18468ee4, + 0x184709ca, 0x18478094, - 0x18480fbc, - 0x18489101, - 0x18490e5d, - 0x18498e9e, - 0x184a119c, - 0x184a9119, - 0x184b10e0, - 0x184b8e37, - 0x184c10a4, - 0x184c866b, - 0x184d1181, - 0x203211c3, - 0x243211cf, - 0x24328907, - 0x243311e1, - 0x243391ee, - 0x243411fb, - 0x2434920d, - 0x2435121c, - 0x24359239, - 0x24361246, - 0x24369254, - 0x24371262, - 0x24379270, - 0x24381279, - 0x24389286, - 0x24391299, - 0x28320b8f, - 0x28328b9b, - 0x28330b6c, - 0x28338bae, + 0x18480fc8, + 0x1848910d, + 0x18490e69, + 0x18498eaa, + 0x184a11a8, + 0x184a9125, + 0x184b10ec, + 0x184b8e43, + 0x184c10b0, + 0x184c865c, + 0x184d118d, + 0x184d80b0, + 0x203211cf, + 0x243211db, + 0x243288f8, + 0x243311ed, + 0x243391fa, + 0x24341207, + 0x24349219, + 0x24351228, + 0x24359245, + 0x24361252, + 0x24369260, + 0x2437126e, + 0x2437927c, + 0x24381285, + 0x24389292, + 0x243912a5, + 0x28320b80, + 0x28328b98, + 0x28330b5d, + 0x28338bab, + 0x28340b8c, + 0x28348094, + 0x283500b0, 0x2c32281d, 0x2c32a82b, 0x2c33283d, @@ -207,7 +211,7 @@ const uint32_t kOpenSSLReasonValues[] = { 0x2c39a917, 0x2c3a292b, 0x2c3aa93c, - 0x2c3b1359, + 0x2c3b1365, 0x2c3ba94d, 0x2c3c2961, 0x2c3ca977, @@ -219,12 +223,12 @@ const uint32_t kOpenSSLReasonValues[] = { 0x2c3faa09, 0x2c402a2c, 0x2c40aa4b, - 0x2c4111c3, + 0x2c4111cf, 0x2c41aa5c, 0x2c422a6f, - 0x2c429135, + 0x2c429141, 0x2c432a80, - 0x2c4386a2, + 0x2c438693, 0x2c4429ad, 0x30320000, 0x30328015, @@ -277,77 +281,79 @@ const uint32_t kOpenSSLReasonValues[] = { 0x304a03b4, 0x304a83c7, 0x304b03d2, - 0x304b83e1, - 0x304c03f2, - 0x304c83fe, - 0x304d0414, - 0x304d8422, - 0x304e0438, - 0x304e844a, - 0x304f045c, - 0x304f846f, - 0x30500482, - 0x30508493, - 0x305104a3, - 0x305184bb, - 0x305204d0, - 0x305284e8, - 0x305304fc, - 0x30538514, - 0x3054052d, - 0x30548546, - 0x30550563, - 0x3055856e, - 0x30560586, - 0x30568596, - 0x305705a7, - 0x305785ba, - 0x305805d0, - 0x305885d9, - 0x305905ee, + 0x304b83e3, + 0x304c03ef, + 0x304c8405, + 0x304d0413, + 0x304d8429, + 0x304e043b, + 0x304e844d, + 0x304f0460, + 0x304f8473, + 0x30500484, + 0x30508494, + 0x305104ac, + 0x305184c1, + 0x305204d9, + 0x305284ed, + 0x30530505, + 0x3053851e, + 0x30540537, + 0x30548554, + 0x3055055f, + 0x30558577, + 0x30560587, + 0x30568598, + 0x305705ab, + 0x305785c1, + 0x305805ca, + 0x305885df, + 0x305905f2, 0x30598601, - 0x305a0610, + 0x305a0621, 0x305a8630, - 0x305b063f, - 0x305b864b, - 0x305c066b, - 0x305c8687, - 0x305d0698, - 0x305d86a2, - 0x34320ac9, - 0x34328add, - 0x34330afa, - 0x34338b0d, - 0x34340b1c, - 0x34348b39, + 0x305b063c, + 0x305b865c, + 0x305c0678, + 0x305c8689, + 0x305d0693, + 0x34320aba, + 0x34328ace, + 0x34330aeb, + 0x34338afe, + 0x34340b0d, + 0x34348b2a, 0x3c320083, - 0x3c328bd8, - 0x3c330bf1, - 0x3c338c0c, - 0x3c340c29, - 0x3c348c44, - 0x3c350c5f, - 0x3c358c74, - 0x3c360c8d, - 0x3c368ca5, - 0x3c370cb6, - 0x3c378cc4, - 0x3c380cd1, - 0x3c388ce5, - 0x3c390b9b, - 0x3c398cf9, - 0x3c3a0d0d, - 0x3c3a8881, - 0x3c3b0d1d, - 0x3c3b8d38, - 0x3c3c0d4a, - 0x3c3c8d60, - 0x3c3d0d6a, - 0x3c3d8d7e, - 0x3c3e0d8c, - 0x3c3e8db1, - 0x3c3f0bc4, - 0x3c3f8d9a, + 0x3c328bd5, + 0x3c330bee, + 0x3c338c09, + 0x3c340c26, + 0x3c348c50, + 0x3c350c6b, + 0x3c358c80, + 0x3c360c99, + 0x3c368cb1, + 0x3c370cc2, + 0x3c378cd0, + 0x3c380cdd, + 0x3c388cf1, + 0x3c390b98, + 0x3c398d05, + 0x3c3a0d19, + 0x3c3a8872, + 0x3c3b0d29, + 0x3c3b8d44, + 0x3c3c0d56, + 0x3c3c8d6c, + 0x3c3d0d76, + 0x3c3d8d8a, + 0x3c3e0d98, + 0x3c3e8dbd, + 0x3c3f0bc1, + 0x3c3f8da6, + 0x3c400094, + 0x3c4080b0, + 0x3c410c41, 0x403217d3, 0x403297e9, 0x40331817, @@ -362,7 +368,7 @@ const uint32_t kOpenSSLReasonValues[] = { 0x403798b8, 0x403818c3, 0x403898d5, - 0x40390de1, + 0x40390ded, 0x403998e5, 0x403a18f8, 0x403a9919, @@ -437,7 +443,7 @@ const uint32_t kOpenSSLReasonValues[] = { 0x405d1e9e, 0x405d9eb5, 0x405e1ed5, - 0x405e8a17, + 0x405e8a08, 0x405f1ef6, 0x405f9f03, 0x40601f11, @@ -474,18 +480,18 @@ const uint32_t kOpenSSLReasonValues[] = { 0x406fa60d, 0x40702620, 0x4070a63d, - 0x40710782, + 0x40710773, 0x4071a64f, 0x40722662, 0x4072a67b, 0x40732693, - 0x407390bd, + 0x407390c9, 0x407426a7, 0x4074a6c1, 0x407526d2, 0x4075a6e6, 0x407626f4, - 0x40769286, + 0x40769292, 0x40772719, 0x4077a73b, 0x40782756, @@ -528,48 +534,48 @@ const uint32_t kOpenSSLReasonValues[] = { 0x422c251d, 0x422ca4d8, 0x422d24b7, - 0x443206ad, - 0x443286bc, - 0x443306c8, - 0x443386d6, - 0x443406e9, - 0x443486fa, - 0x44350701, - 0x4435870b, - 0x4436071e, - 0x44368734, - 0x44370746, - 0x44378753, - 0x44380762, - 0x4438876a, - 0x44390782, - 0x44398790, - 0x443a07a3, - 0x4c3212b0, - 0x4c3292c0, - 0x4c3312d3, - 0x4c3392f3, + 0x4432069e, + 0x443286ad, + 0x443306b9, + 0x443386c7, + 0x443406da, + 0x443486eb, + 0x443506f2, + 0x443586fc, + 0x4436070f, + 0x44368725, + 0x44370737, + 0x44378744, + 0x44380753, + 0x4438875b, + 0x44390773, + 0x44398781, + 0x443a0794, + 0x4c3212bc, + 0x4c3292cc, + 0x4c3312df, + 0x4c3392ff, 0x4c340094, 0x4c3480b0, - 0x4c3512ff, - 0x4c35930d, - 0x4c361329, - 0x4c36933c, - 0x4c37134b, - 0x4c379359, - 0x4c38136e, - 0x4c38937a, - 0x4c39139a, - 0x4c3993c4, - 0x4c3a13dd, - 0x4c3a93f6, - 0x4c3b05d0, - 0x4c3b940f, - 0x4c3c1421, - 0x4c3c9430, - 0x4c3d10bd, - 0x4c3d9449, - 0x4c3e1456, + 0x4c35130b, + 0x4c359319, + 0x4c361335, + 0x4c369348, + 0x4c371357, + 0x4c379365, + 0x4c38137a, + 0x4c389386, + 0x4c3913a6, + 0x4c3993d0, + 0x4c3a13e9, + 0x4c3a9402, + 0x4c3b05c1, + 0x4c3b941b, + 0x4c3c142d, + 0x4c3c943c, + 0x4c3d10c9, + 0x4c3d9455, + 0x4c3e1462, 0x50322a92, 0x5032aaa1, 0x50332aac, @@ -607,7 +613,7 @@ const uint32_t kOpenSSLReasonValues[] = { 0x50432d43, 0x5043ad53, 0x50442d62, - 0x50448414, + 0x50448405, 0x50452d76, 0x5045ad94, 0x50462da7, @@ -631,45 +637,45 @@ const uint32_t kOpenSSLReasonValues[] = { 0x504f2f62, 0x504faf79, 0x50502f88, - 0x50508687, + 0x50508678, 0x50512f9b, - 0x58320e1f, - 0x68320de1, - 0x68328b9b, - 0x68330bae, - 0x68338def, - 0x68340dff, + 0x58320e2b, + 0x68320ded, + 0x68328b98, + 0x68330bab, + 0x68338dfb, + 0x68340e0b, 0x683480b0, - 0x6c320dbd, - 0x6c328b7e, - 0x6c330dc8, - 0x7432098d, - 0x783208f2, - 0x78328907, - 0x78330913, + 0x6c320dc9, + 0x6c328b6f, + 0x6c330dd4, + 0x7432097e, + 0x783208e3, + 0x783288f8, + 0x78330904, 0x78338083, - 0x78340922, - 0x78348937, - 0x78350956, - 0x78358978, - 0x7836098d, - 0x783689a3, - 0x783709b3, - 0x783789c6, - 0x783809d9, - 0x783889eb, - 0x783909f8, - 0x78398a17, - 0x783a0a2c, - 0x783a8a3a, - 0x783b0a44, - 0x783b8a58, - 0x783c0a6f, - 0x783c8a84, - 0x783d0a9b, - 0x783d8ab0, - 0x783e0a06, - 0x7c3211b2, + 0x78340913, + 0x78348928, + 0x78350947, + 0x78358969, + 0x7836097e, + 0x78368994, + 0x783709a4, + 0x783789b7, + 0x783809ca, + 0x783889dc, + 0x783909e9, + 0x78398a08, + 0x783a0a1d, + 0x783a8a2b, + 0x783b0a35, + 0x783b8a49, + 0x783c0a60, + 0x783c8a75, + 0x783d0a8c, + 0x783d8aa1, + 0x783e09f7, + 0x7c3211be, }; const size_t kOpenSSLReasonValuesLen = sizeof(kOpenSSLReasonValues) / sizeof(kOpenSSLReasonValues[0]); @@ -725,7 +731,6 @@ const char kOpenSSLReasonStringData[] = "INVALID_UNIVERSALSTRING_LENGTH\0" "INVALID_UTF8STRING\0" "LIST_ERROR\0" - "MALLOC_FAILURE\0" "MISSING_ASN1_EOS\0" "MISSING_EOC\0" "MISSING_SECOND_NUMBER\0" @@ -833,6 +838,7 @@ const char kOpenSSLReasonStringData[] = "MODULUS_TOO_LARGE\0" "NO_PRIVATE_VALUE\0" "BAD_Q_VALUE\0" + "BAD_VERSION\0" "MISSING_PARAMETERS\0" "NEED_NEW_SETUP_VALUES\0" "BIGNUM_OUT_OF_RANGE\0" @@ -840,6 +846,7 @@ const char kOpenSSLReasonStringData[] = "D2I_ECPKPARAMETERS_FAILURE\0" "EC_GROUP_NEW_BY_NAME_FAILURE\0" "GROUP2PKPARAMETERS_FAILURE\0" + "GROUP_MISMATCH\0" "I2D_ECPKPARAMETERS_FAILURE\0" "INCOMPATIBLE_OBJECTS\0" "INVALID_COMPRESSED_POINT\0" @@ -948,7 +955,6 @@ const char kOpenSSLReasonStringData[] = "BAD_FIXED_HEADER_DECRYPT\0" "BAD_PAD_BYTE_COUNT\0" "BAD_RSA_PARAMETERS\0" - "BAD_VERSION\0" "BLOCK_TYPE_IS_NOT_01\0" "BN_NOT_INITIALIZED\0" "CANNOT_RECOVER_MULTI_PRIME_KEY\0" diff --git a/src/core/ext/client_config/client_channel.c b/src/core/ext/client_config/client_channel.c index 93d54fdcfe..8a98a6bcbe 100644 --- a/src/core/ext/client_config/client_channel.c +++ b/src/core/ext/client_config/client_channel.c @@ -205,7 +205,11 @@ static void cc_on_config_changed(grpc_exec_ctx *exec_ctx, void *arg, gpr_mu_lock(&chand->mu_config); old_lb_policy = chand->lb_policy; chand->lb_policy = lb_policy; - if (lb_policy != NULL || chand->resolver == NULL /* disconnected */) { + if (lb_policy != NULL) { + grpc_exec_ctx_enqueue_list(exec_ctx, &chand->waiting_for_config_closures, + NULL); + } else if (chand->resolver == NULL /* disconnected */) { + grpc_closure_list_fail_all(&chand->waiting_for_config_closures); grpc_exec_ctx_enqueue_list(exec_ctx, &chand->waiting_for_config_closures, NULL); } @@ -293,6 +297,11 @@ static void cc_start_transport_op(grpc_exec_ctx *exec_ctx, grpc_resolver_shutdown(exec_ctx, chand->resolver); GRPC_RESOLVER_UNREF(exec_ctx, chand->resolver, "channel"); chand->resolver = NULL; + if (!chand->started_resolving) { + grpc_closure_list_fail_all(&chand->waiting_for_config_closures); + grpc_exec_ctx_enqueue_list(exec_ctx, &chand->waiting_for_config_closures, + NULL); + } if (chand->lb_policy != NULL) { grpc_pollset_set_del_pollset_set(exec_ctx, chand->lb_policy->interested_parties, @@ -321,10 +330,10 @@ static int cc_pick_subchannel(grpc_exec_ctx *exec_ctx, void *arg, static void continue_picking(grpc_exec_ctx *exec_ctx, void *arg, bool success) { continue_picking_args *cpa = arg; - if (!success) { - grpc_exec_ctx_enqueue(exec_ctx, cpa->on_ready, false, NULL); - } else if (cpa->connected_subchannel == NULL) { + if (cpa->connected_subchannel == NULL) { /* cancelled, do nothing */ + } else if (!success) { + grpc_exec_ctx_enqueue(exec_ctx, cpa->on_ready, false, NULL); } else if (cc_pick_subchannel(exec_ctx, cpa->elem, cpa->initial_metadata, cpa->initial_metadata_flags, cpa->connected_subchannel, cpa->on_ready)) { @@ -381,14 +390,19 @@ static int cc_pick_subchannel(grpc_exec_ctx *exec_ctx, void *elemp, &chand->incoming_configuration, &chand->on_config_changed); } - cpa = gpr_malloc(sizeof(*cpa)); - cpa->initial_metadata = initial_metadata; - cpa->initial_metadata_flags = initial_metadata_flags; - cpa->connected_subchannel = connected_subchannel; - cpa->on_ready = on_ready; - cpa->elem = elem; - grpc_closure_init(&cpa->closure, continue_picking, cpa); - grpc_closure_list_add(&chand->waiting_for_config_closures, &cpa->closure, 1); + if (chand->resolver != NULL) { + cpa = gpr_malloc(sizeof(*cpa)); + cpa->initial_metadata = initial_metadata; + cpa->initial_metadata_flags = initial_metadata_flags; + cpa->connected_subchannel = connected_subchannel; + cpa->on_ready = on_ready; + cpa->elem = elem; + grpc_closure_init(&cpa->closure, continue_picking, cpa); + grpc_closure_list_add(&chand->waiting_for_config_closures, &cpa->closure, + 1); + } else { + grpc_exec_ctx_enqueue(exec_ctx, on_ready, false, NULL); + } gpr_mu_unlock(&chand->mu_config); return 0; } diff --git a/src/core/ext/client_config/parse_address.c b/src/core/ext/client_config/parse_address.c new file mode 100644 index 0000000000..8b4abe24a6 --- /dev/null +++ b/src/core/ext/client_config/parse_address.c @@ -0,0 +1,137 @@ +/* + * + * Copyright 2016, 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 "src/core/ext/client_config/parse_address.h" + +#include <stdio.h> +#include <string.h> +#ifdef GPR_HAVE_UNIX_SOCKET +#include <sys/un.h> +#endif + +#include <grpc/support/alloc.h> +#include <grpc/support/host_port.h> +#include <grpc/support/log.h> +#include <grpc/support/string_util.h> + +#ifdef GPR_HAVE_UNIX_SOCKET +int parse_unix(grpc_uri *uri, struct sockaddr_storage *addr, size_t *len) { + struct sockaddr_un *un = (struct sockaddr_un *)addr; + + un->sun_family = AF_UNIX; + strcpy(un->sun_path, uri->path); + *len = strlen(un->sun_path) + sizeof(un->sun_family) + 1; + + return 1; +} +#endif + +int parse_ipv4(grpc_uri *uri, struct sockaddr_storage *addr, size_t *len) { + const char *host_port = uri->path; + char *host; + char *port; + int port_num; + int result = 0; + struct sockaddr_in *in = (struct sockaddr_in *)addr; + + if (*host_port == '/') ++host_port; + if (!gpr_split_host_port(host_port, &host, &port)) { + return 0; + } + + memset(in, 0, sizeof(*in)); + *len = sizeof(*in); + in->sin_family = AF_INET; + if (inet_pton(AF_INET, host, &in->sin_addr) == 0) { + gpr_log(GPR_ERROR, "invalid ipv4 address: '%s'", host); + goto done; + } + + if (port != NULL) { + if (sscanf(port, "%d", &port_num) != 1 || port_num < 0 || + port_num > 65535) { + gpr_log(GPR_ERROR, "invalid ipv4 port: '%s'", port); + goto done; + } + in->sin_port = htons((uint16_t)port_num); + } else { + gpr_log(GPR_ERROR, "no port given for ipv4 scheme"); + goto done; + } + + result = 1; +done: + gpr_free(host); + gpr_free(port); + return result; +} + +int parse_ipv6(grpc_uri *uri, struct sockaddr_storage *addr, size_t *len) { + const char *host_port = uri->path; + char *host; + char *port; + int port_num; + int result = 0; + struct sockaddr_in6 *in6 = (struct sockaddr_in6 *)addr; + + if (*host_port == '/') ++host_port; + if (!gpr_split_host_port(host_port, &host, &port)) { + return 0; + } + + memset(in6, 0, sizeof(*in6)); + *len = sizeof(*in6); + in6->sin6_family = AF_INET6; + if (inet_pton(AF_INET6, host, &in6->sin6_addr) == 0) { + gpr_log(GPR_ERROR, "invalid ipv6 address: '%s'", host); + goto done; + } + + if (port != NULL) { + if (sscanf(port, "%d", &port_num) != 1 || port_num < 0 || + port_num > 65535) { + gpr_log(GPR_ERROR, "invalid ipv6 port: '%s'", port); + goto done; + } + in6->sin6_port = htons((uint16_t)port_num); + } else { + gpr_log(GPR_ERROR, "no port given for ipv6 scheme"); + goto done; + } + + result = 1; +done: + gpr_free(host); + gpr_free(port); + return result; +} diff --git a/src/cpp/common/create_auth_context.h b/src/core/ext/client_config/parse_address.h index 387407bfec..74c86f4d93 100644 --- a/src/cpp/common/create_auth_context.h +++ b/src/core/ext/client_config/parse_address.h @@ -30,13 +30,27 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -#include <memory> -#include <grpc++/security/auth_context.h> -#include <grpc/grpc.h> +#ifndef GRPC_CORE_EXT_CLIENT_CONFIG_PARSE_ADDRESS_H +#define GRPC_CORE_EXT_CLIENT_CONFIG_PARSE_ADDRESS_H -namespace grpc { +#include <stddef.h> -std::shared_ptr<const AuthContext> CreateAuthContext(grpc_call* call); +#include "src/core/ext/client_config/uri_parser.h" +#include "src/core/lib/iomgr/sockaddr.h" -} // namespace grpc +#ifdef GPR_HAVE_UNIX_SOCKET +/** Populate \a addr and \a len from \a uri, whose path is expected to contain a + * unix socket path. Returns true upon success. */ +int parse_unix(grpc_uri *uri, struct sockaddr_storage *addr, size_t *len); +#endif + +/** Populate /a addr and \a len from \a uri, whose path is expected to contain a + * host:port pair. Returns true upon success. */ +int parse_ipv4(grpc_uri *uri, struct sockaddr_storage *addr, size_t *len); + +/** Populate /a addr and \a len from \a uri, whose path is expected to contain a + * host:port pair. Returns true upon success. */ +int parse_ipv6(grpc_uri *uri, struct sockaddr_storage *addr, size_t *len); + +#endif /* GRPC_CORE_EXT_CLIENT_CONFIG_PARSE_ADDRESS_H */ diff --git a/src/core/ext/client_config/subchannel.c b/src/core/ext/client_config/subchannel.c index 125a291f21..c925c28c67 100644 --- a/src/core/ext/client_config/subchannel.c +++ b/src/core/ext/client_config/subchannel.c @@ -135,8 +135,6 @@ struct grpc_subchannel { int have_alarm; /** our alarm */ grpc_timer alarm; - /** current random value */ - uint32_t random; }; struct grpc_subchannel_call { @@ -297,10 +295,6 @@ void grpc_subchannel_weak_unref(grpc_exec_ctx *exec_ctx, } } -static uint32_t random_seed() { - return (uint32_t)(gpr_time_to_millis(gpr_now(GPR_CLOCK_MONOTONIC))); -} - grpc_subchannel *grpc_subchannel_create(grpc_exec_ctx *exec_ctx, grpc_connector *connector, grpc_subchannel_args *args) { @@ -332,7 +326,6 @@ grpc_subchannel *grpc_subchannel_create(grpc_exec_ctx *exec_ctx, grpc_set_initial_connect_string(&c->addr, &c->addr_len, &c->initial_connect_string); c->args = grpc_channel_args_copy(args->args); - c->random = random_seed(); c->root_external_state_watcher.next = c->root_external_state_watcher.prev = &c->root_external_state_watcher; grpc_closure_init(&c->connected, subchannel_connected, c); diff --git a/src/core/ext/client_config/subchannel_call_holder.c b/src/core/ext/client_config/subchannel_call_holder.c index 3db462b246..9918fbdcb4 100644 --- a/src/core/ext/client_config/subchannel_call_holder.c +++ b/src/core/ext/client_config/subchannel_call_holder.c @@ -252,9 +252,9 @@ char *grpc_subchannel_call_holder_get_peer( grpc_exec_ctx *exec_ctx, grpc_subchannel_call_holder *holder) { grpc_subchannel_call *subchannel_call = GET_CALL(holder); - if (subchannel_call) { - return grpc_subchannel_call_get_peer(exec_ctx, subchannel_call); - } else { + if (subchannel_call == NULL || subchannel_call == CANCELLED_CALL) { return NULL; + } else { + return grpc_subchannel_call_get_peer(exec_ctx, subchannel_call); } } diff --git a/src/core/ext/lb_policy/pick_first/pick_first.c b/src/core/ext/lb_policy/pick_first/pick_first.c index 5926f9d70b..0d215cd196 100644 --- a/src/core/ext/lb_policy/pick_first/pick_first.c +++ b/src/core/ext/lb_policy/pick_first/pick_first.c @@ -109,7 +109,7 @@ static void pf_shutdown(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) { if (selected != NULL) { grpc_connected_subchannel_notify_on_state_change( exec_ctx, selected, NULL, NULL, &p->connectivity_changed); - } else { + } else if (p->num_subchannels > 0) { grpc_subchannel_notify_on_state_change( exec_ctx, p->subchannels[p->checking_subchannel], NULL, NULL, &p->connectivity_changed); diff --git a/src/core/ext/resolver/dns/native/dns_resolver.c b/src/core/ext/resolver/dns/native/dns_resolver.c index 2749b0ca01..620ba4e2aa 100644 --- a/src/core/ext/resolver/dns/native/dns_resolver.c +++ b/src/core/ext/resolver/dns/native/dns_resolver.c @@ -86,7 +86,8 @@ typedef struct { static void dns_destroy(grpc_exec_ctx *exec_ctx, grpc_resolver *r); -static void dns_start_resolving_locked(dns_resolver *r); +static void dns_start_resolving_locked(grpc_exec_ctx *exec_ctx, + dns_resolver *r); static void dns_maybe_finish_next_locked(grpc_exec_ctx *exec_ctx, dns_resolver *r); @@ -119,7 +120,7 @@ static void dns_channel_saw_error(grpc_exec_ctx *exec_ctx, gpr_mu_lock(&r->mu); if (!r->resolving) { gpr_backoff_reset(&r->backoff_state); - dns_start_resolving_locked(r); + dns_start_resolving_locked(exec_ctx, r); } gpr_mu_unlock(&r->mu); } @@ -134,7 +135,7 @@ static void dns_next(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver, r->target_config = target_config; if (r->resolved_version == 0 && !r->resolving) { gpr_backoff_reset(&r->backoff_state); - dns_start_resolving_locked(r); + dns_start_resolving_locked(exec_ctx, r); } else { dns_maybe_finish_next_locked(exec_ctx, r); } @@ -149,7 +150,7 @@ static void dns_on_retry_timer(grpc_exec_ctx *exec_ctx, void *arg, r->have_retry_timer = false; if (success) { if (!r->resolving) { - dns_start_resolving_locked(r); + dns_start_resolving_locked(exec_ctx, r); } } gpr_mu_unlock(&r->mu); @@ -201,11 +202,12 @@ static void dns_on_resolved(grpc_exec_ctx *exec_ctx, void *arg, GRPC_RESOLVER_UNREF(exec_ctx, &r->base, "dns-resolving"); } -static void dns_start_resolving_locked(dns_resolver *r) { +static void dns_start_resolving_locked(grpc_exec_ctx *exec_ctx, + dns_resolver *r) { GRPC_RESOLVER_REF(&r->base, "dns-resolving"); GPR_ASSERT(!r->resolving); r->resolving = 1; - grpc_resolve_address(r->name, r->default_port, dns_on_resolved, r); + grpc_resolve_address(exec_ctx, r->name, r->default_port, dns_on_resolved, r); } static void dns_maybe_finish_next_locked(grpc_exec_ctx *exec_ctx, diff --git a/src/core/ext/resolver/sockaddr/sockaddr_resolver.c b/src/core/ext/resolver/sockaddr/sockaddr_resolver.c index 1d54a86c39..a4fa9acf22 100644 --- a/src/core/ext/resolver/sockaddr/sockaddr_resolver.c +++ b/src/core/ext/resolver/sockaddr/sockaddr_resolver.c @@ -40,11 +40,8 @@ #include <grpc/support/port_platform.h> #include <grpc/support/string_util.h> -#ifdef GPR_HAVE_UNIX_SOCKET -#include <sys/un.h> -#endif - #include "src/core/ext/client_config/lb_policy_registry.h" +#include "src/core/ext/client_config/parse_address.h" #include "src/core/ext/client_config/resolver_registry.h" #include "src/core/lib/iomgr/resolve_address.h" #include "src/core/lib/iomgr/unix_sockets_posix.h" @@ -167,105 +164,12 @@ static char *ipv6_get_default_authority(grpc_resolver_factory *factory, } #ifdef GPR_HAVE_UNIX_SOCKET -static int parse_unix(grpc_uri *uri, struct sockaddr_storage *addr, - size_t *len) { - struct sockaddr_un *un = (struct sockaddr_un *)addr; - - un->sun_family = AF_UNIX; - strcpy(un->sun_path, uri->path); - *len = strlen(un->sun_path) + sizeof(un->sun_family) + 1; - - return 1; -} - char *unix_get_default_authority(grpc_resolver_factory *factory, grpc_uri *uri) { return gpr_strdup("localhost"); } #endif -static int parse_ipv4(grpc_uri *uri, struct sockaddr_storage *addr, - size_t *len) { - const char *host_port = uri->path; - char *host; - char *port; - int port_num; - int result = 0; - struct sockaddr_in *in = (struct sockaddr_in *)addr; - - if (*host_port == '/') ++host_port; - if (!gpr_split_host_port(host_port, &host, &port)) { - return 0; - } - - memset(in, 0, sizeof(*in)); - *len = sizeof(*in); - in->sin_family = AF_INET; - if (inet_pton(AF_INET, host, &in->sin_addr) == 0) { - gpr_log(GPR_ERROR, "invalid ipv4 address: '%s'", host); - goto done; - } - - if (port != NULL) { - if (sscanf(port, "%d", &port_num) != 1 || port_num < 0 || - port_num > 65535) { - gpr_log(GPR_ERROR, "invalid ipv4 port: '%s'", port); - goto done; - } - in->sin_port = htons((uint16_t)port_num); - } else { - gpr_log(GPR_ERROR, "no port given for ipv4 scheme"); - goto done; - } - - result = 1; -done: - gpr_free(host); - gpr_free(port); - return result; -} - -static int parse_ipv6(grpc_uri *uri, struct sockaddr_storage *addr, - size_t *len) { - const char *host_port = uri->path; - char *host; - char *port; - int port_num; - int result = 0; - struct sockaddr_in6 *in6 = (struct sockaddr_in6 *)addr; - - if (*host_port == '/') ++host_port; - if (!gpr_split_host_port(host_port, &host, &port)) { - return 0; - } - - memset(in6, 0, sizeof(*in6)); - *len = sizeof(*in6); - in6->sin6_family = AF_INET6; - if (inet_pton(AF_INET6, host, &in6->sin6_addr) == 0) { - gpr_log(GPR_ERROR, "invalid ipv6 address: '%s'", host); - goto done; - } - - if (port != NULL) { - if (sscanf(port, "%d", &port_num) != 1 || port_num < 0 || - port_num > 65535) { - gpr_log(GPR_ERROR, "invalid ipv6 port: '%s'", port); - goto done; - } - in6->sin6_port = htons((uint16_t)port_num); - } else { - gpr_log(GPR_ERROR, "no port given for ipv6 scheme"); - goto done; - } - - result = 1; -done: - gpr_free(host); - gpr_free(port); - return result; -} - static void do_nothing(void *ignored) {} static grpc_resolver *sockaddr_create( diff --git a/src/core/ext/resolver/zookeeper/zookeeper_resolver.c b/src/core/ext/resolver/zookeeper/zookeeper_resolver.c index 898632c3cd..deb4b9b1ef 100644 --- a/src/core/ext/resolver/zookeeper/zookeeper_resolver.c +++ b/src/core/ext/resolver/zookeeper/zookeeper_resolver.c @@ -299,7 +299,7 @@ static void zookeeper_get_children_node_completion(int rc, const char *value, address = zookeeper_parse_address(value, (size_t)value_len); if (address != NULL) { /** Further resolves address by DNS */ - grpc_resolve_address(address, NULL, zookeeper_dns_resolved, r); + grpc_resolve_address(&exec_ctx, address, NULL, zookeeper_dns_resolved, r); gpr_free(address); } else { gpr_log(GPR_ERROR, "Error in resolving a child node of %s", r->name); @@ -375,8 +375,10 @@ static void zookeeper_get_node_completion(int rc, const char *value, r->resolved_addrs->naddrs = 0; r->resolved_total = 1; /** Further resolves address by DNS */ - grpc_resolve_address(address, NULL, zookeeper_dns_resolved, r); + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + grpc_resolve_address(&exec_ctx, address, NULL, zookeeper_dns_resolved, r); gpr_free(address); + grpc_exec_ctx_finish(&exec_ctx); return; } diff --git a/src/core/ext/transport/chttp2/client/insecure/channel_create.c b/src/core/ext/transport/chttp2/client/insecure/channel_create.c index 0ed115793b..c5d3d8d9cc 100644 --- a/src/core/ext/transport/chttp2/client/insecure/channel_create.c +++ b/src/core/ext/transport/chttp2/client/insecure/channel_create.c @@ -235,5 +235,7 @@ grpc_channel *grpc_insecure_channel_create(const char *target, grpc_exec_ctx_finish(&exec_ctx); - return channel; /* may be NULL */ + return channel != NULL ? channel : grpc_lame_client_channel_create( + target, GRPC_STATUS_INTERNAL, + "Failed to create client channel"); } diff --git a/src/core/ext/transport/chttp2/transport/bin_encoder.c b/src/core/ext/transport/chttp2/transport/bin_encoder.c index db68e750ac..1b43c28be1 100644 --- a/src/core/ext/transport/chttp2/transport/bin_encoder.c +++ b/src/core/ext/transport/chttp2/transport/bin_encoder.c @@ -194,9 +194,13 @@ gpr_slice grpc_chttp2_base64_encode_and_huffman_compress_impl(gpr_slice input) { /* encode full triplets */ for (i = 0; i < input_triplets; i++) { - enc_add2(&out, in[0] >> 2, (uint8_t)((in[0] & 0x3) << 4) | (in[1] >> 4)); - enc_add2(&out, (uint8_t)((in[1] & 0xf) << 2) | (in[2] >> 6), - (uint8_t)(in[2] & 0x3f)); + const uint8_t low_to_high = (uint8_t)((in[0] & 0x3) << 4); + const uint8_t high_to_low = in[1] >> 4; + enc_add2(&out, in[0] >> 2, low_to_high | high_to_low); + + const uint8_t a = (uint8_t)((in[1] & 0xf) << 2); + const uint8_t b = (in[2] >> 6); + enc_add2(&out, a | b, in[2] & 0x3f); in += 3; } @@ -208,12 +212,14 @@ gpr_slice grpc_chttp2_base64_encode_and_huffman_compress_impl(gpr_slice input) { enc_add2(&out, in[0] >> 2, (uint8_t)((in[0] & 0x3) << 4)); in += 1; break; - case 2: - enc_add2(&out, in[0] >> 2, - (uint8_t)((in[0] & 0x3) << 4) | (uint8_t)(in[1] >> 4)); + case 2: { + const uint8_t low_to_high = (uint8_t)((in[0] & 0x3) << 4); + const uint8_t high_to_low = in[1] >> 4; + enc_add2(&out, in[0] >> 2, low_to_high | high_to_low); enc_add1(&out, (uint8_t)((in[1] & 0xf) << 2)); in += 2; break; + } } if (out.temp_length) { diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.c b/src/core/ext/transport/chttp2/transport/hpack_parser.c index a36d2fc382..687936bfd3 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_parser.c +++ b/src/core/ext/transport/chttp2/transport/hpack_parser.c @@ -638,6 +638,10 @@ static int on_hdr(grpc_chttp2_hpack_parser *p, grpc_mdelem *md, return 0; } } + if (p->on_header == NULL) { + GRPC_MDELEM_UNREF(md); + return 0; + } p->on_header(p->on_header_user_data, md); return 1; } @@ -1382,12 +1386,8 @@ static int parse_value_string_with_literal_key(grpc_chttp2_hpack_parser *p, /* PUBLIC INTERFACE */ -static void on_header_not_set(void *user_data, grpc_mdelem *md) { - GPR_UNREACHABLE_CODE(return ); -} - void grpc_chttp2_hpack_parser_init(grpc_chttp2_hpack_parser *p) { - p->on_header = on_header_not_set; + p->on_header = NULL; p->on_header_user_data = NULL; p->state = parse_begin; p->key.str = NULL; @@ -1455,7 +1455,7 @@ grpc_chttp2_parse_error grpc_chttp2_header_parser_parse( stream_parsing->received_close = 1; } } - parser->on_header = on_header_not_set; + parser->on_header = NULL; parser->on_header_user_data = NULL; parser->is_boundary = 0xde; parser->is_eof = 0xde; diff --git a/src/core/lib/channel/compress_filter.c b/src/core/lib/channel/compress_filter.c index 229fdb5ef6..3d42d0e616 100644 --- a/src/core/lib/channel/compress_filter.c +++ b/src/core/lib/channel/compress_filter.c @@ -268,8 +268,14 @@ static void init_channel_elem(grpc_exec_ctx *exec_ctx, channeld->default_compression_algorithm = grpc_channel_args_get_compression_algorithm(args->channel_args); /* Make sure the default isn't disabled. */ - GPR_ASSERT(grpc_compression_options_is_algorithm_enabled( - &channeld->compression_options, channeld->default_compression_algorithm)); + if (!grpc_compression_options_is_algorithm_enabled( + &channeld->compression_options, + channeld->default_compression_algorithm)) { + gpr_log(GPR_DEBUG, + "compression algorithm %d not enabled: switching to none", + channeld->default_compression_algorithm); + channeld->default_compression_algorithm = GRPC_COMPRESS_NONE; + } channeld->compression_options.default_compression_algorithm = channeld->default_compression_algorithm; diff --git a/src/core/lib/http/httpcli.c b/src/core/lib/http/httpcli.c index 76bd1b64dc..f22721ac8f 100644 --- a/src/core/lib/http/httpcli.c +++ b/src/core/lib/http/httpcli.c @@ -246,7 +246,7 @@ static void internal_request_begin( grpc_pollset_set_add_pollset(exec_ctx, req->context->pollset_set, req->pollset); - grpc_resolve_address(request->host, req->handshaker->default_port, + grpc_resolve_address(exec_ctx, request->host, req->handshaker->default_port, on_resolved, req); } diff --git a/src/core/lib/http/parser.c b/src/core/lib/http/parser.c index 01d17fb623..a7efb5e73e 100644 --- a/src/core/lib/http/parser.c +++ b/src/core/lib/http/parser.c @@ -39,7 +39,7 @@ #include <grpc/support/log.h> #include <grpc/support/useful.h> -extern int grpc_http_trace; +int grpc_http1_trace = 0; static char *buf2str(void *buffer, size_t length) { char *out = gpr_malloc(length + 1); @@ -74,7 +74,7 @@ static int handle_response_line(grpc_http_parser *parser) { return 1; error: - if (grpc_http_trace) gpr_log(GPR_ERROR, "Failed parsing response line"); + if (grpc_http1_trace) gpr_log(GPR_ERROR, "Failed parsing response line"); return 0; } @@ -127,7 +127,7 @@ static int handle_request_line(grpc_http_parser *parser) { return 1; error: - if (grpc_http_trace) gpr_log(GPR_ERROR, "Failed parsing request line"); + if (grpc_http1_trace) gpr_log(GPR_ERROR, "Failed parsing request line"); return 0; } @@ -152,7 +152,7 @@ static int add_header(grpc_http_parser *parser) { GPR_ASSERT(cur != end); if (*cur == ' ' || *cur == '\t') { - if (grpc_http_trace) + if (grpc_http1_trace) gpr_log(GPR_ERROR, "Continued header lines not supported yet"); goto error; } @@ -161,7 +161,8 @@ static int add_header(grpc_http_parser *parser) { cur++; } if (cur == end) { - if (grpc_http_trace) gpr_log(GPR_ERROR, "Didn't find ':' in header string"); + if (grpc_http1_trace) + gpr_log(GPR_ERROR, "Didn't find ':' in header string"); goto error; } GPR_ASSERT(cur >= beg); @@ -171,8 +172,8 @@ static int add_header(grpc_http_parser *parser) { while (cur != end && (*cur == ' ' || *cur == '\t')) { cur++; } - GPR_ASSERT(end - cur >= 2); - hdr.value = buf2str(cur, (size_t)(end - cur) - 2); + GPR_ASSERT((size_t)(end - cur) >= parser->cur_line_end_length); + hdr.value = buf2str(cur, (size_t)(end - cur) - parser->cur_line_end_length); if (parser->type == GRPC_HTTP_RESPONSE) { hdr_count = &parser->http.response.hdr_count; @@ -207,7 +208,7 @@ static int finish_line(grpc_http_parser *parser) { parser->state = GRPC_HTTP_HEADERS; break; case GRPC_HTTP_HEADERS: - if (parser->cur_line_length == 2) { + if (parser->cur_line_length == parser->cur_line_end_length) { parser->state = GRPC_HTTP_BODY; break; } @@ -247,21 +248,43 @@ static int addbyte_body(grpc_http_parser *parser, uint8_t byte) { return 1; } +static int check_line(grpc_http_parser *parser) { + if (parser->cur_line_length >= 2 && + parser->cur_line[parser->cur_line_length - 2] == '\r' && + parser->cur_line[parser->cur_line_length - 1] == '\n') { + return 1; + } + + // HTTP request with \n\r line termiantors. + else if (parser->cur_line_length >= 2 && + parser->cur_line[parser->cur_line_length - 2] == '\n' && + parser->cur_line[parser->cur_line_length - 1] == '\r') { + return 1; + } + + // HTTP request with only \n line terminators. + else if (parser->cur_line_length >= 1 && + parser->cur_line[parser->cur_line_length - 1] == '\n') { + parser->cur_line_end_length = 1; + return 1; + } + + return 0; +} + static int addbyte(grpc_http_parser *parser, uint8_t byte) { switch (parser->state) { case GRPC_HTTP_FIRST_LINE: case GRPC_HTTP_HEADERS: if (parser->cur_line_length >= GRPC_HTTP_PARSER_MAX_HEADER_LENGTH) { - if (grpc_http_trace) + if (grpc_http1_trace) gpr_log(GPR_ERROR, "HTTP client max line length (%d) exceeded", GRPC_HTTP_PARSER_MAX_HEADER_LENGTH); return 0; } parser->cur_line[parser->cur_line_length] = byte; parser->cur_line_length++; - if (parser->cur_line_length >= 2 && - parser->cur_line[parser->cur_line_length - 2] == '\r' && - parser->cur_line[parser->cur_line_length - 1] == '\n') { + if (check_line(parser)) { return finish_line(parser); } else { return 1; @@ -277,6 +300,7 @@ void grpc_http_parser_init(grpc_http_parser *parser) { memset(parser, 0, sizeof(*parser)); parser->state = GRPC_HTTP_FIRST_LINE; parser->type = GRPC_HTTP_UNKNOWN; + parser->cur_line_end_length = 2; } void grpc_http_parser_destroy(grpc_http_parser *parser) { diff --git a/src/core/lib/http/parser.h b/src/core/lib/http/parser.h index 8bd73f649a..536637e9a2 100644 --- a/src/core/lib/http/parser.h +++ b/src/core/lib/http/parser.h @@ -105,6 +105,7 @@ typedef struct { uint8_t cur_line[GRPC_HTTP_PARSER_MAX_HEADER_LENGTH]; size_t cur_line_length; + size_t cur_line_end_length; } grpc_http_parser; void grpc_http_parser_init(grpc_http_parser *parser); @@ -113,4 +114,6 @@ void grpc_http_parser_destroy(grpc_http_parser *parser); int grpc_http_parser_parse(grpc_http_parser *parser, gpr_slice slice); int grpc_http_parser_eof(grpc_http_parser *parser); +extern int grpc_http1_trace; + #endif /* GRPC_CORE_LIB_HTTP_PARSER_H */ diff --git a/src/core/lib/iomgr/closure.c b/src/core/lib/iomgr/closure.c index d6f073fc9d..27793c32e4 100644 --- a/src/core/lib/iomgr/closure.c +++ b/src/core/lib/iomgr/closure.c @@ -54,6 +54,12 @@ void grpc_closure_list_add(grpc_closure_list *closure_list, closure_list->tail = closure; } +void grpc_closure_list_fail_all(grpc_closure_list *list) { + for (grpc_closure *c = list->head; c != NULL; c = grpc_closure_next(c)) { + c->final_data &= ~(uintptr_t)1; + } +} + bool grpc_closure_list_empty(grpc_closure_list closure_list) { return closure_list.head == NULL; } diff --git a/src/core/lib/iomgr/closure.h b/src/core/lib/iomgr/closure.h index 8652b53a8b..fdc2daed9d 100644 --- a/src/core/lib/iomgr/closure.h +++ b/src/core/lib/iomgr/closure.h @@ -86,6 +86,9 @@ grpc_closure *grpc_closure_create(grpc_iomgr_cb_func cb, void *cb_arg); void grpc_closure_list_add(grpc_closure_list *list, grpc_closure *closure, bool success); +/** force all success bits in \a list to false */ +void grpc_closure_list_fail_all(grpc_closure_list *list); + /** append all closures from \a src to \a dst and empty \a src. */ void grpc_closure_list_move(grpc_closure_list *src, grpc_closure_list *dst); diff --git a/src/core/lib/iomgr/exec_ctx.h b/src/core/lib/iomgr/exec_ctx.h index e09ef02400..976cc40347 100644 --- a/src/core/lib/iomgr/exec_ctx.h +++ b/src/core/lib/iomgr/exec_ctx.h @@ -93,6 +93,8 @@ void grpc_exec_ctx_enqueue_list(grpc_exec_ctx *exec_ctx, grpc_workqueue *offload_target_or_null); void grpc_exec_ctx_global_init(void); + +void grpc_exec_ctx_global_init(void); void grpc_exec_ctx_global_shutdown(void); #endif /* GRPC_CORE_LIB_IOMGR_EXEC_CTX_H */ diff --git a/src/core/lib/iomgr/resolve_address.h b/src/core/lib/iomgr/resolve_address.h index ecc06340a3..ef198fe0f6 100644 --- a/src/core/lib/iomgr/resolve_address.h +++ b/src/core/lib/iomgr/resolve_address.h @@ -59,8 +59,9 @@ typedef void (*grpc_resolve_cb)(grpc_exec_ctx *exec_ctx, void *arg, /* Asynchronously resolve addr. Use default_port if a port isn't designated in addr, otherwise use the port in addr. */ /* TODO(ctiller): add a timeout here */ -void grpc_resolve_address(const char *addr, const char *default_port, - grpc_resolve_cb cb, void *arg); +extern void (*grpc_resolve_address)(grpc_exec_ctx *exec_ctx, const char *addr, + const char *default_port, + grpc_resolve_cb cb, void *arg); /* Destroy resolved addresses */ void grpc_resolved_addresses_destroy(grpc_resolved_addresses *addresses); diff --git a/src/core/lib/iomgr/resolve_address_posix.c b/src/core/lib/iomgr/resolve_address_posix.c index b9d3bbdb89..cae91eec20 100644 --- a/src/core/lib/iomgr/resolve_address_posix.c +++ b/src/core/lib/iomgr/resolve_address_posix.c @@ -164,8 +164,9 @@ void grpc_resolved_addresses_destroy(grpc_resolved_addresses *addrs) { gpr_free(addrs); } -void grpc_resolve_address(const char *name, const char *default_port, - grpc_resolve_cb cb, void *arg) { +static void resolve_address_impl(grpc_exec_ctx *exec_ctx, const char *name, + const char *default_port, grpc_resolve_cb cb, + void *arg) { request *r = gpr_malloc(sizeof(request)); grpc_closure_init(&r->request_closure, do_request_thread, r); r->name = gpr_strdup(name); @@ -175,4 +176,8 @@ void grpc_resolve_address(const char *name, const char *default_port, grpc_executor_enqueue(&r->request_closure, 1); } +void (*grpc_resolve_address)(grpc_exec_ctx *exec_ctx, const char *name, + const char *default_port, grpc_resolve_cb cb, + void *arg) = resolve_address_impl; + #endif diff --git a/src/core/lib/iomgr/resolve_address_windows.c b/src/core/lib/iomgr/resolve_address_windows.c index 82763d11f4..914736234d 100644 --- a/src/core/lib/iomgr/resolve_address_windows.c +++ b/src/core/lib/iomgr/resolve_address_windows.c @@ -155,8 +155,9 @@ void grpc_resolved_addresses_destroy(grpc_resolved_addresses *addrs) { gpr_free(addrs); } -void grpc_resolve_address(const char *name, const char *default_port, - grpc_resolve_cb cb, void *arg) { +static void resolve_address_impl(grpc_exec_ctx *exec_ctx, const char *name, + const char *default_port, grpc_resolve_cb cb, + void *arg) { request *r = gpr_malloc(sizeof(request)); grpc_closure_init(&r->request_closure, do_request_thread, r); r->name = gpr_strdup(name); @@ -166,4 +167,8 @@ void grpc_resolve_address(const char *name, const char *default_port, grpc_executor_enqueue(&r->request_closure, 1); } +void (*grpc_resolve_address)(grpc_exec_ctx *exec_ctx, const char *name, + const char *default_port, grpc_resolve_cb cb, + void *arg) = resolve_address_impl; + #endif diff --git a/src/core/lib/iomgr/tcp_client_posix.c b/src/core/lib/iomgr/tcp_client_posix.c index 6430cb629f..e93d5734a0 100644 --- a/src/core/lib/iomgr/tcp_client_posix.c +++ b/src/core/lib/iomgr/tcp_client_posix.c @@ -211,11 +211,11 @@ finish: grpc_exec_ctx_enqueue(exec_ctx, closure, *ep != NULL, NULL); } -void grpc_tcp_client_connect(grpc_exec_ctx *exec_ctx, grpc_closure *closure, - grpc_endpoint **ep, - grpc_pollset_set *interested_parties, - const struct sockaddr *addr, size_t addr_len, - gpr_timespec deadline) { +static void tcp_client_connect_impl(grpc_exec_ctx *exec_ctx, + grpc_closure *closure, grpc_endpoint **ep, + grpc_pollset_set *interested_parties, + const struct sockaddr *addr, + size_t addr_len, gpr_timespec deadline) { int fd; grpc_dualstack_mode dsmode; int err; @@ -303,4 +303,19 @@ done: gpr_free(addr_str); } +// overridden by api_fuzzer.c +void (*grpc_tcp_client_connect_impl)( + grpc_exec_ctx *exec_ctx, grpc_closure *closure, grpc_endpoint **ep, + grpc_pollset_set *interested_parties, const struct sockaddr *addr, + size_t addr_len, gpr_timespec deadline) = tcp_client_connect_impl; + +void grpc_tcp_client_connect(grpc_exec_ctx *exec_ctx, grpc_closure *closure, + grpc_endpoint **ep, + grpc_pollset_set *interested_parties, + const struct sockaddr *addr, size_t addr_len, + gpr_timespec deadline) { + grpc_tcp_client_connect_impl(exec_ctx, closure, ep, interested_parties, addr, + addr_len, deadline); +} + #endif diff --git a/src/core/lib/iomgr/timer.c b/src/core/lib/iomgr/timer.c index 713f15b69e..acb5b26c87 100644 --- a/src/core/lib/iomgr/timer.c +++ b/src/core/lib/iomgr/timer.c @@ -70,6 +70,7 @@ static gpr_clock_type g_clock_type; static shard_type g_shards[NUM_SHARDS]; /* Protected by g_mu */ static shard_type *g_shard_queue[NUM_SHARDS]; +static bool g_initialized = false; static int run_some_expired_timers(grpc_exec_ctx *exec_ctx, gpr_timespec now, gpr_timespec *next, int success); @@ -83,6 +84,7 @@ static gpr_timespec compute_min_deadline(shard_type *shard) { void grpc_timer_list_init(gpr_timespec now) { uint32_t i; + g_initialized = true; gpr_mu_init(&g_mu); gpr_mu_init(&g_checker_mu); g_clock_type = now.clock_type; @@ -111,6 +113,7 @@ void grpc_timer_list_shutdown(grpc_exec_ctx *exec_ctx) { } gpr_mu_destroy(&g_mu); gpr_mu_destroy(&g_checker_mu); + g_initialized = false; } /* This is a cheap, but good enough, pointer hash for sharding the tasks: */ @@ -180,6 +183,18 @@ void grpc_timer_init(grpc_exec_ctx *exec_ctx, grpc_timer *timer, timer->deadline = deadline; timer->triggered = 0; + if (!g_initialized) { + timer->triggered = 1; + grpc_exec_ctx_enqueue(exec_ctx, &timer->closure, false, NULL); + return; + } + + if (gpr_time_cmp(deadline, now) <= 0) { + timer->triggered = 1; + grpc_exec_ctx_enqueue(exec_ctx, &timer->closure, true, NULL); + return; + } + /* TODO(ctiller): check deadline expired */ gpr_mu_lock(&shard->mu); diff --git a/src/core/lib/iomgr/udp_server.c b/src/core/lib/iomgr/udp_server.c index 24131179af..df6cf956d9 100644 --- a/src/core/lib/iomgr/udp_server.c +++ b/src/core/lib/iomgr/udp_server.c @@ -166,7 +166,6 @@ static void deactivated_all_ports(grpc_exec_ctx *exec_ctx, grpc_udp_server *s) { if (s->nports) { for (i = 0; i < s->nports; i++) { server_port *sp = &s->ports[i]; - grpc_unlink_if_unix_domain_socket(&sp->addr.sockaddr); sp->destroyed_closure.cb = destroyed_port; sp->destroyed_closure.cb_arg = s; grpc_fd_orphan(exec_ctx, sp->emfd, &sp->destroyed_closure, NULL, @@ -317,8 +316,6 @@ int grpc_udp_server_add_port(grpc_udp_server *s, const void *addr, socklen_t sockname_len; int port; - grpc_unlink_if_unix_domain_socket((struct sockaddr *)addr); - /* Check if this is a wildcard port, and if so, try to keep the port the same as some previously created listener. */ if (grpc_sockaddr_get_port(addr) == 0) { diff --git a/src/core/lib/security/credentials.c b/src/core/lib/security/credentials.c index 2c7d31519c..fd5ad3589b 100644 --- a/src/core/lib/security/credentials.c +++ b/src/core/lib/security/credentials.c @@ -338,10 +338,11 @@ static void ssl_build_config(const char *pem_root_certs, static void ssl_build_server_config( const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pairs, - size_t num_key_cert_pairs, int force_client_auth, + size_t num_key_cert_pairs, + grpc_ssl_client_certificate_request_type client_certificate_request, grpc_ssl_server_config *config) { size_t i; - config->force_client_auth = force_client_auth; + config->client_certificate_request = client_certificate_request; if (pem_root_certs != NULL) { ssl_copy_key_material(pem_root_certs, &config->pem_root_certs, &config->pem_root_certs_size); @@ -391,21 +392,35 @@ grpc_channel_credentials *grpc_ssl_credentials_create( grpc_server_credentials *grpc_ssl_server_credentials_create( const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pairs, size_t num_key_cert_pairs, int force_client_auth, void *reserved) { + return grpc_ssl_server_credentials_create_ex( + pem_root_certs, pem_key_cert_pairs, num_key_cert_pairs, + force_client_auth + ? GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY + : GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE, + reserved); +} + +grpc_server_credentials *grpc_ssl_server_credentials_create_ex( + const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pairs, + size_t num_key_cert_pairs, + grpc_ssl_client_certificate_request_type client_certificate_request, + void *reserved) { grpc_ssl_server_credentials *c = gpr_malloc(sizeof(grpc_ssl_server_credentials)); GRPC_API_TRACE( - "grpc_ssl_server_credentials_create(" + "grpc_ssl_server_credentials_create_ex(" "pem_root_certs=%s, pem_key_cert_pairs=%p, num_key_cert_pairs=%lu, " - "force_client_auth=%d, reserved=%p)", + "client_certificate_request=%d, reserved=%p)", 5, (pem_root_certs, pem_key_cert_pairs, (unsigned long)num_key_cert_pairs, - force_client_auth, reserved)); + client_certificate_request, reserved)); GPR_ASSERT(reserved == NULL); memset(c, 0, sizeof(grpc_ssl_server_credentials)); c->base.type = GRPC_CHANNEL_CREDENTIALS_TYPE_SSL; gpr_ref_init(&c->base.refcount, 1); c->base.vtable = &ssl_server_vtable; ssl_build_server_config(pem_root_certs, pem_key_cert_pairs, - num_key_cert_pairs, force_client_auth, &c->config); + num_key_cert_pairs, client_certificate_request, + &c->config); return &c->base; } diff --git a/src/core/lib/security/security_connector.c b/src/core/lib/security/security_connector.c index 59863ba064..2d2023bdf5 100644 --- a/src/core/lib/security/security_connector.c +++ b/src/core/lib/security/security_connector.c @@ -668,6 +668,31 @@ gpr_slice grpc_get_default_ssl_roots_for_testing(void) { return compute_default_pem_root_certs_once(); } +static tsi_client_certificate_request_type +get_tsi_client_certificate_request_type( + grpc_ssl_client_certificate_request_type grpc_request_type) { + switch (grpc_request_type) { + case GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE: + return TSI_DONT_REQUEST_CLIENT_CERTIFICATE; + + case GRPC_SSL_REQUEST_CLIENT_CERTIFICATE_BUT_DONT_VERIFY: + return TSI_REQUEST_CLIENT_CERTIFICATE_BUT_DONT_VERIFY; + + case GRPC_SSL_REQUEST_CLIENT_CERTIFICATE_AND_VERIFY: + return TSI_REQUEST_CLIENT_CERTIFICATE_AND_VERIFY; + + case GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_BUT_DONT_VERIFY: + return TSI_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_BUT_DONT_VERIFY; + + case GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY: + return TSI_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY; + + default: + // Is this a sane default + return TSI_DONT_REQUEST_CLIENT_CERTIFICATE; + } +} + size_t grpc_get_default_ssl_roots(const unsigned char **pem_root_certs) { /* TODO(jboeuf@google.com): Maybe revisit the approach which consists in loading all the roots once for the lifetime of the process. */ @@ -782,15 +807,16 @@ grpc_security_status grpc_ssl_server_security_connector_create( gpr_ref_init(&c->base.base.refcount, 1); c->base.base.url_scheme = GRPC_SSL_URL_SCHEME; c->base.base.vtable = &ssl_server_vtable; - result = tsi_create_ssl_server_handshaker_factory( + result = tsi_create_ssl_server_handshaker_factory_ex( (const unsigned char **)config->pem_private_keys, config->pem_private_keys_sizes, (const unsigned char **)config->pem_cert_chains, config->pem_cert_chains_sizes, config->num_key_cert_pairs, config->pem_root_certs, config->pem_root_certs_size, - config->force_client_auth, ssl_cipher_suites(), alpn_protocol_strings, - alpn_protocol_string_lengths, (uint16_t)num_alpn_protocols, - &c->handshaker_factory); + get_tsi_client_certificate_request_type( + config->client_certificate_request), + ssl_cipher_suites(), alpn_protocol_strings, alpn_protocol_string_lengths, + (uint16_t)num_alpn_protocols, &c->handshaker_factory); if (result != TSI_OK) { gpr_log(GPR_ERROR, "Handshaker factory creation failed with %s.", tsi_result_to_string(result)); diff --git a/src/core/lib/security/security_connector.h b/src/core/lib/security/security_connector.h index c9e262b1ad..2c893cd5e9 100644 --- a/src/core/lib/security/security_connector.h +++ b/src/core/lib/security/security_connector.h @@ -241,7 +241,7 @@ typedef struct { size_t num_key_cert_pairs; unsigned char *pem_root_certs; size_t pem_root_certs_size; - int force_client_auth; + grpc_ssl_client_certificate_request_type client_certificate_request; } grpc_ssl_server_config; /* Creates an SSL server_security_connector. diff --git a/src/core/lib/support/log.c b/src/core/lib/support/log.c index 04156a5b1f..882abf673c 100644 --- a/src/core/lib/support/log.c +++ b/src/core/lib/support/log.c @@ -31,14 +31,20 @@ * */ +#include <grpc/support/alloc.h> +#include <grpc/support/atm.h> #include <grpc/support/log.h> #include <grpc/support/port_platform.h> +#include "src/core/lib/support/env.h" +#include "src/core/lib/support/string.h" + #include <stdio.h> #include <string.h> extern void gpr_default_log(gpr_log_func_args *args); static gpr_log_func g_log_func = gpr_default_log; +static gpr_atm g_min_severity_to_print = GPR_LOG_VERBOSITY_UNSET; const char *gpr_log_severity_string(gpr_log_severity severity) { switch (severity) { @@ -54,6 +60,9 @@ const char *gpr_log_severity_string(gpr_log_severity severity) { void gpr_log_message(const char *file, int line, gpr_log_severity severity, const char *message) { + if ((gpr_atm)severity < gpr_atm_no_barrier_load(&g_min_severity_to_print)) + return; + gpr_log_func_args lfargs; memset(&lfargs, 0, sizeof(lfargs)); lfargs.file = file; @@ -63,4 +72,28 @@ void gpr_log_message(const char *file, int line, gpr_log_severity severity, g_log_func(&lfargs); } +void gpr_set_log_verbosity(gpr_log_severity min_severity_to_print) { + gpr_atm_no_barrier_store(&g_min_severity_to_print, + (gpr_atm)min_severity_to_print); +} + +void gpr_log_verbosity_init() { + char *verbosity = gpr_getenv("GRPC_VERBOSITY"); + if (verbosity == NULL) return; + + gpr_atm min_severity_to_print = GPR_LOG_VERBOSITY_UNSET; + if (strcmp(verbosity, "DEBUG") == 0) { + min_severity_to_print = (gpr_atm)GPR_LOG_SEVERITY_DEBUG; + } else if (strcmp(verbosity, "INFO") == 0) { + min_severity_to_print = (gpr_atm)GPR_LOG_SEVERITY_INFO; + } else if (strcmp(verbosity, "ERROR") == 0) { + min_severity_to_print = (gpr_atm)GPR_LOG_SEVERITY_ERROR; + } + gpr_free(verbosity); + if ((gpr_atm_no_barrier_load(&g_min_severity_to_print)) == + GPR_LOG_VERBOSITY_UNSET) { + gpr_atm_no_barrier_store(&g_min_severity_to_print, min_severity_to_print); + } +} + void gpr_set_log_function(gpr_log_func f) { g_log_func = f; } diff --git a/src/core/lib/support/time_posix.c b/src/core/lib/support/time_posix.c index f5f62dadc6..11542072fe 100644 --- a/src/core/lib/support/time_posix.c +++ b/src/core/lib/support/time_posix.c @@ -78,7 +78,7 @@ static const clockid_t clockid_for_gpr_clock[] = {CLOCK_MONOTONIC, void gpr_time_init(void) { gpr_precise_clock_init(); } -gpr_timespec gpr_now(gpr_clock_type clock_type) { +static gpr_timespec now_impl(gpr_clock_type clock_type) { struct timespec now; GPR_ASSERT(clock_type != GPR_TIMESPAN); if (clock_type == GPR_CLOCK_PRECISE) { @@ -114,7 +114,7 @@ void gpr_time_init(void) { g_time_start = mach_absolute_time(); } -gpr_timespec gpr_now(gpr_clock_type clock) { +static gpr_timespec now_impl(gpr_clock_type clock) { gpr_timespec now; struct timeval now_tv; double now_dbl; @@ -142,6 +142,12 @@ gpr_timespec gpr_now(gpr_clock_type clock) { } #endif +gpr_timespec (*gpr_now_impl)(gpr_clock_type clock_type) = now_impl; + +gpr_timespec gpr_now(gpr_clock_type clock_type) { + return gpr_now_impl(clock_type); +} + void gpr_sleep_until(gpr_timespec until) { gpr_timespec now; gpr_timespec delta; diff --git a/src/core/lib/surface/call.c b/src/core/lib/surface/call.c index 6581bbd3d1..fa12b6ea61 100644 --- a/src/core/lib/surface/call.c +++ b/src/core/lib/surface/call.c @@ -142,22 +142,23 @@ struct grpc_call { gpr_mu mu; /* client or server call */ - uint8_t is_client; + bool is_client; /* is the alarm set */ - uint8_t have_alarm; + bool have_alarm; /** has grpc_call_destroy been called */ - uint8_t destroy_called; + bool destroy_called; /** flag indicating that cancellation is inherited */ - uint8_t cancellation_is_inherited; + bool cancellation_is_inherited; /** bitmask of live batches */ uint8_t used_batches; /** which ops are in-flight */ - uint8_t sent_initial_metadata; - uint8_t sending_message; - uint8_t sent_final_op; - uint8_t received_initial_metadata; - uint8_t receiving_message; - uint8_t received_final_op; + bool sent_initial_metadata; + bool sending_message; + bool sent_final_op; + bool received_initial_metadata; + bool receiving_message; + bool requested_final_op; + bool received_final_op; /* have we received initial metadata */ bool has_initial_md_been_received; @@ -220,10 +221,7 @@ struct grpc_call { } server; } final_op; - struct { - void *bctlp; - bool success; - } saved_receiving_stream_ready_ctx; + void *saved_receiving_stream_ready_bctlp; }; #define CALL_STACK_FROM_CALL(call) ((grpc_call_stack *)((call) + 1)) @@ -554,21 +552,6 @@ static int prepare_application_metadata(grpc_call *call, int count, int i; grpc_metadata_batch *batch = &call->metadata_batch[0 /* is_receiving */][is_trailing]; - if (prepend_extra_metadata) { - if (call->send_extra_metadata_count == 0) { - prepend_extra_metadata = 0; - } else { - for (i = 0; i < call->send_extra_metadata_count; i++) { - GRPC_MDELEM_REF(call->send_extra_metadata[i].md); - } - for (i = 1; i < call->send_extra_metadata_count; i++) { - call->send_extra_metadata[i].prev = &call->send_extra_metadata[i - 1]; - } - for (i = 0; i < call->send_extra_metadata_count - 1; i++) { - call->send_extra_metadata[i].next = &call->send_extra_metadata[i + 1]; - } - } - } for (i = 0; i < count; i++) { grpc_metadata *md = &metadata[i]; grpc_linked_mdelem *l = (grpc_linked_mdelem *)&md->internal_data; @@ -579,14 +562,37 @@ static int prepare_application_metadata(grpc_call *call, int count, GRPC_MDSTR_LENGTH(l->md->key))) { gpr_log(GPR_ERROR, "attempt to send invalid metadata key: %s", grpc_mdstr_as_c_string(l->md->key)); - return 0; + break; } else if (!grpc_is_binary_header(grpc_mdstr_as_c_string(l->md->key), GRPC_MDSTR_LENGTH(l->md->key)) && !grpc_header_nonbin_value_is_legal( grpc_mdstr_as_c_string(l->md->value), GRPC_MDSTR_LENGTH(l->md->value))) { gpr_log(GPR_ERROR, "attempt to send invalid metadata value"); - return 0; + break; + } + } + if (i != count) { + for (int j = 0; j <= i; j++) { + grpc_metadata *md = &metadata[j]; + grpc_linked_mdelem *l = (grpc_linked_mdelem *)&md->internal_data; + GRPC_MDELEM_UNREF(l->md); + } + return 0; + } + if (prepend_extra_metadata) { + if (call->send_extra_metadata_count == 0) { + prepend_extra_metadata = 0; + } else { + for (i = 0; i < call->send_extra_metadata_count; i++) { + GRPC_MDELEM_REF(call->send_extra_metadata[i].md); + } + for (i = 1; i < call->send_extra_metadata_count; i++) { + call->send_extra_metadata[i].prev = &call->send_extra_metadata[i - 1]; + } + for (i = 0; i < call->send_extra_metadata_count - 1; i++) { + call->send_extra_metadata[i].next = &call->send_extra_metadata[i + 1]; + } } } for (i = 1; i < count; i++) { @@ -1057,12 +1063,12 @@ static void receiving_stream_ready(grpc_exec_ctx *exec_ctx, void *bctlp, grpc_call *call = bctl->call; gpr_mu_lock(&bctl->call->mu); - if (bctl->call->has_initial_md_been_received) { + if (bctl->call->has_initial_md_been_received || !success || + call->receiving_stream == NULL) { gpr_mu_unlock(&bctl->call->mu); process_data_after_md(exec_ctx, bctlp, success); } else { - call->saved_receiving_stream_ready_ctx.bctlp = bctlp; - call->saved_receiving_stream_ready_ctx.success = success; + call->saved_receiving_stream_ready_bctlp = bctlp; gpr_mu_unlock(&bctl->call->mu); } } @@ -1091,13 +1097,11 @@ static void receiving_initial_metadata_ready(grpc_exec_ctx *exec_ctx, } call->has_initial_md_been_received = true; - if (call->saved_receiving_stream_ready_ctx.bctlp != NULL) { + if (call->saved_receiving_stream_ready_bctlp != NULL) { grpc_closure *saved_rsr_closure = grpc_closure_create( - receiving_stream_ready, call->saved_receiving_stream_ready_ctx.bctlp); - grpc_exec_ctx_enqueue( - exec_ctx, saved_rsr_closure, - call->saved_receiving_stream_ready_ctx.success && success, NULL); - call->saved_receiving_stream_ready_ctx.bctlp = NULL; + receiving_stream_ready, call->saved_receiving_stream_ready_bctlp); + call->saved_receiving_stream_ready_bctlp = NULL; + grpc_exec_ctx_enqueue(exec_ctx, saved_rsr_closure, success, NULL); } gpr_mu_unlock(&call->mu); @@ -1133,6 +1137,7 @@ static void finish_batch(grpc_exec_ctx *exec_ctx, void *bctlp, bool success) { &call->metadata_batch[1 /* is_receiving */][1 /* is_trailing */]; grpc_metadata_batch_filter(md, recv_trailing_filter, call); + call->received_final_op = true; if (call->have_alarm) { grpc_timer_cancel(exec_ctx, &call->alarm); } @@ -1377,11 +1382,11 @@ static grpc_call_error call_start_batch(grpc_exec_ctx *exec_ctx, error = GRPC_CALL_ERROR_NOT_ON_SERVER; goto done_with_error; } - if (call->received_final_op) { + if (call->requested_final_op) { error = GRPC_CALL_ERROR_TOO_MANY_OPERATIONS; goto done_with_error; } - call->received_final_op = 1; + call->requested_final_op = 1; call->buffered_metadata[1] = op->data.recv_status_on_client.trailing_metadata; call->final_op.client.status = op->data.recv_status_on_client.status; @@ -1404,11 +1409,11 @@ static grpc_call_error call_start_batch(grpc_exec_ctx *exec_ctx, error = GRPC_CALL_ERROR_NOT_ON_CLIENT; goto done_with_error; } - if (call->received_final_op) { + if (call->requested_final_op) { error = GRPC_CALL_ERROR_TOO_MANY_OPERATIONS; goto done_with_error; } - call->received_final_op = 1; + call->requested_final_op = 1; call->final_op.server.cancelled = op->data.recv_close_on_server.cancelled; bctl->recv_final_op = 1; @@ -1457,7 +1462,7 @@ done_with_error: call->receiving_message = 0; } if (bctl->recv_final_op) { - call->received_final_op = 0; + call->requested_final_op = 0; } gpr_mu_unlock(&call->mu); goto done; diff --git a/src/core/lib/surface/init.c b/src/core/lib/surface/init.c index ec75af6e06..03f379aba8 100644 --- a/src/core/lib/surface/init.c +++ b/src/core/lib/surface/init.c @@ -38,6 +38,7 @@ #include <grpc/grpc.h> #include <grpc/support/alloc.h> +#include <grpc/support/log.h> #include <grpc/support/time.h> #include "src/core/lib/channel/channel_stack.h" #include "src/core/lib/channel/compress_filter.h" @@ -45,6 +46,7 @@ #include "src/core/lib/channel/http_client_filter.h" #include "src/core/lib/channel/http_server_filter.h" #include "src/core/lib/debug/trace.h" +#include "src/core/lib/http/parser.h" #include "src/core/lib/iomgr/executor.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/profiling/timers.h" @@ -69,6 +71,7 @@ static gpr_mu g_init_mu; static int g_initializations; static void do_basic_init(void) { + gpr_log_verbosity_init(); gpr_mu_init(&g_init_mu); grpc_register_built_in_plugins(); g_initializations = 0; @@ -160,6 +163,7 @@ void grpc_init(void) { grpc_register_tracer("connectivity_state", &grpc_connectivity_state_trace); grpc_register_tracer("channel_stack_builder", &grpc_trace_channel_stack_builder); + grpc_register_tracer("http1", &grpc_http1_trace); grpc_security_pre_init(); grpc_iomgr_init(); grpc_executor_init(); diff --git a/src/core/lib/surface/lame_client.c b/src/core/lib/surface/lame_client.c index c1f6812c4e..80bd95df68 100644 --- a/src/core/lib/surface/lame_client.c +++ b/src/core/lib/surface/lame_client.c @@ -99,6 +99,9 @@ static void lame_start_transport_op(grpc_exec_ctx *exec_ctx, if (op->on_consumed != NULL) { op->on_consumed->cb(exec_ctx, op->on_consumed->cb_arg, 1); } + if (op->send_ping != NULL) { + op->send_ping->cb(exec_ctx, op->send_ping->cb_arg, 0); + } } static void init_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, diff --git a/src/core/lib/surface/validate_metadata.c b/src/core/lib/surface/validate_metadata.c index bf4126867f..84f0a083bc 100644 --- a/src/core/lib/surface/validate_metadata.c +++ b/src/core/lib/surface/validate_metadata.c @@ -40,7 +40,7 @@ static int conforms_to(const char *s, size_t len, const uint8_t *legal_bits) { const char *p = s; const char *e = s + len; for (; p != e; p++) { - int idx = *p; + int idx = (uint8_t)*p; int byte = idx / 8; int bit = idx % 8; if ((legal_bits[byte] & (1 << bit)) == 0) return 0; diff --git a/src/core/lib/transport/metadata.h b/src/core/lib/transport/metadata.h index e29e8df2c9..713d9e6782 100644 --- a/src/core/lib/transport/metadata.h +++ b/src/core/lib/transport/metadata.h @@ -120,6 +120,7 @@ void grpc_mdelem_set_user_data(grpc_mdelem *md, void (*destroy_func)(void *), void *user_data); /* Reference counting */ +//#define GRPC_METADATA_REFCOUNT_DEBUG #ifdef GRPC_METADATA_REFCOUNT_DEBUG #define GRPC_MDSTR_REF(s) grpc_mdstr_ref((s), __FILE__, __LINE__) #define GRPC_MDSTR_UNREF(s) grpc_mdstr_unref((s), __FILE__, __LINE__) diff --git a/src/core/lib/tsi/ssl_transport_security.c b/src/core/lib/tsi/ssl_transport_security.c index 045901cc72..e91c6316e7 100644 --- a/src/core/lib/tsi/ssl_transport_security.c +++ b/src/core/lib/tsi/ssl_transport_security.c @@ -718,6 +718,14 @@ static tsi_result build_alpn_protocol_name_list( return TSI_OK; } +// The verification callback is used for clients that don't really care about +// the server's certificate, but we need to pull it anyway, in case a higher +// layer wants to look at it. In this case the verification may fail, but +// we don't really care. +static int NullVerifyCallback(int preverify_ok, X509_STORE_CTX *ctx) { + return 1; +} + /* --- tsi_frame_protector methods implementation. ---*/ static tsi_result ssl_protector_protect(tsi_frame_protector *self, @@ -1390,6 +1398,26 @@ tsi_result tsi_create_ssl_server_handshaker_factory( const char *cipher_list, const unsigned char **alpn_protocols, const unsigned char *alpn_protocols_lengths, uint16_t num_alpn_protocols, tsi_ssl_handshaker_factory **factory) { + return tsi_create_ssl_server_handshaker_factory_ex( + pem_private_keys, pem_private_keys_sizes, pem_cert_chains, + pem_cert_chains_sizes, key_cert_pair_count, pem_client_root_certs, + pem_client_root_certs_size, + force_client_auth ? TSI_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY + : TSI_DONT_REQUEST_CLIENT_CERTIFICATE, + cipher_list, alpn_protocols, alpn_protocols_lengths, num_alpn_protocols, + factory); +} + +tsi_result tsi_create_ssl_server_handshaker_factory_ex( + const unsigned char **pem_private_keys, + const size_t *pem_private_keys_sizes, const unsigned char **pem_cert_chains, + const size_t *pem_cert_chains_sizes, size_t key_cert_pair_count, + const unsigned char *pem_client_root_certs, + size_t pem_client_root_certs_size, + tsi_client_certificate_request_type client_certificate_request, + const char *cipher_list, const unsigned char **alpn_protocols, + const unsigned char *alpn_protocols_lengths, uint16_t num_alpn_protocols, + tsi_ssl_handshaker_factory **factory) { tsi_ssl_server_handshaker_factory *impl = NULL; tsi_result result = TSI_OK; size_t i = 0; @@ -1445,7 +1473,6 @@ tsi_result tsi_create_ssl_server_handshaker_factory( if (result != TSI_OK) break; if (pem_client_root_certs != NULL) { - int flags = SSL_VERIFY_PEER; STACK_OF(X509_NAME) *root_names = NULL; result = ssl_ctx_load_verification_certs( impl->ssl_contexts[i], pem_client_root_certs, @@ -1455,8 +1482,29 @@ tsi_result tsi_create_ssl_server_handshaker_factory( break; } SSL_CTX_set_client_CA_list(impl->ssl_contexts[i], root_names); - if (force_client_auth) flags |= SSL_VERIFY_FAIL_IF_NO_PEER_CERT; - SSL_CTX_set_verify(impl->ssl_contexts[i], flags, NULL); + switch (client_certificate_request) { + case TSI_DONT_REQUEST_CLIENT_CERTIFICATE: + SSL_CTX_set_verify(impl->ssl_contexts[i], SSL_VERIFY_NONE, NULL); + break; + case TSI_REQUEST_CLIENT_CERTIFICATE_BUT_DONT_VERIFY: + SSL_CTX_set_verify(impl->ssl_contexts[i], SSL_VERIFY_PEER, + NullVerifyCallback); + break; + case TSI_REQUEST_CLIENT_CERTIFICATE_AND_VERIFY: + SSL_CTX_set_verify(impl->ssl_contexts[i], SSL_VERIFY_PEER, NULL); + break; + case TSI_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_BUT_DONT_VERIFY: + SSL_CTX_set_verify( + impl->ssl_contexts[i], + SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, + NullVerifyCallback); + break; + case TSI_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY: + SSL_CTX_set_verify( + impl->ssl_contexts[i], + SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, NULL); + break; + } /* TODO(jboeuf): Add revocation verification. */ } diff --git a/src/core/lib/tsi/ssl_transport_security.h b/src/core/lib/tsi/ssl_transport_security.h index 211c8f9656..7407246118 100644 --- a/src/core/lib/tsi/ssl_transport_security.h +++ b/src/core/lib/tsi/ssl_transport_security.h @@ -142,6 +142,23 @@ tsi_result tsi_create_ssl_server_handshaker_factory( const unsigned char *alpn_protocols_lengths, uint16_t num_alpn_protocols, tsi_ssl_handshaker_factory **factory); +/* Same as tsi_create_ssl_server_handshaker_factory method except uses + tsi_client_certificate_request_type to support more ways to handle client + certificate authentication. + - client_certificate_request, if set to non-zero will force the client to + authenticate with an SSL cert. Note that this option is ignored if + pem_client_root_certs is NULL or pem_client_roots_certs_size is 0 */ +tsi_result tsi_create_ssl_server_handshaker_factory_ex( + const unsigned char **pem_private_keys, + const size_t *pem_private_keys_sizes, const unsigned char **pem_cert_chains, + const size_t *pem_cert_chains_sizes, size_t key_cert_pair_count, + const unsigned char *pem_client_root_certs, + size_t pem_client_root_certs_size, + tsi_client_certificate_request_type client_certificate_request, + const char *cipher_suites, const unsigned char **alpn_protocols, + const unsigned char *alpn_protocols_lengths, uint16_t num_alpn_protocols, + tsi_ssl_handshaker_factory **factory); + /* Creates a handshaker. - self is the factory from which the handshaker will be created. - server_name_indication indicates the name of the server the client is diff --git a/src/core/lib/tsi/transport_security_interface.h b/src/core/lib/tsi/transport_security_interface.h index d81ec0963a..3e8c9d7ffe 100644 --- a/src/core/lib/tsi/transport_security_interface.h +++ b/src/core/lib/tsi/transport_security_interface.h @@ -59,6 +59,15 @@ typedef enum { TSI_OUT_OF_RESOURCES = 12 } tsi_result; +typedef enum { + // Default option + TSI_DONT_REQUEST_CLIENT_CERTIFICATE, + TSI_REQUEST_CLIENT_CERTIFICATE_BUT_DONT_VERIFY, + TSI_REQUEST_CLIENT_CERTIFICATE_AND_VERIFY, + TSI_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_BUT_DONT_VERIFY, + TSI_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY, +} tsi_client_certificate_request_type; + const char *tsi_result_to_string(tsi_result result); /* --- tsi tracing --- */ diff --git a/src/cpp/client/client_context.cc b/src/cpp/client/client_context.cc index c277d7ebe8..32c7794ade 100644 --- a/src/cpp/client/client_context.cc +++ b/src/cpp/client/client_context.cc @@ -42,7 +42,6 @@ #include <grpc/support/string_util.h> #include "src/core/lib/channel/compress_filter.h" -#include "src/cpp/common/create_auth_context.h" namespace grpc { @@ -116,13 +115,6 @@ void ClientContext::set_compression_algorithm( AddMetadata(GRPC_COMPRESS_REQUEST_ALGORITHM_KEY, algorithm_name); } -std::shared_ptr<const AuthContext> ClientContext::auth_context() const { - if (auth_context_.get() == nullptr) { - auth_context_ = CreateAuthContext(call_); - } - return auth_context_; -} - void ClientContext::TryCancel() { grpc::unique_lock<grpc::mutex> lock(mu_); if (call_) { diff --git a/src/cpp/server/secure_server_credentials.cc b/src/cpp/server/secure_server_credentials.cc index d472667a7e..33bdc2a1f4 100644 --- a/src/cpp/server/secure_server_credentials.cc +++ b/src/cpp/server/secure_server_credentials.cc @@ -130,10 +130,14 @@ std::shared_ptr<ServerCredentials> SslServerCredentials( key_cert_pair->cert_chain.c_str()}; pem_key_cert_pairs.push_back(p); } - grpc_server_credentials* c_creds = grpc_ssl_server_credentials_create( + grpc_server_credentials* c_creds = grpc_ssl_server_credentials_create_ex( options.pem_root_certs.empty() ? nullptr : options.pem_root_certs.c_str(), pem_key_cert_pairs.empty() ? nullptr : &pem_key_cert_pairs[0], - pem_key_cert_pairs.size(), options.force_client_auth, nullptr); + pem_key_cert_pairs.size(), + options.force_client_auth + ? GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY + : options.client_certificate_request, + nullptr); return std::shared_ptr<ServerCredentials>( new SecureServerCredentials(c_creds)); } diff --git a/src/cpp/server/server_context.cc b/src/cpp/server/server_context.cc index e05a7df28a..204fef1b09 100644 --- a/src/cpp/server/server_context.cc +++ b/src/cpp/server/server_context.cc @@ -44,7 +44,6 @@ #include "src/core/lib/channel/compress_filter.h" #include "src/core/lib/surface/call.h" -#include "src/cpp/common/create_auth_context.h" namespace grpc { @@ -214,18 +213,6 @@ void ServerContext::set_compression_algorithm( AddInitialMetadata(GRPC_COMPRESS_REQUEST_ALGORITHM_KEY, algorithm_name); } -void ServerContext::set_call(grpc_call* call) { - call_ = call; - auth_context_ = CreateAuthContext(call); -} - -std::shared_ptr<const AuthContext> ServerContext::auth_context() const { - if (auth_context_.get() == nullptr) { - auth_context_ = CreateAuthContext(call_); - } - return auth_context_; -} - grpc::string ServerContext::peer() const { grpc::string peer; if (call_) { diff --git a/src/csharp/Grpc.Core.Tests/CallOptionsTest.cs b/src/csharp/Grpc.Core.Tests/CallOptionsTest.cs index a3a613be74..99a2d47e6e 100644 --- a/src/csharp/Grpc.Core.Tests/CallOptionsTest.cs +++ b/src/csharp/Grpc.Core.Tests/CallOptionsTest.cs @@ -54,10 +54,20 @@ namespace Grpc.Core.Tests var deadline = DateTime.UtcNow; Assert.AreEqual(deadline, options.WithDeadline(deadline).Deadline.Value); - var token = new CancellationTokenSource().Token; - Assert.AreEqual(token, options.WithCancellationToken(token).CancellationToken); + var cancellationToken = new CancellationTokenSource().Token; + Assert.AreEqual(cancellationToken, options.WithCancellationToken(cancellationToken).CancellationToken); + + var writeOptions = new WriteOptions(); + Assert.AreSame(writeOptions, options.WithWriteOptions(writeOptions).WriteOptions); + + var propagationToken = new ContextPropagationToken(CallSafeHandle.NullInstance, DateTime.UtcNow, + CancellationToken.None, ContextPropagationOptions.Default); + Assert.AreSame(propagationToken, options.WithPropagationToken(propagationToken).PropagationToken); + + var credentials = new FakeCallCredentials(); + Assert.AreSame(credentials, options.WithCredentials(credentials).Credentials); - // Change original instance is unchanged. + // Check that the original instance is unchanged. Assert.IsNull(options.Headers); Assert.IsNull(options.Deadline); Assert.AreEqual(CancellationToken.None, options.CancellationToken); diff --git a/src/csharp/Grpc.Core/CallOptions.cs b/src/csharp/Grpc.Core/CallOptions.cs index caf8210d91..9ca88849ee 100644 --- a/src/csharp/Grpc.Core/CallOptions.cs +++ b/src/csharp/Grpc.Core/CallOptions.cs @@ -100,10 +100,7 @@ namespace Grpc.Core /// </summary> public WriteOptions WriteOptions { - get - { - return this.writeOptions; - } + get { return this.writeOptions; } } /// <summary> @@ -111,10 +108,7 @@ namespace Grpc.Core /// </summary> public ContextPropagationToken PropagationToken { - get - { - return this.propagationToken; - } + get { return this.propagationToken; } } /// <summary> @@ -122,10 +116,7 @@ namespace Grpc.Core /// </summary> public CallCredentials Credentials { - get - { - return this.credentials; - } + get { return this.credentials; } } /// <summary> @@ -165,6 +156,42 @@ namespace Grpc.Core } /// <summary> + /// Returns new instance of <see cref="CallOptions"/> with + /// <c>WriteOptions</c> set to the value provided. Values of all other fields are preserved. + /// </summary> + /// <param name="writeOptions">The write options.</param> + public CallOptions WithWriteOptions(WriteOptions writeOptions) + { + var newOptions = this; + newOptions.writeOptions = writeOptions; + return newOptions; + } + + /// <summary> + /// Returns new instance of <see cref="CallOptions"/> with + /// <c>PropagationToken</c> set to the value provided. Values of all other fields are preserved. + /// </summary> + /// <param name="propagationToken">The context propagation token.</param> + public CallOptions WithPropagationToken(ContextPropagationToken propagationToken) + { + var newOptions = this; + newOptions.propagationToken = propagationToken; + return newOptions; + } + + /// <summary> + /// Returns new instance of <see cref="CallOptions"/> with + /// <c>Credentials</c> set to the value provided. Values of all other fields are preserved. + /// </summary> + /// <param name="credentials">The call credentials.</param> + public CallOptions WithCredentials(CallCredentials credentials) + { + var newOptions = this; + newOptions.credentials = credentials; + return newOptions; + } + + /// <summary> /// Returns a new instance of <see cref="CallOptions"/> with /// all previously unset values set to their defaults and deadline and cancellation /// token propagated when appropriate. diff --git a/src/csharp/Grpc.IntegrationTesting.StressClient/.gitignore b/src/csharp/Grpc.IntegrationTesting.StressClient/.gitignore new file mode 100644 index 0000000000..a382af2294 --- /dev/null +++ b/src/csharp/Grpc.IntegrationTesting.StressClient/.gitignore @@ -0,0 +1,3 @@ +bin +obj + diff --git a/src/csharp/Grpc.IntegrationTesting.StressClient/Grpc.IntegrationTesting.StressClient.csproj b/src/csharp/Grpc.IntegrationTesting.StressClient/Grpc.IntegrationTesting.StressClient.csproj new file mode 100644 index 0000000000..d6eba74289 --- /dev/null +++ b/src/csharp/Grpc.IntegrationTesting.StressClient/Grpc.IntegrationTesting.StressClient.csproj @@ -0,0 +1,60 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProjectGuid>{ADEBA147-80AE-4710-82E9-5B7F93690266}</ProjectGuid> + <OutputType>Exe</OutputType> + <RootNamespace>Grpc.IntegrationTesting.StressClient</RootNamespace> + <AssemblyName>Grpc.IntegrationTesting.StressClient</AssemblyName> + <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug</OutputPath> + <DefineConstants>DEBUG;</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <PlatformTarget>AnyCPU</PlatformTarget> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release</OutputPath> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <PlatformTarget>AnyCPU</PlatformTarget> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseSigned|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\ReleaseSigned</OutputPath> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <SignAssembly>True</SignAssembly> + <AssemblyOriginatorKeyFile>..\keys\Grpc.snk</AssemblyOriginatorKeyFile> + </PropertyGroup> + <ItemGroup> + <Reference Include="System" /> + </ItemGroup> + <ItemGroup> + <Compile Include="..\Grpc.Core\Version.cs"> + <Link>Version.cs</Link> + </Compile> + <Compile Include="Program.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> + <ItemGroup> + <ProjectReference Include="..\Grpc.Core\Grpc.Core.csproj"> + <Project>{CCC4440E-49F7-4790-B0AF-FEABB0837AE7}</Project> + <Name>Grpc.Core</Name> + </ProjectReference> + <ProjectReference Include="..\Grpc.IntegrationTesting\Grpc.IntegrationTesting.csproj"> + <Project>{C61154BA-DD4A-4838-8420-0162A28925E0}</Project> + <Name>Grpc.IntegrationTesting</Name> + </ProjectReference> + </ItemGroup> +</Project>
\ No newline at end of file diff --git a/src/csharp/Grpc.IntegrationTesting.StressClient/Program.cs b/src/csharp/Grpc.IntegrationTesting.StressClient/Program.cs new file mode 100644 index 0000000000..dffdf22fa5 --- /dev/null +++ b/src/csharp/Grpc.IntegrationTesting.StressClient/Program.cs @@ -0,0 +1,45 @@ +#region Copyright notice and license + +// Copyright 2016, 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. + +#endregion + +using System; + +namespace Grpc.IntegrationTesting.StressClient +{ + class MainClass + { + public static void Main(string[] args) + { + StressTestClient.Run(args); + } + } +} diff --git a/src/csharp/Grpc.IntegrationTesting.StressClient/Properties/AssemblyInfo.cs b/src/csharp/Grpc.IntegrationTesting.StressClient/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..e845bbfb9e --- /dev/null +++ b/src/csharp/Grpc.IntegrationTesting.StressClient/Properties/AssemblyInfo.cs @@ -0,0 +1,11 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +[assembly: AssemblyTitle("Grpc.IntegrationTesting.StressClient")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("Google Inc. All rights reserved.")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] diff --git a/src/csharp/Grpc.IntegrationTesting/ClientRunners.cs b/src/csharp/Grpc.IntegrationTesting/ClientRunners.cs index f954ca5f34..b4572756f2 100644 --- a/src/csharp/Grpc.IntegrationTesting/ClientRunners.cs +++ b/src/csharp/Grpc.IntegrationTesting/ClientRunners.cs @@ -129,6 +129,7 @@ namespace Grpc.IntegrationTesting public ClientRunnerImpl(List<Channel> channels, ClientType clientType, RpcType rpcType, int outstandingRpcsPerChannel, LoadParams loadParams, PayloadConfig payloadConfig, HistogramParams histogramParams) { GrpcPreconditions.CheckArgument(outstandingRpcsPerChannel > 0, "outstandingRpcsPerChannel"); + GrpcPreconditions.CheckNotNull(histogramParams, "histogramParams"); this.channels = new List<Channel>(channels); this.clientType = clientType; this.rpcType = rpcType; diff --git a/src/csharp/Grpc.IntegrationTesting/Control.cs b/src/csharp/Grpc.IntegrationTesting/Control.cs index 291bc75397..3fa8d43f38 100644 --- a/src/csharp/Grpc.IntegrationTesting/Control.cs +++ b/src/csharp/Grpc.IntegrationTesting/Control.cs @@ -26,69 +26,84 @@ namespace Grpc.Testing { "CiRzcmMvcHJvdG8vZ3JwYy90ZXN0aW5nL2NvbnRyb2wucHJvdG8SDGdycGMu", "dGVzdGluZxolc3JjL3Byb3RvL2dycGMvdGVzdGluZy9wYXlsb2Fkcy5wcm90", "bxoic3JjL3Byb3RvL2dycGMvdGVzdGluZy9zdGF0cy5wcm90byIlCg1Qb2lz", - "c29uUGFyYW1zEhQKDG9mZmVyZWRfbG9hZBgBIAEoASJBCg1Vbmlmb3JtUGFy", - "YW1zEhcKD2ludGVyYXJyaXZhbF9sbxgBIAEoARIXCg9pbnRlcmFycml2YWxf", - "aGkYAiABKAEiKwoTRGV0ZXJtaW5pc3RpY1BhcmFtcxIUCgxvZmZlcmVkX2xv", - "YWQYASABKAEiOAoMUGFyZXRvUGFyYW1zEhkKEWludGVyYXJyaXZhbF9iYXNl", - "GAEgASgBEg0KBWFscGhhGAIgASgBIhIKEENsb3NlZExvb3BQYXJhbXMijgIK", - "CkxvYWRQYXJhbXMSNQoLY2xvc2VkX2xvb3AYASABKAsyHi5ncnBjLnRlc3Rp", - "bmcuQ2xvc2VkTG9vcFBhcmFtc0gAEi4KB3BvaXNzb24YAiABKAsyGy5ncnBj", - "LnRlc3RpbmcuUG9pc3NvblBhcmFtc0gAEi4KB3VuaWZvcm0YAyABKAsyGy5n", - "cnBjLnRlc3RpbmcuVW5pZm9ybVBhcmFtc0gAEjMKBmRldGVybRgEIAEoCzIh", - "LmdycGMudGVzdGluZy5EZXRlcm1pbmlzdGljUGFyYW1zSAASLAoGcGFyZXRv", - "GAUgASgLMhouZ3JwYy50ZXN0aW5nLlBhcmV0b1BhcmFtc0gAQgYKBGxvYWQi", - "QwoOU2VjdXJpdHlQYXJhbXMSEwoLdXNlX3Rlc3RfY2EYASABKAgSHAoUc2Vy", - "dmVyX2hvc3Rfb3ZlcnJpZGUYAiABKAki1gMKDENsaWVudENvbmZpZxIWCg5z", - "ZXJ2ZXJfdGFyZ2V0cxgBIAMoCRItCgtjbGllbnRfdHlwZRgCIAEoDjIYLmdy", - "cGMudGVzdGluZy5DbGllbnRUeXBlEjUKD3NlY3VyaXR5X3BhcmFtcxgDIAEo", - "CzIcLmdycGMudGVzdGluZy5TZWN1cml0eVBhcmFtcxIkChxvdXRzdGFuZGlu", - "Z19ycGNzX3Blcl9jaGFubmVsGAQgASgFEhcKD2NsaWVudF9jaGFubmVscxgF", - "IAEoBRIcChRhc3luY19jbGllbnRfdGhyZWFkcxgHIAEoBRInCghycGNfdHlw", - "ZRgIIAEoDjIVLmdycGMudGVzdGluZy5ScGNUeXBlEi0KC2xvYWRfcGFyYW1z", - "GAogASgLMhguZ3JwYy50ZXN0aW5nLkxvYWRQYXJhbXMSMwoOcGF5bG9hZF9j", - "b25maWcYCyABKAsyGy5ncnBjLnRlc3RpbmcuUGF5bG9hZENvbmZpZxI3ChBo", - "aXN0b2dyYW1fcGFyYW1zGAwgASgLMh0uZ3JwYy50ZXN0aW5nLkhpc3RvZ3Jh", - "bVBhcmFtcxIRCgljb3JlX2xpc3QYDSADKAUSEgoKY29yZV9saW1pdBgOIAEo", - "BSI4CgxDbGllbnRTdGF0dXMSKAoFc3RhdHMYASABKAsyGS5ncnBjLnRlc3Rp", - "bmcuQ2xpZW50U3RhdHMiFQoETWFyaxINCgVyZXNldBgBIAEoCCJoCgpDbGll", - "bnRBcmdzEisKBXNldHVwGAEgASgLMhouZ3JwYy50ZXN0aW5nLkNsaWVudENv", - "bmZpZ0gAEiIKBG1hcmsYAiABKAsyEi5ncnBjLnRlc3RpbmcuTWFya0gAQgkK", - "B2FyZ3R5cGUi/AEKDFNlcnZlckNvbmZpZxItCgtzZXJ2ZXJfdHlwZRgBIAEo", - "DjIYLmdycGMudGVzdGluZy5TZXJ2ZXJUeXBlEjUKD3NlY3VyaXR5X3BhcmFt", - "cxgCIAEoCzIcLmdycGMudGVzdGluZy5TZWN1cml0eVBhcmFtcxIMCgRwb3J0", - "GAQgASgFEhwKFGFzeW5jX3NlcnZlcl90aHJlYWRzGAcgASgFEhIKCmNvcmVf", - "bGltaXQYCCABKAUSMwoOcGF5bG9hZF9jb25maWcYCSABKAsyGy5ncnBjLnRl", - "c3RpbmcuUGF5bG9hZENvbmZpZxIRCgljb3JlX2xpc3QYCiADKAUiaAoKU2Vy", - "dmVyQXJncxIrCgVzZXR1cBgBIAEoCzIaLmdycGMudGVzdGluZy5TZXJ2ZXJD", - "b25maWdIABIiCgRtYXJrGAIgASgLMhIuZ3JwYy50ZXN0aW5nLk1hcmtIAEIJ", - "Cgdhcmd0eXBlIlUKDFNlcnZlclN0YXR1cxIoCgVzdGF0cxgBIAEoCzIZLmdy", - "cGMudGVzdGluZy5TZXJ2ZXJTdGF0cxIMCgRwb3J0GAIgASgFEg0KBWNvcmVz", - "GAMgASgFIg0KC0NvcmVSZXF1ZXN0Ih0KDENvcmVSZXNwb25zZRINCgVjb3Jl", - "cxgBIAEoBSIGCgRWb2lkKi8KCkNsaWVudFR5cGUSDwoLU1lOQ19DTElFTlQQ", - "ABIQCgxBU1lOQ19DTElFTlQQASpJCgpTZXJ2ZXJUeXBlEg8KC1NZTkNfU0VS", - "VkVSEAASEAoMQVNZTkNfU0VSVkVSEAESGAoUQVNZTkNfR0VORVJJQ19TRVJW", - "RVIQAiojCgdScGNUeXBlEgkKBVVOQVJZEAASDQoJU1RSRUFNSU5HEAFiBnBy", - "b3RvMw==")); + "c29uUGFyYW1zEhQKDG9mZmVyZWRfbG9hZBgBIAEoASISChBDbG9zZWRMb29w", + "UGFyYW1zInsKCkxvYWRQYXJhbXMSNQoLY2xvc2VkX2xvb3AYASABKAsyHi5n", + "cnBjLnRlc3RpbmcuQ2xvc2VkTG9vcFBhcmFtc0gAEi4KB3BvaXNzb24YAiAB", + "KAsyGy5ncnBjLnRlc3RpbmcuUG9pc3NvblBhcmFtc0gAQgYKBGxvYWQiQwoO", + "U2VjdXJpdHlQYXJhbXMSEwoLdXNlX3Rlc3RfY2EYASABKAgSHAoUc2VydmVy", + "X2hvc3Rfb3ZlcnJpZGUYAiABKAki8AMKDENsaWVudENvbmZpZxIWCg5zZXJ2", + "ZXJfdGFyZ2V0cxgBIAMoCRItCgtjbGllbnRfdHlwZRgCIAEoDjIYLmdycGMu", + "dGVzdGluZy5DbGllbnRUeXBlEjUKD3NlY3VyaXR5X3BhcmFtcxgDIAEoCzIc", + "LmdycGMudGVzdGluZy5TZWN1cml0eVBhcmFtcxIkChxvdXRzdGFuZGluZ19y", + "cGNzX3Blcl9jaGFubmVsGAQgASgFEhcKD2NsaWVudF9jaGFubmVscxgFIAEo", + "BRIcChRhc3luY19jbGllbnRfdGhyZWFkcxgHIAEoBRInCghycGNfdHlwZRgI", + "IAEoDjIVLmdycGMudGVzdGluZy5ScGNUeXBlEi0KC2xvYWRfcGFyYW1zGAog", + "ASgLMhguZ3JwYy50ZXN0aW5nLkxvYWRQYXJhbXMSMwoOcGF5bG9hZF9jb25m", + "aWcYCyABKAsyGy5ncnBjLnRlc3RpbmcuUGF5bG9hZENvbmZpZxI3ChBoaXN0", + "b2dyYW1fcGFyYW1zGAwgASgLMh0uZ3JwYy50ZXN0aW5nLkhpc3RvZ3JhbVBh", + "cmFtcxIRCgljb3JlX2xpc3QYDSADKAUSEgoKY29yZV9saW1pdBgOIAEoBRIY", + "ChBvdGhlcl9jbGllbnRfYXBpGA8gASgJIjgKDENsaWVudFN0YXR1cxIoCgVz", + "dGF0cxgBIAEoCzIZLmdycGMudGVzdGluZy5DbGllbnRTdGF0cyIVCgRNYXJr", + "Eg0KBXJlc2V0GAEgASgIImgKCkNsaWVudEFyZ3MSKwoFc2V0dXAYASABKAsy", + "Gi5ncnBjLnRlc3RpbmcuQ2xpZW50Q29uZmlnSAASIgoEbWFyaxgCIAEoCzIS", + "LmdycGMudGVzdGluZy5NYXJrSABCCQoHYXJndHlwZSKWAgoMU2VydmVyQ29u", + "ZmlnEi0KC3NlcnZlcl90eXBlGAEgASgOMhguZ3JwYy50ZXN0aW5nLlNlcnZl", + "clR5cGUSNQoPc2VjdXJpdHlfcGFyYW1zGAIgASgLMhwuZ3JwYy50ZXN0aW5n", + "LlNlY3VyaXR5UGFyYW1zEgwKBHBvcnQYBCABKAUSHAoUYXN5bmNfc2VydmVy", + "X3RocmVhZHMYByABKAUSEgoKY29yZV9saW1pdBgIIAEoBRIzCg5wYXlsb2Fk", + "X2NvbmZpZxgJIAEoCzIbLmdycGMudGVzdGluZy5QYXlsb2FkQ29uZmlnEhEK", + "CWNvcmVfbGlzdBgKIAMoBRIYChBvdGhlcl9zZXJ2ZXJfYXBpGAsgASgJImgK", + "ClNlcnZlckFyZ3MSKwoFc2V0dXAYASABKAsyGi5ncnBjLnRlc3RpbmcuU2Vy", + "dmVyQ29uZmlnSAASIgoEbWFyaxgCIAEoCzISLmdycGMudGVzdGluZy5NYXJr", + "SABCCQoHYXJndHlwZSJVCgxTZXJ2ZXJTdGF0dXMSKAoFc3RhdHMYASABKAsy", + "GS5ncnBjLnRlc3RpbmcuU2VydmVyU3RhdHMSDAoEcG9ydBgCIAEoBRINCgVj", + "b3JlcxgDIAEoBSINCgtDb3JlUmVxdWVzdCIdCgxDb3JlUmVzcG9uc2USDQoF", + "Y29yZXMYASABKAUiBgoEVm9pZCL9AQoIU2NlbmFyaW8SDAoEbmFtZRgBIAEo", + "CRIxCg1jbGllbnRfY29uZmlnGAIgASgLMhouZ3JwYy50ZXN0aW5nLkNsaWVu", + "dENvbmZpZxITCgtudW1fY2xpZW50cxgDIAEoBRIxCg1zZXJ2ZXJfY29uZmln", + "GAQgASgLMhouZ3JwYy50ZXN0aW5nLlNlcnZlckNvbmZpZxITCgtudW1fc2Vy", + "dmVycxgFIAEoBRIWCg53YXJtdXBfc2Vjb25kcxgGIAEoBRIZChFiZW5jaG1h", + "cmtfc2Vjb25kcxgHIAEoBRIgChhzcGF3bl9sb2NhbF93b3JrZXJfY291bnQY", + "CCABKAUiNgoJU2NlbmFyaW9zEikKCXNjZW5hcmlvcxgBIAMoCzIWLmdycGMu", + "dGVzdGluZy5TY2VuYXJpbyKSAgoVU2NlbmFyaW9SZXN1bHRTdW1tYXJ5EgsK", + "A3FwcxgBIAEoARIbChNxcHNfcGVyX3NlcnZlcl9jb3JlGAIgASgBEhoKEnNl", + "cnZlcl9zeXN0ZW1fdGltZRgDIAEoARIYChBzZXJ2ZXJfdXNlcl90aW1lGAQg", + "ASgBEhoKEmNsaWVudF9zeXN0ZW1fdGltZRgFIAEoARIYChBjbGllbnRfdXNl", + "cl90aW1lGAYgASgBEhIKCmxhdGVuY3lfNTAYByABKAESEgoKbGF0ZW5jeV85", + "MBgIIAEoARISCgpsYXRlbmN5Xzk1GAkgASgBEhIKCmxhdGVuY3lfOTkYCiAB", + "KAESEwoLbGF0ZW5jeV85OTkYCyABKAEimAIKDlNjZW5hcmlvUmVzdWx0EigK", + "CHNjZW5hcmlvGAEgASgLMhYuZ3JwYy50ZXN0aW5nLlNjZW5hcmlvEi4KCWxh", + "dGVuY2llcxgCIAEoCzIbLmdycGMudGVzdGluZy5IaXN0b2dyYW1EYXRhEi8K", + "DGNsaWVudF9zdGF0cxgDIAMoCzIZLmdycGMudGVzdGluZy5DbGllbnRTdGF0", + "cxIvCgxzZXJ2ZXJfc3RhdHMYBCADKAsyGS5ncnBjLnRlc3RpbmcuU2VydmVy", + "U3RhdHMSFAoMc2VydmVyX2NvcmVzGAUgAygFEjQKB3N1bW1hcnkYBiABKAsy", + "Iy5ncnBjLnRlc3RpbmcuU2NlbmFyaW9SZXN1bHRTdW1tYXJ5KkEKCkNsaWVu", + "dFR5cGUSDwoLU1lOQ19DTElFTlQQABIQCgxBU1lOQ19DTElFTlQQARIQCgxP", + "VEhFUl9DTElFTlQQAipbCgpTZXJ2ZXJUeXBlEg8KC1NZTkNfU0VSVkVSEAAS", + "EAoMQVNZTkNfU0VSVkVSEAESGAoUQVNZTkNfR0VORVJJQ19TRVJWRVIQAhIQ", + "CgxPVEhFUl9TRVJWRVIQAyojCgdScGNUeXBlEgkKBVVOQVJZEAASDQoJU1RS", + "RUFNSU5HEAFiBnByb3RvMw==")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { global::Grpc.Testing.PayloadsReflection.Descriptor, global::Grpc.Testing.StatsReflection.Descriptor, }, new pbr::GeneratedCodeInfo(new[] {typeof(global::Grpc.Testing.ClientType), typeof(global::Grpc.Testing.ServerType), typeof(global::Grpc.Testing.RpcType), }, new pbr::GeneratedCodeInfo[] { new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.PoissonParams), global::Grpc.Testing.PoissonParams.Parser, new[]{ "OfferedLoad" }, null, null, null), - new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.UniformParams), global::Grpc.Testing.UniformParams.Parser, new[]{ "InterarrivalLo", "InterarrivalHi" }, null, null, null), - new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.DeterministicParams), global::Grpc.Testing.DeterministicParams.Parser, new[]{ "OfferedLoad" }, null, null, null), - new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.ParetoParams), global::Grpc.Testing.ParetoParams.Parser, new[]{ "InterarrivalBase", "Alpha" }, null, null, null), new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.ClosedLoopParams), global::Grpc.Testing.ClosedLoopParams.Parser, null, null, null, null), - new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.LoadParams), global::Grpc.Testing.LoadParams.Parser, new[]{ "ClosedLoop", "Poisson", "Uniform", "Determ", "Pareto" }, new[]{ "Load" }, null, null), + new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.LoadParams), global::Grpc.Testing.LoadParams.Parser, new[]{ "ClosedLoop", "Poisson" }, new[]{ "Load" }, null, null), new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.SecurityParams), global::Grpc.Testing.SecurityParams.Parser, new[]{ "UseTestCa", "ServerHostOverride" }, null, null, null), - new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.ClientConfig), global::Grpc.Testing.ClientConfig.Parser, new[]{ "ServerTargets", "ClientType", "SecurityParams", "OutstandingRpcsPerChannel", "ClientChannels", "AsyncClientThreads", "RpcType", "LoadParams", "PayloadConfig", "HistogramParams", "CoreList", "CoreLimit" }, null, null, null), + new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.ClientConfig), global::Grpc.Testing.ClientConfig.Parser, new[]{ "ServerTargets", "ClientType", "SecurityParams", "OutstandingRpcsPerChannel", "ClientChannels", "AsyncClientThreads", "RpcType", "LoadParams", "PayloadConfig", "HistogramParams", "CoreList", "CoreLimit", "OtherClientApi" }, null, null, null), new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.ClientStatus), global::Grpc.Testing.ClientStatus.Parser, new[]{ "Stats" }, null, null, null), new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.Mark), global::Grpc.Testing.Mark.Parser, new[]{ "Reset" }, null, null, null), new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.ClientArgs), global::Grpc.Testing.ClientArgs.Parser, new[]{ "Setup", "Mark" }, new[]{ "Argtype" }, null, null), - new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.ServerConfig), global::Grpc.Testing.ServerConfig.Parser, new[]{ "ServerType", "SecurityParams", "Port", "AsyncServerThreads", "CoreLimit", "PayloadConfig", "CoreList" }, null, null, null), + new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.ServerConfig), global::Grpc.Testing.ServerConfig.Parser, new[]{ "ServerType", "SecurityParams", "Port", "AsyncServerThreads", "CoreLimit", "PayloadConfig", "CoreList", "OtherServerApi" }, null, null, null), new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.ServerArgs), global::Grpc.Testing.ServerArgs.Parser, new[]{ "Setup", "Mark" }, new[]{ "Argtype" }, null, null), new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.ServerStatus), global::Grpc.Testing.ServerStatus.Parser, new[]{ "Stats", "Port", "Cores" }, null, null, null), new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.CoreRequest), global::Grpc.Testing.CoreRequest.Parser, null, null, null, null), new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.CoreResponse), global::Grpc.Testing.CoreResponse.Parser, new[]{ "Cores" }, null, null, null), - new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.Void), global::Grpc.Testing.Void.Parser, null, null, null, null) + new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.Void), global::Grpc.Testing.Void.Parser, null, null, null, null), + new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.Scenario), global::Grpc.Testing.Scenario.Parser, new[]{ "Name", "ClientConfig", "NumClients", "ServerConfig", "NumServers", "WarmupSeconds", "BenchmarkSeconds", "SpawnLocalWorkerCount" }, null, null, null), + new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.Scenarios), global::Grpc.Testing.Scenarios.Parser, new[]{ "Scenarios_" }, null, null, null), + new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.ScenarioResultSummary), global::Grpc.Testing.ScenarioResultSummary.Parser, new[]{ "Qps", "QpsPerServerCore", "ServerSystemTime", "ServerUserTime", "ClientSystemTime", "ClientUserTime", "Latency50", "Latency90", "Latency95", "Latency99", "Latency999" }, null, null, null), + new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.ScenarioResult), global::Grpc.Testing.ScenarioResult.Parser, new[]{ "Scenario", "Latencies", "ClientStats", "ServerStats", "ServerCores", "Summary" }, null, null, null) })); } #endregion @@ -96,14 +111,26 @@ namespace Grpc.Testing { } #region Enums public enum ClientType { + /// <summary> + /// Many languages support a basic distinction between using + /// sync or async client, and this allows the specification + /// </summary> SYNC_CLIENT = 0, ASYNC_CLIENT = 1, + /// <summary> + /// used for some language-specific variants + /// </summary> + OTHER_CLIENT = 2, } public enum ServerType { SYNC_SERVER = 0, ASYNC_SERVER = 1, ASYNC_GENERIC_SERVER = 2, + /// <summary> + /// used for some language-specific variants + /// </summary> + OTHER_SERVER = 3, } public enum RpcType { @@ -224,369 +251,6 @@ namespace Grpc.Testing { } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class UniformParams : pb::IMessage<UniformParams> { - private static readonly pb::MessageParser<UniformParams> _parser = new pb::MessageParser<UniformParams>(() => new UniformParams()); - public static pb::MessageParser<UniformParams> Parser { get { return _parser; } } - - public static pbr::MessageDescriptor Descriptor { - get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[1]; } - } - - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - public UniformParams() { - OnConstruction(); - } - - partial void OnConstruction(); - - public UniformParams(UniformParams other) : this() { - interarrivalLo_ = other.interarrivalLo_; - interarrivalHi_ = other.interarrivalHi_; - } - - public UniformParams Clone() { - return new UniformParams(this); - } - - /// <summary>Field number for the "interarrival_lo" field.</summary> - public const int InterarrivalLoFieldNumber = 1; - private double interarrivalLo_; - public double InterarrivalLo { - get { return interarrivalLo_; } - set { - interarrivalLo_ = value; - } - } - - /// <summary>Field number for the "interarrival_hi" field.</summary> - public const int InterarrivalHiFieldNumber = 2; - private double interarrivalHi_; - public double InterarrivalHi { - get { return interarrivalHi_; } - set { - interarrivalHi_ = value; - } - } - - public override bool Equals(object other) { - return Equals(other as UniformParams); - } - - public bool Equals(UniformParams other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (InterarrivalLo != other.InterarrivalLo) return false; - if (InterarrivalHi != other.InterarrivalHi) return false; - return true; - } - - public override int GetHashCode() { - int hash = 1; - if (InterarrivalLo != 0D) hash ^= InterarrivalLo.GetHashCode(); - if (InterarrivalHi != 0D) hash ^= InterarrivalHi.GetHashCode(); - return hash; - } - - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - public void WriteTo(pb::CodedOutputStream output) { - if (InterarrivalLo != 0D) { - output.WriteRawTag(9); - output.WriteDouble(InterarrivalLo); - } - if (InterarrivalHi != 0D) { - output.WriteRawTag(17); - output.WriteDouble(InterarrivalHi); - } - } - - public int CalculateSize() { - int size = 0; - if (InterarrivalLo != 0D) { - size += 1 + 8; - } - if (InterarrivalHi != 0D) { - size += 1 + 8; - } - return size; - } - - public void MergeFrom(UniformParams other) { - if (other == null) { - return; - } - if (other.InterarrivalLo != 0D) { - InterarrivalLo = other.InterarrivalLo; - } - if (other.InterarrivalHi != 0D) { - InterarrivalHi = other.InterarrivalHi; - } - } - - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - input.SkipLastField(); - break; - case 9: { - InterarrivalLo = input.ReadDouble(); - break; - } - case 17: { - InterarrivalHi = input.ReadDouble(); - break; - } - } - } - } - - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class DeterministicParams : pb::IMessage<DeterministicParams> { - private static readonly pb::MessageParser<DeterministicParams> _parser = new pb::MessageParser<DeterministicParams>(() => new DeterministicParams()); - public static pb::MessageParser<DeterministicParams> Parser { get { return _parser; } } - - public static pbr::MessageDescriptor Descriptor { - get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[2]; } - } - - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - public DeterministicParams() { - OnConstruction(); - } - - partial void OnConstruction(); - - public DeterministicParams(DeterministicParams other) : this() { - offeredLoad_ = other.offeredLoad_; - } - - public DeterministicParams Clone() { - return new DeterministicParams(this); - } - - /// <summary>Field number for the "offered_load" field.</summary> - public const int OfferedLoadFieldNumber = 1; - private double offeredLoad_; - public double OfferedLoad { - get { return offeredLoad_; } - set { - offeredLoad_ = value; - } - } - - public override bool Equals(object other) { - return Equals(other as DeterministicParams); - } - - public bool Equals(DeterministicParams other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (OfferedLoad != other.OfferedLoad) return false; - return true; - } - - public override int GetHashCode() { - int hash = 1; - if (OfferedLoad != 0D) hash ^= OfferedLoad.GetHashCode(); - return hash; - } - - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - public void WriteTo(pb::CodedOutputStream output) { - if (OfferedLoad != 0D) { - output.WriteRawTag(9); - output.WriteDouble(OfferedLoad); - } - } - - public int CalculateSize() { - int size = 0; - if (OfferedLoad != 0D) { - size += 1 + 8; - } - return size; - } - - public void MergeFrom(DeterministicParams other) { - if (other == null) { - return; - } - if (other.OfferedLoad != 0D) { - OfferedLoad = other.OfferedLoad; - } - } - - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - input.SkipLastField(); - break; - case 9: { - OfferedLoad = input.ReadDouble(); - break; - } - } - } - } - - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - public sealed partial class ParetoParams : pb::IMessage<ParetoParams> { - private static readonly pb::MessageParser<ParetoParams> _parser = new pb::MessageParser<ParetoParams>(() => new ParetoParams()); - public static pb::MessageParser<ParetoParams> Parser { get { return _parser; } } - - public static pbr::MessageDescriptor Descriptor { - get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[3]; } - } - - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - public ParetoParams() { - OnConstruction(); - } - - partial void OnConstruction(); - - public ParetoParams(ParetoParams other) : this() { - interarrivalBase_ = other.interarrivalBase_; - alpha_ = other.alpha_; - } - - public ParetoParams Clone() { - return new ParetoParams(this); - } - - /// <summary>Field number for the "interarrival_base" field.</summary> - public const int InterarrivalBaseFieldNumber = 1; - private double interarrivalBase_; - public double InterarrivalBase { - get { return interarrivalBase_; } - set { - interarrivalBase_ = value; - } - } - - /// <summary>Field number for the "alpha" field.</summary> - public const int AlphaFieldNumber = 2; - private double alpha_; - public double Alpha { - get { return alpha_; } - set { - alpha_ = value; - } - } - - public override bool Equals(object other) { - return Equals(other as ParetoParams); - } - - public bool Equals(ParetoParams other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (InterarrivalBase != other.InterarrivalBase) return false; - if (Alpha != other.Alpha) return false; - return true; - } - - public override int GetHashCode() { - int hash = 1; - if (InterarrivalBase != 0D) hash ^= InterarrivalBase.GetHashCode(); - if (Alpha != 0D) hash ^= Alpha.GetHashCode(); - return hash; - } - - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - public void WriteTo(pb::CodedOutputStream output) { - if (InterarrivalBase != 0D) { - output.WriteRawTag(9); - output.WriteDouble(InterarrivalBase); - } - if (Alpha != 0D) { - output.WriteRawTag(17); - output.WriteDouble(Alpha); - } - } - - public int CalculateSize() { - int size = 0; - if (InterarrivalBase != 0D) { - size += 1 + 8; - } - if (Alpha != 0D) { - size += 1 + 8; - } - return size; - } - - public void MergeFrom(ParetoParams other) { - if (other == null) { - return; - } - if (other.InterarrivalBase != 0D) { - InterarrivalBase = other.InterarrivalBase; - } - if (other.Alpha != 0D) { - Alpha = other.Alpha; - } - } - - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - input.SkipLastField(); - break; - case 9: { - InterarrivalBase = input.ReadDouble(); - break; - } - case 17: { - Alpha = input.ReadDouble(); - break; - } - } - } - } - - } - /// <summary> /// Once an RPC finishes, immediately start a new one. /// No configuration parameters needed. @@ -597,7 +261,7 @@ namespace Grpc.Testing { public static pb::MessageParser<ClosedLoopParams> Parser { get { return _parser; } } public static pbr::MessageDescriptor Descriptor { - get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[4]; } + get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[1]; } } pbr::MessageDescriptor pb::IMessage.Descriptor { @@ -673,7 +337,7 @@ namespace Grpc.Testing { public static pb::MessageParser<LoadParams> Parser { get { return _parser; } } public static pbr::MessageDescriptor Descriptor { - get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[5]; } + get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[2]; } } pbr::MessageDescriptor pb::IMessage.Descriptor { @@ -694,15 +358,6 @@ namespace Grpc.Testing { case LoadOneofCase.Poisson: Poisson = other.Poisson.Clone(); break; - case LoadOneofCase.Uniform: - Uniform = other.Uniform.Clone(); - break; - case LoadOneofCase.Determ: - Determ = other.Determ.Clone(); - break; - case LoadOneofCase.Pareto: - Pareto = other.Pareto.Clone(); - break; } } @@ -731,45 +386,12 @@ namespace Grpc.Testing { } } - /// <summary>Field number for the "uniform" field.</summary> - public const int UniformFieldNumber = 3; - public global::Grpc.Testing.UniformParams Uniform { - get { return loadCase_ == LoadOneofCase.Uniform ? (global::Grpc.Testing.UniformParams) load_ : null; } - set { - load_ = value; - loadCase_ = value == null ? LoadOneofCase.None : LoadOneofCase.Uniform; - } - } - - /// <summary>Field number for the "determ" field.</summary> - public const int DetermFieldNumber = 4; - public global::Grpc.Testing.DeterministicParams Determ { - get { return loadCase_ == LoadOneofCase.Determ ? (global::Grpc.Testing.DeterministicParams) load_ : null; } - set { - load_ = value; - loadCase_ = value == null ? LoadOneofCase.None : LoadOneofCase.Determ; - } - } - - /// <summary>Field number for the "pareto" field.</summary> - public const int ParetoFieldNumber = 5; - public global::Grpc.Testing.ParetoParams Pareto { - get { return loadCase_ == LoadOneofCase.Pareto ? (global::Grpc.Testing.ParetoParams) load_ : null; } - set { - load_ = value; - loadCase_ = value == null ? LoadOneofCase.None : LoadOneofCase.Pareto; - } - } - private object load_; /// <summary>Enum of possible cases for the "load" oneof.</summary> public enum LoadOneofCase { None = 0, ClosedLoop = 1, Poisson = 2, - Uniform = 3, - Determ = 4, - Pareto = 5, } private LoadOneofCase loadCase_ = LoadOneofCase.None; public LoadOneofCase LoadCase { @@ -794,9 +416,6 @@ namespace Grpc.Testing { } if (!object.Equals(ClosedLoop, other.ClosedLoop)) return false; if (!object.Equals(Poisson, other.Poisson)) return false; - if (!object.Equals(Uniform, other.Uniform)) return false; - if (!object.Equals(Determ, other.Determ)) return false; - if (!object.Equals(Pareto, other.Pareto)) return false; if (LoadCase != other.LoadCase) return false; return true; } @@ -805,9 +424,6 @@ namespace Grpc.Testing { int hash = 1; if (loadCase_ == LoadOneofCase.ClosedLoop) hash ^= ClosedLoop.GetHashCode(); if (loadCase_ == LoadOneofCase.Poisson) hash ^= Poisson.GetHashCode(); - if (loadCase_ == LoadOneofCase.Uniform) hash ^= Uniform.GetHashCode(); - if (loadCase_ == LoadOneofCase.Determ) hash ^= Determ.GetHashCode(); - if (loadCase_ == LoadOneofCase.Pareto) hash ^= Pareto.GetHashCode(); hash ^= (int) loadCase_; return hash; } @@ -825,18 +441,6 @@ namespace Grpc.Testing { output.WriteRawTag(18); output.WriteMessage(Poisson); } - if (loadCase_ == LoadOneofCase.Uniform) { - output.WriteRawTag(26); - output.WriteMessage(Uniform); - } - if (loadCase_ == LoadOneofCase.Determ) { - output.WriteRawTag(34); - output.WriteMessage(Determ); - } - if (loadCase_ == LoadOneofCase.Pareto) { - output.WriteRawTag(42); - output.WriteMessage(Pareto); - } } public int CalculateSize() { @@ -847,15 +451,6 @@ namespace Grpc.Testing { if (loadCase_ == LoadOneofCase.Poisson) { size += 1 + pb::CodedOutputStream.ComputeMessageSize(Poisson); } - if (loadCase_ == LoadOneofCase.Uniform) { - size += 1 + pb::CodedOutputStream.ComputeMessageSize(Uniform); - } - if (loadCase_ == LoadOneofCase.Determ) { - size += 1 + pb::CodedOutputStream.ComputeMessageSize(Determ); - } - if (loadCase_ == LoadOneofCase.Pareto) { - size += 1 + pb::CodedOutputStream.ComputeMessageSize(Pareto); - } return size; } @@ -870,15 +465,6 @@ namespace Grpc.Testing { case LoadOneofCase.Poisson: Poisson = other.Poisson; break; - case LoadOneofCase.Uniform: - Uniform = other.Uniform; - break; - case LoadOneofCase.Determ: - Determ = other.Determ; - break; - case LoadOneofCase.Pareto: - Pareto = other.Pareto; - break; } } @@ -908,33 +494,6 @@ namespace Grpc.Testing { Poisson = subBuilder; break; } - case 26: { - global::Grpc.Testing.UniformParams subBuilder = new global::Grpc.Testing.UniformParams(); - if (loadCase_ == LoadOneofCase.Uniform) { - subBuilder.MergeFrom(Uniform); - } - input.ReadMessage(subBuilder); - Uniform = subBuilder; - break; - } - case 34: { - global::Grpc.Testing.DeterministicParams subBuilder = new global::Grpc.Testing.DeterministicParams(); - if (loadCase_ == LoadOneofCase.Determ) { - subBuilder.MergeFrom(Determ); - } - input.ReadMessage(subBuilder); - Determ = subBuilder; - break; - } - case 42: { - global::Grpc.Testing.ParetoParams subBuilder = new global::Grpc.Testing.ParetoParams(); - if (loadCase_ == LoadOneofCase.Pareto) { - subBuilder.MergeFrom(Pareto); - } - input.ReadMessage(subBuilder); - Pareto = subBuilder; - break; - } } } } @@ -950,7 +509,7 @@ namespace Grpc.Testing { public static pb::MessageParser<SecurityParams> Parser { get { return _parser; } } public static pbr::MessageDescriptor Descriptor { - get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[6]; } + get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[3]; } } pbr::MessageDescriptor pb::IMessage.Descriptor { @@ -1080,7 +639,7 @@ namespace Grpc.Testing { public static pb::MessageParser<ClientConfig> Parser { get { return _parser; } } public static pbr::MessageDescriptor Descriptor { - get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[7]; } + get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[4]; } } pbr::MessageDescriptor pb::IMessage.Descriptor { @@ -1106,6 +665,7 @@ namespace Grpc.Testing { HistogramParams = other.histogramParams_ != null ? other.HistogramParams.Clone() : null; coreList_ = other.coreList_.Clone(); coreLimit_ = other.coreLimit_; + otherClientApi_ = other.otherClientApi_; } public ClientConfig Clone() { @@ -1250,6 +810,19 @@ namespace Grpc.Testing { } } + /// <summary>Field number for the "other_client_api" field.</summary> + public const int OtherClientApiFieldNumber = 15; + private string otherClientApi_ = ""; + /// <summary> + /// If we use an OTHER_CLIENT client_type, this string gives more detail + /// </summary> + public string OtherClientApi { + get { return otherClientApi_; } + set { + otherClientApi_ = pb::Preconditions.CheckNotNull(value, "value"); + } + } + public override bool Equals(object other) { return Equals(other as ClientConfig); } @@ -1273,6 +846,7 @@ namespace Grpc.Testing { if (!object.Equals(HistogramParams, other.HistogramParams)) return false; if(!coreList_.Equals(other.coreList_)) return false; if (CoreLimit != other.CoreLimit) return false; + if (OtherClientApi != other.OtherClientApi) return false; return true; } @@ -1290,6 +864,7 @@ namespace Grpc.Testing { if (histogramParams_ != null) hash ^= HistogramParams.GetHashCode(); hash ^= coreList_.GetHashCode(); if (CoreLimit != 0) hash ^= CoreLimit.GetHashCode(); + if (OtherClientApi.Length != 0) hash ^= OtherClientApi.GetHashCode(); return hash; } @@ -1340,6 +915,10 @@ namespace Grpc.Testing { output.WriteRawTag(112); output.WriteInt32(CoreLimit); } + if (OtherClientApi.Length != 0) { + output.WriteRawTag(122); + output.WriteString(OtherClientApi); + } } public int CalculateSize() { @@ -1376,6 +955,9 @@ namespace Grpc.Testing { if (CoreLimit != 0) { size += 1 + pb::CodedOutputStream.ComputeInt32Size(CoreLimit); } + if (OtherClientApi.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(OtherClientApi); + } return size; } @@ -1427,6 +1009,9 @@ namespace Grpc.Testing { if (other.CoreLimit != 0) { CoreLimit = other.CoreLimit; } + if (other.OtherClientApi.Length != 0) { + OtherClientApi = other.OtherClientApi; + } } public void MergeFrom(pb::CodedInputStream input) { @@ -1497,6 +1082,10 @@ namespace Grpc.Testing { CoreLimit = input.ReadInt32(); break; } + case 122: { + OtherClientApi = input.ReadString(); + break; + } } } } @@ -1509,7 +1098,7 @@ namespace Grpc.Testing { public static pb::MessageParser<ClientStatus> Parser { get { return _parser; } } public static pbr::MessageDescriptor Descriptor { - get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[8]; } + get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[5]; } } pbr::MessageDescriptor pb::IMessage.Descriptor { @@ -1621,7 +1210,7 @@ namespace Grpc.Testing { public static pb::MessageParser<Mark> Parser { get { return _parser; } } public static pbr::MessageDescriptor Descriptor { - get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[9]; } + get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[6]; } } pbr::MessageDescriptor pb::IMessage.Descriptor { @@ -1727,7 +1316,7 @@ namespace Grpc.Testing { public static pb::MessageParser<ClientArgs> Parser { get { return _parser; } } public static pbr::MessageDescriptor Descriptor { - get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[10]; } + get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[7]; } } pbr::MessageDescriptor pb::IMessage.Descriptor { @@ -1896,7 +1485,7 @@ namespace Grpc.Testing { public static pb::MessageParser<ServerConfig> Parser { get { return _parser; } } public static pbr::MessageDescriptor Descriptor { - get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[11]; } + get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[8]; } } pbr::MessageDescriptor pb::IMessage.Descriptor { @@ -1917,6 +1506,7 @@ namespace Grpc.Testing { coreLimit_ = other.coreLimit_; PayloadConfig = other.payloadConfig_ != null ? other.PayloadConfig.Clone() : null; coreList_ = other.coreList_.Clone(); + otherServerApi_ = other.otherServerApi_; } public ServerConfig Clone() { @@ -2007,6 +1597,19 @@ namespace Grpc.Testing { get { return coreList_; } } + /// <summary>Field number for the "other_server_api" field.</summary> + public const int OtherServerApiFieldNumber = 11; + private string otherServerApi_ = ""; + /// <summary> + /// If we use an OTHER_SERVER client_type, this string gives more detail + /// </summary> + public string OtherServerApi { + get { return otherServerApi_; } + set { + otherServerApi_ = pb::Preconditions.CheckNotNull(value, "value"); + } + } + public override bool Equals(object other) { return Equals(other as ServerConfig); } @@ -2025,6 +1628,7 @@ namespace Grpc.Testing { if (CoreLimit != other.CoreLimit) return false; if (!object.Equals(PayloadConfig, other.PayloadConfig)) return false; if(!coreList_.Equals(other.coreList_)) return false; + if (OtherServerApi != other.OtherServerApi) return false; return true; } @@ -2037,6 +1641,7 @@ namespace Grpc.Testing { if (CoreLimit != 0) hash ^= CoreLimit.GetHashCode(); if (payloadConfig_ != null) hash ^= PayloadConfig.GetHashCode(); hash ^= coreList_.GetHashCode(); + if (OtherServerApi.Length != 0) hash ^= OtherServerApi.GetHashCode(); return hash; } @@ -2070,6 +1675,10 @@ namespace Grpc.Testing { output.WriteMessage(PayloadConfig); } coreList_.WriteTo(output, _repeated_coreList_codec); + if (OtherServerApi.Length != 0) { + output.WriteRawTag(90); + output.WriteString(OtherServerApi); + } } public int CalculateSize() { @@ -2093,6 +1702,9 @@ namespace Grpc.Testing { size += 1 + pb::CodedOutputStream.ComputeMessageSize(PayloadConfig); } size += coreList_.CalculateSize(_repeated_coreList_codec); + if (OtherServerApi.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(OtherServerApi); + } return size; } @@ -2125,6 +1737,9 @@ namespace Grpc.Testing { PayloadConfig.MergeFrom(other.PayloadConfig); } coreList_.Add(other.coreList_); + if (other.OtherServerApi.Length != 0) { + OtherServerApi = other.OtherServerApi; + } } public void MergeFrom(pb::CodedInputStream input) { @@ -2169,6 +1784,10 @@ namespace Grpc.Testing { coreList_.AddEntriesFrom(input, _repeated_coreList_codec); break; } + case 90: { + OtherServerApi = input.ReadString(); + break; + } } } } @@ -2181,7 +1800,7 @@ namespace Grpc.Testing { public static pb::MessageParser<ServerArgs> Parser { get { return _parser; } } public static pbr::MessageDescriptor Descriptor { - get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[12]; } + get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[9]; } } pbr::MessageDescriptor pb::IMessage.Descriptor { @@ -2350,7 +1969,7 @@ namespace Grpc.Testing { public static pb::MessageParser<ServerStatus> Parser { get { return _parser; } } public static pbr::MessageDescriptor Descriptor { - get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[13]; } + get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[10]; } } pbr::MessageDescriptor pb::IMessage.Descriptor { @@ -2519,7 +2138,7 @@ namespace Grpc.Testing { public static pb::MessageParser<CoreRequest> Parser { get { return _parser; } } public static pbr::MessageDescriptor Descriptor { - get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[14]; } + get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[11]; } } pbr::MessageDescriptor pb::IMessage.Descriptor { @@ -2595,7 +2214,7 @@ namespace Grpc.Testing { public static pb::MessageParser<CoreResponse> Parser { get { return _parser; } } public static pbr::MessageDescriptor Descriptor { - get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[15]; } + get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[12]; } } pbr::MessageDescriptor pb::IMessage.Descriptor { @@ -2701,7 +2320,7 @@ namespace Grpc.Testing { public static pb::MessageParser<Void> Parser { get { return _parser; } } public static pbr::MessageDescriptor Descriptor { - get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[16]; } + get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[13]; } } pbr::MessageDescriptor pb::IMessage.Descriptor { @@ -2771,6 +2390,1087 @@ namespace Grpc.Testing { } + /// <summary> + /// A single performance scenario: input to qps_json_driver + /// </summary> + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class Scenario : pb::IMessage<Scenario> { + private static readonly pb::MessageParser<Scenario> _parser = new pb::MessageParser<Scenario>(() => new Scenario()); + public static pb::MessageParser<Scenario> Parser { get { return _parser; } } + + public static pbr::MessageDescriptor Descriptor { + get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[14]; } + } + + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + public Scenario() { + OnConstruction(); + } + + partial void OnConstruction(); + + public Scenario(Scenario other) : this() { + name_ = other.name_; + ClientConfig = other.clientConfig_ != null ? other.ClientConfig.Clone() : null; + numClients_ = other.numClients_; + ServerConfig = other.serverConfig_ != null ? other.ServerConfig.Clone() : null; + numServers_ = other.numServers_; + warmupSeconds_ = other.warmupSeconds_; + benchmarkSeconds_ = other.benchmarkSeconds_; + spawnLocalWorkerCount_ = other.spawnLocalWorkerCount_; + } + + public Scenario Clone() { + return new Scenario(this); + } + + /// <summary>Field number for the "name" field.</summary> + public const int NameFieldNumber = 1; + private string name_ = ""; + /// <summary> + /// Human readable name for this scenario + /// </summary> + public string Name { + get { return name_; } + set { + name_ = pb::Preconditions.CheckNotNull(value, "value"); + } + } + + /// <summary>Field number for the "client_config" field.</summary> + public const int ClientConfigFieldNumber = 2; + private global::Grpc.Testing.ClientConfig clientConfig_; + /// <summary> + /// Client configuration + /// </summary> + public global::Grpc.Testing.ClientConfig ClientConfig { + get { return clientConfig_; } + set { + clientConfig_ = value; + } + } + + /// <summary>Field number for the "num_clients" field.</summary> + public const int NumClientsFieldNumber = 3; + private int numClients_; + /// <summary> + /// Number of clients to start for the test + /// </summary> + public int NumClients { + get { return numClients_; } + set { + numClients_ = value; + } + } + + /// <summary>Field number for the "server_config" field.</summary> + public const int ServerConfigFieldNumber = 4; + private global::Grpc.Testing.ServerConfig serverConfig_; + /// <summary> + /// Server configuration + /// </summary> + public global::Grpc.Testing.ServerConfig ServerConfig { + get { return serverConfig_; } + set { + serverConfig_ = value; + } + } + + /// <summary>Field number for the "num_servers" field.</summary> + public const int NumServersFieldNumber = 5; + private int numServers_; + /// <summary> + /// Number of servers to start for the test + /// </summary> + public int NumServers { + get { return numServers_; } + set { + numServers_ = value; + } + } + + /// <summary>Field number for the "warmup_seconds" field.</summary> + public const int WarmupSecondsFieldNumber = 6; + private int warmupSeconds_; + /// <summary> + /// Warmup period, in seconds + /// </summary> + public int WarmupSeconds { + get { return warmupSeconds_; } + set { + warmupSeconds_ = value; + } + } + + /// <summary>Field number for the "benchmark_seconds" field.</summary> + public const int BenchmarkSecondsFieldNumber = 7; + private int benchmarkSeconds_; + /// <summary> + /// Benchmark time, in seconds + /// </summary> + public int BenchmarkSeconds { + get { return benchmarkSeconds_; } + set { + benchmarkSeconds_ = value; + } + } + + /// <summary>Field number for the "spawn_local_worker_count" field.</summary> + public const int SpawnLocalWorkerCountFieldNumber = 8; + private int spawnLocalWorkerCount_; + /// <summary> + /// Number of workers to spawn locally (usually zero) + /// </summary> + public int SpawnLocalWorkerCount { + get { return spawnLocalWorkerCount_; } + set { + spawnLocalWorkerCount_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as Scenario); + } + + public bool Equals(Scenario other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Name != other.Name) return false; + if (!object.Equals(ClientConfig, other.ClientConfig)) return false; + if (NumClients != other.NumClients) return false; + if (!object.Equals(ServerConfig, other.ServerConfig)) return false; + if (NumServers != other.NumServers) return false; + if (WarmupSeconds != other.WarmupSeconds) return false; + if (BenchmarkSeconds != other.BenchmarkSeconds) return false; + if (SpawnLocalWorkerCount != other.SpawnLocalWorkerCount) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Name.Length != 0) hash ^= Name.GetHashCode(); + if (clientConfig_ != null) hash ^= ClientConfig.GetHashCode(); + if (NumClients != 0) hash ^= NumClients.GetHashCode(); + if (serverConfig_ != null) hash ^= ServerConfig.GetHashCode(); + if (NumServers != 0) hash ^= NumServers.GetHashCode(); + if (WarmupSeconds != 0) hash ^= WarmupSeconds.GetHashCode(); + if (BenchmarkSeconds != 0) hash ^= BenchmarkSeconds.GetHashCode(); + if (SpawnLocalWorkerCount != 0) hash ^= SpawnLocalWorkerCount.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Name.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Name); + } + if (clientConfig_ != null) { + output.WriteRawTag(18); + output.WriteMessage(ClientConfig); + } + if (NumClients != 0) { + output.WriteRawTag(24); + output.WriteInt32(NumClients); + } + if (serverConfig_ != null) { + output.WriteRawTag(34); + output.WriteMessage(ServerConfig); + } + if (NumServers != 0) { + output.WriteRawTag(40); + output.WriteInt32(NumServers); + } + if (WarmupSeconds != 0) { + output.WriteRawTag(48); + output.WriteInt32(WarmupSeconds); + } + if (BenchmarkSeconds != 0) { + output.WriteRawTag(56); + output.WriteInt32(BenchmarkSeconds); + } + if (SpawnLocalWorkerCount != 0) { + output.WriteRawTag(64); + output.WriteInt32(SpawnLocalWorkerCount); + } + } + + public int CalculateSize() { + int size = 0; + if (Name.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); + } + if (clientConfig_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(ClientConfig); + } + if (NumClients != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(NumClients); + } + if (serverConfig_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(ServerConfig); + } + if (NumServers != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(NumServers); + } + if (WarmupSeconds != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(WarmupSeconds); + } + if (BenchmarkSeconds != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(BenchmarkSeconds); + } + if (SpawnLocalWorkerCount != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(SpawnLocalWorkerCount); + } + return size; + } + + public void MergeFrom(Scenario other) { + if (other == null) { + return; + } + if (other.Name.Length != 0) { + Name = other.Name; + } + if (other.clientConfig_ != null) { + if (clientConfig_ == null) { + clientConfig_ = new global::Grpc.Testing.ClientConfig(); + } + ClientConfig.MergeFrom(other.ClientConfig); + } + if (other.NumClients != 0) { + NumClients = other.NumClients; + } + if (other.serverConfig_ != null) { + if (serverConfig_ == null) { + serverConfig_ = new global::Grpc.Testing.ServerConfig(); + } + ServerConfig.MergeFrom(other.ServerConfig); + } + if (other.NumServers != 0) { + NumServers = other.NumServers; + } + if (other.WarmupSeconds != 0) { + WarmupSeconds = other.WarmupSeconds; + } + if (other.BenchmarkSeconds != 0) { + BenchmarkSeconds = other.BenchmarkSeconds; + } + if (other.SpawnLocalWorkerCount != 0) { + SpawnLocalWorkerCount = other.SpawnLocalWorkerCount; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + Name = input.ReadString(); + break; + } + case 18: { + if (clientConfig_ == null) { + clientConfig_ = new global::Grpc.Testing.ClientConfig(); + } + input.ReadMessage(clientConfig_); + break; + } + case 24: { + NumClients = input.ReadInt32(); + break; + } + case 34: { + if (serverConfig_ == null) { + serverConfig_ = new global::Grpc.Testing.ServerConfig(); + } + input.ReadMessage(serverConfig_); + break; + } + case 40: { + NumServers = input.ReadInt32(); + break; + } + case 48: { + WarmupSeconds = input.ReadInt32(); + break; + } + case 56: { + BenchmarkSeconds = input.ReadInt32(); + break; + } + case 64: { + SpawnLocalWorkerCount = input.ReadInt32(); + break; + } + } + } + } + + } + + /// <summary> + /// A set of scenarios to be run with qps_json_driver + /// </summary> + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class Scenarios : pb::IMessage<Scenarios> { + private static readonly pb::MessageParser<Scenarios> _parser = new pb::MessageParser<Scenarios>(() => new Scenarios()); + public static pb::MessageParser<Scenarios> Parser { get { return _parser; } } + + public static pbr::MessageDescriptor Descriptor { + get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[15]; } + } + + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + public Scenarios() { + OnConstruction(); + } + + partial void OnConstruction(); + + public Scenarios(Scenarios other) : this() { + scenarios_ = other.scenarios_.Clone(); + } + + public Scenarios Clone() { + return new Scenarios(this); + } + + /// <summary>Field number for the "scenarios" field.</summary> + public const int Scenarios_FieldNumber = 1; + private static readonly pb::FieldCodec<global::Grpc.Testing.Scenario> _repeated_scenarios_codec + = pb::FieldCodec.ForMessage(10, global::Grpc.Testing.Scenario.Parser); + private readonly pbc::RepeatedField<global::Grpc.Testing.Scenario> scenarios_ = new pbc::RepeatedField<global::Grpc.Testing.Scenario>(); + public pbc::RepeatedField<global::Grpc.Testing.Scenario> Scenarios_ { + get { return scenarios_; } + } + + public override bool Equals(object other) { + return Equals(other as Scenarios); + } + + public bool Equals(Scenarios other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if(!scenarios_.Equals(other.scenarios_)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + hash ^= scenarios_.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + scenarios_.WriteTo(output, _repeated_scenarios_codec); + } + + public int CalculateSize() { + int size = 0; + size += scenarios_.CalculateSize(_repeated_scenarios_codec); + return size; + } + + public void MergeFrom(Scenarios other) { + if (other == null) { + return; + } + scenarios_.Add(other.scenarios_); + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + scenarios_.AddEntriesFrom(input, _repeated_scenarios_codec); + break; + } + } + } + } + + } + + /// <summary> + /// Basic summary that can be computed from ClientStats and ServerStats + /// once the scenario has finished. + /// </summary> + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class ScenarioResultSummary : pb::IMessage<ScenarioResultSummary> { + private static readonly pb::MessageParser<ScenarioResultSummary> _parser = new pb::MessageParser<ScenarioResultSummary>(() => new ScenarioResultSummary()); + public static pb::MessageParser<ScenarioResultSummary> Parser { get { return _parser; } } + + public static pbr::MessageDescriptor Descriptor { + get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[16]; } + } + + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + public ScenarioResultSummary() { + OnConstruction(); + } + + partial void OnConstruction(); + + public ScenarioResultSummary(ScenarioResultSummary other) : this() { + qps_ = other.qps_; + qpsPerServerCore_ = other.qpsPerServerCore_; + serverSystemTime_ = other.serverSystemTime_; + serverUserTime_ = other.serverUserTime_; + clientSystemTime_ = other.clientSystemTime_; + clientUserTime_ = other.clientUserTime_; + latency50_ = other.latency50_; + latency90_ = other.latency90_; + latency95_ = other.latency95_; + latency99_ = other.latency99_; + latency999_ = other.latency999_; + } + + public ScenarioResultSummary Clone() { + return new ScenarioResultSummary(this); + } + + /// <summary>Field number for the "qps" field.</summary> + public const int QpsFieldNumber = 1; + private double qps_; + /// <summary> + /// Total number of operations per second over all clients. + /// </summary> + public double Qps { + get { return qps_; } + set { + qps_ = value; + } + } + + /// <summary>Field number for the "qps_per_server_core" field.</summary> + public const int QpsPerServerCoreFieldNumber = 2; + private double qpsPerServerCore_; + /// <summary> + /// QPS per one server core. + /// </summary> + public double QpsPerServerCore { + get { return qpsPerServerCore_; } + set { + qpsPerServerCore_ = value; + } + } + + /// <summary>Field number for the "server_system_time" field.</summary> + public const int ServerSystemTimeFieldNumber = 3; + private double serverSystemTime_; + /// <summary> + /// server load based on system_time (0.85 => 85%) + /// </summary> + public double ServerSystemTime { + get { return serverSystemTime_; } + set { + serverSystemTime_ = value; + } + } + + /// <summary>Field number for the "server_user_time" field.</summary> + public const int ServerUserTimeFieldNumber = 4; + private double serverUserTime_; + /// <summary> + /// server load based on user_time (0.85 => 85%) + /// </summary> + public double ServerUserTime { + get { return serverUserTime_; } + set { + serverUserTime_ = value; + } + } + + /// <summary>Field number for the "client_system_time" field.</summary> + public const int ClientSystemTimeFieldNumber = 5; + private double clientSystemTime_; + /// <summary> + /// client load based on system_time (0.85 => 85%) + /// </summary> + public double ClientSystemTime { + get { return clientSystemTime_; } + set { + clientSystemTime_ = value; + } + } + + /// <summary>Field number for the "client_user_time" field.</summary> + public const int ClientUserTimeFieldNumber = 6; + private double clientUserTime_; + /// <summary> + /// client load based on user_time (0.85 => 85%) + /// </summary> + public double ClientUserTime { + get { return clientUserTime_; } + set { + clientUserTime_ = value; + } + } + + /// <summary>Field number for the "latency_50" field.</summary> + public const int Latency50FieldNumber = 7; + private double latency50_; + /// <summary> + /// X% latency percentiles (in nanoseconds) + /// </summary> + public double Latency50 { + get { return latency50_; } + set { + latency50_ = value; + } + } + + /// <summary>Field number for the "latency_90" field.</summary> + public const int Latency90FieldNumber = 8; + private double latency90_; + public double Latency90 { + get { return latency90_; } + set { + latency90_ = value; + } + } + + /// <summary>Field number for the "latency_95" field.</summary> + public const int Latency95FieldNumber = 9; + private double latency95_; + public double Latency95 { + get { return latency95_; } + set { + latency95_ = value; + } + } + + /// <summary>Field number for the "latency_99" field.</summary> + public const int Latency99FieldNumber = 10; + private double latency99_; + public double Latency99 { + get { return latency99_; } + set { + latency99_ = value; + } + } + + /// <summary>Field number for the "latency_999" field.</summary> + public const int Latency999FieldNumber = 11; + private double latency999_; + public double Latency999 { + get { return latency999_; } + set { + latency999_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as ScenarioResultSummary); + } + + public bool Equals(ScenarioResultSummary other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Qps != other.Qps) return false; + if (QpsPerServerCore != other.QpsPerServerCore) return false; + if (ServerSystemTime != other.ServerSystemTime) return false; + if (ServerUserTime != other.ServerUserTime) return false; + if (ClientSystemTime != other.ClientSystemTime) return false; + if (ClientUserTime != other.ClientUserTime) return false; + if (Latency50 != other.Latency50) return false; + if (Latency90 != other.Latency90) return false; + if (Latency95 != other.Latency95) return false; + if (Latency99 != other.Latency99) return false; + if (Latency999 != other.Latency999) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Qps != 0D) hash ^= Qps.GetHashCode(); + if (QpsPerServerCore != 0D) hash ^= QpsPerServerCore.GetHashCode(); + if (ServerSystemTime != 0D) hash ^= ServerSystemTime.GetHashCode(); + if (ServerUserTime != 0D) hash ^= ServerUserTime.GetHashCode(); + if (ClientSystemTime != 0D) hash ^= ClientSystemTime.GetHashCode(); + if (ClientUserTime != 0D) hash ^= ClientUserTime.GetHashCode(); + if (Latency50 != 0D) hash ^= Latency50.GetHashCode(); + if (Latency90 != 0D) hash ^= Latency90.GetHashCode(); + if (Latency95 != 0D) hash ^= Latency95.GetHashCode(); + if (Latency99 != 0D) hash ^= Latency99.GetHashCode(); + if (Latency999 != 0D) hash ^= Latency999.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Qps != 0D) { + output.WriteRawTag(9); + output.WriteDouble(Qps); + } + if (QpsPerServerCore != 0D) { + output.WriteRawTag(17); + output.WriteDouble(QpsPerServerCore); + } + if (ServerSystemTime != 0D) { + output.WriteRawTag(25); + output.WriteDouble(ServerSystemTime); + } + if (ServerUserTime != 0D) { + output.WriteRawTag(33); + output.WriteDouble(ServerUserTime); + } + if (ClientSystemTime != 0D) { + output.WriteRawTag(41); + output.WriteDouble(ClientSystemTime); + } + if (ClientUserTime != 0D) { + output.WriteRawTag(49); + output.WriteDouble(ClientUserTime); + } + if (Latency50 != 0D) { + output.WriteRawTag(57); + output.WriteDouble(Latency50); + } + if (Latency90 != 0D) { + output.WriteRawTag(65); + output.WriteDouble(Latency90); + } + if (Latency95 != 0D) { + output.WriteRawTag(73); + output.WriteDouble(Latency95); + } + if (Latency99 != 0D) { + output.WriteRawTag(81); + output.WriteDouble(Latency99); + } + if (Latency999 != 0D) { + output.WriteRawTag(89); + output.WriteDouble(Latency999); + } + } + + public int CalculateSize() { + int size = 0; + if (Qps != 0D) { + size += 1 + 8; + } + if (QpsPerServerCore != 0D) { + size += 1 + 8; + } + if (ServerSystemTime != 0D) { + size += 1 + 8; + } + if (ServerUserTime != 0D) { + size += 1 + 8; + } + if (ClientSystemTime != 0D) { + size += 1 + 8; + } + if (ClientUserTime != 0D) { + size += 1 + 8; + } + if (Latency50 != 0D) { + size += 1 + 8; + } + if (Latency90 != 0D) { + size += 1 + 8; + } + if (Latency95 != 0D) { + size += 1 + 8; + } + if (Latency99 != 0D) { + size += 1 + 8; + } + if (Latency999 != 0D) { + size += 1 + 8; + } + return size; + } + + public void MergeFrom(ScenarioResultSummary other) { + if (other == null) { + return; + } + if (other.Qps != 0D) { + Qps = other.Qps; + } + if (other.QpsPerServerCore != 0D) { + QpsPerServerCore = other.QpsPerServerCore; + } + if (other.ServerSystemTime != 0D) { + ServerSystemTime = other.ServerSystemTime; + } + if (other.ServerUserTime != 0D) { + ServerUserTime = other.ServerUserTime; + } + if (other.ClientSystemTime != 0D) { + ClientSystemTime = other.ClientSystemTime; + } + if (other.ClientUserTime != 0D) { + ClientUserTime = other.ClientUserTime; + } + if (other.Latency50 != 0D) { + Latency50 = other.Latency50; + } + if (other.Latency90 != 0D) { + Latency90 = other.Latency90; + } + if (other.Latency95 != 0D) { + Latency95 = other.Latency95; + } + if (other.Latency99 != 0D) { + Latency99 = other.Latency99; + } + if (other.Latency999 != 0D) { + Latency999 = other.Latency999; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 9: { + Qps = input.ReadDouble(); + break; + } + case 17: { + QpsPerServerCore = input.ReadDouble(); + break; + } + case 25: { + ServerSystemTime = input.ReadDouble(); + break; + } + case 33: { + ServerUserTime = input.ReadDouble(); + break; + } + case 41: { + ClientSystemTime = input.ReadDouble(); + break; + } + case 49: { + ClientUserTime = input.ReadDouble(); + break; + } + case 57: { + Latency50 = input.ReadDouble(); + break; + } + case 65: { + Latency90 = input.ReadDouble(); + break; + } + case 73: { + Latency95 = input.ReadDouble(); + break; + } + case 81: { + Latency99 = input.ReadDouble(); + break; + } + case 89: { + Latency999 = input.ReadDouble(); + break; + } + } + } + } + + } + + /// <summary> + /// Results of a single benchmark scenario. + /// </summary> + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class ScenarioResult : pb::IMessage<ScenarioResult> { + private static readonly pb::MessageParser<ScenarioResult> _parser = new pb::MessageParser<ScenarioResult>(() => new ScenarioResult()); + public static pb::MessageParser<ScenarioResult> Parser { get { return _parser; } } + + public static pbr::MessageDescriptor Descriptor { + get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[17]; } + } + + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + public ScenarioResult() { + OnConstruction(); + } + + partial void OnConstruction(); + + public ScenarioResult(ScenarioResult other) : this() { + Scenario = other.scenario_ != null ? other.Scenario.Clone() : null; + Latencies = other.latencies_ != null ? other.Latencies.Clone() : null; + clientStats_ = other.clientStats_.Clone(); + serverStats_ = other.serverStats_.Clone(); + serverCores_ = other.serverCores_.Clone(); + Summary = other.summary_ != null ? other.Summary.Clone() : null; + } + + public ScenarioResult Clone() { + return new ScenarioResult(this); + } + + /// <summary>Field number for the "scenario" field.</summary> + public const int ScenarioFieldNumber = 1; + private global::Grpc.Testing.Scenario scenario_; + /// <summary> + /// Inputs used to run the scenario. + /// </summary> + public global::Grpc.Testing.Scenario Scenario { + get { return scenario_; } + set { + scenario_ = value; + } + } + + /// <summary>Field number for the "latencies" field.</summary> + public const int LatenciesFieldNumber = 2; + private global::Grpc.Testing.HistogramData latencies_; + /// <summary> + /// Histograms from all clients merged into one histogram. + /// </summary> + public global::Grpc.Testing.HistogramData Latencies { + get { return latencies_; } + set { + latencies_ = value; + } + } + + /// <summary>Field number for the "client_stats" field.</summary> + public const int ClientStatsFieldNumber = 3; + private static readonly pb::FieldCodec<global::Grpc.Testing.ClientStats> _repeated_clientStats_codec + = pb::FieldCodec.ForMessage(26, global::Grpc.Testing.ClientStats.Parser); + private readonly pbc::RepeatedField<global::Grpc.Testing.ClientStats> clientStats_ = new pbc::RepeatedField<global::Grpc.Testing.ClientStats>(); + /// <summary> + /// Client stats for each client + /// </summary> + public pbc::RepeatedField<global::Grpc.Testing.ClientStats> ClientStats { + get { return clientStats_; } + } + + /// <summary>Field number for the "server_stats" field.</summary> + public const int ServerStatsFieldNumber = 4; + private static readonly pb::FieldCodec<global::Grpc.Testing.ServerStats> _repeated_serverStats_codec + = pb::FieldCodec.ForMessage(34, global::Grpc.Testing.ServerStats.Parser); + private readonly pbc::RepeatedField<global::Grpc.Testing.ServerStats> serverStats_ = new pbc::RepeatedField<global::Grpc.Testing.ServerStats>(); + /// <summary> + /// Server stats for each server + /// </summary> + public pbc::RepeatedField<global::Grpc.Testing.ServerStats> ServerStats { + get { return serverStats_; } + } + + /// <summary>Field number for the "server_cores" field.</summary> + public const int ServerCoresFieldNumber = 5; + private static readonly pb::FieldCodec<int> _repeated_serverCores_codec + = pb::FieldCodec.ForInt32(42); + private readonly pbc::RepeatedField<int> serverCores_ = new pbc::RepeatedField<int>(); + /// <summary> + /// Number of cores available to each server + /// </summary> + public pbc::RepeatedField<int> ServerCores { + get { return serverCores_; } + } + + /// <summary>Field number for the "summary" field.</summary> + public const int SummaryFieldNumber = 6; + private global::Grpc.Testing.ScenarioResultSummary summary_; + /// <summary> + /// An after-the-fact computed summary + /// </summary> + public global::Grpc.Testing.ScenarioResultSummary Summary { + get { return summary_; } + set { + summary_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as ScenarioResult); + } + + public bool Equals(ScenarioResult other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (!object.Equals(Scenario, other.Scenario)) return false; + if (!object.Equals(Latencies, other.Latencies)) return false; + if(!clientStats_.Equals(other.clientStats_)) return false; + if(!serverStats_.Equals(other.serverStats_)) return false; + if(!serverCores_.Equals(other.serverCores_)) return false; + if (!object.Equals(Summary, other.Summary)) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (scenario_ != null) hash ^= Scenario.GetHashCode(); + if (latencies_ != null) hash ^= Latencies.GetHashCode(); + hash ^= clientStats_.GetHashCode(); + hash ^= serverStats_.GetHashCode(); + hash ^= serverCores_.GetHashCode(); + if (summary_ != null) hash ^= Summary.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (scenario_ != null) { + output.WriteRawTag(10); + output.WriteMessage(Scenario); + } + if (latencies_ != null) { + output.WriteRawTag(18); + output.WriteMessage(Latencies); + } + clientStats_.WriteTo(output, _repeated_clientStats_codec); + serverStats_.WriteTo(output, _repeated_serverStats_codec); + serverCores_.WriteTo(output, _repeated_serverCores_codec); + if (summary_ != null) { + output.WriteRawTag(50); + output.WriteMessage(Summary); + } + } + + public int CalculateSize() { + int size = 0; + if (scenario_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Scenario); + } + if (latencies_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Latencies); + } + size += clientStats_.CalculateSize(_repeated_clientStats_codec); + size += serverStats_.CalculateSize(_repeated_serverStats_codec); + size += serverCores_.CalculateSize(_repeated_serverCores_codec); + if (summary_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Summary); + } + return size; + } + + public void MergeFrom(ScenarioResult other) { + if (other == null) { + return; + } + if (other.scenario_ != null) { + if (scenario_ == null) { + scenario_ = new global::Grpc.Testing.Scenario(); + } + Scenario.MergeFrom(other.Scenario); + } + if (other.latencies_ != null) { + if (latencies_ == null) { + latencies_ = new global::Grpc.Testing.HistogramData(); + } + Latencies.MergeFrom(other.Latencies); + } + clientStats_.Add(other.clientStats_); + serverStats_.Add(other.serverStats_); + serverCores_.Add(other.serverCores_); + if (other.summary_ != null) { + if (summary_ == null) { + summary_ = new global::Grpc.Testing.ScenarioResultSummary(); + } + Summary.MergeFrom(other.Summary); + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + if (scenario_ == null) { + scenario_ = new global::Grpc.Testing.Scenario(); + } + input.ReadMessage(scenario_); + break; + } + case 18: { + if (latencies_ == null) { + latencies_ = new global::Grpc.Testing.HistogramData(); + } + input.ReadMessage(latencies_); + break; + } + case 26: { + clientStats_.AddEntriesFrom(input, _repeated_clientStats_codec); + break; + } + case 34: { + serverStats_.AddEntriesFrom(input, _repeated_serverStats_codec); + break; + } + case 42: + case 40: { + serverCores_.AddEntriesFrom(input, _repeated_serverCores_codec); + break; + } + case 50: { + if (summary_ == null) { + summary_ = new global::Grpc.Testing.ScenarioResultSummary(); + } + input.ReadMessage(summary_); + break; + } + } + } + } + + } + #endregion } diff --git a/src/csharp/Grpc.IntegrationTesting/Grpc.IntegrationTesting.csproj b/src/csharp/Grpc.IntegrationTesting/Grpc.IntegrationTesting.csproj index c16d0e5c5d..9685cf1837 100644 --- a/src/csharp/Grpc.IntegrationTesting/Grpc.IntegrationTesting.csproj +++ b/src/csharp/Grpc.IntegrationTesting/Grpc.IntegrationTesting.csproj @@ -113,6 +113,9 @@ <Compile Include="GeneratedClientTest.cs" /> <Compile Include="InterarrivalTimers.cs" /> <Compile Include="NUnitMain.cs" /> + <Compile Include="StressTestClient.cs" /> + <Compile Include="Metrics.cs" /> + <Compile Include="MetricsGrpc.cs" /> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <ItemGroup> diff --git a/src/csharp/Grpc.IntegrationTesting/Messages.cs b/src/csharp/Grpc.IntegrationTesting/Messages.cs index 7ca47860f6..fcff475941 100644 --- a/src/csharp/Grpc.IntegrationTesting/Messages.cs +++ b/src/csharp/Grpc.IntegrationTesting/Messages.cs @@ -47,11 +47,12 @@ namespace Grpc.Testing { "c3Npb24YBiABKA4yHS5ncnBjLnRlc3RpbmcuQ29tcHJlc3Npb25UeXBlEjEK", "D3Jlc3BvbnNlX3N0YXR1cxgHIAEoCzIYLmdycGMudGVzdGluZy5FY2hvU3Rh", "dHVzIkUKG1N0cmVhbWluZ091dHB1dENhbGxSZXNwb25zZRImCgdwYXlsb2Fk", - "GAEgASgLMhUuZ3JwYy50ZXN0aW5nLlBheWxvYWQiMwoNUmVjb25uZWN0SW5m", - "bxIOCgZwYXNzZWQYASABKAgSEgoKYmFja29mZl9tcxgCIAMoBSo/CgtQYXls", - "b2FkVHlwZRIQCgxDT01QUkVTU0FCTEUQABISCg5VTkNPTVBSRVNTQUJMRRAB", - "EgoKBlJBTkRPTRACKjIKD0NvbXByZXNzaW9uVHlwZRIICgROT05FEAASCAoE", - "R1pJUBABEgsKB0RFRkxBVEUQAmIGcHJvdG8z")); + "GAEgASgLMhUuZ3JwYy50ZXN0aW5nLlBheWxvYWQiMwoPUmVjb25uZWN0UGFy", + "YW1zEiAKGG1heF9yZWNvbm5lY3RfYmFja29mZl9tcxgBIAEoBSIzCg1SZWNv", + "bm5lY3RJbmZvEg4KBnBhc3NlZBgBIAEoCBISCgpiYWNrb2ZmX21zGAIgAygF", + "Kj8KC1BheWxvYWRUeXBlEhAKDENPTVBSRVNTQUJMRRAAEhIKDlVOQ09NUFJF", + "U1NBQkxFEAESCgoGUkFORE9NEAIqMgoPQ29tcHJlc3Npb25UeXBlEggKBE5P", + "TkUQABIICgRHWklQEAESCwoHREVGTEFURRACYgZwcm90bzM=")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedCodeInfo(new[] {typeof(global::Grpc.Testing.PayloadType), typeof(global::Grpc.Testing.CompressionType), }, new pbr::GeneratedCodeInfo[] { @@ -64,6 +65,7 @@ namespace Grpc.Testing { new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.ResponseParameters), global::Grpc.Testing.ResponseParameters.Parser, new[]{ "Size", "IntervalUs" }, null, null, null), new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.StreamingOutputCallRequest), global::Grpc.Testing.StreamingOutputCallRequest.Parser, new[]{ "ResponseType", "ResponseParameters", "Payload", "ResponseCompression", "ResponseStatus" }, null, null, null), new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.StreamingOutputCallResponse), global::Grpc.Testing.StreamingOutputCallResponse.Parser, new[]{ "Payload" }, null, null, null), + new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.ReconnectParams), global::Grpc.Testing.ReconnectParams.Parser, new[]{ "MaxReconnectBackoffMs" }, null, null, null), new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.ReconnectInfo), global::Grpc.Testing.ReconnectInfo.Parser, new[]{ "Passed", "BackoffMs" }, null, null, null) })); } @@ -1574,6 +1576,113 @@ namespace Grpc.Testing { /// <summary> /// For reconnect interop test only. + /// Client tells server what reconnection parameters it used. + /// </summary> + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class ReconnectParams : pb::IMessage<ReconnectParams> { + private static readonly pb::MessageParser<ReconnectParams> _parser = new pb::MessageParser<ReconnectParams>(() => new ReconnectParams()); + public static pb::MessageParser<ReconnectParams> Parser { get { return _parser; } } + + public static pbr::MessageDescriptor Descriptor { + get { return global::Grpc.Testing.MessagesReflection.Descriptor.MessageTypes[9]; } + } + + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + public ReconnectParams() { + OnConstruction(); + } + + partial void OnConstruction(); + + public ReconnectParams(ReconnectParams other) : this() { + maxReconnectBackoffMs_ = other.maxReconnectBackoffMs_; + } + + public ReconnectParams Clone() { + return new ReconnectParams(this); + } + + /// <summary>Field number for the "max_reconnect_backoff_ms" field.</summary> + public const int MaxReconnectBackoffMsFieldNumber = 1; + private int maxReconnectBackoffMs_; + public int MaxReconnectBackoffMs { + get { return maxReconnectBackoffMs_; } + set { + maxReconnectBackoffMs_ = value; + } + } + + public override bool Equals(object other) { + return Equals(other as ReconnectParams); + } + + public bool Equals(ReconnectParams other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (MaxReconnectBackoffMs != other.MaxReconnectBackoffMs) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (MaxReconnectBackoffMs != 0) hash ^= MaxReconnectBackoffMs.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (MaxReconnectBackoffMs != 0) { + output.WriteRawTag(8); + output.WriteInt32(MaxReconnectBackoffMs); + } + } + + public int CalculateSize() { + int size = 0; + if (MaxReconnectBackoffMs != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(MaxReconnectBackoffMs); + } + return size; + } + + public void MergeFrom(ReconnectParams other) { + if (other == null) { + return; + } + if (other.MaxReconnectBackoffMs != 0) { + MaxReconnectBackoffMs = other.MaxReconnectBackoffMs; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 8: { + MaxReconnectBackoffMs = input.ReadInt32(); + break; + } + } + } + } + + } + + /// <summary> + /// For reconnect interop test only. /// Server tells client whether its reconnects are following the spec and the /// reconnect backoffs it saw. /// </summary> @@ -1583,7 +1692,7 @@ namespace Grpc.Testing { public static pb::MessageParser<ReconnectInfo> Parser { get { return _parser; } } public static pbr::MessageDescriptor Descriptor { - get { return global::Grpc.Testing.MessagesReflection.Descriptor.MessageTypes[9]; } + get { return global::Grpc.Testing.MessagesReflection.Descriptor.MessageTypes[10]; } } pbr::MessageDescriptor pb::IMessage.Descriptor { diff --git a/src/csharp/Grpc.IntegrationTesting/Metrics.cs b/src/csharp/Grpc.IntegrationTesting/Metrics.cs new file mode 100644 index 0000000000..3163949d32 --- /dev/null +++ b/src/csharp/Grpc.IntegrationTesting/Metrics.cs @@ -0,0 +1,452 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: src/proto/grpc/testing/metrics.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Grpc.Testing { + + /// <summary>Holder for reflection information generated from src/proto/grpc/testing/metrics.proto</summary> + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class MetricsReflection { + + #region Descriptor + /// <summary>File descriptor for src/proto/grpc/testing/metrics.proto</summary> + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static MetricsReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "CiRzcmMvcHJvdG8vZ3JwYy90ZXN0aW5nL21ldHJpY3MucHJvdG8SDGdycGMu", + "dGVzdGluZyJsCg1HYXVnZVJlc3BvbnNlEgwKBG5hbWUYASABKAkSFAoKbG9u", + "Z192YWx1ZRgCIAEoA0gAEhYKDGRvdWJsZV92YWx1ZRgDIAEoAUgAEhYKDHN0", + "cmluZ192YWx1ZRgEIAEoCUgAQgcKBXZhbHVlIhwKDEdhdWdlUmVxdWVzdBIM", + "CgRuYW1lGAEgASgJIg4KDEVtcHR5TWVzc2FnZTKgAQoOTWV0cmljc1NlcnZp", + "Y2USSQoMR2V0QWxsR2F1Z2VzEhouZ3JwYy50ZXN0aW5nLkVtcHR5TWVzc2Fn", + "ZRobLmdycGMudGVzdGluZy5HYXVnZVJlc3BvbnNlMAESQwoIR2V0R2F1Z2US", + "Gi5ncnBjLnRlc3RpbmcuR2F1Z2VSZXF1ZXN0GhsuZ3JwYy50ZXN0aW5nLkdh", + "dWdlUmVzcG9uc2ViBnByb3RvMw==")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedCodeInfo(null, new pbr::GeneratedCodeInfo[] { + new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.GaugeResponse), global::Grpc.Testing.GaugeResponse.Parser, new[]{ "Name", "LongValue", "DoubleValue", "StringValue" }, new[]{ "Value" }, null, null), + new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.GaugeRequest), global::Grpc.Testing.GaugeRequest.Parser, new[]{ "Name" }, null, null, null), + new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.EmptyMessage), global::Grpc.Testing.EmptyMessage.Parser, null, null, null, null) + })); + } + #endregion + + } + #region Messages + /// <summary> + /// Reponse message containing the gauge name and value + /// </summary> + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class GaugeResponse : pb::IMessage<GaugeResponse> { + private static readonly pb::MessageParser<GaugeResponse> _parser = new pb::MessageParser<GaugeResponse>(() => new GaugeResponse()); + public static pb::MessageParser<GaugeResponse> Parser { get { return _parser; } } + + public static pbr::MessageDescriptor Descriptor { + get { return global::Grpc.Testing.MetricsReflection.Descriptor.MessageTypes[0]; } + } + + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + public GaugeResponse() { + OnConstruction(); + } + + partial void OnConstruction(); + + public GaugeResponse(GaugeResponse other) : this() { + name_ = other.name_; + switch (other.ValueCase) { + case ValueOneofCase.LongValue: + LongValue = other.LongValue; + break; + case ValueOneofCase.DoubleValue: + DoubleValue = other.DoubleValue; + break; + case ValueOneofCase.StringValue: + StringValue = other.StringValue; + break; + } + + } + + public GaugeResponse Clone() { + return new GaugeResponse(this); + } + + /// <summary>Field number for the "name" field.</summary> + public const int NameFieldNumber = 1; + private string name_ = ""; + public string Name { + get { return name_; } + set { + name_ = pb::Preconditions.CheckNotNull(value, "value"); + } + } + + /// <summary>Field number for the "long_value" field.</summary> + public const int LongValueFieldNumber = 2; + public long LongValue { + get { return valueCase_ == ValueOneofCase.LongValue ? (long) value_ : 0L; } + set { + value_ = value; + valueCase_ = ValueOneofCase.LongValue; + } + } + + /// <summary>Field number for the "double_value" field.</summary> + public const int DoubleValueFieldNumber = 3; + public double DoubleValue { + get { return valueCase_ == ValueOneofCase.DoubleValue ? (double) value_ : 0D; } + set { + value_ = value; + valueCase_ = ValueOneofCase.DoubleValue; + } + } + + /// <summary>Field number for the "string_value" field.</summary> + public const int StringValueFieldNumber = 4; + public string StringValue { + get { return valueCase_ == ValueOneofCase.StringValue ? (string) value_ : ""; } + set { + value_ = pb::Preconditions.CheckNotNull(value, "value"); + valueCase_ = ValueOneofCase.StringValue; + } + } + + private object value_; + /// <summary>Enum of possible cases for the "value" oneof.</summary> + public enum ValueOneofCase { + None = 0, + LongValue = 2, + DoubleValue = 3, + StringValue = 4, + } + private ValueOneofCase valueCase_ = ValueOneofCase.None; + public ValueOneofCase ValueCase { + get { return valueCase_; } + } + + public void ClearValue() { + valueCase_ = ValueOneofCase.None; + value_ = null; + } + + public override bool Equals(object other) { + return Equals(other as GaugeResponse); + } + + public bool Equals(GaugeResponse other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Name != other.Name) return false; + if (LongValue != other.LongValue) return false; + if (DoubleValue != other.DoubleValue) return false; + if (StringValue != other.StringValue) return false; + if (ValueCase != other.ValueCase) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Name.Length != 0) hash ^= Name.GetHashCode(); + if (valueCase_ == ValueOneofCase.LongValue) hash ^= LongValue.GetHashCode(); + if (valueCase_ == ValueOneofCase.DoubleValue) hash ^= DoubleValue.GetHashCode(); + if (valueCase_ == ValueOneofCase.StringValue) hash ^= StringValue.GetHashCode(); + hash ^= (int) valueCase_; + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Name.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Name); + } + if (valueCase_ == ValueOneofCase.LongValue) { + output.WriteRawTag(16); + output.WriteInt64(LongValue); + } + if (valueCase_ == ValueOneofCase.DoubleValue) { + output.WriteRawTag(25); + output.WriteDouble(DoubleValue); + } + if (valueCase_ == ValueOneofCase.StringValue) { + output.WriteRawTag(34); + output.WriteString(StringValue); + } + } + + public int CalculateSize() { + int size = 0; + if (Name.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); + } + if (valueCase_ == ValueOneofCase.LongValue) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(LongValue); + } + if (valueCase_ == ValueOneofCase.DoubleValue) { + size += 1 + 8; + } + if (valueCase_ == ValueOneofCase.StringValue) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(StringValue); + } + return size; + } + + public void MergeFrom(GaugeResponse other) { + if (other == null) { + return; + } + if (other.Name.Length != 0) { + Name = other.Name; + } + switch (other.ValueCase) { + case ValueOneofCase.LongValue: + LongValue = other.LongValue; + break; + case ValueOneofCase.DoubleValue: + DoubleValue = other.DoubleValue; + break; + case ValueOneofCase.StringValue: + StringValue = other.StringValue; + break; + } + + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + Name = input.ReadString(); + break; + } + case 16: { + LongValue = input.ReadInt64(); + break; + } + case 25: { + DoubleValue = input.ReadDouble(); + break; + } + case 34: { + StringValue = input.ReadString(); + break; + } + } + } + } + + } + + /// <summary> + /// Request message containing the gauge name + /// </summary> + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class GaugeRequest : pb::IMessage<GaugeRequest> { + private static readonly pb::MessageParser<GaugeRequest> _parser = new pb::MessageParser<GaugeRequest>(() => new GaugeRequest()); + public static pb::MessageParser<GaugeRequest> Parser { get { return _parser; } } + + public static pbr::MessageDescriptor Descriptor { + get { return global::Grpc.Testing.MetricsReflection.Descriptor.MessageTypes[1]; } + } + + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + public GaugeRequest() { + OnConstruction(); + } + + partial void OnConstruction(); + + public GaugeRequest(GaugeRequest other) : this() { + name_ = other.name_; + } + + public GaugeRequest Clone() { + return new GaugeRequest(this); + } + + /// <summary>Field number for the "name" field.</summary> + public const int NameFieldNumber = 1; + private string name_ = ""; + public string Name { + get { return name_; } + set { + name_ = pb::Preconditions.CheckNotNull(value, "value"); + } + } + + public override bool Equals(object other) { + return Equals(other as GaugeRequest); + } + + public bool Equals(GaugeRequest other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Name != other.Name) return false; + return true; + } + + public override int GetHashCode() { + int hash = 1; + if (Name.Length != 0) hash ^= Name.GetHashCode(); + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + if (Name.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Name); + } + } + + public int CalculateSize() { + int size = 0; + if (Name.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); + } + return size; + } + + public void MergeFrom(GaugeRequest other) { + if (other == null) { + return; + } + if (other.Name.Length != 0) { + Name = other.Name; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + Name = input.ReadString(); + break; + } + } + } + } + + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class EmptyMessage : pb::IMessage<EmptyMessage> { + private static readonly pb::MessageParser<EmptyMessage> _parser = new pb::MessageParser<EmptyMessage>(() => new EmptyMessage()); + public static pb::MessageParser<EmptyMessage> Parser { get { return _parser; } } + + public static pbr::MessageDescriptor Descriptor { + get { return global::Grpc.Testing.MetricsReflection.Descriptor.MessageTypes[2]; } + } + + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + public EmptyMessage() { + OnConstruction(); + } + + partial void OnConstruction(); + + public EmptyMessage(EmptyMessage other) : this() { + } + + public EmptyMessage Clone() { + return new EmptyMessage(this); + } + + public override bool Equals(object other) { + return Equals(other as EmptyMessage); + } + + public bool Equals(EmptyMessage other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return true; + } + + public override int GetHashCode() { + int hash = 1; + return hash; + } + + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + public void WriteTo(pb::CodedOutputStream output) { + } + + public int CalculateSize() { + int size = 0; + return size; + } + + public void MergeFrom(EmptyMessage other) { + if (other == null) { + return; + } + } + + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/src/csharp/Grpc.IntegrationTesting/MetricsGrpc.cs b/src/csharp/Grpc.IntegrationTesting/MetricsGrpc.cs new file mode 100644 index 0000000000..cc01ae91a1 --- /dev/null +++ b/src/csharp/Grpc.IntegrationTesting/MetricsGrpc.cs @@ -0,0 +1,146 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: src/proto/grpc/testing/metrics.proto +#region Designer generated code + +using System; +using System.Threading; +using System.Threading.Tasks; +using Grpc.Core; + +namespace Grpc.Testing { + public static class MetricsService + { + static readonly string __ServiceName = "grpc.testing.MetricsService"; + + static readonly Marshaller<global::Grpc.Testing.EmptyMessage> __Marshaller_EmptyMessage = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.EmptyMessage.Parser.ParseFrom); + static readonly Marshaller<global::Grpc.Testing.GaugeResponse> __Marshaller_GaugeResponse = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.GaugeResponse.Parser.ParseFrom); + static readonly Marshaller<global::Grpc.Testing.GaugeRequest> __Marshaller_GaugeRequest = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.GaugeRequest.Parser.ParseFrom); + + static readonly Method<global::Grpc.Testing.EmptyMessage, global::Grpc.Testing.GaugeResponse> __Method_GetAllGauges = new Method<global::Grpc.Testing.EmptyMessage, global::Grpc.Testing.GaugeResponse>( + MethodType.ServerStreaming, + __ServiceName, + "GetAllGauges", + __Marshaller_EmptyMessage, + __Marshaller_GaugeResponse); + + static readonly Method<global::Grpc.Testing.GaugeRequest, global::Grpc.Testing.GaugeResponse> __Method_GetGauge = new Method<global::Grpc.Testing.GaugeRequest, global::Grpc.Testing.GaugeResponse>( + MethodType.Unary, + __ServiceName, + "GetGauge", + __Marshaller_GaugeRequest, + __Marshaller_GaugeResponse); + + // service descriptor + public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor + { + get { return global::Grpc.Testing.MetricsReflection.Descriptor.Services[0]; } + } + + // client interface + [System.Obsolete("Client side interfaced will be removed in the next release. Use client class directly.")] + public interface IMetricsServiceClient + { + AsyncServerStreamingCall<global::Grpc.Testing.GaugeResponse> GetAllGauges(global::Grpc.Testing.EmptyMessage request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)); + AsyncServerStreamingCall<global::Grpc.Testing.GaugeResponse> GetAllGauges(global::Grpc.Testing.EmptyMessage request, CallOptions options); + global::Grpc.Testing.GaugeResponse GetGauge(global::Grpc.Testing.GaugeRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)); + global::Grpc.Testing.GaugeResponse GetGauge(global::Grpc.Testing.GaugeRequest request, CallOptions options); + AsyncUnaryCall<global::Grpc.Testing.GaugeResponse> GetGaugeAsync(global::Grpc.Testing.GaugeRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)); + AsyncUnaryCall<global::Grpc.Testing.GaugeResponse> GetGaugeAsync(global::Grpc.Testing.GaugeRequest request, CallOptions options); + } + + // server-side interface + [System.Obsolete("Service implementations should inherit from the generated abstract base class instead.")] + public interface IMetricsService + { + Task GetAllGauges(global::Grpc.Testing.EmptyMessage request, IServerStreamWriter<global::Grpc.Testing.GaugeResponse> responseStream, ServerCallContext context); + Task<global::Grpc.Testing.GaugeResponse> GetGauge(global::Grpc.Testing.GaugeRequest request, ServerCallContext context); + } + + // server-side abstract class + public abstract class MetricsServiceBase + { + public virtual Task GetAllGauges(global::Grpc.Testing.EmptyMessage request, IServerStreamWriter<global::Grpc.Testing.GaugeResponse> responseStream, ServerCallContext context) + { + throw new RpcException(new Status(StatusCode.Unimplemented, "")); + } + + public virtual Task<global::Grpc.Testing.GaugeResponse> GetGauge(global::Grpc.Testing.GaugeRequest request, ServerCallContext context) + { + throw new RpcException(new Status(StatusCode.Unimplemented, "")); + } + + } + + // client stub + public class MetricsServiceClient : ClientBase<MetricsServiceClient>, IMetricsServiceClient + { + public MetricsServiceClient(Channel channel) : base(channel) + { + } + public MetricsServiceClient(CallInvoker callInvoker) : base(callInvoker) + { + } + ///<summary>Protected parameterless constructor to allow creation of test doubles.</summary> + protected MetricsServiceClient() : base() + { + } + ///<summary>Protected constructor to allow creation of configured clients.</summary> + protected MetricsServiceClient(ClientBaseConfiguration configuration) : base(configuration) + { + } + + public virtual AsyncServerStreamingCall<global::Grpc.Testing.GaugeResponse> GetAllGauges(global::Grpc.Testing.EmptyMessage request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + { + return GetAllGauges(request, new CallOptions(headers, deadline, cancellationToken)); + } + public virtual AsyncServerStreamingCall<global::Grpc.Testing.GaugeResponse> GetAllGauges(global::Grpc.Testing.EmptyMessage request, CallOptions options) + { + return CallInvoker.AsyncServerStreamingCall(__Method_GetAllGauges, null, options, request); + } + public virtual global::Grpc.Testing.GaugeResponse GetGauge(global::Grpc.Testing.GaugeRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + { + return GetGauge(request, new CallOptions(headers, deadline, cancellationToken)); + } + public virtual global::Grpc.Testing.GaugeResponse GetGauge(global::Grpc.Testing.GaugeRequest request, CallOptions options) + { + return CallInvoker.BlockingUnaryCall(__Method_GetGauge, null, options, request); + } + public virtual AsyncUnaryCall<global::Grpc.Testing.GaugeResponse> GetGaugeAsync(global::Grpc.Testing.GaugeRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + { + return GetGaugeAsync(request, new CallOptions(headers, deadline, cancellationToken)); + } + public virtual AsyncUnaryCall<global::Grpc.Testing.GaugeResponse> GetGaugeAsync(global::Grpc.Testing.GaugeRequest request, CallOptions options) + { + return CallInvoker.AsyncUnaryCall(__Method_GetGauge, null, options, request); + } + protected override MetricsServiceClient NewInstance(ClientBaseConfiguration configuration) + { + return new MetricsServiceClient(configuration); + } + } + + // creates service definition that can be registered with a server + public static ServerServiceDefinition BindService(IMetricsService serviceImpl) + { + return ServerServiceDefinition.CreateBuilder(__ServiceName) + .AddMethod(__Method_GetAllGauges, serviceImpl.GetAllGauges) + .AddMethod(__Method_GetGauge, serviceImpl.GetGauge).Build(); + } + + // creates service definition that can be registered with a server + public static ServerServiceDefinition BindService(MetricsServiceBase serviceImpl) + { + return ServerServiceDefinition.CreateBuilder(__ServiceName) + .AddMethod(__Method_GetAllGauges, serviceImpl.GetAllGauges) + .AddMethod(__Method_GetGauge, serviceImpl.GetGauge).Build(); + } + + // creates a new client + public static MetricsServiceClient NewClient(Channel channel) + { + return new MetricsServiceClient(channel); + } + + } +} +#endregion diff --git a/src/csharp/Grpc.IntegrationTesting/StressTestClient.cs b/src/csharp/Grpc.IntegrationTesting/StressTestClient.cs new file mode 100644 index 0000000000..8db691cb04 --- /dev/null +++ b/src/csharp/Grpc.IntegrationTesting/StressTestClient.cs @@ -0,0 +1,318 @@ +#region Copyright notice and license + +// Copyright 2015-2016, 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. + +#endregion + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; + +using CommandLine; +using CommandLine.Text; +using Grpc.Core; +using Grpc.Core.Logging; +using Grpc.Core.Utils; +using Grpc.Testing; + +namespace Grpc.IntegrationTesting +{ + public class StressTestClient + { + static readonly ILogger Logger = GrpcEnvironment.Logger.ForType<StressTestClient>(); + const double SecondsToNanos = 1e9; + + private class ClientOptions + { + [Option("server_addresses", DefaultValue = "localhost:8080")] + public string ServerAddresses { get; set; } + + [Option("test_cases", DefaultValue = "large_unary:100")] + public string TestCases { get; set; } + + [Option("test_duration_secs", DefaultValue = -1)] + public int TestDurationSecs { get; set; } + + [Option("num_channels_per_server", DefaultValue = 1)] + public int NumChannelsPerServer { get; set; } + + [Option("num_stubs_per_channel", DefaultValue = 1)] + public int NumStubsPerChannel { get; set; } + + [Option("metrics_port", DefaultValue = 8081)] + public int MetricsPort { get; set; } + + [HelpOption] + public string GetUsage() + { + var help = new HelpText + { + Heading = "gRPC C# stress test client", + AddDashesToOption = true + }; + help.AddPreOptionsLine("Usage:"); + help.AddOptions(this); + return help; + } + } + + ClientOptions options; + List<string> serverAddresses; + Dictionary<string, int> weightedTestCases; + WeightedRandomGenerator testCaseGenerator; + + // cancellation will be emitted once test_duration_secs has elapsed. + CancellationTokenSource finishedTokenSource = new CancellationTokenSource(); + Histogram histogram = new Histogram(0.01, 60 * SecondsToNanos); + + private StressTestClient(ClientOptions options, List<string> serverAddresses, Dictionary<string, int> weightedTestCases) + { + this.options = options; + this.serverAddresses = serverAddresses; + this.weightedTestCases = weightedTestCases; + this.testCaseGenerator = new WeightedRandomGenerator(this.weightedTestCases); + } + + public static void Run(string[] args) + { + var options = new ClientOptions(); + if (!Parser.Default.ParseArguments(args, options)) + { + Environment.Exit(1); + } + + GrpcPreconditions.CheckArgument(options.NumChannelsPerServer > 0); + GrpcPreconditions.CheckArgument(options.NumStubsPerChannel > 0); + + var serverAddresses = options.ServerAddresses.Split(','); + GrpcPreconditions.CheckArgument(serverAddresses.Length > 0, "You need to provide at least one server address"); + + var testCases = ParseWeightedTestCases(options.TestCases); + GrpcPreconditions.CheckArgument(testCases.Count > 0, "You need to provide at least one test case"); + + var interopClient = new StressTestClient(options, serverAddresses.ToList(), testCases); + interopClient.Run().Wait(); + } + + async Task Run() + { + var metricsServer = new Server() + { + Services = { MetricsService.BindService(new MetricsServiceImpl(histogram)) }, + Ports = { { "[::]", options.MetricsPort, ServerCredentials.Insecure } } + }; + metricsServer.Start(); + + if (options.TestDurationSecs >= 0) + { + finishedTokenSource.CancelAfter(TimeSpan.FromSeconds(options.TestDurationSecs)); + } + + var tasks = new List<Task>(); + var channels = new List<Channel>(); + foreach (var serverAddress in serverAddresses) + { + for (int i = 0; i < options.NumChannelsPerServer; i++) + { + var channel = new Channel(serverAddress, ChannelCredentials.Insecure); + channels.Add(channel); + for (int j = 0; j < options.NumStubsPerChannel; j++) + { + var client = TestService.NewClient(channel); + var task = Task.Factory.StartNew(() => RunBodyAsync(client).GetAwaiter().GetResult(), + TaskCreationOptions.LongRunning); + tasks.Add(task); + } + } + } + await Task.WhenAll(tasks); + + foreach (var channel in channels) + { + await channel.ShutdownAsync(); + } + + await metricsServer.ShutdownAsync(); + } + + async Task RunBodyAsync(TestService.TestServiceClient client) + { + Logger.Info("Starting stress test client thread."); + while (!finishedTokenSource.Token.IsCancellationRequested) + { + var testCase = testCaseGenerator.GetNext(); + + var stopwatch = Stopwatch.StartNew(); + + await RunTestCaseAsync(client, testCase); + + stopwatch.Stop(); + histogram.AddObservation(stopwatch.Elapsed.TotalSeconds * SecondsToNanos); + } + Logger.Info("Stress test client thread finished."); + } + + async Task RunTestCaseAsync(TestService.TestServiceClient client, string testCase) + { + switch (testCase) + { + case "empty_unary": + InteropClient.RunEmptyUnary(client); + break; + case "large_unary": + InteropClient.RunLargeUnary(client); + break; + case "client_streaming": + await InteropClient.RunClientStreamingAsync(client); + break; + case "server_streaming": + await InteropClient.RunServerStreamingAsync(client); + break; + case "ping_pong": + await InteropClient.RunPingPongAsync(client); + break; + case "empty_stream": + await InteropClient.RunEmptyStreamAsync(client); + break; + case "cancel_after_begin": + await InteropClient.RunCancelAfterBeginAsync(client); + break; + case "cancel_after_first_response": + await InteropClient.RunCancelAfterFirstResponseAsync(client); + break; + case "timeout_on_sleeping_server": + await InteropClient.RunTimeoutOnSleepingServerAsync(client); + break; + case "custom_metadata": + await InteropClient.RunCustomMetadataAsync(client); + break; + case "status_code_and_message": + await InteropClient.RunStatusCodeAndMessageAsync(client); + break; + default: + throw new ArgumentException("Unsupported test case " + testCase); + } + } + + static Dictionary<string, int> ParseWeightedTestCases(string weightedTestCases) + { + var result = new Dictionary<string, int>(); + foreach (var weightedTestCase in weightedTestCases.Split(',')) + { + var parts = weightedTestCase.Split(new char[] {':'}, 2); + GrpcPreconditions.CheckArgument(parts.Length == 2, "Malformed test_cases option."); + result.Add(parts[0], int.Parse(parts[1])); + } + return result; + } + + class WeightedRandomGenerator + { + readonly Random random = new Random(); + readonly List<Tuple<int, string>> cumulativeSums; + readonly int weightSum; + + public WeightedRandomGenerator(Dictionary<string, int> weightedItems) + { + cumulativeSums = new List<Tuple<int, string>>(); + weightSum = 0; + foreach (var entry in weightedItems) + { + weightSum += entry.Value; + cumulativeSums.Add(Tuple.Create(weightSum, entry.Key)); + } + } + + public string GetNext() + { + int rand = random.Next(weightSum); + foreach (var entry in cumulativeSums) + { + if (rand < entry.Item1) + { + return entry.Item2; + } + } + throw new InvalidOperationException("GetNext() failed."); + } + } + + class MetricsServiceImpl : MetricsService.MetricsServiceBase + { + const string GaugeName = "csharp_overall_qps"; + + readonly Histogram histogram; + readonly WallClockStopwatch wallClockStopwatch = new WallClockStopwatch(); + + public MetricsServiceImpl(Histogram histogram) + { + this.histogram = histogram; + } + + public override Task<GaugeResponse> GetGauge(GaugeRequest request, ServerCallContext context) + { + if (request.Name == GaugeName) + { + long qps = GetQpsAndReset(); + + return Task.FromResult(new GaugeResponse + { + Name = GaugeName, + LongValue = qps + }); + } + throw new RpcException(new Status(StatusCode.InvalidArgument, "Gauge does not exist")); + } + + public override async Task GetAllGauges(EmptyMessage request, IServerStreamWriter<GaugeResponse> responseStream, ServerCallContext context) + { + long qps = GetQpsAndReset(); + + var response = new GaugeResponse + { + Name = GaugeName, + LongValue = qps + }; + await responseStream.WriteAsync(response); + } + + long GetQpsAndReset() + { + var snapshot = histogram.GetSnapshot(true); + var elapsedSnapshot = wallClockStopwatch.GetElapsedSnapshot(true); + + return (long) (snapshot.Count / elapsedSnapshot.Seconds); + } + } + } +} diff --git a/src/csharp/Grpc.IntegrationTesting/Test.cs b/src/csharp/Grpc.IntegrationTesting/Test.cs index 91e0a1e04c..363f6444ec 100644 --- a/src/csharp/Grpc.IntegrationTesting/Test.cs +++ b/src/csharp/Grpc.IntegrationTesting/Test.cs @@ -40,10 +40,10 @@ namespace Grpc.Testing { "bWluZ091dHB1dENhbGxSZXF1ZXN0GikuZ3JwYy50ZXN0aW5nLlN0cmVhbWlu", "Z091dHB1dENhbGxSZXNwb25zZSgBMAEyVQoUVW5pbXBsZW1lbnRlZFNlcnZp", "Y2USPQoRVW5pbXBsZW1lbnRlZENhbGwSEy5ncnBjLnRlc3RpbmcuRW1wdHka", - "Ey5ncnBjLnRlc3RpbmcuRW1wdHkyfwoQUmVjb25uZWN0U2VydmljZRIxCgVT", - "dGFydBITLmdycGMudGVzdGluZy5FbXB0eRoTLmdycGMudGVzdGluZy5FbXB0", - "eRI4CgRTdG9wEhMuZ3JwYy50ZXN0aW5nLkVtcHR5GhsuZ3JwYy50ZXN0aW5n", - "LlJlY29ubmVjdEluZm9iBnByb3RvMw==")); + "Ey5ncnBjLnRlc3RpbmcuRW1wdHkyiQEKEFJlY29ubmVjdFNlcnZpY2USOwoF", + "U3RhcnQSHS5ncnBjLnRlc3RpbmcuUmVjb25uZWN0UGFyYW1zGhMuZ3JwYy50", + "ZXN0aW5nLkVtcHR5EjgKBFN0b3ASEy5ncnBjLnRlc3RpbmcuRW1wdHkaGy5n", + "cnBjLnRlc3RpbmcuUmVjb25uZWN0SW5mb2IGcHJvdG8z")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { global::Grpc.Testing.EmptyReflection.Descriptor, global::Grpc.Testing.MessagesReflection.Descriptor, }, new pbr::GeneratedCodeInfo(null, null)); diff --git a/src/csharp/Grpc.IntegrationTesting/TestGrpc.cs b/src/csharp/Grpc.IntegrationTesting/TestGrpc.cs index b84ec2d984..31746cbe71 100644 --- a/src/csharp/Grpc.IntegrationTesting/TestGrpc.cs +++ b/src/csharp/Grpc.IntegrationTesting/TestGrpc.cs @@ -367,14 +367,15 @@ namespace Grpc.Testing { { static readonly string __ServiceName = "grpc.testing.ReconnectService"; + static readonly Marshaller<global::Grpc.Testing.ReconnectParams> __Marshaller_ReconnectParams = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.ReconnectParams.Parser.ParseFrom); static readonly Marshaller<global::Grpc.Testing.Empty> __Marshaller_Empty = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.Empty.Parser.ParseFrom); static readonly Marshaller<global::Grpc.Testing.ReconnectInfo> __Marshaller_ReconnectInfo = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.ReconnectInfo.Parser.ParseFrom); - static readonly Method<global::Grpc.Testing.Empty, global::Grpc.Testing.Empty> __Method_Start = new Method<global::Grpc.Testing.Empty, global::Grpc.Testing.Empty>( + static readonly Method<global::Grpc.Testing.ReconnectParams, global::Grpc.Testing.Empty> __Method_Start = new Method<global::Grpc.Testing.ReconnectParams, global::Grpc.Testing.Empty>( MethodType.Unary, __ServiceName, "Start", - __Marshaller_Empty, + __Marshaller_ReconnectParams, __Marshaller_Empty); static readonly Method<global::Grpc.Testing.Empty, global::Grpc.Testing.ReconnectInfo> __Method_Stop = new Method<global::Grpc.Testing.Empty, global::Grpc.Testing.ReconnectInfo>( @@ -394,10 +395,10 @@ namespace Grpc.Testing { [System.Obsolete("Client side interfaced will be removed in the next release. Use client class directly.")] public interface IReconnectServiceClient { - global::Grpc.Testing.Empty Start(global::Grpc.Testing.Empty request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)); - global::Grpc.Testing.Empty Start(global::Grpc.Testing.Empty request, CallOptions options); - AsyncUnaryCall<global::Grpc.Testing.Empty> StartAsync(global::Grpc.Testing.Empty request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)); - AsyncUnaryCall<global::Grpc.Testing.Empty> StartAsync(global::Grpc.Testing.Empty request, CallOptions options); + global::Grpc.Testing.Empty Start(global::Grpc.Testing.ReconnectParams request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)); + global::Grpc.Testing.Empty Start(global::Grpc.Testing.ReconnectParams request, CallOptions options); + AsyncUnaryCall<global::Grpc.Testing.Empty> StartAsync(global::Grpc.Testing.ReconnectParams request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)); + AsyncUnaryCall<global::Grpc.Testing.Empty> StartAsync(global::Grpc.Testing.ReconnectParams request, CallOptions options); global::Grpc.Testing.ReconnectInfo Stop(global::Grpc.Testing.Empty request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)); global::Grpc.Testing.ReconnectInfo Stop(global::Grpc.Testing.Empty request, CallOptions options); AsyncUnaryCall<global::Grpc.Testing.ReconnectInfo> StopAsync(global::Grpc.Testing.Empty request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)); @@ -408,14 +409,14 @@ namespace Grpc.Testing { [System.Obsolete("Service implementations should inherit from the generated abstract base class instead.")] public interface IReconnectService { - Task<global::Grpc.Testing.Empty> Start(global::Grpc.Testing.Empty request, ServerCallContext context); + Task<global::Grpc.Testing.Empty> Start(global::Grpc.Testing.ReconnectParams request, ServerCallContext context); Task<global::Grpc.Testing.ReconnectInfo> Stop(global::Grpc.Testing.Empty request, ServerCallContext context); } // server-side abstract class public abstract class ReconnectServiceBase { - public virtual Task<global::Grpc.Testing.Empty> Start(global::Grpc.Testing.Empty request, ServerCallContext context) + public virtual Task<global::Grpc.Testing.Empty> Start(global::Grpc.Testing.ReconnectParams request, ServerCallContext context) { throw new RpcException(new Status(StatusCode.Unimplemented, "")); } @@ -445,19 +446,19 @@ namespace Grpc.Testing { { } - public virtual global::Grpc.Testing.Empty Start(global::Grpc.Testing.Empty request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + public virtual global::Grpc.Testing.Empty Start(global::Grpc.Testing.ReconnectParams request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { return Start(request, new CallOptions(headers, deadline, cancellationToken)); } - public virtual global::Grpc.Testing.Empty Start(global::Grpc.Testing.Empty request, CallOptions options) + public virtual global::Grpc.Testing.Empty Start(global::Grpc.Testing.ReconnectParams request, CallOptions options) { return CallInvoker.BlockingUnaryCall(__Method_Start, null, options, request); } - public virtual AsyncUnaryCall<global::Grpc.Testing.Empty> StartAsync(global::Grpc.Testing.Empty request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + public virtual AsyncUnaryCall<global::Grpc.Testing.Empty> StartAsync(global::Grpc.Testing.ReconnectParams request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { return StartAsync(request, new CallOptions(headers, deadline, cancellationToken)); } - public virtual AsyncUnaryCall<global::Grpc.Testing.Empty> StartAsync(global::Grpc.Testing.Empty request, CallOptions options) + public virtual AsyncUnaryCall<global::Grpc.Testing.Empty> StartAsync(global::Grpc.Testing.ReconnectParams request, CallOptions options) { return CallInvoker.AsyncUnaryCall(__Method_Start, null, options, request); } diff --git a/src/csharp/Grpc.sln b/src/csharp/Grpc.sln index 8ff35e8c0d..9be36c0caa 100644 --- a/src/csharp/Grpc.sln +++ b/src/csharp/Grpc.sln @@ -34,6 +34,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Grpc.HealthCheck.Tests", "G EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Grpc.IntegrationTesting.QpsWorker", "Grpc.IntegrationTesting.QpsWorker\Grpc.IntegrationTesting.QpsWorker.csproj", "{B82B7DFE-7F7B-40EF-B3D6-064FF2B01294}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Grpc.IntegrationTesting.StressClient", "Grpc.IntegrationTesting.StressClient\Grpc.IntegrationTesting.StressClient.csproj", "{ADEBA147-80AE-4710-82E9-5B7F93690266}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -83,6 +85,12 @@ Global {AA5E328A-8835-49D7-98ED-C29F2B3049F0}.Release|Any CPU.Build.0 = Release|Any CPU
{AA5E328A-8835-49D7-98ED-C29F2B3049F0}.ReleaseSigned|Any CPU.ActiveCfg = ReleaseSigned|Any CPU
{AA5E328A-8835-49D7-98ED-C29F2B3049F0}.ReleaseSigned|Any CPU.Build.0 = ReleaseSigned|Any CPU
+ {ADEBA147-80AE-4710-82E9-5B7F93690266}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {ADEBA147-80AE-4710-82E9-5B7F93690266}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {ADEBA147-80AE-4710-82E9-5B7F93690266}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {ADEBA147-80AE-4710-82E9-5B7F93690266}.Release|Any CPU.Build.0 = Release|Any CPU
+ {ADEBA147-80AE-4710-82E9-5B7F93690266}.ReleaseSigned|Any CPU.ActiveCfg = Release|Any CPU
+ {ADEBA147-80AE-4710-82E9-5B7F93690266}.ReleaseSigned|Any CPU.Build.0 = Release|Any CPU
{AE21D0EE-9A2C-4C15-AB7F-5224EED5B0EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AE21D0EE-9A2C-4C15-AB7F-5224EED5B0EA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AE21D0EE-9A2C-4C15-AB7F-5224EED5B0EA}.Release|Any CPU.ActiveCfg = Release|Any CPU
diff --git a/src/csharp/ext/grpc_csharp_ext.c b/src/csharp/ext/grpc_csharp_ext.c index 8d769e5f6a..aeef8a79e9 100644 --- a/src/csharp/ext/grpc_csharp_ext.c +++ b/src/csharp/ext/grpc_csharp_ext.c @@ -911,9 +911,12 @@ grpcsharp_ssl_server_credentials_create( key_cert_pairs[i].private_key = key_cert_pair_private_key_array[i]; } } - creds = grpc_ssl_server_credentials_create(pem_root_certs, key_cert_pairs, - num_key_cert_pairs, - force_client_auth, NULL); + creds = grpc_ssl_server_credentials_create_ex( + pem_root_certs, key_cert_pairs, num_key_cert_pairs, + force_client_auth + ? GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY + : GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE, + NULL); gpr_free(key_cert_pairs); return creds; } diff --git a/src/csharp/generate_proto_csharp.sh b/src/csharp/generate_proto_csharp.sh index 9ac770b79d..79488e02a5 100755 --- a/src/csharp/generate_proto_csharp.sh +++ b/src/csharp/generate_proto_csharp.sh @@ -45,4 +45,4 @@ $PROTOC --plugin=$PLUGIN --csharp_out=$HEALTHCHECK_DIR --grpc_out=$HEALTHCHECK_D -I src/proto/grpc/health/v1 src/proto/grpc/health/v1/health.proto $PROTOC --plugin=$PLUGIN --csharp_out=$TESTING_DIR --grpc_out=$TESTING_DIR \ - -I . src/proto/grpc/testing/{control,empty,messages,payloads,services,stats,test}.proto + -I . src/proto/grpc/testing/{control,empty,messages,metrics,payloads,services,stats,test}.proto diff --git a/src/node/ext/server_credentials.cc b/src/node/ext/server_credentials.cc index 5285d53df4..cff821aafc 100644 --- a/src/node/ext/server_credentials.cc +++ b/src/node/ext/server_credentials.cc @@ -145,9 +145,13 @@ NAN_METHOD(ServerCredentials::CreateSsl) { return Nan::ThrowTypeError( "createSsl's second argument must be a list of objects"); } - int force_client_auth = 0; + + grpc_ssl_client_certificate_request_type client_certificate_request; if (info[2]->IsBoolean()) { - force_client_auth = (int)Nan::To<bool>(info[2]).FromJust(); + client_certificate_request = + Nan::To<bool>(info[2]).FromJust() + ? GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY + : GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE; } else if (!(info[2]->IsUndefined() || info[2]->IsNull())) { return Nan::ThrowTypeError( "createSsl's third argument must be a boolean if provided"); @@ -180,8 +184,9 @@ NAN_METHOD(ServerCredentials::CreateSsl) { key_cert_pairs[i].private_key = ::node::Buffer::Data(maybe_key); key_cert_pairs[i].cert_chain = ::node::Buffer::Data(maybe_cert); } - grpc_server_credentials *creds = grpc_ssl_server_credentials_create( - root_certs, key_cert_pairs, key_cert_pair_count, force_client_auth, NULL); + grpc_server_credentials *creds = grpc_ssl_server_credentials_create_ex( + root_certs, key_cert_pairs, key_cert_pair_count, + client_certificate_request, NULL); delete key_cert_pairs; if (creds == NULL) { info.GetReturnValue().SetNull(); diff --git a/src/node/performance/worker.js b/src/node/performance/worker.js index 98577bdbc9..7ef9b84fe7 100644 --- a/src/node/performance/worker.js +++ b/src/node/performance/worker.js @@ -33,6 +33,7 @@ 'use strict'; +var console = require('console'); var worker_service_impl = require('./worker_service_impl'); var grpc = require('../../../'); @@ -48,6 +49,7 @@ function runServer(port) { var address = '0.0.0.0:' + port; server.bind(address, server_creds); server.start(); + console.log('running QPS worker on %s', address); return server; } diff --git a/src/node/performance/worker_service_impl.js b/src/node/performance/worker_service_impl.js index 17458e4b93..4b5cb8f9c2 100644 --- a/src/node/performance/worker_service_impl.js +++ b/src/node/performance/worker_service_impl.js @@ -34,6 +34,7 @@ 'use strict'; var os = require('os'); +var console = require('console'); var BenchmarkClient = require('./benchmark_client'); var BenchmarkServer = require('./benchmark_server'); @@ -49,6 +50,7 @@ exports.runClient = function runClient(call) { switch (request.argtype) { case 'setup': var setup = request.setup; + console.log('ClientConfig %j', setup); client = new BenchmarkClient(setup.server_targets, setup.client_channels, setup.histogram_params, @@ -118,6 +120,7 @@ exports.runServer = function runServer(call) { var stats; switch (request.argtype) { case 'setup': + console.log('ServerConfig %j', request.setup); server = new BenchmarkServer('[::]', request.setup.port, request.setup.security_params); server.start(); diff --git a/src/php/ext/grpc/server_credentials.c b/src/php/ext/grpc/server_credentials.c index 79188246bc..f3951b31fe 100644 --- a/src/php/ext/grpc/server_credentials.c +++ b/src/php/ext/grpc/server_credentials.c @@ -115,10 +115,11 @@ PHP_METHOD(ServerCredentials, createSsl) { "createSsl expects 3 strings", 1 TSRMLS_CC); return; } - /* TODO: add a force_client_auth field in ServerCredentials and pass it as - * the last parameter. */ - grpc_server_credentials *creds = grpc_ssl_server_credentials_create( - pem_root_certs, &pem_key_cert_pair, 1, 0, NULL); + /* TODO: add a client_certificate_request field in ServerCredentials and pass + * it as the last parameter. */ + grpc_server_credentials *creds = grpc_ssl_server_credentials_create_ex( + pem_root_certs, &pem_key_cert_pair, 1, + GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE, NULL); zval *creds_object = grpc_php_wrap_server_credentials(creds); RETURN_DESTROY_ZVAL(creds_object); } diff --git a/src/php/tests/bootstrap.php b/src/php/tests/bootstrap.php index b61f2c40a5..8b3d4347e2 100644 --- a/src/php/tests/bootstrap.php +++ b/src/php/tests/bootstrap.php @@ -17,5 +17,5 @@ */ error_reporting(E_ALL | E_STRICT); -require dirname(__DIR__) . '/vendor/autoload.php'; +require dirname(__DIR__).'/vendor/autoload.php'; date_default_timezone_set('UTC'); diff --git a/src/php/tests/generated_code/GeneratedCodeWithCallbackTest.php b/src/php/tests/generated_code/GeneratedCodeWithCallbackTest.php index 6bb1955ccb..6b70b8ac10 100644 --- a/src/php/tests/generated_code/GeneratedCodeWithCallbackTest.php +++ b/src/php/tests/generated_code/GeneratedCodeWithCallbackTest.php @@ -46,7 +46,8 @@ class GeneratedCodeWithCallbackTest extends AbstractGeneratedCodeTest $a_copy['foo'] = ['bar']; return $a_copy; - }]); + }, + ]); } public function tearDown() diff --git a/src/php/tests/generated_code/math_client.php b/src/php/tests/generated_code/math_client.php index b8652ceb08..6ee92bc465 100644 --- a/src/php/tests/generated_code/math_client.php +++ b/src/php/tests/generated_code/math_client.php @@ -38,13 +38,13 @@ include 'tests/generated_code/math.php'; function p($line) { - print("$line<br/>\n"); + echo "$line<br/>\n"; } $host = 'localhost:50051'; p("Connecting to host: $host"); $client = new math\MathClient($host, [ - 'credentials' => Grpc\ChannelCredentials::createInsecure() + 'credentials' => Grpc\ChannelCredentials::createInsecure(), ]); p('Client class: '.get_class($client)); p(''); diff --git a/src/php/tests/unit_tests/CallCredentials3Test.php b/src/php/tests/unit_tests/CallCredentials3Test.php index 6d98815d16..8f5e109bf5 100644 --- a/src/php/tests/unit_tests/CallCredentials3Test.php +++ b/src/php/tests/unit_tests/CallCredentials3Test.php @@ -132,5 +132,4 @@ class CallCredentials3Test extends PHPUnit_Framework_TestCase unset($call); unset($server_call); } - } diff --git a/src/php/tests/unit_tests/CallTest.php b/src/php/tests/unit_tests/CallTest.php index 1170a440fa..fa026f0935 100755 --- a/src/php/tests/unit_tests/CallTest.php +++ b/src/php/tests/unit_tests/CallTest.php @@ -94,7 +94,7 @@ class CallTest extends PHPUnit_Framework_TestCase public function testCancel() { - $this->assertNull($this->call->cancel()); + $this->assertNull($this->call->cancel()); } /** @@ -118,5 +118,4 @@ class CallTest extends PHPUnit_Framework_TestCase ]; $result = $this->call->startBatch($batch); } - } diff --git a/src/php/tests/unit_tests/ChannelCredentialsTest.php b/src/php/tests/unit_tests/ChannelCredentialsTest.php index 1a42d69428..56c1d8f006 100644 --- a/src/php/tests/unit_tests/ChannelCredentialsTest.php +++ b/src/php/tests/unit_tests/ChannelCredentialsTest.php @@ -70,4 +70,4 @@ class ChanellCredentialsTest extends PHPUnit_Framework_TestCase $channel_credentials = Grpc\ChannelCredentials::createInsecure(); $this->assertNull($channel_credentials); } -}
\ No newline at end of file +} diff --git a/src/php/tests/unit_tests/ChannelTest.php b/src/php/tests/unit_tests/ChannelTest.php index b6eac3109a..a1f9053c39 100644 --- a/src/php/tests/unit_tests/ChannelTest.php +++ b/src/php/tests/unit_tests/ChannelTest.php @@ -78,5 +78,4 @@ class ChannelTest extends PHPUnit_Framework_TestCase ] ); } - -}
\ No newline at end of file +} diff --git a/src/php/tests/unit_tests/EndToEndTest.php b/src/php/tests/unit_tests/EndToEndTest.php index 3fa92c950b..2b09f9d112 100755 --- a/src/php/tests/unit_tests/EndToEndTest.php +++ b/src/php/tests/unit_tests/EndToEndTest.php @@ -261,7 +261,8 @@ class EndToEndTest extends PHPUnit_Framework_TestCase Grpc\OP_SEND_INITIAL_METADATA => [], Grpc\OP_SEND_CLOSE_FROM_CLIENT => true, Grpc\OP_SEND_MESSAGE => ['message' => 'abc', - 'flags' => 'invalid'], + 'flags' => 'invalid', + ], ]); } @@ -574,7 +575,7 @@ class EndToEndTest extends PHPUnit_Framework_TestCase public function testGetConnectivityStateInvalidParam() { $this->assertTrue($this->channel->getConnectivityState( - new Grpc\Timeval)); + new Grpc\Timeval())); } /** @@ -591,12 +592,11 @@ class EndToEndTest extends PHPUnit_Framework_TestCase */ public function testChannelConstructorInvalidParam() { - $this->channel = new Grpc\Channel('localhost:'.$this->port, NULL); + $this->channel = new Grpc\Channel('localhost:'.$this->port, null); } public function testClose() { $this->assertNull($this->channel->close()); } - } diff --git a/src/php/tests/unit_tests/ServerTest.php b/src/php/tests/unit_tests/ServerTest.php index d18f9abe9b..76aaa06970 100644 --- a/src/php/tests/unit_tests/ServerTest.php +++ b/src/php/tests/unit_tests/ServerTest.php @@ -67,5 +67,4 @@ class ServerTest extends PHPUnit_Framework_TestCase $this->server = new Grpc\Server([]); $this->port = $this->server->addSecureHttp2Port(['0.0.0.0:0']); } - -}
\ No newline at end of file +} diff --git a/src/php/tests/unit_tests/TimevalTest.php b/src/php/tests/unit_tests/TimevalTest.php index 43abba126a..a3dbce079f 100755 --- a/src/php/tests/unit_tests/TimevalTest.php +++ b/src/php/tests/unit_tests/TimevalTest.php @@ -94,13 +94,13 @@ class TimevalTest extends PHPUnit_Framework_TestCase public function testSimilar() { - $a = Grpc\Timeval::now(); - $delta = new Grpc\Timeval(1000); - $b = $a->add($delta); - $thresh = new Grpc\Timeval(1100); - $this->assertTrue(Grpc\Timeval::similar($a, $b, $thresh)); - $thresh = new Grpc\Timeval(900); - $this->assertFalse(Grpc\Timeval::similar($a, $b, $thresh)); + $a = Grpc\Timeval::now(); + $delta = new Grpc\Timeval(1000); + $b = $a->add($delta); + $thresh = new Grpc\Timeval(1100); + $this->assertTrue(Grpc\Timeval::similar($a, $b, $thresh)); + $thresh = new Grpc\Timeval(900); + $this->assertFalse(Grpc\Timeval::similar($a, $b, $thresh)); } public function testSleepUntil() @@ -155,5 +155,4 @@ class TimevalTest extends PHPUnit_Framework_TestCase { $a = Grpc\Timeval::similar(1000, 1100, 1200); } - } diff --git a/src/proto/grpc/testing/control.proto b/src/proto/grpc/testing/control.proto index 458b19c4d6..20496a8116 100644 --- a/src/proto/grpc/testing/control.proto +++ b/src/proto/grpc/testing/control.proto @@ -35,14 +35,18 @@ import "src/proto/grpc/testing/stats.proto"; package grpc.testing; enum ClientType { + // Many languages support a basic distinction between using + // sync or async client, and this allows the specification SYNC_CLIENT = 0; ASYNC_CLIENT = 1; + OTHER_CLIENT = 2; // used for some language-specific variants } enum ServerType { SYNC_SERVER = 0; ASYNC_SERVER = 1; ASYNC_GENERIC_SERVER = 2; + OTHER_SERVER = 3; // used for some language-specific variants } enum RpcType { @@ -57,18 +61,6 @@ message PoissonParams { double offered_load = 1; } -message UniformParams { - double interarrival_lo = 1; - double interarrival_hi = 2; -} - -message DeterministicParams { double offered_load = 1; } - -message ParetoParams { - double interarrival_base = 1; - double alpha = 2; -} - // Once an RPC finishes, immediately start a new one. // No configuration parameters needed. message ClosedLoopParams {} @@ -77,9 +69,6 @@ message LoadParams { oneof load { ClosedLoopParams closed_loop = 1; PoissonParams poisson = 2; - UniformParams uniform = 3; - DeterministicParams determ = 4; - ParetoParams pareto = 5; }; } @@ -111,6 +100,9 @@ message ClientConfig { // Specify the cores we should run the client on, if desired repeated int32 core_list = 13; int32 core_limit = 14; + + // If we use an OTHER_CLIENT client_type, this string gives more detail + string other_client_api = 15; } message ClientStatus { ClientStats stats = 1; } @@ -142,6 +134,9 @@ message ServerConfig { // Specify the cores we should run the server on, if desired repeated int32 core_list = 10; + + // If we use an OTHER_SERVER client_type, this string gives more detail + string other_server_api = 11; } message ServerArgs { @@ -194,3 +189,44 @@ message Scenario { message Scenarios { repeated Scenario scenarios = 1; } + +// Basic summary that can be computed from ClientStats and ServerStats +// once the scenario has finished. +message ScenarioResultSummary +{ + // Total number of operations per second over all clients. + double qps = 1; + // QPS per one server core. + double qps_per_server_core = 2; + // server load based on system_time (0.85 => 85%) + double server_system_time = 3; + // server load based on user_time (0.85 => 85%) + double server_user_time = 4; + // client load based on system_time (0.85 => 85%) + double client_system_time = 5; + // client load based on user_time (0.85 => 85%) + double client_user_time = 6; + + // X% latency percentiles (in nanoseconds) + double latency_50 = 7; + double latency_90 = 8; + double latency_95 = 9; + double latency_99 = 10; + double latency_999 = 11; +} + +// Results of a single benchmark scenario. +message ScenarioResult { + // Inputs used to run the scenario. + Scenario scenario = 1; + // Histograms from all clients merged into one histogram. + HistogramData latencies = 2; + // Client stats for each client + repeated ClientStats client_stats = 3; + // Server stats for each server + repeated ServerStats server_stats = 4; + // Number of cores available to each server + repeated int32 server_cores = 5; + // An after-the-fact computed summary + ScenarioResultSummary summary = 6; +} diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi index 842635f56b..94d13b5999 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi @@ -302,6 +302,8 @@ def server_credentials_ssl(pem_root_certs, pem_key_cert_pairs, (<SslPemKeyCertPair>pem_key_cert_pairs[i]).c_pair) credentials.c_credentials = grpc_ssl_server_credentials_create( c_pem_root_certs, credentials.c_ssl_pem_key_cert_pairs, - credentials.c_ssl_pem_key_cert_pairs_count, force_client_auth, NULL) + credentials.c_ssl_pem_key_cert_pairs_count, + GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY if force_client_auth else GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE, + NULL) return credentials diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi index 7696f8c7f7..3d158a7707 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi @@ -105,6 +105,13 @@ cdef extern from "grpc/_cython/loader.h": GRPC_SSL_ROOTS_OVERRIDE_FAILED_PERMANENTLY GRPC_SSL_ROOTS_OVERRIDE_FAILED + ctypedef enum grpc_ssl_client_certificate_request_type: + GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE, + GRPC_SSL_REQUEST_CLIENT_CERTIFICATE_BUT_DONT_VERIFY + GRPC_SSL_REQUEST_CLIENT_CERTIFICATE_AND_VERIFY + GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_BUT_DONT_VERIFY + GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY + struct grpc_byte_buffer_reader: # We don't care about the internals pass diff --git a/src/python/grpcio/grpc/_cython/imports.generated.c b/src/python/grpcio/grpc/_cython/imports.generated.c index edad9a3131..563e605b75 100644 --- a/src/python/grpcio/grpc/_cython/imports.generated.c +++ b/src/python/grpcio/grpc/_cython/imports.generated.c @@ -153,6 +153,7 @@ grpc_metadata_credentials_create_from_plugin_type grpc_metadata_credentials_crea grpc_secure_channel_create_type grpc_secure_channel_create_import; grpc_server_credentials_release_type grpc_server_credentials_release_import; grpc_ssl_server_credentials_create_type grpc_ssl_server_credentials_create_import; +grpc_ssl_server_credentials_create_ex_type grpc_ssl_server_credentials_create_ex_import; grpc_server_add_secure_http2_port_type grpc_server_add_secure_http2_port_import; grpc_call_set_credentials_type grpc_call_set_credentials_import; grpc_server_credentials_set_auth_metadata_processor_type grpc_server_credentials_set_auth_metadata_processor_import; @@ -175,6 +176,8 @@ grpc_byte_buffer_reader_readall_type grpc_byte_buffer_reader_readall_import; grpc_raw_byte_buffer_from_reader_type grpc_raw_byte_buffer_from_reader_import; gpr_log_type gpr_log_import; gpr_log_message_type gpr_log_message_import; +gpr_set_log_verbosity_type gpr_set_log_verbosity_import; +gpr_log_verbosity_init_type gpr_log_verbosity_init_import; gpr_set_log_function_type gpr_set_log_function_import; gpr_slice_ref_type gpr_slice_ref_import; gpr_slice_unref_type gpr_slice_unref_import; @@ -420,6 +423,7 @@ void pygrpc_load_imports(HMODULE library) { grpc_secure_channel_create_import = (grpc_secure_channel_create_type) GetProcAddress(library, "grpc_secure_channel_create"); grpc_server_credentials_release_import = (grpc_server_credentials_release_type) GetProcAddress(library, "grpc_server_credentials_release"); grpc_ssl_server_credentials_create_import = (grpc_ssl_server_credentials_create_type) GetProcAddress(library, "grpc_ssl_server_credentials_create"); + grpc_ssl_server_credentials_create_ex_import = (grpc_ssl_server_credentials_create_ex_type) GetProcAddress(library, "grpc_ssl_server_credentials_create_ex"); grpc_server_add_secure_http2_port_import = (grpc_server_add_secure_http2_port_type) GetProcAddress(library, "grpc_server_add_secure_http2_port"); grpc_call_set_credentials_import = (grpc_call_set_credentials_type) GetProcAddress(library, "grpc_call_set_credentials"); grpc_server_credentials_set_auth_metadata_processor_import = (grpc_server_credentials_set_auth_metadata_processor_type) GetProcAddress(library, "grpc_server_credentials_set_auth_metadata_processor"); @@ -442,6 +446,8 @@ void pygrpc_load_imports(HMODULE library) { grpc_raw_byte_buffer_from_reader_import = (grpc_raw_byte_buffer_from_reader_type) GetProcAddress(library, "grpc_raw_byte_buffer_from_reader"); gpr_log_import = (gpr_log_type) GetProcAddress(library, "gpr_log"); gpr_log_message_import = (gpr_log_message_type) GetProcAddress(library, "gpr_log_message"); + gpr_set_log_verbosity_import = (gpr_set_log_verbosity_type) GetProcAddress(library, "gpr_set_log_verbosity"); + gpr_log_verbosity_init_import = (gpr_log_verbosity_init_type) GetProcAddress(library, "gpr_log_verbosity_init"); gpr_set_log_function_import = (gpr_set_log_function_type) GetProcAddress(library, "gpr_set_log_function"); gpr_slice_ref_import = (gpr_slice_ref_type) GetProcAddress(library, "gpr_slice_ref"); gpr_slice_unref_import = (gpr_slice_unref_type) GetProcAddress(library, "gpr_slice_unref"); diff --git a/src/python/grpcio/grpc/_cython/imports.generated.h b/src/python/grpcio/grpc/_cython/imports.generated.h index 7354de4ba2..177a0b287e 100644 --- a/src/python/grpcio/grpc/_cython/imports.generated.h +++ b/src/python/grpcio/grpc/_cython/imports.generated.h @@ -409,6 +409,9 @@ extern grpc_server_credentials_release_type grpc_server_credentials_release_impo typedef grpc_server_credentials *(*grpc_ssl_server_credentials_create_type)(const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pairs, size_t num_key_cert_pairs, int force_client_auth, void *reserved); extern grpc_ssl_server_credentials_create_type grpc_ssl_server_credentials_create_import; #define grpc_ssl_server_credentials_create grpc_ssl_server_credentials_create_import +typedef grpc_server_credentials *(*grpc_ssl_server_credentials_create_ex_type)(const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pairs, size_t num_key_cert_pairs, grpc_ssl_client_certificate_request_type client_certificate_request, void *reserved); +extern grpc_ssl_server_credentials_create_ex_type grpc_ssl_server_credentials_create_ex_import; +#define grpc_ssl_server_credentials_create_ex grpc_ssl_server_credentials_create_ex_import typedef int(*grpc_server_add_secure_http2_port_type)(grpc_server *server, const char *addr, grpc_server_credentials *creds); extern grpc_server_add_secure_http2_port_type grpc_server_add_secure_http2_port_import; #define grpc_server_add_secure_http2_port grpc_server_add_secure_http2_port_import @@ -475,6 +478,12 @@ extern gpr_log_type gpr_log_import; typedef void(*gpr_log_message_type)(const char *file, int line, gpr_log_severity severity, const char *message); extern gpr_log_message_type gpr_log_message_import; #define gpr_log_message gpr_log_message_import +typedef void(*gpr_set_log_verbosity_type)(gpr_log_severity min_severity_to_print); +extern gpr_set_log_verbosity_type gpr_set_log_verbosity_import; +#define gpr_set_log_verbosity gpr_set_log_verbosity_import +typedef void(*gpr_log_verbosity_init_type)(); +extern gpr_log_verbosity_init_type gpr_log_verbosity_init_import; +#define gpr_log_verbosity_init gpr_log_verbosity_init_import typedef void(*gpr_set_log_function_type)(gpr_log_func func); extern gpr_set_log_function_type gpr_set_log_function_import; #define gpr_set_log_function gpr_set_log_function_import diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 1f7f2a196b..c5a0a398b4 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -74,6 +74,7 @@ CORE_SOURCE_FILES = [ 'src/core/lib/support/tmpfile_posix.c', 'src/core/lib/support/tmpfile_win32.c', 'src/core/lib/support/wrap_memcpy.c', + 'src/core/lib/surface/init.c', 'src/core/lib/channel/channel_args.c', 'src/core/lib/channel/channel_stack.c', 'src/core/lib/channel/channel_stack_builder.c', @@ -143,7 +144,6 @@ CORE_SOURCE_FILES = [ 'src/core/lib/surface/channel_stack_type.c', 'src/core/lib/surface/completion_queue.c', 'src/core/lib/surface/event_string.c', - 'src/core/lib/surface/init.c', 'src/core/lib/surface/lame_client.c', 'src/core/lib/surface/metadata_array.c', 'src/core/lib/surface/server.c', @@ -210,6 +210,7 @@ CORE_SOURCE_FILES = [ 'src/core/ext/client_config/lb_policy.c', 'src/core/ext/client_config/lb_policy_factory.c', 'src/core/ext/client_config/lb_policy_registry.c', + 'src/core/ext/client_config/parse_address.c', 'src/core/ext/client_config/resolver.c', 'src/core/ext/client_config/resolver_factory.c', 'src/core/ext/client_config/resolver_registry.c', @@ -310,6 +311,7 @@ CORE_SOURCE_FILES = [ 'third_party/boringssl/crypto/bn/shift.c', 'third_party/boringssl/crypto/bn/sqrt.c', 'third_party/boringssl/crypto/buf/buf.c', + 'third_party/boringssl/crypto/bytestring/asn1_compat.c', 'third_party/boringssl/crypto/bytestring/ber.c', 'third_party/boringssl/crypto/bytestring/cbb.c', 'third_party/boringssl/crypto/bytestring/cbs.c', @@ -333,6 +335,7 @@ CORE_SOURCE_FILES = [ 'third_party/boringssl/crypto/cpu-intel.c', 'third_party/boringssl/crypto/crypto.c', 'third_party/boringssl/crypto/curve25519/curve25519.c', + 'third_party/boringssl/crypto/curve25519/x25519-x86_64.c', 'third_party/boringssl/crypto/des/des.c', 'third_party/boringssl/crypto/dh/check.c', 'third_party/boringssl/crypto/dh/dh.c', @@ -524,6 +527,7 @@ CORE_SOURCE_FILES = [ 'third_party/boringssl/ssl/ssl_buffer.c', 'third_party/boringssl/ssl/ssl_cert.c', 'third_party/boringssl/ssl/ssl_cipher.c', + 'third_party/boringssl/ssl/ssl_ecdh.c', 'third_party/boringssl/ssl/ssl_file.c', 'third_party/boringssl/ssl/ssl_lib.c', 'third_party/boringssl/ssl/ssl_rsa.c', diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.c b/src/ruby/ext/grpc/rb_grpc_imports.generated.c index 149ce6c48a..16ecb669ad 100644 --- a/src/ruby/ext/grpc/rb_grpc_imports.generated.c +++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.c @@ -153,6 +153,7 @@ grpc_metadata_credentials_create_from_plugin_type grpc_metadata_credentials_crea grpc_secure_channel_create_type grpc_secure_channel_create_import; grpc_server_credentials_release_type grpc_server_credentials_release_import; grpc_ssl_server_credentials_create_type grpc_ssl_server_credentials_create_import; +grpc_ssl_server_credentials_create_ex_type grpc_ssl_server_credentials_create_ex_import; grpc_server_add_secure_http2_port_type grpc_server_add_secure_http2_port_import; grpc_call_set_credentials_type grpc_call_set_credentials_import; grpc_server_credentials_set_auth_metadata_processor_type grpc_server_credentials_set_auth_metadata_processor_import; @@ -175,6 +176,8 @@ grpc_byte_buffer_reader_readall_type grpc_byte_buffer_reader_readall_import; grpc_raw_byte_buffer_from_reader_type grpc_raw_byte_buffer_from_reader_import; gpr_log_type gpr_log_import; gpr_log_message_type gpr_log_message_import; +gpr_set_log_verbosity_type gpr_set_log_verbosity_import; +gpr_log_verbosity_init_type gpr_log_verbosity_init_import; gpr_set_log_function_type gpr_set_log_function_import; gpr_slice_ref_type gpr_slice_ref_import; gpr_slice_unref_type gpr_slice_unref_import; @@ -416,6 +419,7 @@ void grpc_rb_load_imports(HMODULE library) { grpc_secure_channel_create_import = (grpc_secure_channel_create_type) GetProcAddress(library, "grpc_secure_channel_create"); grpc_server_credentials_release_import = (grpc_server_credentials_release_type) GetProcAddress(library, "grpc_server_credentials_release"); grpc_ssl_server_credentials_create_import = (grpc_ssl_server_credentials_create_type) GetProcAddress(library, "grpc_ssl_server_credentials_create"); + grpc_ssl_server_credentials_create_ex_import = (grpc_ssl_server_credentials_create_ex_type) GetProcAddress(library, "grpc_ssl_server_credentials_create_ex"); grpc_server_add_secure_http2_port_import = (grpc_server_add_secure_http2_port_type) GetProcAddress(library, "grpc_server_add_secure_http2_port"); grpc_call_set_credentials_import = (grpc_call_set_credentials_type) GetProcAddress(library, "grpc_call_set_credentials"); grpc_server_credentials_set_auth_metadata_processor_import = (grpc_server_credentials_set_auth_metadata_processor_type) GetProcAddress(library, "grpc_server_credentials_set_auth_metadata_processor"); @@ -438,6 +442,8 @@ void grpc_rb_load_imports(HMODULE library) { grpc_raw_byte_buffer_from_reader_import = (grpc_raw_byte_buffer_from_reader_type) GetProcAddress(library, "grpc_raw_byte_buffer_from_reader"); gpr_log_import = (gpr_log_type) GetProcAddress(library, "gpr_log"); gpr_log_message_import = (gpr_log_message_type) GetProcAddress(library, "gpr_log_message"); + gpr_set_log_verbosity_import = (gpr_set_log_verbosity_type) GetProcAddress(library, "gpr_set_log_verbosity"); + gpr_log_verbosity_init_import = (gpr_log_verbosity_init_type) GetProcAddress(library, "gpr_log_verbosity_init"); gpr_set_log_function_import = (gpr_set_log_function_type) GetProcAddress(library, "gpr_set_log_function"); gpr_slice_ref_import = (gpr_slice_ref_type) GetProcAddress(library, "gpr_slice_ref"); gpr_slice_unref_import = (gpr_slice_unref_type) GetProcAddress(library, "gpr_slice_unref"); diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.h b/src/ruby/ext/grpc/rb_grpc_imports.generated.h index 098319db77..b260042d5b 100644 --- a/src/ruby/ext/grpc/rb_grpc_imports.generated.h +++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.h @@ -409,6 +409,9 @@ extern grpc_server_credentials_release_type grpc_server_credentials_release_impo typedef grpc_server_credentials *(*grpc_ssl_server_credentials_create_type)(const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pairs, size_t num_key_cert_pairs, int force_client_auth, void *reserved); extern grpc_ssl_server_credentials_create_type grpc_ssl_server_credentials_create_import; #define grpc_ssl_server_credentials_create grpc_ssl_server_credentials_create_import +typedef grpc_server_credentials *(*grpc_ssl_server_credentials_create_ex_type)(const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pairs, size_t num_key_cert_pairs, grpc_ssl_client_certificate_request_type client_certificate_request, void *reserved); +extern grpc_ssl_server_credentials_create_ex_type grpc_ssl_server_credentials_create_ex_import; +#define grpc_ssl_server_credentials_create_ex grpc_ssl_server_credentials_create_ex_import typedef int(*grpc_server_add_secure_http2_port_type)(grpc_server *server, const char *addr, grpc_server_credentials *creds); extern grpc_server_add_secure_http2_port_type grpc_server_add_secure_http2_port_import; #define grpc_server_add_secure_http2_port grpc_server_add_secure_http2_port_import @@ -475,6 +478,12 @@ extern gpr_log_type gpr_log_import; typedef void(*gpr_log_message_type)(const char *file, int line, gpr_log_severity severity, const char *message); extern gpr_log_message_type gpr_log_message_import; #define gpr_log_message gpr_log_message_import +typedef void(*gpr_set_log_verbosity_type)(gpr_log_severity min_severity_to_print); +extern gpr_set_log_verbosity_type gpr_set_log_verbosity_import; +#define gpr_set_log_verbosity gpr_set_log_verbosity_import +typedef void(*gpr_log_verbosity_init_type)(); +extern gpr_log_verbosity_init_type gpr_log_verbosity_init_import; +#define gpr_log_verbosity_init gpr_log_verbosity_init_import typedef void(*gpr_set_log_function_type)(gpr_log_func func); extern gpr_set_log_function_type gpr_set_log_function_import; #define gpr_set_log_function gpr_set_log_function_import diff --git a/src/ruby/ext/grpc/rb_server_credentials.c b/src/ruby/ext/grpc/rb_server_credentials.c index 33b8372850..b2d7280a30 100644 --- a/src/ruby/ext/grpc/rb_server_credentials.c +++ b/src/ruby/ext/grpc/rb_server_credentials.c @@ -90,9 +90,12 @@ static void grpc_rb_server_credentials_mark(void *p) { static const rb_data_type_t grpc_rb_server_credentials_data_type = { "grpc_server_credentials", - {grpc_rb_server_credentials_mark, grpc_rb_server_credentials_free, - GRPC_RB_MEMSIZE_UNAVAILABLE, {NULL, NULL}}, - NULL, NULL, + {grpc_rb_server_credentials_mark, + grpc_rb_server_credentials_free, + GRPC_RB_MEMSIZE_UNAVAILABLE, + {NULL, NULL}}, + NULL, + NULL, #ifdef RUBY_TYPED_FREE_IMMEDIATELY RUBY_TYPED_FREE_IMMEDIATELY #endif @@ -219,7 +222,9 @@ static VALUE grpc_rb_server_credentials_init(VALUE self, VALUE pem_root_certs, } } - auth_client = TYPE(force_client_auth) == T_TRUE; + auth_client = TYPE(force_client_auth) == T_TRUE + ? GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY + : GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE; key_cert_pairs = ALLOC_N(grpc_ssl_pem_key_cert_pair, num_key_certs); for (i = 0; i < num_key_certs; i++) { key_cert = rb_ary_entry(pem_key_certs, i); @@ -233,13 +238,12 @@ static VALUE grpc_rb_server_credentials_init(VALUE self, VALUE pem_root_certs, &grpc_rb_server_credentials_data_type, wrapper); if (pem_root_certs == Qnil) { - creds = grpc_ssl_server_credentials_create(NULL, key_cert_pairs, - num_key_certs, - auth_client, NULL); + creds = grpc_ssl_server_credentials_create_ex( + NULL, key_cert_pairs, num_key_certs, auth_client, NULL); } else { - creds = grpc_ssl_server_credentials_create(RSTRING_PTR(pem_root_certs), - key_cert_pairs, num_key_certs, - auth_client, NULL); + creds = grpc_ssl_server_credentials_create_ex(RSTRING_PTR(pem_root_certs), + key_cert_pairs, num_key_certs, + auth_client, NULL); } xfree(key_cert_pairs); if (creds == NULL) { diff --git a/src/ruby/lib/grpc/generic/client_stub.rb b/src/ruby/lib/grpc/generic/client_stub.rb index 98e83a8396..a6bb92d72c 100644 --- a/src/ruby/lib/grpc/generic/client_stub.rb +++ b/src/ruby/lib/grpc/generic/client_stub.rb @@ -85,7 +85,8 @@ module GRPC # when present, this is the default timeout used for calls # # @param host [String] the host the stub connects to - # @param q [Core::CompletionQueue] used to wait for events + # @param q [Core::CompletionQueue] used to wait for events - now deprecated + # since each new active call gets its own separately # @param creds [Core::ChannelCredentials|Symbol] the channel credentials, or # :this_channel_is_insecure # @param channel_override [Core::Channel] a pre-created channel @@ -97,7 +98,6 @@ module GRPC propagate_mask: nil, **kw) fail(TypeError, '!CompletionQueue') unless q.is_a?(Core::CompletionQueue) - @queue = q @ch = ClientStub.setup_channel(channel_override, host, creds, **kw) alt_host = kw[Core::Channel::SSL_TARGET] @host = alt_host.nil? ? host : alt_host @@ -458,14 +458,17 @@ module GRPC if deadline.nil? deadline = from_relative_time(timeout.nil? ? @timeout : timeout) end - call = @ch.create_call(@queue, + # Provide each new client call with its own completion queue + call_queue = Core::CompletionQueue.new + call = @ch.create_call(call_queue, parent, # parent call @propagate_mask, # propagation options method, nil, # host use nil, deadline) call.set_credentials! credentials unless credentials.nil? - ActiveCall.new(call, @queue, marshal, unmarshal, deadline, started: false) + ActiveCall.new(call, call_queue, marshal, unmarshal, deadline, + started: false) end end end diff --git a/src/ruby/qps/server.rb b/src/ruby/qps/server.rb index 26f46a3140..f05fbbdaaf 100644 --- a/src/ruby/qps/server.rb +++ b/src/ruby/qps/server.rb @@ -88,4 +88,7 @@ class BenchmarkServer def get_port @port end + def stop + @server.stop + end end diff --git a/src/ruby/qps/src/proto/grpc/testing/control.rb b/src/ruby/qps/src/proto/grpc/testing/control.rb index d007123f26..958fca320b 100644 --- a/src/ruby/qps/src/proto/grpc/testing/control.rb +++ b/src/ruby/qps/src/proto/grpc/testing/control.rb @@ -9,26 +9,12 @@ Google::Protobuf::DescriptorPool.generated_pool.build do add_message "grpc.testing.PoissonParams" do optional :offered_load, :double, 1 end - add_message "grpc.testing.UniformParams" do - optional :interarrival_lo, :double, 1 - optional :interarrival_hi, :double, 2 - end - add_message "grpc.testing.DeterministicParams" do - optional :offered_load, :double, 1 - end - add_message "grpc.testing.ParetoParams" do - optional :interarrival_base, :double, 1 - optional :alpha, :double, 2 - end add_message "grpc.testing.ClosedLoopParams" do end add_message "grpc.testing.LoadParams" do oneof :load do optional :closed_loop, :message, 1, "grpc.testing.ClosedLoopParams" optional :poisson, :message, 2, "grpc.testing.PoissonParams" - optional :uniform, :message, 3, "grpc.testing.UniformParams" - optional :determ, :message, 4, "grpc.testing.DeterministicParams" - optional :pareto, :message, 5, "grpc.testing.ParetoParams" end end add_message "grpc.testing.SecurityParams" do @@ -48,6 +34,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do optional :histogram_params, :message, 12, "grpc.testing.HistogramParams" repeated :core_list, :int32, 13 optional :core_limit, :int32, 14 + optional :other_client_api, :string, 15 end add_message "grpc.testing.ClientStatus" do optional :stats, :message, 1, "grpc.testing.ClientStats" @@ -69,6 +56,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do optional :core_limit, :int32, 8 optional :payload_config, :message, 9, "grpc.testing.PayloadConfig" repeated :core_list, :int32, 10 + optional :other_server_api, :string, 11 end add_message "grpc.testing.ServerArgs" do oneof :argtype do @@ -88,14 +76,50 @@ Google::Protobuf::DescriptorPool.generated_pool.build do end add_message "grpc.testing.Void" do end + add_message "grpc.testing.Scenario" do + optional :name, :string, 1 + optional :client_config, :message, 2, "grpc.testing.ClientConfig" + optional :num_clients, :int32, 3 + optional :server_config, :message, 4, "grpc.testing.ServerConfig" + optional :num_servers, :int32, 5 + optional :warmup_seconds, :int32, 6 + optional :benchmark_seconds, :int32, 7 + optional :spawn_local_worker_count, :int32, 8 + end + add_message "grpc.testing.Scenarios" do + repeated :scenarios, :message, 1, "grpc.testing.Scenario" + end + add_message "grpc.testing.ScenarioResultSummary" do + optional :qps, :double, 1 + optional :qps_per_server_core, :double, 2 + optional :server_system_time, :double, 3 + optional :server_user_time, :double, 4 + optional :client_system_time, :double, 5 + optional :client_user_time, :double, 6 + optional :latency_50, :double, 7 + optional :latency_90, :double, 8 + optional :latency_95, :double, 9 + optional :latency_99, :double, 10 + optional :latency_999, :double, 11 + end + add_message "grpc.testing.ScenarioResult" do + optional :scenario, :message, 1, "grpc.testing.Scenario" + optional :latencies, :message, 2, "grpc.testing.HistogramData" + repeated :client_stats, :message, 3, "grpc.testing.ClientStats" + repeated :server_stats, :message, 4, "grpc.testing.ServerStats" + repeated :server_cores, :int32, 5 + optional :summary, :message, 6, "grpc.testing.ScenarioResultSummary" + end add_enum "grpc.testing.ClientType" do value :SYNC_CLIENT, 0 value :ASYNC_CLIENT, 1 + value :OTHER_CLIENT, 2 end add_enum "grpc.testing.ServerType" do value :SYNC_SERVER, 0 value :ASYNC_SERVER, 1 value :ASYNC_GENERIC_SERVER, 2 + value :OTHER_SERVER, 3 end add_enum "grpc.testing.RpcType" do value :UNARY, 0 @@ -106,9 +130,6 @@ end module Grpc module Testing PoissonParams = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.PoissonParams").msgclass - UniformParams = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.UniformParams").msgclass - DeterministicParams = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.DeterministicParams").msgclass - ParetoParams = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.ParetoParams").msgclass ClosedLoopParams = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.ClosedLoopParams").msgclass LoadParams = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.LoadParams").msgclass SecurityParams = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.SecurityParams").msgclass @@ -122,6 +143,10 @@ module Grpc CoreRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.CoreRequest").msgclass CoreResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.CoreResponse").msgclass Void = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.Void").msgclass + Scenario = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.Scenario").msgclass + Scenarios = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.Scenarios").msgclass + ScenarioResultSummary = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.ScenarioResultSummary").msgclass + ScenarioResult = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.ScenarioResult").msgclass ClientType = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.ClientType").enummodule ServerType = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.ServerType").enummodule RpcType = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.RpcType").enummodule diff --git a/src/ruby/qps/src/proto/grpc/testing/messages.rb b/src/ruby/qps/src/proto/grpc/testing/messages.rb index b9c32dbef5..2bdfe0eade 100644 --- a/src/ruby/qps/src/proto/grpc/testing/messages.rb +++ b/src/ruby/qps/src/proto/grpc/testing/messages.rb @@ -46,6 +46,9 @@ Google::Protobuf::DescriptorPool.generated_pool.build do add_message "grpc.testing.StreamingOutputCallResponse" do optional :payload, :message, 1, "grpc.testing.Payload" end + add_message "grpc.testing.ReconnectParams" do + optional :max_reconnect_backoff_ms, :int32, 1 + end add_message "grpc.testing.ReconnectInfo" do optional :passed, :bool, 1 repeated :backoff_ms, :int32, 2 @@ -73,6 +76,7 @@ module Grpc ResponseParameters = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.ResponseParameters").msgclass StreamingOutputCallRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.StreamingOutputCallRequest").msgclass StreamingOutputCallResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.StreamingOutputCallResponse").msgclass + ReconnectParams = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.ReconnectParams").msgclass ReconnectInfo = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.ReconnectInfo").msgclass PayloadType = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.PayloadType").enummodule CompressionType = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.CompressionType").enummodule diff --git a/src/ruby/qps/worker.rb b/src/ruby/qps/worker.rb index 7c29204cc2..665fb86352 100755 --- a/src/ruby/qps/worker.rb +++ b/src/ruby/qps/worker.rb @@ -55,12 +55,12 @@ class WorkerServiceImpl < Grpc::Testing::WorkerService::Service Thread.new { bms = '' gtss = Grpc::Testing::ServerStatus - reqs.each do |req| + reqs.each do |req| case req.argtype.to_s when 'setup' bms = BenchmarkServer.new(req.setup, @server_port) q.push(gtss.new(stats: bms.mark(false), port: bms.get_port)) - when 'mark' + when 'mark' q.push(gtss.new(stats: bms.mark(req.mark.reset), cores: cpu_cores)) end end |