diff options
author | 2017-05-26 00:31:18 +0200 | |
---|---|---|
committer | 2017-05-26 00:31:18 +0200 | |
commit | 5a1d197f1ced4ed9f64a3816ac48e89d4c7687f6 (patch) | |
tree | f16f3aa8f064c366db409ed9c879aba4d250693b /test/cpp | |
parent | 670d8bf67512998437b8bb87c393c764774294ed (diff) | |
parent | 0bd14cc89df05b04d0cd7b526c921eb60de4cf63 (diff) |
Merge branch 'master' of https://github.com/grpc/grpc into import
Diffstat (limited to 'test/cpp')
-rw-r--r-- | test/cpp/end2end/grpclb_end2end_test.cc | 6 | ||||
-rw-r--r-- | test/cpp/end2end/round_robin_end2end_test.cc | 31 | ||||
-rw-r--r-- | test/cpp/microbenchmarks/bm_fullstack_trickle.cc | 5 |
3 files changed, 16 insertions, 26 deletions
diff --git a/test/cpp/end2end/grpclb_end2end_test.cc b/test/cpp/end2end/grpclb_end2end_test.cc index 31aeee0e80..8f901247cc 100644 --- a/test/cpp/end2end/grpclb_end2end_test.cc +++ b/test/cpp/end2end/grpclb_end2end_test.cc @@ -569,9 +569,11 @@ TEST_F(SingleBalancerTest, RepeatedServerlist) { // only the first half of the backends will receive them. for (size_t i = 0; i < backends_.size(); ++i) { if (i < backends_.size() / 2) - EXPECT_EQ(1U, backend_servers_[i].service_->request_count()); + EXPECT_EQ(1U, backend_servers_[i].service_->request_count()) + << "for backend #" << i; else - EXPECT_EQ(0U, backend_servers_[i].service_->request_count()); + EXPECT_EQ(0U, backend_servers_[i].service_->request_count()) + << "for backend #" << i; } EXPECT_EQ(statuses_and_responses.size(), num_backends_ / 2); for (const auto& status_and_response : statuses_and_responses) { diff --git a/test/cpp/end2end/round_robin_end2end_test.cc b/test/cpp/end2end/round_robin_end2end_test.cc index f8e3cc06c0..ea7639bc8f 100644 --- a/test/cpp/end2end/round_robin_end2end_test.cc +++ b/test/cpp/end2end/round_robin_end2end_test.cc @@ -42,7 +42,6 @@ #include <grpc++/server_builder.h> #include <grpc/grpc.h> #include <grpc/support/log.h> -#include <grpc/support/thd.h> #include <grpc/support/time.h> #include "src/proto/grpc/testing/echo.grpc.pb.h" @@ -131,22 +130,10 @@ class RoundRobinEnd2endTest : public ::testing::Test { int port_; std::unique_ptr<Server> server_; MyTestServiceImpl service_; - std::unique_ptr<std::thread> thread_; explicit ServerData(const grpc::string& server_host) { port_ = grpc_pick_unused_port_or_die(); gpr_log(GPR_INFO, "starting server on port %d", port_); - std::mutex mu; - std::condition_variable cond; - thread_.reset(new std::thread( - std::bind(&ServerData::Start, this, server_host, &mu, &cond))); - std::unique_lock<std::mutex> lock(mu); - cond.wait(lock); - gpr_log(GPR_INFO, "server startup complete"); - } - - void Start(const grpc::string& server_host, std::mutex* mu, - std::condition_variable* cond) { std::ostringstream server_address; server_address << server_host << ":" << port_; ServerBuilder builder; @@ -154,18 +141,13 @@ class RoundRobinEnd2endTest : public ::testing::Test { InsecureServerCredentials()); builder.RegisterService(&service_); server_ = builder.BuildAndStart(); - std::lock_guard<std::mutex> lock(*mu); - cond->notify_one(); + gpr_log(GPR_INFO, "server startup complete"); } - void Shutdown() { - server_->Shutdown(); - thread_->join(); - } + void Shutdown() { server_->Shutdown(); } }; const grpc::string server_host_; - CompletionQueue cli_cq_; std::shared_ptr<Channel> channel_; std::unique_ptr<grpc::testing::EchoTestService::Stub> stub_; std::vector<std::unique_ptr<ServerData>> servers_; @@ -197,10 +179,13 @@ TEST_F(RoundRobinEnd2endTest, RoundRobin) { const int kNumServers = 3; StartServers(kNumServers); ResetStub(true /* round_robin */); - SendRpc(kNumServers); - // One request should have gone to each server. + // Send one RPC per backend and make sure they are used in order. + // Note: This relies on the fact that the subchannels are reported in + // state READY in the order in which the addresses are specified, + // which is only true because the backends are all local. for (size_t i = 0; i < servers_.size(); ++i) { - EXPECT_EQ(1, servers_[i]->service_.request_count()); + SendRpc(1); + EXPECT_EQ(1, servers_[i]->service_.request_count()) << "for backend #" << i; } // Check LB policy name for the channel. EXPECT_EQ("round_robin", channel_->GetLoadBalancingPolicyName()); diff --git a/test/cpp/microbenchmarks/bm_fullstack_trickle.cc b/test/cpp/microbenchmarks/bm_fullstack_trickle.cc index 6b9fa8b38d..d7e3a9cf47 100644 --- a/test/cpp/microbenchmarks/bm_fullstack_trickle.cc +++ b/test/cpp/microbenchmarks/bm_fullstack_trickle.cc @@ -101,6 +101,8 @@ class TrickledCHTTP2 : public EndpointPairFixture { } void AddToLabel(std::ostream& out, benchmark::State& state) { + grpc_chttp2_transport* client = + reinterpret_cast<grpc_chttp2_transport*>(client_transport_); out << " writes/iter:" << ((double)stats_.num_writes / (double)state.iterations()) << " cli_transport_stalls/iter:" @@ -116,7 +118,8 @@ class TrickledCHTTP2 : public EndpointPairFixture { (double)state.iterations()) << " svr_stream_stalls/iter:" << ((double)server_stats_.streams_stalled_due_to_stream_flow_control / - (double)state.iterations()); + (double)state.iterations()) + << " cli_bw_est:" << (double)client->bdp_estimator.bw_est; } void Log(int64_t iteration) { |