Make RPC type configurable

pull/1113/head
vjpai 10 years ago
parent 46f65239cf
commit 653803e310
  1. 7
      test/cpp/qps/qps_driver.cc
  2. 8
      test/cpp/qps/qpstest.proto
  3. 4
      test/cpp/qps/worker.cc

@ -42,6 +42,8 @@ DEFINE_int32(num_servers, 1, "Number of server binaries");
// Common config // Common config
DEFINE_bool(enable_ssl, false, "Use SSL"); DEFINE_bool(enable_ssl, false, "Use SSL");
DEFINE_string(rpc_type, "UNARY_TEST",
"Type of RPC: UNARY_TEST or STREAMING_TEST");
// Server config // Server config
DEFINE_int32(server_threads, 1, "Number of server threads"); DEFINE_int32(server_threads, 1, "Number of server threads");
@ -59,6 +61,7 @@ using grpc::testing::ClientConfig;
using grpc::testing::ServerConfig; using grpc::testing::ServerConfig;
using grpc::testing::ClientType; using grpc::testing::ClientType;
using grpc::testing::ServerType; using grpc::testing::ServerType;
using grpc::testing::RpcType;
using grpc::testing::ResourceUsage; using grpc::testing::ResourceUsage;
using grpc::testing::sum; using grpc::testing::sum;
@ -73,6 +76,9 @@ int main(int argc, char **argv) {
grpc_init(); grpc_init();
ParseCommandLineFlags(&argc, &argv, true); ParseCommandLineFlags(&argc, &argv, true);
RpcType rpc_type;
RpcType_Parse(FLAGS_rpc_type, &rpc_type);
ClientType client_type; ClientType client_type;
ServerType server_type; ServerType server_type;
GPR_ASSERT(ClientType_Parse(FLAGS_client_type, &client_type)); GPR_ASSERT(ClientType_Parse(FLAGS_client_type, &client_type));
@ -86,6 +92,7 @@ int main(int argc, char **argv) {
client_config.set_client_channels(FLAGS_client_channels); client_config.set_client_channels(FLAGS_client_channels);
client_config.set_payload_size(FLAGS_payload_size); client_config.set_payload_size(FLAGS_payload_size);
client_config.set_async_client_threads(FLAGS_async_client_threads); client_config.set_async_client_threads(FLAGS_async_client_threads);
client_config.set_rpc_type(rpc_type);
ServerConfig server_config; ServerConfig server_config;
server_config.set_server_type(server_type); server_config.set_server_type(server_type);

@ -87,9 +87,9 @@ enum ServerType {
ASYNC_SERVER = 2; ASYNC_SERVER = 2;
} }
enum TestType { enum RpcType {
UNARY_TEST = 1; UNARY = 1;
STREAMING_TEST = 2; STREAMING = 2;
} }
message ClientConfig { message ClientConfig {
@ -101,7 +101,7 @@ message ClientConfig {
required int32 payload_size = 6; required int32 payload_size = 6;
// only for async client: // only for async client:
optional int32 async_client_threads = 7; optional int32 async_client_threads = 7;
optional TestType test_type = 8 [default=UNARY_TEST]; optional RpcType rpc_type = 8 [default=UNARY];
} }
// Request current stats // Request current stats

@ -77,11 +77,11 @@ namespace testing {
std::unique_ptr<Client> CreateClient(const ClientConfig& config) { std::unique_ptr<Client> CreateClient(const ClientConfig& config) {
switch (config.client_type()) { switch (config.client_type()) {
case ClientType::SYNCHRONOUS_CLIENT: case ClientType::SYNCHRONOUS_CLIENT:
return (config.test_type() == TestType::UNARY_TEST) ? return (config.rpc_type() == RpcType::UNARY) ?
CreateSynchronousUnaryClient(config) : CreateSynchronousUnaryClient(config) :
CreateSynchronousStreamingClient(config); CreateSynchronousStreamingClient(config);
case ClientType::ASYNC_CLIENT: case ClientType::ASYNC_CLIENT:
return (config.test_type() == TestType::UNARY_TEST) ? return (config.rpc_type() == RpcType::UNARY) ?
CreateAsyncUnaryClient(config) : CreateAsyncStreamingClient(config); CreateAsyncUnaryClient(config) : CreateAsyncStreamingClient(config);
} }
abort(); abort();

Loading…
Cancel
Save