|
|
|
@ -122,7 +122,8 @@ InteropClient::InteropClient(std::shared_ptr<Channel> channel, |
|
|
|
|
: serviceStub_(channel, new_stub_every_test_case), |
|
|
|
|
do_not_abort_on_transient_failures_(do_not_abort_on_transient_failures) {} |
|
|
|
|
|
|
|
|
|
bool InteropClient::AssertStatusOk(const Status& s) { |
|
|
|
|
bool InteropClient::AssertStatusOk(const Status& s, |
|
|
|
|
const grpc::string& optional_debug_string) { |
|
|
|
|
if (s.ok()) { |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
@ -131,17 +132,21 @@ bool InteropClient::AssertStatusOk(const Status& s) { |
|
|
|
|
// already checked for s.ok() above). So, the following will call abort()
|
|
|
|
|
// (unless s.error_code() corresponds to a transient failure and
|
|
|
|
|
// 'do_not_abort_on_transient_failures' is true)
|
|
|
|
|
return AssertStatusCode(s, StatusCode::OK); |
|
|
|
|
return AssertStatusCode(s, StatusCode::OK, optional_debug_string); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool InteropClient::AssertStatusCode(const Status& s, |
|
|
|
|
StatusCode expected_code) { |
|
|
|
|
bool InteropClient::AssertStatusCode( |
|
|
|
|
const Status& s, StatusCode expected_code, |
|
|
|
|
const grpc::string& optional_debug_string) { |
|
|
|
|
if (s.error_code() == expected_code) { |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
gpr_log(GPR_ERROR, "Error status code: %d (expected: %d), message: %s", |
|
|
|
|
s.error_code(), expected_code, s.error_message().c_str()); |
|
|
|
|
gpr_log(GPR_ERROR, |
|
|
|
|
"Error status code: %d (expected: %d), message: %s," |
|
|
|
|
" debug string: %s", |
|
|
|
|
s.error_code(), expected_code, s.error_message().c_str(), |
|
|
|
|
optional_debug_string.c_str()); |
|
|
|
|
|
|
|
|
|
// In case of transient transient/retryable failures (like a broken
|
|
|
|
|
// connection) we may or may not abort (see TransientFailureOrAbort())
|
|
|
|
@ -161,7 +166,7 @@ bool InteropClient::DoEmpty() { |
|
|
|
|
|
|
|
|
|
Status s = serviceStub_.Get()->EmptyCall(&context, request, &response); |
|
|
|
|
|
|
|
|
|
if (!AssertStatusOk(s)) { |
|
|
|
|
if (!AssertStatusOk(s, context.debug_error_string())) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -191,7 +196,7 @@ bool InteropClient::PerformLargeUnary(SimpleRequest* request, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Status s = serviceStub_.Get()->UnaryCall(&context, *request, response); |
|
|
|
|
if (!AssertStatusOk(s)) { |
|
|
|
|
if (!AssertStatusOk(s, context.debug_error_string())) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -241,7 +246,7 @@ bool InteropClient::DoOauth2AuthToken(const grpc::string& username, |
|
|
|
|
|
|
|
|
|
Status s = serviceStub_.Get()->UnaryCall(&context, request, &response); |
|
|
|
|
|
|
|
|
|
if (!AssertStatusOk(s)) { |
|
|
|
|
if (!AssertStatusOk(s, context.debug_error_string())) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -269,7 +274,7 @@ bool InteropClient::DoPerRpcCreds(const grpc::string& json_key) { |
|
|
|
|
|
|
|
|
|
Status s = serviceStub_.Get()->UnaryCall(&context, request, &response); |
|
|
|
|
|
|
|
|
|
if (!AssertStatusOk(s)) { |
|
|
|
|
if (!AssertStatusOk(s, context.debug_error_string())) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -412,7 +417,7 @@ bool InteropClient::DoRequestStreaming() { |
|
|
|
|
GPR_ASSERT(stream->WritesDone()); |
|
|
|
|
|
|
|
|
|
Status s = stream->Finish(); |
|
|
|
|
if (!AssertStatusOk(s)) { |
|
|
|
|
if (!AssertStatusOk(s, context.debug_error_string())) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -451,7 +456,7 @@ bool InteropClient::DoResponseStreaming() { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Status s = stream->Finish(); |
|
|
|
|
if (!AssertStatusOk(s)) { |
|
|
|
|
if (!AssertStatusOk(s, context.debug_error_string())) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -516,7 +521,7 @@ bool InteropClient::DoClientCompressedStreaming() { |
|
|
|
|
GPR_ASSERT(stream->WritesDone()); |
|
|
|
|
|
|
|
|
|
s = stream->Finish(); |
|
|
|
|
if (!AssertStatusOk(s)) { |
|
|
|
|
if (!AssertStatusOk(s, context.debug_error_string())) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -578,7 +583,7 @@ bool InteropClient::DoServerCompressedStreaming() { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Status s = stream->Finish(); |
|
|
|
|
if (!AssertStatusOk(s)) { |
|
|
|
|
if (!AssertStatusOk(s, context.debug_error_string())) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
@ -619,7 +624,7 @@ bool InteropClient::DoResponseStreamingWithSlowConsumer() { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Status s = stream->Finish(); |
|
|
|
|
if (!AssertStatusOk(s)) { |
|
|
|
|
if (!AssertStatusOk(s, context.debug_error_string())) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -666,7 +671,7 @@ bool InteropClient::DoHalfDuplex() { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Status s = stream->Finish(); |
|
|
|
|
if (!AssertStatusOk(s)) { |
|
|
|
|
if (!AssertStatusOk(s, context.debug_error_string())) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -710,7 +715,7 @@ bool InteropClient::DoPingPong() { |
|
|
|
|
GPR_ASSERT(!stream->Read(&response)); |
|
|
|
|
|
|
|
|
|
Status s = stream->Finish(); |
|
|
|
|
if (!AssertStatusOk(s)) { |
|
|
|
|
if (!AssertStatusOk(s, context.debug_error_string())) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -732,7 +737,8 @@ bool InteropClient::DoCancelAfterBegin() { |
|
|
|
|
context.TryCancel(); |
|
|
|
|
Status s = stream->Finish(); |
|
|
|
|
|
|
|
|
|
if (!AssertStatusCode(s, StatusCode::CANCELLED)) { |
|
|
|
|
if (!AssertStatusCode(s, StatusCode::CANCELLED, |
|
|
|
|
context.debug_error_string())) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -790,7 +796,8 @@ bool InteropClient::DoTimeoutOnSleepingServer() { |
|
|
|
|
stream->Write(request); |
|
|
|
|
|
|
|
|
|
Status s = stream->Finish(); |
|
|
|
|
if (!AssertStatusCode(s, StatusCode::DEADLINE_EXCEEDED)) { |
|
|
|
|
if (!AssertStatusCode(s, StatusCode::DEADLINE_EXCEEDED, |
|
|
|
|
context.debug_error_string())) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -810,7 +817,7 @@ bool InteropClient::DoEmptyStream() { |
|
|
|
|
GPR_ASSERT(stream->Read(&response) == false); |
|
|
|
|
|
|
|
|
|
Status s = stream->Finish(); |
|
|
|
|
if (!AssertStatusOk(s)) { |
|
|
|
|
if (!AssertStatusOk(s, context.debug_error_string())) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -833,7 +840,8 @@ bool InteropClient::DoStatusWithMessage() { |
|
|
|
|
requested_status->set_code(test_code); |
|
|
|
|
requested_status->set_message(test_msg); |
|
|
|
|
Status s = serviceStub_.Get()->UnaryCall(&context, request, &response); |
|
|
|
|
if (!AssertStatusCode(s, grpc::StatusCode::UNKNOWN)) { |
|
|
|
|
if (!AssertStatusCode(s, grpc::StatusCode::UNKNOWN, |
|
|
|
|
context.debug_error_string())) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
GPR_ASSERT(s.error_message() == test_msg); |
|
|
|
@ -853,7 +861,8 @@ bool InteropClient::DoStatusWithMessage() { |
|
|
|
|
while (stream->Read(&streaming_response)) |
|
|
|
|
; |
|
|
|
|
s = stream->Finish(); |
|
|
|
|
if (!AssertStatusCode(s, grpc::StatusCode::UNKNOWN)) { |
|
|
|
|
if (!AssertStatusCode(s, grpc::StatusCode::UNKNOWN, |
|
|
|
|
context.debug_error_string())) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
GPR_ASSERT(s.error_message() == test_msg); |
|
|
|
@ -880,7 +889,7 @@ bool InteropClient::DoCacheableUnary() { |
|
|
|
|
context1.AddMetadata("x-user-ip", "1.2.3.4"); |
|
|
|
|
Status s1 = |
|
|
|
|
serviceStub_.Get()->CacheableUnaryCall(&context1, request, &response1); |
|
|
|
|
if (!AssertStatusOk(s1)) { |
|
|
|
|
if (!AssertStatusOk(s1, context1.debug_error_string())) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
gpr_log(GPR_DEBUG, "response 1 payload: %s", |
|
|
|
@ -893,7 +902,7 @@ bool InteropClient::DoCacheableUnary() { |
|
|
|
|
context2.AddMetadata("x-user-ip", "1.2.3.4"); |
|
|
|
|
Status s2 = |
|
|
|
|
serviceStub_.Get()->CacheableUnaryCall(&context2, request, &response2); |
|
|
|
|
if (!AssertStatusOk(s2)) { |
|
|
|
|
if (!AssertStatusOk(s2, context2.debug_error_string())) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
gpr_log(GPR_DEBUG, "response 2 payload: %s", |
|
|
|
@ -915,7 +924,7 @@ bool InteropClient::DoCacheableUnary() { |
|
|
|
|
context3.AddMetadata("x-user-ip", "1.2.3.4"); |
|
|
|
|
Status s3 = |
|
|
|
|
serviceStub_.Get()->CacheableUnaryCall(&context3, request1, &response3); |
|
|
|
|
if (!AssertStatusOk(s3)) { |
|
|
|
|
if (!AssertStatusOk(s3, context3.debug_error_string())) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
gpr_log(GPR_DEBUG, "response 3 payload: %s", |
|
|
|
@ -946,7 +955,7 @@ bool InteropClient::DoCustomMetadata() { |
|
|
|
|
request.mutable_payload()->set_body(payload.c_str(), kLargeRequestSize); |
|
|
|
|
|
|
|
|
|
Status s = serviceStub_.Get()->UnaryCall(&context, request, &response); |
|
|
|
|
if (!AssertStatusOk(s)) { |
|
|
|
|
if (!AssertStatusOk(s, context.debug_error_string())) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -997,7 +1006,7 @@ bool InteropClient::DoCustomMetadata() { |
|
|
|
|
GPR_ASSERT(!stream->Read(&response)); |
|
|
|
|
|
|
|
|
|
Status s = stream->Finish(); |
|
|
|
|
if (!AssertStatusOk(s)) { |
|
|
|
|
if (!AssertStatusOk(s, context.debug_error_string())) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1028,7 +1037,8 @@ bool InteropClient::DoUnimplementedService() { |
|
|
|
|
|
|
|
|
|
Status s = stub->UnimplementedCall(&context, request, &response); |
|
|
|
|
|
|
|
|
|
if (!AssertStatusCode(s, StatusCode::UNIMPLEMENTED)) { |
|
|
|
|
if (!AssertStatusCode(s, StatusCode::UNIMPLEMENTED, |
|
|
|
|
context.debug_error_string())) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1046,7 +1056,8 @@ bool InteropClient::DoUnimplementedMethod() { |
|
|
|
|
Status s = |
|
|
|
|
serviceStub_.Get()->UnimplementedCall(&context, request, &response); |
|
|
|
|
|
|
|
|
|
if (!AssertStatusCode(s, StatusCode::UNIMPLEMENTED)) { |
|
|
|
|
if (!AssertStatusCode(s, StatusCode::UNIMPLEMENTED, |
|
|
|
|
context.debug_error_string())) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|