Skip to content
Snippets Groups Projects
Commit 9671a907 authored by Yang Gao's avatar Yang Gao
Browse files

Merge pull request #4907 from vjpai/generic_qps

Make generic QPS test work properly
parents 1613fdfb 36e77701
No related branches found
No related tags found
No related merge requests found
...@@ -31,8 +31,8 @@ ...@@ -31,8 +31,8 @@
* *
*/ */
#include <grpc/byte_buffer_reader.h>
#include <grpc++/support/byte_buffer.h> #include <grpc++/support/byte_buffer.h>
#include <grpc/byte_buffer_reader.h>
namespace grpc { namespace grpc {
...@@ -84,8 +84,10 @@ ByteBuffer::ByteBuffer(const ByteBuffer& buf) ...@@ -84,8 +84,10 @@ ByteBuffer::ByteBuffer(const ByteBuffer& buf)
: buffer_(grpc_byte_buffer_copy(buf.buffer_)) {} : buffer_(grpc_byte_buffer_copy(buf.buffer_)) {}
ByteBuffer& ByteBuffer::operator=(const ByteBuffer& buf) { ByteBuffer& ByteBuffer::operator=(const ByteBuffer& buf) {
Clear(); // first remove existing data Clear(); // first remove existing data
buffer_ = grpc_byte_buffer_copy(buf.buffer_); // then copy if (buf.buffer_) {
buffer_ = grpc_byte_buffer_copy(buf.buffer_); // then copy
}
return *this; return *this;
} }
......
// Copyright 2015, Google Inc. // Copyright 2015-2016, Google Inc.
// All rights reserved. // All rights reserved.
// //
// Redistribution and use in source and binary forms, with or without // Redistribution and use in source and binary forms, with or without
...@@ -42,6 +42,7 @@ enum ClientType { ...@@ -42,6 +42,7 @@ enum ClientType {
enum ServerType { enum ServerType {
SYNC_SERVER = 0; SYNC_SERVER = 0;
ASYNC_SERVER = 1; ASYNC_SERVER = 1;
ASYNC_GENERIC_SERVER = 2;
} }
enum RpcType { enum RpcType {
......
...@@ -60,7 +60,7 @@ static void RunGenericAsyncStreamingPingPong() { ...@@ -60,7 +60,7 @@ static void RunGenericAsyncStreamingPingPong() {
bbuf->set_req_size(0); bbuf->set_req_size(0);
ServerConfig server_config; ServerConfig server_config;
server_config.set_server_type(ASYNC_SERVER); server_config.set_server_type(ASYNC_GENERIC_SERVER);
server_config.set_host("localhost"); server_config.set_host("localhost");
server_config.set_async_server_threads(1); server_config.set_async_server_threads(1);
......
...@@ -170,7 +170,7 @@ static void QpsDriver() { ...@@ -170,7 +170,7 @@ static void QpsDriver() {
GPR_ASSERT(!client_config.payload_config().has_bytebuf_params() || GPR_ASSERT(!client_config.payload_config().has_bytebuf_params() ||
(client_config.client_type() == ASYNC_CLIENT && (client_config.client_type() == ASYNC_CLIENT &&
client_config.rpc_type() == STREAMING && client_config.rpc_type() == STREAMING &&
server_config.server_type() == ASYNC_SERVER)); server_config.server_type() == ASYNC_GENERIC_SERVER));
const auto result = RunScenario( const auto result = RunScenario(
client_config, FLAGS_num_clients, server_config, FLAGS_num_servers, client_config, FLAGS_num_clients, server_config, FLAGS_num_servers,
......
...@@ -97,6 +97,8 @@ static std::unique_ptr<Server> CreateServer(const ServerConfig& config) { ...@@ -97,6 +97,8 @@ static std::unique_ptr<Server> CreateServer(const ServerConfig& config) {
return CreateSynchronousServer(config); return CreateSynchronousServer(config);
case ServerType::ASYNC_SERVER: case ServerType::ASYNC_SERVER:
return CreateAsyncServer(config); return CreateAsyncServer(config);
case ServerType::ASYNC_GENERIC_SERVER:
return CreateAsyncGenericServer(config);
default: default:
abort(); abort();
} }
......
...@@ -108,6 +108,7 @@ class Server { ...@@ -108,6 +108,7 @@ class Server {
std::unique_ptr<Server> CreateSynchronousServer(const ServerConfig& config); std::unique_ptr<Server> CreateSynchronousServer(const ServerConfig& config);
std::unique_ptr<Server> CreateAsyncServer(const ServerConfig& config); std::unique_ptr<Server> CreateAsyncServer(const ServerConfig& config);
std::unique_ptr<Server> CreateAsyncGenericServer(const ServerConfig& config);
} // namespace testing } // namespace testing
} // namespace grpc } // namespace grpc
......
...@@ -373,7 +373,7 @@ static Status ProcessGenericRPC(const PayloadConfig &payload_config, ...@@ -373,7 +373,7 @@ static Status ProcessGenericRPC(const PayloadConfig &payload_config,
const ByteBuffer *request, const ByteBuffer *request,
ByteBuffer *response) { ByteBuffer *response) {
int resp_size = payload_config.bytebuf_params().resp_size(); int resp_size = payload_config.bytebuf_params().resp_size();
std::unique_ptr<char> buf(new char[resp_size]); std::unique_ptr<char[]> buf(new char[resp_size]);
gpr_slice s = gpr_slice_from_copied_buffer(buf.get(), resp_size); gpr_slice s = gpr_slice_from_copied_buffer(buf.get(), resp_size);
Slice slice(s, Slice::STEAL_REF); Slice slice(s, Slice::STEAL_REF);
*response = ByteBuffer(&slice, 1); *response = ByteBuffer(&slice, 1);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment