Add support for server-side channel args to qps_test

pull/10860/head
Craig Tiller 8 years ago
parent 017b452b7b
commit edec4f5f81
  1. 2
      src/proto/grpc/testing/control.proto
  2. 25
      test/cpp/qps/server.h
  3. 5
      test/cpp/qps/server_async.cc
  4. 5
      test/cpp/qps/server_sync.cc

@ -158,6 +158,8 @@ message ServerConfig {
// Buffer pool size (no buffer pool specified if unset)
int32 resource_quota_size = 1001;
repeated ChannelArg channel_args = 1002;
}
message ServerArgs {

@ -34,8 +34,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/proto/grpc/testing/control.pb.h"
@ -106,6 +109,28 @@ class Server {
}
}
static void ApplyServerConfig(const ServerConfig& config,
ServerBuilder* builder) {
if (config.resource_quota_size() > 0) {
builder->SetResourceQuota(
ResourceQuota("QpsServerTest").Resize(config.resource_quota_size()));
}
for (auto arg : config.channel_args()) {
switch (arg.value_case()) {
case ChannelArg::kStrValue:
builder->AddChannelArgument(arg.name(), arg.str_value());
break;
case ChannelArg::kIntValue:
builder->AddChannelArgument(arg.name(), arg.int_value());
break;
default:
gpr_log(GPR_ERROR, "Channel arg '%s' ignored due to unknown type",
arg.name().c_str());
}
}
}
private:
int port_;
int cores_;

@ -96,10 +96,7 @@ class AsyncQpsServerTest final : public grpc::testing::Server {
srv_cqs_.emplace_back(builder.AddCompletionQueue());
}
if (config.resource_quota_size() > 0) {
builder.SetResourceQuota(ResourceQuota("AsyncQpsServerTest")
.Resize(config.resource_quota_size()));
}
ApplyServerConfig(config, &builder);
server_ = builder.BuildAndStart();

@ -94,10 +94,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()));
}
ApplyServerConfig(config, &builder);
builder.RegisterService(&service_);

Loading…
Cancel
Save