From 094dc6822c894ac4095d955522a08be7111167c2 Mon Sep 17 00:00:00 2001 From: Adele Zhou Date: Wed, 12 Sep 2018 00:05:29 -0700 Subject: [PATCH 1/2] Added long_connection test. --- doc/interop-test-descriptions.md | 5 +++++ test/cpp/interop/client.cc | 8 +++++++- test/cpp/interop/interop_client.cc | 28 ++++++++++++++++++++++++++++ test/cpp/interop/interop_client.h | 2 ++ 4 files changed, 42 insertions(+), 1 deletion(-) diff --git a/doc/interop-test-descriptions.md b/doc/interop-test-descriptions.md index 3c33189196e..79281611006 100644 --- a/doc/interop-test-descriptions.md +++ b/doc/interop-test-descriptions.md @@ -944,6 +944,11 @@ the experimental flag, `soak_iterations`. This tests puts stress on several gRPC components; the resolver, the load balancer, and the RPC hotpath. +#### long_connection + +The client performs a number of large_unary RPCs over a single connection +with a fixed but configuration interval between the RPCs. + ### TODO Tests #### High priority: diff --git a/test/cpp/interop/client.cc b/test/cpp/interop/client.cc index 7bcf23c0eb6..324f2e694fb 100644 --- a/test/cpp/interop/client.cc +++ b/test/cpp/interop/client.cc @@ -57,6 +57,7 @@ DEFINE_string( "half_duplex : half-duplex streaming;\n" "jwt_token_creds: large_unary with JWT token auth;\n" "large_unary : single request and (large) response;\n" + "long_connection: sends large_unary rpcs over a single long connection;\n" "oauth2_auth_token: raw oauth2 access token auth;\n" "per_rpc_creds: raw oauth2 access token on a single rpc;\n" "ping_pong : full-duplex streaming;\n" @@ -84,10 +85,12 @@ DEFINE_bool(do_not_abort_on_transient_failures, false, "whether abort() is called or not. It does not control whether the " "test is retried in case of transient failures (and currently the " "interop tests are not retried even if this flag is set to true)"); - DEFINE_int32(soak_iterations, 1000, "number of iterations to use for the two soak tests; rpc_soak and " "channel_soak"); +DEFINE_int32(iteration_interval, 10, + "The interval in seconds between rpcs. This is used by " + "long_connection test"); using grpc::testing::CreateChannelForTestCase; using grpc::testing::GetServiceAccountJsonKey; @@ -163,6 +166,9 @@ int main(int argc, char** argv) { FLAGS_soak_iterations); actions["rpc_soak"] = std::bind(&grpc::testing::InteropClient::DoRpcSoakTest, &client, FLAGS_soak_iterations); + actions["long_connection"] = + std::bind(&grpc::testing::InteropClient::DoLongConnectionTest, &client, + FLAGS_soak_iterations, FLAGS_iteration_interval); UpdateActions(&actions); diff --git a/test/cpp/interop/interop_client.cc b/test/cpp/interop/interop_client.cc index b7ce90803ba..42d9c0bb0d5 100644 --- a/test/cpp/interop/interop_client.cc +++ b/test/cpp/interop/interop_client.cc @@ -1052,6 +1052,34 @@ bool InteropClient::DoChannelSoakTest(int32_t soak_iterations) { return true; } +bool InteropClient::DoLongConnectionTest(int32_t soak_iterations, + int32_t iteration_interval) { + gpr_log(GPR_DEBUG, "Sending %d RPCs...", soak_iterations); + GPR_ASSERT(soak_iterations > 0); + GPR_ASSERT(iteration_interval > 0); + SimpleRequest request; + SimpleResponse response; + int num_failures = 0; + for (int i = 0; i < soak_iterations; ++i) { + gpr_log(GPR_DEBUG, "Sending RPC number %d...", i); + if (!PerformLargeUnary(&request, &response)) { + gpr_log(GPR_ERROR, "Iteration %d failed.", i); + num_failures++; + } + gpr_sleep_until( + gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), + gpr_time_from_seconds(iteration_interval, GPR_TIMESPAN))); + } + if (num_failures == 0) { + gpr_log(GPR_DEBUG, "long_connection test done."); + return true; + } else { + gpr_log(GPR_DEBUG, "long_connection test failed with %d rpc failures.", + num_failures); + return false; + } +} + bool InteropClient::DoUnimplementedService() { gpr_log(GPR_DEBUG, "Sending a request for an unimplemented service..."); diff --git a/test/cpp/interop/interop_client.h b/test/cpp/interop/interop_client.h index e5be44d1d47..8ad063b8245 100644 --- a/test/cpp/interop/interop_client.h +++ b/test/cpp/interop/interop_client.h @@ -76,6 +76,8 @@ class InteropClient { // languages bool DoChannelSoakTest(int32_t soak_iterations); bool DoRpcSoakTest(int32_t soak_iterations); + bool DoLongConnectionTest(int32_t soak_iterations, + int32_t iteration_interval); // Auth tests. // username is a string containing the user email From 165417e4faf4928128fc3492ace5aa907c8f51fe Mon Sep 17 00:00:00 2001 From: Adele Zhou Date: Wed, 12 Sep 2018 14:30:02 -0700 Subject: [PATCH 2/2] Change the test name to long_lived_channel --- doc/interop-test-descriptions.md | 6 +++--- test/cpp/interop/client.cc | 6 +++--- test/cpp/interop/interop_client.cc | 8 ++++---- test/cpp/interop/interop_client.h | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/doc/interop-test-descriptions.md b/doc/interop-test-descriptions.md index 79281611006..1d6535d7ea0 100644 --- a/doc/interop-test-descriptions.md +++ b/doc/interop-test-descriptions.md @@ -944,10 +944,10 @@ the experimental flag, `soak_iterations`. This tests puts stress on several gRPC components; the resolver, the load balancer, and the RPC hotpath. -#### long_connection +#### long_lived_channel -The client performs a number of large_unary RPCs over a single connection -with a fixed but configuration interval between the RPCs. +The client performs a number of large_unary RPCs over a single long-lived +channel with a fixed but configurable interval between each RPC. ### TODO Tests diff --git a/test/cpp/interop/client.cc b/test/cpp/interop/client.cc index 324f2e694fb..a4b1a85f856 100644 --- a/test/cpp/interop/client.cc +++ b/test/cpp/interop/client.cc @@ -57,7 +57,7 @@ DEFINE_string( "half_duplex : half-duplex streaming;\n" "jwt_token_creds: large_unary with JWT token auth;\n" "large_unary : single request and (large) response;\n" - "long_connection: sends large_unary rpcs over a single long connection;\n" + "long_lived_channel: sends large_unary rpcs over a long-lived channel;\n" "oauth2_auth_token: raw oauth2 access token auth;\n" "per_rpc_creds: raw oauth2 access token on a single rpc;\n" "ping_pong : full-duplex streaming;\n" @@ -166,8 +166,8 @@ int main(int argc, char** argv) { FLAGS_soak_iterations); actions["rpc_soak"] = std::bind(&grpc::testing::InteropClient::DoRpcSoakTest, &client, FLAGS_soak_iterations); - actions["long_connection"] = - std::bind(&grpc::testing::InteropClient::DoLongConnectionTest, &client, + actions["long_lived_channel"] = + std::bind(&grpc::testing::InteropClient::DoLongLivedChannelTest, &client, FLAGS_soak_iterations, FLAGS_iteration_interval); UpdateActions(&actions); diff --git a/test/cpp/interop/interop_client.cc b/test/cpp/interop/interop_client.cc index 42d9c0bb0d5..a99cf8122f8 100644 --- a/test/cpp/interop/interop_client.cc +++ b/test/cpp/interop/interop_client.cc @@ -1052,8 +1052,8 @@ bool InteropClient::DoChannelSoakTest(int32_t soak_iterations) { return true; } -bool InteropClient::DoLongConnectionTest(int32_t soak_iterations, - int32_t iteration_interval) { +bool InteropClient::DoLongLivedChannelTest(int32_t soak_iterations, + int32_t iteration_interval) { gpr_log(GPR_DEBUG, "Sending %d RPCs...", soak_iterations); GPR_ASSERT(soak_iterations > 0); GPR_ASSERT(iteration_interval > 0); @@ -1071,10 +1071,10 @@ bool InteropClient::DoLongConnectionTest(int32_t soak_iterations, gpr_time_from_seconds(iteration_interval, GPR_TIMESPAN))); } if (num_failures == 0) { - gpr_log(GPR_DEBUG, "long_connection test done."); + gpr_log(GPR_DEBUG, "long_lived_channel test done."); return true; } else { - gpr_log(GPR_DEBUG, "long_connection test failed with %d rpc failures.", + gpr_log(GPR_DEBUG, "long_lived_channel test failed with %d rpc failures.", num_failures); return false; } diff --git a/test/cpp/interop/interop_client.h b/test/cpp/interop/interop_client.h index 8ad063b8245..0ceff55c5c2 100644 --- a/test/cpp/interop/interop_client.h +++ b/test/cpp/interop/interop_client.h @@ -76,8 +76,8 @@ class InteropClient { // languages bool DoChannelSoakTest(int32_t soak_iterations); bool DoRpcSoakTest(int32_t soak_iterations); - bool DoLongConnectionTest(int32_t soak_iterations, - int32_t iteration_interval); + bool DoLongLivedChannelTest(int32_t soak_iterations, + int32_t iteration_interval); // Auth tests. // username is a string containing the user email