diff options
author | 2017-08-24 10:42:27 -0700 | |
---|---|---|
committer | 2017-10-19 14:29:13 -0700 | |
commit | 088112fea12ec364990909cda3a96e7d792480b3 (patch) | |
tree | 1fde83a8b7332891ccbb409da0ac97abd3ebe68d /test/cpp/qps/client.h | |
parent | ac581ee24b24d9088d8755ce45daa4ec471ab951 (diff) |
Create inproc version of QPS test and add a few simple tests of this to standard testing suite.
Diffstat (limited to 'test/cpp/qps/client.h')
-rw-r--r-- | test/cpp/qps/client.h | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/test/cpp/qps/client.h b/test/cpp/qps/client.h index abf755b393..48c8995666 100644 --- a/test/cpp/qps/client.h +++ b/test/cpp/qps/client.h @@ -37,10 +37,14 @@ #include "src/cpp/util/core_stats.h" #include "test/cpp/qps/histogram.h" #include "test/cpp/qps/interarrival.h" +#include "test/cpp/qps/qps_worker.h" +#include "test/cpp/qps/server.h" #include "test/cpp/qps/usage_timer.h" #include "test/cpp/util/create_test_channel.h" #include "test/cpp/util/test_credentials_provider.h" +#define INPROC_NAME_PREFIX "qpsinproc:" + namespace grpc { namespace testing { @@ -422,11 +426,24 @@ class ClientImpl : public Client { type = config.security_params().cred_type(); } - channel_ = CreateTestChannel( - target, type, config.security_params().server_host_override(), - !config.security_params().use_test_ca(), - std::shared_ptr<CallCredentials>(), args); - gpr_log(GPR_INFO, "Connecting to %s", target.c_str()); + grpc::string inproc_pfx(INPROC_NAME_PREFIX); + if (target.find(inproc_pfx) != 0) { + channel_ = CreateTestChannel( + target, type, config.security_params().server_host_override(), + !config.security_params().use_test_ca(), + std::shared_ptr<CallCredentials>(), args); + gpr_log(GPR_INFO, "Connecting to %s", target.c_str()); + GPR_ASSERT(channel_->WaitForConnected( + gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), + gpr_time_from_seconds(300, GPR_TIMESPAN)))); + is_inproc_ = false; + } else { + grpc::string tgt = target; + tgt.erase(0, inproc_pfx.length()); + int srv_num = std::stoi(tgt); + channel_ = (*g_inproc_servers)[srv_num]->InProcessChannel(args); + is_inproc_ = true; + } stub_ = create_stub(channel_); } Channel* get_channel() { return channel_.get(); } @@ -434,9 +451,11 @@ class ClientImpl : public Client { std::unique_ptr<std::thread> WaitForReady() { return std::unique_ptr<std::thread>(new std::thread([this]() { - GPR_ASSERT(channel_->WaitForConnected( - gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), - gpr_time_from_seconds(10, GPR_TIMESPAN)))); + if (!is_inproc_) { + GPR_ASSERT(channel_->WaitForConnected( + gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), + gpr_time_from_seconds(10, GPR_TIMESPAN)))); + } })); } @@ -455,6 +474,7 @@ class ClientImpl : public Client { std::shared_ptr<Channel> channel_; std::unique_ptr<StubType> stub_; + bool is_inproc_; }; std::vector<ClientChannelInfo> channels_; std::function<std::unique_ptr<StubType>(const std::shared_ptr<Channel>&)> |