From 653803e3109c38fa54a21ee7e93cdf4b42482bd1 Mon Sep 17 00:00:00 2001 From: vjpai Date: Mon, 23 Mar 2015 10:19:12 -0700 Subject: [PATCH] Make RPC type configurable --- test/cpp/qps/qps_driver.cc | 7 +++++++ test/cpp/qps/qpstest.proto | 8 ++++---- test/cpp/qps/worker.cc | 4 ++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/test/cpp/qps/qps_driver.cc b/test/cpp/qps/qps_driver.cc index bf51e7408e9..764fe136a81 100644 --- a/test/cpp/qps/qps_driver.cc +++ b/test/cpp/qps/qps_driver.cc @@ -42,6 +42,8 @@ DEFINE_int32(num_servers, 1, "Number of server binaries"); // Common config DEFINE_bool(enable_ssl, false, "Use SSL"); +DEFINE_string(rpc_type, "UNARY_TEST", + "Type of RPC: UNARY_TEST or STREAMING_TEST"); // Server config DEFINE_int32(server_threads, 1, "Number of server threads"); @@ -59,6 +61,7 @@ using grpc::testing::ClientConfig; using grpc::testing::ServerConfig; using grpc::testing::ClientType; using grpc::testing::ServerType; +using grpc::testing::RpcType; using grpc::testing::ResourceUsage; using grpc::testing::sum; @@ -73,6 +76,9 @@ int main(int argc, char **argv) { grpc_init(); ParseCommandLineFlags(&argc, &argv, true); + RpcType rpc_type; + RpcType_Parse(FLAGS_rpc_type, &rpc_type); + ClientType client_type; ServerType server_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_payload_size(FLAGS_payload_size); client_config.set_async_client_threads(FLAGS_async_client_threads); + client_config.set_rpc_type(rpc_type); ServerConfig server_config; server_config.set_server_type(server_type); diff --git a/test/cpp/qps/qpstest.proto b/test/cpp/qps/qpstest.proto index 70cc926f16f..1553ef5f07e 100644 --- a/test/cpp/qps/qpstest.proto +++ b/test/cpp/qps/qpstest.proto @@ -87,9 +87,9 @@ enum ServerType { ASYNC_SERVER = 2; } -enum TestType { - UNARY_TEST = 1; - STREAMING_TEST = 2; +enum RpcType { + UNARY = 1; + STREAMING = 2; } message ClientConfig { @@ -101,7 +101,7 @@ message ClientConfig { required int32 payload_size = 6; // only for async client: optional int32 async_client_threads = 7; - optional TestType test_type = 8 [default=UNARY_TEST]; + optional RpcType rpc_type = 8 [default=UNARY]; } // Request current stats diff --git a/test/cpp/qps/worker.cc b/test/cpp/qps/worker.cc index 4c8c7cfea9d..afe3ce90861 100644 --- a/test/cpp/qps/worker.cc +++ b/test/cpp/qps/worker.cc @@ -77,11 +77,11 @@ namespace testing { std::unique_ptr CreateClient(const ClientConfig& config) { switch (config.client_type()) { case ClientType::SYNCHRONOUS_CLIENT: - return (config.test_type() == TestType::UNARY_TEST) ? + return (config.rpc_type() == RpcType::UNARY) ? CreateSynchronousUnaryClient(config) : CreateSynchronousStreamingClient(config); case ClientType::ASYNC_CLIENT: - return (config.test_type() == TestType::UNARY_TEST) ? + return (config.rpc_type() == RpcType::UNARY) ? CreateAsyncUnaryClient(config) : CreateAsyncStreamingClient(config); } abort();