Skip to content

Commit

Permalink
Add unimplemented RPC test
Browse files Browse the repository at this point in the history
  • Loading branch information
vjpai committed Mar 7, 2019
1 parent 96f8b7a commit 240bf86
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions test/cpp/end2end/client_callback_end2end_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1084,6 +1084,39 @@ TEST_P(ClientCallbackEnd2endTest, SimultaneousReadAndWritesDone) {
test.Await();
}

TEST_P(ClientCallbackEnd2endTest, UnimplementedRpc) {
MAYBE_SKIP_TEST;
ChannelArguments args;
const auto& channel_creds = GetCredentialsProvider()->GetChannelCredentials(
GetParam().credentials_type, &args);
std::shared_ptr<Channel> channel =
(GetParam().protocol == Protocol::TCP)
? 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 request;
EchoResponse response;
ClientContext cli_ctx;
request.set_message("Hello world.");
std::mutex mu;
std::condition_variable cv;
bool done = false;
stub->experimental_async()->Unimplemented(
&cli_ctx, &request, &response, [&done, &mu, &cv](Status s) {
EXPECT_EQ(StatusCode::UNIMPLEMENTED, s.error_code());
EXPECT_EQ("", s.error_message());

std::lock_guard<std::mutex> l(mu);
done = true;
cv.notify_one();
});
std::unique_lock<std::mutex> l(mu);
while (!done) {
cv.wait(l);
}
}

std::vector<TestScenario> CreateTestScenarios(bool test_insecure) {
std::vector<TestScenario> scenarios;
std::vector<grpc::string> credentials_types{
Expand Down

0 comments on commit 240bf86

Please sign in to comment.