diff options
Diffstat (limited to 'test/cpp')
-rw-r--r-- | test/cpp/interop/client.cc | 9 | ||||
-rw-r--r-- | test/cpp/interop/interop_client.cc | 18 | ||||
-rw-r--r-- | test/cpp/interop/interop_client.h | 1 | ||||
-rw-r--r-- | test/cpp/interop/interop_server.cc | 38 |
4 files changed, 54 insertions, 12 deletions
diff --git a/test/cpp/interop/client.cc b/test/cpp/interop/client.cc index 999be9d8a3..245e27b2bb 100644 --- a/test/cpp/interop/client.cc +++ b/test/cpp/interop/client.cc @@ -79,7 +79,8 @@ DEFINE_string(test_case, "large_unary", "slow_consumer : single request with response streaming with " "slow client consumer;\n" "status_code_and_message: verify status code & message;\n" - "timeout_on_sleeping_server: deadline exceeds on stream;\n"); + "timeout_on_sleeping_server: deadline exceeds on stream;\n" + "unimplemented_method: client calls an unimplemented_method;\n"); DEFINE_string(default_service_account, "", "Email of GCE default service account"); DEFINE_string(service_account_key_file, "", @@ -149,6 +150,8 @@ int main(int argc, char** argv) { client.DoStatusWithMessage(); } else if (FLAGS_test_case == "custom_metadata") { client.DoCustomMetadata(); + } else if (FLAGS_test_case == "unimplemented_method") { + client.DoUnimplementedMethod(); } else if (FLAGS_test_case == "cacheable_unary") { client.DoCacheableUnary(); } else if (FLAGS_test_case == "all") { @@ -168,6 +171,7 @@ int main(int argc, char** argv) { client.DoEmptyStream(); client.DoStatusWithMessage(); client.DoCustomMetadata(); + client.DoUnimplementedMethod(); client.DoCacheableUnary(); // service_account_creds and jwt_token_creds can only run with ssl. if (FLAGS_use_tls) { @@ -202,7 +206,8 @@ int main(int argc, char** argv) { "server_compressed_unary", "server_streaming", "status_code_and_message", - "timeout_on_sleeping_server"}; + "timeout_on_sleeping_server", + "unimplemented_method"}; char* joined_testcases = gpr_strjoin_sep(testcases, GPR_ARRAY_SIZE(testcases), "\n", NULL); diff --git a/test/cpp/interop/interop_client.cc b/test/cpp/interop/interop_client.cc index e9a804ccae..effbb8a42e 100644 --- a/test/cpp/interop/interop_client.cc +++ b/test/cpp/interop/interop_client.cc @@ -981,5 +981,23 @@ bool InteropClient::DoCustomMetadata() { return true; } +bool InteropClient::DoUnimplementedMethod() { + gpr_log(GPR_DEBUG, "Sending a request for an unimplemented rpc..."); + + Empty request = Empty::default_instance(); + Empty response = Empty::default_instance(); + ClientContext context; + + Status s = serviceStub_.Get()->UnimplementedMethod( + &context, request, &response); + + if (!AssertStatusCode(s, StatusCode::UNIMPLEMENTED)) { + return false; + } + + gpr_log(GPR_DEBUG, "unimplemented rpc done."); + return true; +} + } // namespace testing } // namespace grpc diff --git a/test/cpp/interop/interop_client.h b/test/cpp/interop/interop_client.h index 1e89f0987d..0a96e7734d 100644 --- a/test/cpp/interop/interop_client.h +++ b/test/cpp/interop/interop_client.h @@ -79,6 +79,7 @@ class InteropClient { bool DoEmptyStream(); bool DoStatusWithMessage(); bool DoCustomMetadata(); + bool DoUnimplementedMethod(); bool DoCacheableUnary(); // Auth tests. // username is a string containing the user email diff --git a/test/cpp/interop/interop_server.cc b/test/cpp/interop/interop_server.cc index 58f20aa611..e0016148e8 100644 --- a/test/cpp/interop/interop_server.cc +++ b/test/cpp/interop/interop_server.cc @@ -83,6 +83,8 @@ const char kEchoInitialMetadataKey[] = "x-grpc-test-echo-initial"; const char kEchoTrailingBinMetadataKey[] = "x-grpc-test-echo-trailing-bin"; const char kEchoUserAgentKey[] = "x-grpc-test-echo-useragent"; +namespace { + void MaybeEchoMetadata(ServerContext* context) { const auto& client_metadata = context->client_metadata(); GPR_ASSERT(client_metadata.count(kEchoInitialMetadataKey) <= 1); @@ -146,6 +148,28 @@ bool CheckExpectedCompression(const ServerContext& context, return true; } +Status RequestedStatusOrOk(const SimpleRequest* request) { + if (request->has_response_status()) { + return Status( + static_cast<grpc::StatusCode>(request->response_status().code()), + request->response_status().message()); + } else { + return Status::OK; + } +} + +Status RequestedStatusOrOk(const StreamingOutputCallRequest* request) { + if (request->has_response_status()) { + return Status( + static_cast<grpc::StatusCode>(request->response_status().code()), + request->response_status().message()); + } else { + return Status::OK; + } +} + +} // anonomous namespace + class TestServiceImpl : public TestService::Service { public: Status EmptyCall(ServerContext* context, const grpc::testing::Empty* request, @@ -191,13 +215,7 @@ class TestServiceImpl : public TestService::Service { } } - if (request->has_response_status()) { - return Status( - static_cast<grpc::StatusCode>(request->response_status().code()), - request->response_status().message()); - } - - return Status::OK; + return RequestedStatusOrOk(request); } Status StreamingOutputCall( @@ -235,7 +253,7 @@ class TestServiceImpl : public TestService::Service { write_success = writer->Write(response, wopts); } if (write_success) { - return Status::OK; + return RequestedStatusOrOk(request); } else { return Status(grpc::StatusCode::INTERNAL, "Error writing response."); } @@ -285,7 +303,7 @@ class TestServiceImpl : public TestService::Service { } } if (write_success) { - return Status::OK; + return RequestedStatusOrOk(&request); } else { return Status(grpc::StatusCode::INTERNAL, "Error writing response."); } @@ -314,7 +332,7 @@ class TestServiceImpl : public TestService::Service { write_success = stream->Write(response); } if (write_success) { - return Status::OK; + return RequestedStatusOrOk(&request); } else { return Status(grpc::StatusCode::INTERNAL, "Error writing response."); } |