diff options
author | Yang Gao <yangg@google.com> | 2016-04-05 21:33:45 +0000 |
---|---|---|
committer | Yang Gao <yangg@google.com> | 2016-04-05 21:33:45 +0000 |
commit | db566d21292e089232663092f31bf27efa3d0391 (patch) | |
tree | 62d6a97c4bd136629a6d423ee917b693d4731f30 /test/cpp | |
parent | b49a1e5849529bdd769587dbd798edfabe516d5f (diff) | |
parent | abb4f5f3ab911d0b0c5bc7d76c27592a1656bd12 (diff) |
Merge branch 'master' into hpack_table
Diffstat (limited to 'test/cpp')
-rw-r--r-- | test/cpp/end2end/client_crash_test.cc | 2 | ||||
-rw-r--r-- | test/cpp/end2end/server_crash_test_client.cc | 1 | ||||
-rw-r--r-- | test/cpp/interop/reconnect_interop_client.cc | 26 | ||||
-rw-r--r-- | test/cpp/interop/reconnect_interop_server.cc | 10 | ||||
-rw-r--r-- | test/cpp/util/create_test_channel.cc | 15 | ||||
-rw-r--r-- | test/cpp/util/create_test_channel.h | 8 |
6 files changed, 50 insertions, 12 deletions
diff --git a/test/cpp/end2end/client_crash_test.cc b/test/cpp/end2end/client_crash_test.cc index c01f40dbc2..30b04fb9b9 100644 --- a/test/cpp/end2end/client_crash_test.cc +++ b/test/cpp/end2end/client_crash_test.cc @@ -88,6 +88,7 @@ TEST_F(CrashTest, KillBeforeWrite) { EchoRequest request; EchoResponse response; ClientContext context; + context.set_fail_fast(false); auto stream = stub->BidiStream(&context); @@ -113,6 +114,7 @@ TEST_F(CrashTest, KillAfterWrite) { EchoRequest request; EchoResponse response; ClientContext context; + context.set_fail_fast(false); auto stream = stub->BidiStream(&context); diff --git a/test/cpp/end2end/server_crash_test_client.cc b/test/cpp/end2end/server_crash_test_client.cc index 1964840fa5..ece948d5a7 100644 --- a/test/cpp/end2end/server_crash_test_client.cc +++ b/test/cpp/end2end/server_crash_test_client.cc @@ -63,6 +63,7 @@ int main(int argc, char** argv) { EchoRequest request; EchoResponse response; grpc::ClientContext context; + context.set_fail_fast(false); if (FLAGS_mode == "bidi") { auto stream = stub->BidiStream(&context); diff --git a/test/cpp/interop/reconnect_interop_client.cc b/test/cpp/interop/reconnect_interop_client.cc index 87e3bd6c76..797e52c744 100644 --- a/test/cpp/interop/reconnect_interop_client.cc +++ b/test/cpp/interop/reconnect_interop_client.cc @@ -37,6 +37,7 @@ #include <gflags/gflags.h> #include <grpc++/channel.h> #include <grpc++/client_context.h> +#include <grpc++/support/channel_arguments.h> #include <grpc/grpc.h> #include <grpc/support/log.h> #include "src/proto/grpc/testing/empty.grpc.pb.h" @@ -48,13 +49,18 @@ DEFINE_int32(server_control_port, 0, "Server port for control rpcs."); DEFINE_int32(server_retry_port, 0, "Server port for testing reconnection."); DEFINE_string(server_host, "127.0.0.1", "Server host to connect to"); +DEFINE_int32(max_reconnect_backoff_ms, 0, + "Maximum backoff time, or 0 for default."); +using grpc::CallCredentials; using grpc::Channel; +using grpc::ChannelArguments; using grpc::ClientContext; using grpc::CreateTestChannel; using grpc::Status; using grpc::testing::Empty; using grpc::testing::ReconnectInfo; +using grpc::testing::ReconnectParams; using grpc::testing::ReconnectService; int main(int argc, char** argv) { @@ -68,17 +74,25 @@ int main(int argc, char** argv) { ReconnectService::NewStub( CreateTestChannel(server_address.str(), false))); ClientContext start_context; - Empty empty_request; + ReconnectParams reconnect_params; + reconnect_params.set_max_reconnect_backoff_ms(FLAGS_max_reconnect_backoff_ms); Empty empty_response; Status start_status = - control_stub->Start(&start_context, empty_request, &empty_response); + control_stub->Start(&start_context, reconnect_params, &empty_response); GPR_ASSERT(start_status.ok()); gpr_log(GPR_INFO, "Starting connections with retries."); server_address.str(""); server_address << FLAGS_server_host << ':' << FLAGS_server_retry_port; + ChannelArguments channel_args; + if (FLAGS_max_reconnect_backoff_ms > 0) { + channel_args.SetInt(GRPC_ARG_MAX_RECONNECT_BACKOFF_MS, + FLAGS_max_reconnect_backoff_ms); + } std::shared_ptr<Channel> retry_channel = - CreateTestChannel(server_address.str(), true); + CreateTestChannel(server_address.str(), "foo.test.google.fr", true, false, + std::shared_ptr<CallCredentials>(), channel_args); + // About 13 retries. const int kDeadlineSeconds = 540; // Use any rpc to test retry. @@ -88,15 +102,15 @@ int main(int argc, char** argv) { retry_context.set_deadline(std::chrono::system_clock::now() + std::chrono::seconds(kDeadlineSeconds)); Status retry_status = - retry_stub->Start(&retry_context, empty_request, &empty_response); + retry_stub->Start(&retry_context, reconnect_params, &empty_response); GPR_ASSERT(retry_status.error_code() == grpc::StatusCode::DEADLINE_EXCEEDED); gpr_log(GPR_INFO, "Done retrying, getting final data from server"); ClientContext stop_context; ReconnectInfo response; - Status stop_status = - control_stub->Stop(&stop_context, empty_request, &response); + Status stop_status = control_stub->Stop(&stop_context, Empty(), &response); GPR_ASSERT(stop_status.ok()); GPR_ASSERT(response.passed() == true); + gpr_log(GPR_INFO, "Passed"); return 0; } diff --git a/test/cpp/interop/reconnect_interop_server.cc b/test/cpp/interop/reconnect_interop_server.cc index e2114fae19..53d51e80e7 100644 --- a/test/cpp/interop/reconnect_interop_server.cc +++ b/test/cpp/interop/reconnect_interop_server.cc @@ -71,6 +71,7 @@ using grpc::Status; using grpc::testing::Empty; using grpc::testing::ReconnectService; using grpc::testing::ReconnectInfo; +using grpc::testing::ReconnectParams; static bool got_sigint = false; @@ -92,7 +93,8 @@ class ReconnectServiceImpl : public ReconnectService::Service { void Poll(int seconds) { reconnect_server_poll(&tcp_server_, seconds); } - Status Start(ServerContext* context, const Empty* request, Empty* response) { + Status Start(ServerContext* context, const ReconnectParams* request, + Empty* response) { bool start_server = true; std::unique_lock<std::mutex> lock(mu_); while (serving_ && !shutdown_) { @@ -105,6 +107,8 @@ class ReconnectServiceImpl : public ReconnectService::Service { if (server_started_) { start_server = false; } else { + tcp_server_.max_reconnect_backoff_ms = + request->max_reconnect_backoff_ms(); server_started_ = true; } lock.unlock(); @@ -133,7 +137,9 @@ class ReconnectServiceImpl : public ReconnectService::Service { const double kTransmissionDelay = 100.0; const double kBackoffMultiplier = 1.6; const double kJitterFactor = 0.2; - const int kMaxBackoffMs = 120 * 1000; + const int kMaxBackoffMs = tcp_server_.max_reconnect_backoff_ms + ? tcp_server_.max_reconnect_backoff_ms + : 120 * 1000; bool passed = true; for (timestamp_list* cur = tcp_server_.head; cur && cur->next; cur = cur->next) { diff --git a/test/cpp/util/create_test_channel.cc b/test/cpp/util/create_test_channel.cc index 0cd9f9e767..fe8b5d5423 100644 --- a/test/cpp/util/create_test_channel.cc +++ b/test/cpp/util/create_test_channel.cc @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -58,8 +58,9 @@ namespace grpc { std::shared_ptr<Channel> CreateTestChannel( const grpc::string& server, const grpc::string& override_hostname, bool enable_ssl, bool use_prod_roots, - const std::shared_ptr<CallCredentials>& creds) { - ChannelArguments channel_args; + const std::shared_ptr<CallCredentials>& creds, + const ChannelArguments& args) { + ChannelArguments channel_args(args); if (enable_ssl) { const char* roots_certs = use_prod_roots ? "" : test_root_cert; SslCredentialsOptions ssl_opts = {roots_certs, "", ""}; @@ -83,6 +84,14 @@ std::shared_ptr<Channel> CreateTestChannel( std::shared_ptr<Channel> CreateTestChannel( const grpc::string& server, const grpc::string& override_hostname, + bool enable_ssl, bool use_prod_roots, + const std::shared_ptr<CallCredentials>& creds) { + return CreateTestChannel(server, override_hostname, enable_ssl, + use_prod_roots, creds, ChannelArguments()); +} + +std::shared_ptr<Channel> CreateTestChannel( + const grpc::string& server, const grpc::string& override_hostname, bool enable_ssl, bool use_prod_roots) { return CreateTestChannel(server, override_hostname, enable_ssl, use_prod_roots, std::shared_ptr<CallCredentials>()); diff --git a/test/cpp/util/create_test_channel.h b/test/cpp/util/create_test_channel.h index b50d653de3..4ff666dc1b 100644 --- a/test/cpp/util/create_test_channel.h +++ b/test/cpp/util/create_test_channel.h @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -53,6 +53,12 @@ std::shared_ptr<Channel> CreateTestChannel( bool enable_ssl, bool use_prod_roots, const std::shared_ptr<CallCredentials>& creds); +std::shared_ptr<Channel> CreateTestChannel( + const grpc::string& server, const grpc::string& override_hostname, + bool enable_ssl, bool use_prod_roots, + const std::shared_ptr<CallCredentials>& creds, + const ChannelArguments& args); + } // namespace grpc #endif // GRPC_TEST_CPP_UTIL_CREATE_TEST_CHANNEL_H |