Add channel args to qps server

pull/11532/head
Craig Tiller 7 years ago
parent a1a3f363ee
commit 873ee82277
  1. 1
      src/proto/grpc/testing/control.proto
  2. 28
      test/cpp/qps/server.h
  3. 5
      test/cpp/qps/server_async.cc
  4. 8
      test/cpp/qps/server_sync.cc

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

@ -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_;

@ -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();

@ -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_);

Loading…
Cancel
Save