aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/cpp')
-rw-r--r--test/cpp/OWNERS4
-rw-r--r--test/cpp/end2end/async_end2end_test.cc60
-rw-r--r--test/cpp/end2end/client_lb_end2end_test.cc13
-rw-r--r--test/cpp/end2end/end2end_test.cc62
-rw-r--r--test/cpp/end2end/grpclb_end2end_test.cc22
-rw-r--r--test/cpp/end2end/thread_stress_test.cc102
-rw-r--r--test/cpp/interop/BUILD13
-rw-r--r--test/cpp/microbenchmarks/bm_cq_multiple_threads.cc12
-rw-r--r--test/cpp/microbenchmarks/bm_fullstack_streaming_ping_pong.cc16
-rw-r--r--test/cpp/microbenchmarks/bm_fullstack_streaming_pump.cc6
-rw-r--r--test/cpp/microbenchmarks/bm_fullstack_unary_ping_pong.cc54
-rw-r--r--test/cpp/microbenchmarks/fullstack_fixtures.h21
-rw-r--r--test/cpp/qps/OWNERS2
13 files changed, 287 insertions, 100 deletions
diff --git a/test/cpp/OWNERS b/test/cpp/OWNERS
deleted file mode 100644
index 8dca75ce91..0000000000
--- a/test/cpp/OWNERS
+++ /dev/null
@@ -1,4 +0,0 @@
-@ctiller
-@markdroth
-@dgquintas
-
diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc
index 7b78071217..7cb7b262de 100644
--- a/test/cpp/end2end/async_end2end_test.cc
+++ b/test/cpp/end2end/async_end2end_test.cc
@@ -212,14 +212,16 @@ class ServerBuilderSyncPluginDisabler : public ::grpc::ServerBuilderOption {
class TestScenario {
public:
- TestScenario(bool non_block, const grpc::string& creds_type, bool hcs,
- const grpc::string& content)
+ TestScenario(bool non_block, bool inproc_stub, const grpc::string& creds_type,
+ bool hcs, const grpc::string& content)
: disable_blocking(non_block),
+ inproc(inproc_stub),
health_check_service(hcs),
credentials_type(creds_type),
message_content(content) {}
void Log() const;
bool disable_blocking;
+ bool inproc;
bool health_check_service;
// Although the below grpc::string's are logically const, we can't declare
// them const because of a limitation in the way old compilers (e.g., gcc-4.4)
@@ -232,6 +234,7 @@ static std::ostream& operator<<(std::ostream& out,
const TestScenario& scenario) {
return out << "TestScenario{disable_blocking="
<< (scenario.disable_blocking ? "true" : "false")
+ << ", inproc=" << (scenario.inproc ? "true" : "false")
<< ", credentials='" << scenario.credentials_type
<< ", health_check_service="
<< (scenario.health_check_service ? "true" : "false")
@@ -294,7 +297,9 @@ class AsyncEnd2endTest : public ::testing::TestWithParam<TestScenario> {
auto channel_creds = GetCredentialsProvider()->GetChannelCredentials(
GetParam().credentials_type, &args);
std::shared_ptr<Channel> channel =
- CreateCustomChannel(server_address_.str(), channel_creds, args);
+ !(GetParam().inproc)
+ ? CreateCustomChannel(server_address_.str(), channel_creds, args)
+ : server_->InProcessChannel(args);
stub_ = grpc::testing::EchoTestService::NewStub(channel);
}
@@ -512,7 +517,7 @@ TEST_P(AsyncEnd2endTest, SimpleClientStreamingWithCoalescingApi) {
// up until server read is initiated. For write of send_request smaller than
// the flow control window size, the request can take the free ride with
// initial metadata due to coalescing, thus write tag:3 will come up here.
- if (GetParam().message_content.length() < 65536) {
+ if (GetParam().message_content.length() < 65536 || GetParam().inproc) {
Verifier(GetParam().disable_blocking)
.Expect(2, true)
.Expect(3, true)
@@ -523,7 +528,7 @@ TEST_P(AsyncEnd2endTest, SimpleClientStreamingWithCoalescingApi) {
srv_stream.Read(&recv_request, tag(4));
- if (GetParam().message_content.length() < 65536) {
+ if (GetParam().message_content.length() < 65536 || GetParam().inproc) {
Verifier(GetParam().disable_blocking).Expect(4, true).Verify(cq_.get());
} else {
Verifier(GetParam().disable_blocking)
@@ -807,7 +812,7 @@ TEST_P(AsyncEnd2endTest, SimpleBidiStreamingWithCoalescingApiWAF) {
// up until server read is initiated. For write of send_request smaller than
// the flow control window size, the request can take the free ride with
// initial metadata due to coalescing, thus write tag:3 will come up here.
- if (GetParam().message_content.length() < 65536) {
+ if (GetParam().message_content.length() < 65536 || GetParam().inproc) {
Verifier(GetParam().disable_blocking)
.Expect(2, true)
.Expect(3, true)
@@ -818,7 +823,7 @@ TEST_P(AsyncEnd2endTest, SimpleBidiStreamingWithCoalescingApiWAF) {
srv_stream.Read(&recv_request, tag(4));
- if (GetParam().message_content.length() < 65536) {
+ if (GetParam().message_content.length() < 65536 || GetParam().inproc) {
Verifier(GetParam().disable_blocking).Expect(4, true).Verify(cq_.get());
} else {
Verifier(GetParam().disable_blocking)
@@ -875,7 +880,7 @@ TEST_P(AsyncEnd2endTest, SimpleBidiStreamingWithCoalescingApiWL) {
// up until server read is initiated. For write of send_request smaller than
// the flow control window size, the request can take the free ride with
// initial metadata due to coalescing, thus write tag:3 will come up here.
- if (GetParam().message_content.length() < 65536) {
+ if (GetParam().message_content.length() < 65536 || GetParam().inproc) {
Verifier(GetParam().disable_blocking)
.Expect(2, true)
.Expect(3, true)
@@ -886,7 +891,7 @@ TEST_P(AsyncEnd2endTest, SimpleBidiStreamingWithCoalescingApiWL) {
srv_stream.Read(&recv_request, tag(4));
- if (GetParam().message_content.length() < 65536) {
+ if (GetParam().message_content.length() < 65536 || GetParam().inproc) {
Verifier(GetParam().disable_blocking).Expect(4, true).Verify(cq_.get());
} else {
Verifier(GetParam().disable_blocking)
@@ -1223,7 +1228,9 @@ TEST_P(AsyncEnd2endTest, UnimplementedRpc) {
auto channel_creds = GetCredentialsProvider()->GetChannelCredentials(
GetParam().credentials_type, &args);
std::shared_ptr<Channel> channel =
- CreateCustomChannel(server_address_.str(), channel_creds, args);
+ !(GetParam().inproc)
+ ? CreateCustomChannel(server_address_.str(), channel_creds, args)
+ : server_->InProcessChannel(args);
std::unique_ptr<grpc::testing::UnimplementedEchoService::Stub> stub;
stub = grpc::testing::UnimplementedEchoService::NewStub(channel);
EchoRequest send_request;
@@ -1634,13 +1641,17 @@ class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest {
// This is expected to succeed in all cases
cli_stream->WritesDone(tag(7));
verif.Expect(7, true);
- got_tag = verif.Next(cq_.get(), ignore_cq_result);
+ // TODO(vjpai): Consider whether the following is too flexible
+ // or whether it should just be reset to ignore_cq_result
+ bool ignore_cq_wd_result =
+ ignore_cq_result || (server_try_cancel == CANCEL_BEFORE_PROCESSING);
+ got_tag = verif.Next(cq_.get(), ignore_cq_wd_result);
GPR_ASSERT((got_tag == 7) || (got_tag == 11 && want_done_tag));
if (got_tag == 11) {
EXPECT_TRUE(srv_ctx.IsCancelled());
want_done_tag = false;
// Now get the other entry that we were waiting on
- EXPECT_EQ(verif.Next(cq_.get(), ignore_cq_result), 7);
+ EXPECT_EQ(verif.Next(cq_.get(), ignore_cq_wd_result), 7);
}
// This is expected to fail in all cases i.e for all values of
@@ -1732,8 +1743,14 @@ std::vector<TestScenario> CreateTestScenarios(bool test_disable_blocking,
std::vector<grpc::string> credentials_types;
std::vector<grpc::string> messages;
- if (GetCredentialsProvider()->GetChannelCredentials(kInsecureCredentialsType,
- nullptr) != nullptr) {
+ auto insec_ok = [] {
+ // Only allow insecure credentials type when it is registered with the
+ // provider. User may create providers that do not have insecure.
+ return GetCredentialsProvider()->GetChannelCredentials(
+ kInsecureCredentialsType, nullptr) != nullptr;
+ };
+
+ if (insec_ok()) {
credentials_types.push_back(kInsecureCredentialsType);
}
auto sec_list = GetCredentialsProvider()->GetSecureCredentialsTypeList();
@@ -1755,14 +1772,19 @@ std::vector<TestScenario> CreateTestScenarios(bool test_disable_blocking,
// TODO (sreek) Renable tests with health check service after the issue
// https://github.com/grpc/grpc/issues/11223 is resolved
for (auto health_check_service : {false}) {
- for (auto cred = credentials_types.begin(); cred != credentials_types.end();
- ++cred) {
- for (auto msg = messages.begin(); msg != messages.end(); msg++) {
- scenarios.emplace_back(false, *cred, health_check_service, *msg);
+ for (auto msg = messages.begin(); msg != messages.end(); msg++) {
+ for (auto cred = credentials_types.begin();
+ cred != credentials_types.end(); ++cred) {
+ scenarios.emplace_back(false, false, *cred, health_check_service, *msg);
if (test_disable_blocking) {
- scenarios.emplace_back(true, *cred, health_check_service, *msg);
+ scenarios.emplace_back(true, false, *cred, health_check_service,
+ *msg);
}
}
+ if (insec_ok()) {
+ scenarios.emplace_back(false, true, kInsecureCredentialsType,
+ health_check_service, *msg);
+ }
}
}
return scenarios;
diff --git a/test/cpp/end2end/client_lb_end2end_test.cc b/test/cpp/end2end/client_lb_end2end_test.cc
index 6d3f5a9d46..e1160ecdc6 100644
--- a/test/cpp/end2end/client_lb_end2end_test.cc
+++ b/test/cpp/end2end/client_lb_end2end_test.cc
@@ -35,6 +35,7 @@
extern "C" {
#include "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h"
+#include "src/core/ext/filters/client_channel/subchannel_index.h"
}
#include "src/proto/grpc/testing/echo.grpc.pb.h"
@@ -331,10 +332,14 @@ TEST_F(ClientLbEnd2endTest, PickFirstManyUpdates) {
for (size_t i = 0; i < servers_.size(); ++i) {
ports.emplace_back(servers_[i]->port_);
}
- for (size_t i = 0; i < 1000; ++i) {
- std::random_shuffle(ports.begin(), ports.end());
- SetNextResolution(ports);
- if (i % 10 == 0) SendRpc();
+ for (const bool force_creation : {true, false}) {
+ grpc_subchannel_index_test_only_set_force_creation(force_creation);
+ gpr_log(GPR_INFO, "Force subchannel creation: %d", force_creation);
+ for (size_t i = 0; i < 1000; ++i) {
+ std::random_shuffle(ports.begin(), ports.end());
+ SetNextResolution(ports);
+ if (i % 10 == 0) SendRpc();
+ }
}
// Check LB policy name for the channel.
EXPECT_EQ("pick_first", channel_->GetLoadBalancingPolicyName());
diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc
index d72dda3f59..8d12971bc1 100644
--- a/test/cpp/end2end/end2end_test.cc
+++ b/test/cpp/end2end/end2end_test.cc
@@ -193,10 +193,11 @@ class TestServiceImplDupPkg
class TestScenario {
public:
- TestScenario(bool proxy, const grpc::string& creds_type)
- : use_proxy(proxy), credentials_type(creds_type) {}
+ TestScenario(bool proxy, bool inproc_stub, const grpc::string& creds_type)
+ : use_proxy(proxy), inproc(inproc_stub), credentials_type(creds_type) {}
void Log() const;
bool use_proxy;
+ bool inproc;
// Although the below grpc::string is logically const, we can't declare
// them const because of a limitation in the way old compilers (e.g., gcc-4.4)
// manage vector insertion using a copy constructor
@@ -206,8 +207,9 @@ class TestScenario {
static std::ostream& operator<<(std::ostream& out,
const TestScenario& scenario) {
return out << "TestScenario{use_proxy="
- << (scenario.use_proxy ? "true" : "false") << ", credentials='"
- << scenario.credentials_type << "'}";
+ << (scenario.use_proxy ? "true" : "false")
+ << ", inproc=" << (scenario.inproc ? "true" : "false")
+ << ", credentials='" << scenario.credentials_type << "'}";
}
void TestScenario::Log() const {
@@ -273,7 +275,13 @@ class End2endTest : public ::testing::TestWithParam<TestScenario> {
args.SetUserAgentPrefix(user_agent_prefix_);
}
args.SetString(GRPC_ARG_SECONDARY_USER_AGENT_STRING, "end2end_test");
- channel_ = CreateCustomChannel(server_address_.str(), channel_creds, args);
+
+ if (!GetParam().inproc) {
+ channel_ =
+ CreateCustomChannel(server_address_.str(), channel_creds, args);
+ } else {
+ channel_ = server_->InProcessChannel(args);
+ }
}
void ResetStub() {
@@ -633,6 +641,10 @@ TEST_P(End2endServerTryCancelTest, BidiStreamServerCancelAfter) {
}
TEST_P(End2endTest, SimpleRpcWithCustomUserAgentPrefix) {
+ // User-Agent is an HTTP header for HTTP transports only
+ if (GetParam().inproc) {
+ return;
+ }
user_agent_prefix_ = "custom_prefix";
ResetStub();
EchoRequest request;
@@ -1065,6 +1077,10 @@ TEST_P(End2endTest, SimultaneousReadWritesDone) {
}
TEST_P(End2endTest, ChannelState) {
+ if (GetParam().inproc) {
+ return;
+ }
+
ResetStub();
// Start IDLE
EXPECT_EQ(GRPC_CHANNEL_IDLE, channel_->GetState(false));
@@ -1088,7 +1104,8 @@ TEST_P(End2endTest, ChannelState) {
// Takes 10s.
TEST_P(End2endTest, ChannelStateTimeout) {
- if (GetParam().credentials_type != kInsecureCredentialsType) {
+ if ((GetParam().credentials_type != kInsecureCredentialsType) ||
+ GetParam().inproc) {
return;
}
int port = grpc_pick_unused_port_or_die();
@@ -1669,51 +1686,56 @@ TEST_P(ResourceQuotaEnd2endTest, SimpleRequest) {
std::vector<TestScenario> CreateTestScenarios(bool use_proxy,
bool test_insecure,
- bool test_secure) {
+ bool test_secure,
+ bool test_inproc) {
std::vector<TestScenario> scenarios;
std::vector<grpc::string> credentials_types;
if (test_secure) {
credentials_types =
GetCredentialsProvider()->GetSecureCredentialsTypeList();
}
- if (test_insecure) {
- // Only add insecure credentials type when it is registered with the
+ auto insec_ok = [] {
+ // Only allow insecure credentials type when it is registered with the
// provider. User may create providers that do not have insecure.
- if (GetCredentialsProvider()->GetChannelCredentials(
- kInsecureCredentialsType, nullptr) != nullptr) {
- credentials_types.push_back(kInsecureCredentialsType);
- }
+ return GetCredentialsProvider()->GetChannelCredentials(
+ kInsecureCredentialsType, nullptr) != nullptr;
+ };
+ if (test_insecure && insec_ok()) {
+ credentials_types.push_back(kInsecureCredentialsType);
}
GPR_ASSERT(!credentials_types.empty());
for (auto it = credentials_types.begin(); it != credentials_types.end();
++it) {
- scenarios.emplace_back(false, *it);
+ scenarios.emplace_back(false, false, *it);
if (use_proxy) {
- scenarios.emplace_back(true, *it);
+ scenarios.emplace_back(true, false, *it);
}
}
+ if (test_inproc && insec_ok()) {
+ scenarios.emplace_back(false, true, kInsecureCredentialsType);
+ }
return scenarios;
}
INSTANTIATE_TEST_CASE_P(End2end, End2endTest,
::testing::ValuesIn(CreateTestScenarios(false, true,
- true)));
+ true, true)));
INSTANTIATE_TEST_CASE_P(End2endServerTryCancel, End2endServerTryCancelTest,
::testing::ValuesIn(CreateTestScenarios(false, true,
- true)));
+ true, true)));
INSTANTIATE_TEST_CASE_P(ProxyEnd2end, ProxyEnd2endTest,
::testing::ValuesIn(CreateTestScenarios(true, true,
- true)));
+ true, false)));
INSTANTIATE_TEST_CASE_P(SecureEnd2end, SecureEnd2endTest,
::testing::ValuesIn(CreateTestScenarios(false, false,
- true)));
+ true, false)));
INSTANTIATE_TEST_CASE_P(ResourceQuotaEnd2end, ResourceQuotaEnd2endTest,
::testing::ValuesIn(CreateTestScenarios(false, true,
- true)));
+ true, true)));
} // namespace
} // namespace testing
diff --git a/test/cpp/end2end/grpclb_end2end_test.cc b/test/cpp/end2end/grpclb_end2end_test.cc
index a8ac631fbd..86cce2d30d 100644
--- a/test/cpp/end2end/grpclb_end2end_test.cc
+++ b/test/cpp/end2end/grpclb_end2end_test.cc
@@ -195,12 +195,13 @@ class BalancerServiceImpl : public BalancerService {
for (const auto& response_and_delay : responses_and_delays) {
{
std::unique_lock<std::mutex> lock(mu_);
- if (shutdown_) break;
+ if (shutdown_) goto done;
}
SendResponse(stream, response_and_delay.first, response_and_delay.second);
}
{
std::unique_lock<std::mutex> lock(mu_);
+ if (shutdown_) goto done;
serverlist_cond_.wait(lock);
}
@@ -210,6 +211,9 @@ class BalancerServiceImpl : public BalancerService {
gpr_log(GPR_INFO, "LB: recv client load report msg: '%s'",
request.DebugString().c_str());
GPR_ASSERT(request.has_client_stats());
+ // We need to acquire the lock here in order to prevent the notify_one
+ // below from firing before its corresponding wait is executed.
+ std::lock_guard<std::mutex> lock(mu_);
client_stats_.num_calls_started +=
request.client_stats().num_calls_started();
client_stats_.num_calls_finished +=
@@ -225,10 +229,9 @@ class BalancerServiceImpl : public BalancerService {
.num_calls_finished_with_client_failed_to_send();
client_stats_.num_calls_finished_known_received +=
request.client_stats().num_calls_finished_known_received();
- std::lock_guard<std::mutex> lock(mu_);
load_report_cond_.notify_one();
}
-
+ done:
gpr_log(GPR_INFO, "LB: done");
return Status::OK;
}
@@ -429,19 +432,24 @@ class GrpclbEnd2endTest : public ::testing::Test {
explicit ServerThread(const grpc::string& type,
const grpc::string& server_host, T* service)
: type_(type), service_(service) {
+ std::mutex mu;
+ // We need to acquire the lock here in order to prevent the notify_one
+ // by ServerThread::Start from firing before the wait below is hit.
+ std::unique_lock<std::mutex> lock(mu);
port_ = grpc_pick_unused_port_or_die();
gpr_log(GPR_INFO, "starting %s server on port %d", type_.c_str(), port_);
- std::mutex mu;
std::condition_variable cond;
thread_.reset(new std::thread(
std::bind(&ServerThread::Start, this, server_host, &mu, &cond)));
- std::unique_lock<std::mutex> lock(mu);
cond.wait(lock);
gpr_log(GPR_INFO, "%s server startup complete", type_.c_str());
}
void Start(const grpc::string& server_host, std::mutex* mu,
std::condition_variable* cond) {
+ // We need to acquire the lock here in order to prevent the notify_one
+ // below from firing before its corresponding wait is executed.
+ std::lock_guard<std::mutex> lock(*mu);
std::ostringstream server_address;
server_address << server_host << ":" << port_;
ServerBuilder builder;
@@ -449,13 +457,12 @@ class GrpclbEnd2endTest : public ::testing::Test {
InsecureServerCredentials());
builder.RegisterService(service_);
server_ = builder.BuildAndStart();
- std::lock_guard<std::mutex> lock(*mu);
cond->notify_one();
}
void Shutdown() {
gpr_log(GPR_INFO, "%s about to shutdown", type_.c_str());
- server_->Shutdown();
+ server_->Shutdown(grpc_timeout_milliseconds_to_deadline(0));
thread_->join();
gpr_log(GPR_INFO, "%s shutdown completed", type_.c_str());
}
@@ -821,6 +828,7 @@ TEST_F(UpdatesTest, UpdateBalancersDeadUpdate) {
// Kill balancer 0
gpr_log(GPR_INFO, "********** ABOUT TO KILL BALANCER 0 *************");
+ balancers_[0]->NotifyDoneWithServerlists();
if (balancers_[0]->Shutdown()) balancer_servers_[0].Shutdown();
gpr_log(GPR_INFO, "********** KILLED BALANCER 0 *************");
diff --git a/test/cpp/end2end/thread_stress_test.cc b/test/cpp/end2end/thread_stress_test.cc
index 542df00fb4..f990a7ed9d 100644
--- a/test/cpp/end2end/thread_stress_test.cc
+++ b/test/cpp/end2end/thread_stress_test.cc
@@ -151,16 +151,6 @@ class TestServiceImpl : public ::grpc::testing::EchoTestService::Service {
std::mutex mu_;
};
-class TestServiceImplDupPkg
- : public ::grpc::testing::duplicate::EchoTestService::Service {
- public:
- Status Echo(ServerContext* context, const EchoRequest* request,
- EchoResponse* response) override {
- response->set_message("no package");
- return Status::OK;
- }
-};
-
template <class Service>
class CommonStressTest {
public:
@@ -168,63 +158,92 @@ class CommonStressTest {
virtual ~CommonStressTest() {}
virtual void SetUp() = 0;
virtual void TearDown() = 0;
- void ResetStub() {
- std::shared_ptr<Channel> channel =
- CreateChannel(server_address_.str(), InsecureChannelCredentials());
- stub_ = grpc::testing::EchoTestService::NewStub(channel);
- }
+ virtual void ResetStub() = 0;
grpc::testing::EchoTestService::Stub* GetStub() { return stub_.get(); }
protected:
- void SetUpStart(ServerBuilder* builder, Service* service) {
- int port = grpc_pick_unused_port_or_die();
- server_address_ << "localhost:" << port;
- // Setup server
- builder->AddListeningPort(server_address_.str(),
- InsecureServerCredentials());
+ std::unique_ptr<grpc::testing::EchoTestService::Stub> stub_;
+ std::unique_ptr<Server> server_;
+
+ virtual void SetUpStart(ServerBuilder* builder, Service* service) = 0;
+ void SetUpStartCommon(ServerBuilder* builder, Service* service) {
builder->RegisterService(service);
builder->SetMaxMessageSize(
kMaxMessageSize_); // For testing max message size.
- builder->RegisterService(&dup_pkg_service_);
}
void SetUpEnd(ServerBuilder* builder) { server_ = builder->BuildAndStart(); }
void TearDownStart() { server_->Shutdown(); }
void TearDownEnd() {}
private:
- std::unique_ptr<grpc::testing::EchoTestService::Stub> stub_;
- std::unique_ptr<Server> server_;
- std::ostringstream server_address_;
const int kMaxMessageSize_;
- TestServiceImplDupPkg dup_pkg_service_;
};
-class CommonStressTestSyncServer : public CommonStressTest<TestServiceImpl> {
+template <class Service>
+class CommonStressTestInsecure : public CommonStressTest<Service> {
+ public:
+ void ResetStub() override {
+ std::shared_ptr<Channel> channel =
+ CreateChannel(server_address_.str(), InsecureChannelCredentials());
+ this->stub_ = grpc::testing::EchoTestService::NewStub(channel);
+ }
+
+ protected:
+ void SetUpStart(ServerBuilder* builder, Service* service) override {
+ int port = grpc_pick_unused_port_or_die();
+ this->server_address_ << "localhost:" << port;
+ // Setup server
+ builder->AddListeningPort(server_address_.str(),
+ InsecureServerCredentials());
+ this->SetUpStartCommon(builder, service);
+ }
+
+ private:
+ std::ostringstream server_address_;
+};
+
+template <class Service>
+class CommonStressTestInproc : public CommonStressTest<Service> {
+ public:
+ void ResetStub() override {
+ ChannelArguments args;
+ std::shared_ptr<Channel> channel = this->server_->InProcessChannel(args);
+ this->stub_ = grpc::testing::EchoTestService::NewStub(channel);
+ }
+
+ protected:
+ void SetUpStart(ServerBuilder* builder, Service* service) override {
+ this->SetUpStartCommon(builder, service);
+ }
+};
+
+template <class BaseClass>
+class CommonStressTestSyncServer : public BaseClass {
public:
void SetUp() override {
ServerBuilder builder;
- SetUpStart(&builder, &service_);
- SetUpEnd(&builder);
+ this->SetUpStart(&builder, &service_);
+ this->SetUpEnd(&builder);
}
void TearDown() override {
- TearDownStart();
- TearDownEnd();
+ this->TearDownStart();
+ this->TearDownEnd();
}
private:
TestServiceImpl service_;
};
-class CommonStressTestAsyncServer
- : public CommonStressTest<grpc::testing::EchoTestService::AsyncService> {
+template <class BaseClass>
+class CommonStressTestAsyncServer : public BaseClass {
public:
CommonStressTestAsyncServer() : contexts_(kNumAsyncServerThreads * 100) {}
void SetUp() override {
shutting_down_ = false;
ServerBuilder builder;
- SetUpStart(&builder, &service_);
+ this->SetUpStart(&builder, &service_);
cq_ = builder.AddCompletionQueue();
- SetUpEnd(&builder);
+ this->SetUpEnd(&builder);
for (int i = 0; i < kNumAsyncServerThreads * 100; i++) {
RefreshContext(i);
}
@@ -236,7 +255,7 @@ class CommonStressTestAsyncServer
void TearDown() override {
{
std::unique_lock<std::mutex> l(mu_);
- TearDownStart();
+ this->TearDownStart();
shutting_down_ = true;
cq_->Shutdown();
}
@@ -249,7 +268,7 @@ class CommonStressTestAsyncServer
bool ignored_ok;
while (cq_->Next(&ignored_tag, &ignored_ok))
;
- TearDownEnd();
+ this->TearDownEnd();
}
private:
@@ -332,8 +351,13 @@ static void SendRpc(grpc::testing::EchoTestService::Stub* stub, int num_rpcs) {
}
}
-typedef ::testing::Types<CommonStressTestSyncServer,
- CommonStressTestAsyncServer>
+typedef ::testing::Types<
+ CommonStressTestSyncServer<CommonStressTestInsecure<TestServiceImpl>>,
+ CommonStressTestSyncServer<CommonStressTestInproc<TestServiceImpl>>,
+ CommonStressTestAsyncServer<
+ CommonStressTestInsecure<grpc::testing::EchoTestService::AsyncService>>,
+ CommonStressTestAsyncServer<
+ CommonStressTestInproc<grpc::testing::EchoTestService::AsyncService>>>
CommonTypes;
TYPED_TEST_CASE(End2endTest, CommonTypes);
TYPED_TEST(End2endTest, ThreadStress) {
diff --git a/test/cpp/interop/BUILD b/test/cpp/interop/BUILD
index 0de5a6f4da..9123bd929e 100644
--- a/test/cpp/interop/BUILD
+++ b/test/cpp/interop/BUILD
@@ -88,13 +88,22 @@ grpc_cc_library(
],
)
-grpc_cc_binary(
- name = "interop_client",
+grpc_cc_library(
+ name = "interop_client_main",
srcs = [
"client.cc",
],
+ language = "C++",
deps = [
":client_helper_lib",
+ ],
+)
+
+grpc_cc_binary(
+ name = "interop_client",
+ language = "C++",
+ deps = [
+ ":interop_client_main",
"//:grpc++",
],
)
diff --git a/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc b/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc
index 1e3830a556..f79db15a47 100644
--- a/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc
+++ b/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc
@@ -41,6 +41,7 @@ namespace testing {
static void* g_tag = (void*)(intptr_t)10; // Some random number
static grpc_completion_queue* g_cq;
static grpc_event_engine_vtable g_vtable;
+static const grpc_event_engine_vtable* g_old_vtable;
static void pollset_shutdown(grpc_exec_ctx* exec_ctx, grpc_pollset* ps,
grpc_closure* closure) {
@@ -72,7 +73,7 @@ static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* ps,
grpc_pollset_worker** worker, gpr_timespec now,
gpr_timespec deadline) {
if (gpr_time_cmp(deadline, gpr_time_0(GPR_CLOCK_MONOTONIC)) == 0) {
- gpr_log(GPR_ERROR, "no-op");
+ gpr_log(GPR_DEBUG, "no-op");
return GRPC_ERROR_NONE;
}
@@ -98,7 +99,12 @@ static void init_engine_vtable() {
static void setup() {
grpc_init();
+
+ /* Override the event engine with our test event engine (g_vtable); but before
+ * that, save the current event engine in g_old_vtable. We will have to set
+ * g_old_vtable back before calling grpc_shutdown() */
init_engine_vtable();
+ g_old_vtable = grpc_get_event_engine_test_only();
grpc_set_event_engine_test_only(&g_vtable);
g_cq = grpc_completion_queue_create_for_next(NULL);
@@ -115,6 +121,10 @@ static void teardown() {
}
grpc_completion_queue_destroy(g_cq);
+
+ /* Restore the old event engine before calling grpc_shutdown */
+ grpc_set_event_engine_test_only(g_old_vtable);
+ grpc_shutdown();
}
/* A few notes about Multi-threaded benchmarks:
diff --git a/test/cpp/microbenchmarks/bm_fullstack_streaming_ping_pong.cc b/test/cpp/microbenchmarks/bm_fullstack_streaming_ping_pong.cc
index f420bd7421..0712a40018 100644
--- a/test/cpp/microbenchmarks/bm_fullstack_streaming_ping_pong.cc
+++ b/test/cpp/microbenchmarks/bm_fullstack_streaming_ping_pong.cc
@@ -414,24 +414,34 @@ BENCHMARK_TEMPLATE(BM_StreamingPingPong, InProcessCHTTP2, NoOpMutator,
->Apply(StreamingPingPongArgs);
BENCHMARK_TEMPLATE(BM_StreamingPingPong, TCP, NoOpMutator, NoOpMutator)
->Apply(StreamingPingPongArgs);
+BENCHMARK_TEMPLATE(BM_StreamingPingPong, InProcess, NoOpMutator, NoOpMutator)
+ ->Apply(StreamingPingPongArgs);
BENCHMARK_TEMPLATE(BM_StreamingPingPongMsgs, InProcessCHTTP2, NoOpMutator,
NoOpMutator)
->Range(0, 128 * 1024 * 1024);
BENCHMARK_TEMPLATE(BM_StreamingPingPongMsgs, TCP, NoOpMutator, NoOpMutator)
->Range(0, 128 * 1024 * 1024);
+BENCHMARK_TEMPLATE(BM_StreamingPingPongMsgs, InProcess, NoOpMutator,
+ NoOpMutator)
+ ->Range(0, 128 * 1024 * 1024);
BENCHMARK_TEMPLATE(BM_StreamingPingPong, MinInProcessCHTTP2, NoOpMutator,
NoOpMutator)
->Apply(StreamingPingPongArgs);
BENCHMARK_TEMPLATE(BM_StreamingPingPong, MinTCP, NoOpMutator, NoOpMutator)
->Apply(StreamingPingPongArgs);
+BENCHMARK_TEMPLATE(BM_StreamingPingPong, MinInProcess, NoOpMutator, NoOpMutator)
+ ->Apply(StreamingPingPongArgs);
BENCHMARK_TEMPLATE(BM_StreamingPingPongMsgs, MinInProcessCHTTP2, NoOpMutator,
NoOpMutator)
->Range(0, 128 * 1024 * 1024);
BENCHMARK_TEMPLATE(BM_StreamingPingPongMsgs, MinTCP, NoOpMutator, NoOpMutator)
->Range(0, 128 * 1024 * 1024);
+BENCHMARK_TEMPLATE(BM_StreamingPingPongMsgs, MinInProcess, NoOpMutator,
+ NoOpMutator)
+ ->Range(0, 128 * 1024 * 1024);
// Generate Args for StreamingPingPongWithCoalescingApi benchmarks. Currently
// generates args for only "small streams" (i.e streams with 0, 1 or 2 messages)
@@ -459,6 +469,12 @@ BENCHMARK_TEMPLATE(BM_StreamingPingPongWithCoalescingApi, InProcessCHTTP2,
BENCHMARK_TEMPLATE(BM_StreamingPingPongWithCoalescingApi, MinInProcessCHTTP2,
NoOpMutator, NoOpMutator)
->Apply(StreamingPingPongWithCoalescingApiArgs);
+BENCHMARK_TEMPLATE(BM_StreamingPingPongWithCoalescingApi, InProcess,
+ NoOpMutator, NoOpMutator)
+ ->Apply(StreamingPingPongWithCoalescingApiArgs);
+BENCHMARK_TEMPLATE(BM_StreamingPingPongWithCoalescingApi, MinInProcess,
+ NoOpMutator, NoOpMutator)
+ ->Apply(StreamingPingPongWithCoalescingApiArgs);
} // namespace testing
} // namespace grpc
diff --git a/test/cpp/microbenchmarks/bm_fullstack_streaming_pump.cc b/test/cpp/microbenchmarks/bm_fullstack_streaming_pump.cc
index fc2d67ff11..6fbf9da0ad 100644
--- a/test/cpp/microbenchmarks/bm_fullstack_streaming_pump.cc
+++ b/test/cpp/microbenchmarks/bm_fullstack_streaming_pump.cc
@@ -173,6 +173,8 @@ BENCHMARK_TEMPLATE(BM_PumpStreamClientToServer, TCP)
->Range(0, 128 * 1024 * 1024);
BENCHMARK_TEMPLATE(BM_PumpStreamClientToServer, UDS)
->Range(0, 128 * 1024 * 1024);
+BENCHMARK_TEMPLATE(BM_PumpStreamClientToServer, InProcess)
+ ->Range(0, 128 * 1024 * 1024);
BENCHMARK_TEMPLATE(BM_PumpStreamClientToServer, SockPair)
->Range(0, 128 * 1024 * 1024);
BENCHMARK_TEMPLATE(BM_PumpStreamClientToServer, InProcessCHTTP2)
@@ -181,16 +183,20 @@ BENCHMARK_TEMPLATE(BM_PumpStreamServerToClient, TCP)
->Range(0, 128 * 1024 * 1024);
BENCHMARK_TEMPLATE(BM_PumpStreamServerToClient, UDS)
->Range(0, 128 * 1024 * 1024);
+BENCHMARK_TEMPLATE(BM_PumpStreamServerToClient, InProcess)
+ ->Range(0, 128 * 1024 * 1024);
BENCHMARK_TEMPLATE(BM_PumpStreamServerToClient, SockPair)
->Range(0, 128 * 1024 * 1024);
BENCHMARK_TEMPLATE(BM_PumpStreamServerToClient, InProcessCHTTP2)
->Range(0, 128 * 1024 * 1024);
BENCHMARK_TEMPLATE(BM_PumpStreamClientToServer, MinTCP)->Arg(0);
BENCHMARK_TEMPLATE(BM_PumpStreamClientToServer, MinUDS)->Arg(0);
+BENCHMARK_TEMPLATE(BM_PumpStreamClientToServer, MinInProcess)->Arg(0);
BENCHMARK_TEMPLATE(BM_PumpStreamClientToServer, MinSockPair)->Arg(0);
BENCHMARK_TEMPLATE(BM_PumpStreamClientToServer, MinInProcessCHTTP2)->Arg(0);
BENCHMARK_TEMPLATE(BM_PumpStreamServerToClient, MinTCP)->Arg(0);
BENCHMARK_TEMPLATE(BM_PumpStreamServerToClient, MinUDS)->Arg(0);
+BENCHMARK_TEMPLATE(BM_PumpStreamServerToClient, MinInProcess)->Arg(0);
BENCHMARK_TEMPLATE(BM_PumpStreamServerToClient, MinSockPair)->Arg(0);
BENCHMARK_TEMPLATE(BM_PumpStreamServerToClient, MinInProcessCHTTP2)->Arg(0);
diff --git a/test/cpp/microbenchmarks/bm_fullstack_unary_ping_pong.cc b/test/cpp/microbenchmarks/bm_fullstack_unary_ping_pong.cc
index ee2d5ec7f4..9af751245f 100644
--- a/test/cpp/microbenchmarks/bm_fullstack_unary_ping_pong.cc
+++ b/test/cpp/microbenchmarks/bm_fullstack_unary_ping_pong.cc
@@ -132,6 +132,10 @@ BENCHMARK_TEMPLATE(BM_UnaryPingPong, UDS, NoOpMutator, NoOpMutator)
->Args({0, 0});
BENCHMARK_TEMPLATE(BM_UnaryPingPong, MinUDS, NoOpMutator, NoOpMutator)
->Args({0, 0});
+BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess, NoOpMutator, NoOpMutator)
+ ->Apply(SweepSizesArgs);
+BENCHMARK_TEMPLATE(BM_UnaryPingPong, MinInProcess, NoOpMutator, NoOpMutator)
+ ->Apply(SweepSizesArgs);
BENCHMARK_TEMPLATE(BM_UnaryPingPong, SockPair, NoOpMutator, NoOpMutator)
->Args({0, 0});
BENCHMARK_TEMPLATE(BM_UnaryPingPong, MinSockPair, NoOpMutator, NoOpMutator)
@@ -191,6 +195,56 @@ BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, NoOpMutator,
BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, NoOpMutator,
Server_AddInitialMetadata<RandomAsciiMetadata<10>, 100>)
->Args({0, 0});
+BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess,
+ Client_AddMetadata<RandomBinaryMetadata<10>, 1>, NoOpMutator)
+ ->Args({0, 0});
+BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess,
+ Client_AddMetadata<RandomBinaryMetadata<31>, 1>, NoOpMutator)
+ ->Args({0, 0});
+BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess,
+ Client_AddMetadata<RandomBinaryMetadata<100>, 1>,
+ NoOpMutator)
+ ->Args({0, 0});
+BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess,
+ Client_AddMetadata<RandomBinaryMetadata<10>, 2>, NoOpMutator)
+ ->Args({0, 0});
+BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess,
+ Client_AddMetadata<RandomBinaryMetadata<31>, 2>, NoOpMutator)
+ ->Args({0, 0});
+BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess,
+ Client_AddMetadata<RandomBinaryMetadata<100>, 2>,
+ NoOpMutator)
+ ->Args({0, 0});
+BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess, NoOpMutator,
+ Server_AddInitialMetadata<RandomBinaryMetadata<10>, 1>)
+ ->Args({0, 0});
+BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess, NoOpMutator,
+ Server_AddInitialMetadata<RandomBinaryMetadata<31>, 1>)
+ ->Args({0, 0});
+BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess, NoOpMutator,
+ Server_AddInitialMetadata<RandomBinaryMetadata<100>, 1>)
+ ->Args({0, 0});
+BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess,
+ Client_AddMetadata<RandomAsciiMetadata<10>, 1>, NoOpMutator)
+ ->Args({0, 0});
+BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess,
+ Client_AddMetadata<RandomAsciiMetadata<31>, 1>, NoOpMutator)
+ ->Args({0, 0});
+BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess,
+ Client_AddMetadata<RandomAsciiMetadata<100>, 1>, NoOpMutator)
+ ->Args({0, 0});
+BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess, NoOpMutator,
+ Server_AddInitialMetadata<RandomAsciiMetadata<10>, 1>)
+ ->Args({0, 0});
+BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess, NoOpMutator,
+ Server_AddInitialMetadata<RandomAsciiMetadata<31>, 1>)
+ ->Args({0, 0});
+BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess, NoOpMutator,
+ Server_AddInitialMetadata<RandomAsciiMetadata<100>, 1>)
+ ->Args({0, 0});
+BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcess, NoOpMutator,
+ Server_AddInitialMetadata<RandomAsciiMetadata<10>, 100>)
+ ->Args({0, 0});
} // namespace testing
} // namespace grpc
diff --git a/test/cpp/microbenchmarks/fullstack_fixtures.h b/test/cpp/microbenchmarks/fullstack_fixtures.h
index 2320086afc..5477b860b4 100644
--- a/test/cpp/microbenchmarks/fullstack_fixtures.h
+++ b/test/cpp/microbenchmarks/fullstack_fixtures.h
@@ -66,14 +66,21 @@ class FullstackFixture : public BaseFixture {
FullstackFixture(Service* service, const FixtureConfiguration& config,
const grpc::string& address) {
ServerBuilder b;
- b.AddListeningPort(address, InsecureServerCredentials());
+ if (address.length() > 0) {
+ b.AddListeningPort(address, InsecureServerCredentials());
+ }
cq_ = b.AddCompletionQueue(true);
b.RegisterService(service);
config.ApplyCommonServerBuilderConfig(&b);
server_ = b.BuildAndStart();
ChannelArguments args;
config.ApplyCommonChannelArguments(&args);
- channel_ = CreateCustomChannel(address, InsecureChannelCredentials(), args);
+ if (address.length() > 0) {
+ channel_ =
+ CreateCustomChannel(address, InsecureChannelCredentials(), args);
+ } else {
+ channel_ = server_->InProcessChannel(args);
+ }
}
virtual ~FullstackFixture() {
@@ -139,6 +146,15 @@ class UDS : public FullstackFixture {
}
};
+class InProcess : public FullstackFixture {
+ public:
+ InProcess(Service* service,
+ const FixtureConfiguration& fixture_configuration =
+ FixtureConfiguration())
+ : FullstackFixture(service, fixture_configuration, "") {}
+ ~InProcess() {}
+};
+
class EndpointPairFixture : public BaseFixture {
public:
EndpointPairFixture(Service* service, grpc_endpoint_pair endpoints,
@@ -279,6 +295,7 @@ class MinStackize : public Base {
typedef MinStackize<TCP> MinTCP;
typedef MinStackize<UDS> MinUDS;
+typedef MinStackize<InProcess> MinInProcess;
typedef MinStackize<SockPair> MinSockPair;
typedef MinStackize<InProcessCHTTP2> MinInProcessCHTTP2;
diff --git a/test/cpp/qps/OWNERS b/test/cpp/qps/OWNERS
deleted file mode 100644
index 8ccea9ad9b..0000000000
--- a/test/cpp/qps/OWNERS
+++ /dev/null
@@ -1,2 +0,0 @@
-@vjpai
-