Skip to content
Snippets Groups Projects
Commit ca5cdf45 authored by Noah Eisen's avatar Noah Eisen
Browse files

Add unimplemented_service test case for cpp interop client

parent 9785c8f9
No related branches found
No related tags found
No related merge requests found
...@@ -80,7 +80,8 @@ DEFINE_string(test_case, "large_unary", ...@@ -80,7 +80,8 @@ DEFINE_string(test_case, "large_unary",
"slow client consumer;\n" "slow client consumer;\n"
"status_code_and_message: verify status code & message;\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"); "unimplemented_method: client calls an unimplemented method;\n"
"unimplemented_service: client calls an unimplemented service;\n");
DEFINE_string(default_service_account, "", DEFINE_string(default_service_account, "",
"Email of GCE default service account"); "Email of GCE default service account");
DEFINE_string(service_account_key_file, "", DEFINE_string(service_account_key_file, "",
...@@ -152,6 +153,8 @@ int main(int argc, char** argv) { ...@@ -152,6 +153,8 @@ int main(int argc, char** argv) {
client.DoCustomMetadata(); client.DoCustomMetadata();
} else if (FLAGS_test_case == "unimplemented_method") { } else if (FLAGS_test_case == "unimplemented_method") {
client.DoUnimplementedMethod(); client.DoUnimplementedMethod();
} else if (FLAGS_test_case == "unimplemented_service") {
client.DoUnimplementedService();
} else if (FLAGS_test_case == "cacheable_unary") { } else if (FLAGS_test_case == "cacheable_unary") {
client.DoCacheableUnary(); client.DoCacheableUnary();
} else if (FLAGS_test_case == "all") { } else if (FLAGS_test_case == "all") {
...@@ -172,6 +175,7 @@ int main(int argc, char** argv) { ...@@ -172,6 +175,7 @@ int main(int argc, char** argv) {
client.DoStatusWithMessage(); client.DoStatusWithMessage();
client.DoCustomMetadata(); client.DoCustomMetadata();
client.DoUnimplementedMethod(); client.DoUnimplementedMethod();
client.DoUnimplementedService();
client.DoCacheableUnary(); client.DoCacheableUnary();
// service_account_creds and jwt_token_creds can only run with ssl. // service_account_creds and jwt_token_creds can only run with ssl.
if (FLAGS_use_tls) { if (FLAGS_use_tls) {
...@@ -207,7 +211,8 @@ int main(int argc, char** argv) { ...@@ -207,7 +211,8 @@ int main(int argc, char** argv) {
"server_streaming", "server_streaming",
"status_code_and_message", "status_code_and_message",
"timeout_on_sleeping_server", "timeout_on_sleeping_server",
"unimplemented_method"}; "unimplemented_method",
"unimplemented_service"};
char* joined_testcases = char* joined_testcases =
gpr_strjoin_sep(testcases, GPR_ARRAY_SIZE(testcases), "\n", NULL); gpr_strjoin_sep(testcases, GPR_ARRAY_SIZE(testcases), "\n", NULL);
......
...@@ -107,6 +107,11 @@ TestService::Stub* InteropClient::ServiceStub::Get() { ...@@ -107,6 +107,11 @@ TestService::Stub* InteropClient::ServiceStub::Get() {
return stub_.get(); return stub_.get();
} }
UnimplementedService::Stub*
InteropClient::ServiceStub::GetUnimplementedServiceStub() {
return UnimplementedService::NewStub(channel_).get();
}
void InteropClient::ServiceStub::Reset(std::shared_ptr<Channel> channel) { void InteropClient::ServiceStub::Reset(std::shared_ptr<Channel> channel) {
channel_ = channel; channel_ = channel;
...@@ -1002,6 +1007,27 @@ bool InteropClient::DoCustomMetadata() { ...@@ -1002,6 +1007,27 @@ bool InteropClient::DoCustomMetadata() {
return true; return true;
} }
bool InteropClient::DoUnimplementedService() {
gpr_log(GPR_DEBUG, "Sending a request for an unimplemented service...");
Empty request = Empty::default_instance();
Empty response = Empty::default_instance();
ClientContext context;
UnimplementedService::Stub* stub =
serviceStub_.GetUnimplementedServiceStub();
Status s =
stub->UnimplementedCall(&context, request, &response);
if (!AssertStatusCode(s, StatusCode::UNIMPLEMENTED)) {
return false;
}
gpr_log(GPR_DEBUG, "unimplemented service done.");
return true;
}
bool InteropClient::DoUnimplementedMethod() { bool InteropClient::DoUnimplementedMethod() {
gpr_log(GPR_DEBUG, "Sending a request for an unimplemented rpc..."); gpr_log(GPR_DEBUG, "Sending a request for an unimplemented rpc...");
......
...@@ -80,6 +80,7 @@ class InteropClient { ...@@ -80,6 +80,7 @@ class InteropClient {
bool DoStatusWithMessage(); bool DoStatusWithMessage();
bool DoCustomMetadata(); bool DoCustomMetadata();
bool DoUnimplementedMethod(); bool DoUnimplementedMethod();
bool DoUnimplementedService();
bool DoCacheableUnary(); bool DoCacheableUnary();
// Auth tests. // Auth tests.
// username is a string containing the user email // username is a string containing the user email
...@@ -100,6 +101,7 @@ class InteropClient { ...@@ -100,6 +101,7 @@ class InteropClient {
ServiceStub(std::shared_ptr<Channel> channel, bool new_stub_every_call); ServiceStub(std::shared_ptr<Channel> channel, bool new_stub_every_call);
TestService::Stub* Get(); TestService::Stub* Get();
UnimplementedService::Stub* GetUnimplementedServiceStub();
void Reset(std::shared_ptr<Channel> channel); void Reset(std::shared_ptr<Channel> channel);
......
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