diff options
author | Craig Tiller <ctiller@google.com> | 2017-07-06 09:22:10 -0700 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2017-07-06 09:22:10 -0700 |
commit | 873ee82277869e91a7ac17b555c3d98b317f6878 (patch) | |
tree | 3d21dc4cfaf2b4f8c6a65b9f2c83c2a913fc6773 /test/cpp | |
parent | a1a3f363ee0309bdfbcdf919ab57468e3522731a (diff) |
Add channel args to qps server
Diffstat (limited to 'test/cpp')
-rw-r--r-- | test/cpp/qps/server.h | 28 | ||||
-rw-r--r-- | test/cpp/qps/server_async.cc | 5 | ||||
-rw-r--r-- | test/cpp/qps/server_sync.cc | 8 |
3 files changed, 30 insertions, 11 deletions
diff --git a/test/cpp/qps/server.h b/test/cpp/qps/server.h index a3b4d7d241..4b699e0708 100644 --- a/test/cpp/qps/server.h +++ b/test/cpp/qps/server.h @@ -19,8 +19,11 @@ #ifndef TEST_QPS_SERVER_H #define TEST_QPS_SERVER_H +#include <grpc++/resource_quota.h> #include <grpc++/security/server_credentials.h> +#include <grpc++/server_builder.h> #include <grpc/support/cpu.h> +#include <grpc/support/log.h> #include <vector> #include "src/core/lib/surface/completion_queue.h" @@ -102,6 +105,31 @@ class Server { return 0; } + protected: + static void ApplyConfigToBuilder(const ServerConfig& config, + ServerBuilder* builder) { + if (config.resource_quota_size() > 0) { + builder->SetResourceQuota(ResourceQuota("AsyncQpsServerTest") + .Resize(config.resource_quota_size())); + } + for (const auto& channel_arg : config.channel_args()) { + switch (channel_arg.value_case()) { + case ChannelArg::kStrValue: + builder->AddChannelArgument(channel_arg.name(), + channel_arg.str_value()); + break; + case ChannelArg::kIntValue: + builder->AddChannelArgument(channel_arg.name(), + channel_arg.int_value()); + break; + case ChannelArg::VALUE_NOT_SET: + gpr_log(GPR_ERROR, "Channel arg '%s' does not have a value", + channel_arg.name().c_str()); + break; + } + } + } + private: int port_; int cores_; diff --git a/test/cpp/qps/server_async.cc b/test/cpp/qps/server_async.cc index 96d7e5ef74..122976c397 100644 --- a/test/cpp/qps/server_async.cc +++ b/test/cpp/qps/server_async.cc @@ -99,10 +99,7 @@ class AsyncQpsServerTest final : public grpc::testing::Server { cq_.emplace_back(i % srv_cqs_.size()); } - if (config.resource_quota_size() > 0) { - builder.SetResourceQuota(ResourceQuota("AsyncQpsServerTest") - .Resize(config.resource_quota_size())); - } + ApplyConfigToBuilder(config, &builder); server_ = builder.BuildAndStart(); diff --git a/test/cpp/qps/server_sync.cc b/test/cpp/qps/server_sync.cc index 90aa89491f..07e41817b3 100644 --- a/test/cpp/qps/server_sync.cc +++ b/test/cpp/qps/server_sync.cc @@ -19,15 +19,12 @@ #include <atomic> #include <thread> -#include <grpc++/resource_quota.h> #include <grpc++/security/server_credentials.h> #include <grpc++/server.h> -#include <grpc++/server_builder.h> #include <grpc++/server_context.h> #include <grpc/grpc.h> #include <grpc/support/alloc.h> #include <grpc/support/host_port.h> -#include <grpc/support/log.h> #include "src/proto/grpc/testing/services.grpc.pb.h" #include "test/cpp/qps/server.h" @@ -166,10 +163,7 @@ class SynchronousServer final : public grpc::testing::Server { Server::CreateServerCredentials(config)); gpr_free(server_address); - if (config.resource_quota_size() > 0) { - builder.SetResourceQuota(ResourceQuota("AsyncQpsServerTest") - .Resize(config.resource_quota_size())); - } + ApplyConfigToBuilder(config, &builder); builder.RegisterService(&service_); |