Skip to content

Commit

Permalink
Merge pull request grpc#1067 from yang-g/print
Browse files Browse the repository at this point in the history
Print out status when it is not ok in interop tests
  • Loading branch information
donnadionne committed Mar 19, 2015
2 parents 6cf02ed + 3c220df commit f209397
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions test/cpp/interop/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,15 @@ std::shared_ptr<ChannelInterface> CreateChannelForTestCase(
}
}

void AssertOkOrPrintErrorStatus(const grpc::Status& s) {
if (s.IsOk()) {
return;
}
gpr_log(GPR_INFO, "Error status code: %d, message: %s",
s.code(), s.details().c_str());
GPR_ASSERT(0);
}

void DoEmpty() {
gpr_log(GPR_INFO, "Sending an empty rpc...");
std::shared_ptr<ChannelInterface> channel =
Expand All @@ -172,8 +181,8 @@ void DoEmpty() {
ClientContext context;

grpc::Status s = stub->EmptyCall(&context, request, &response);
AssertOkOrPrintErrorStatus(s);

GPR_ASSERT(s.IsOk());
gpr_log(GPR_INFO, "Empty rpc done.");
}

Expand All @@ -190,7 +199,7 @@ void PerformLargeUnary(std::shared_ptr<ChannelInterface> channel,

grpc::Status s = stub->UnaryCall(&context, *request, response);

GPR_ASSERT(s.IsOk());
AssertOkOrPrintErrorStatus(s);
GPR_ASSERT(response->payload().type() ==
grpc::testing::PayloadType::COMPRESSABLE);
GPR_ASSERT(response->payload().body() ==
Expand Down Expand Up @@ -285,7 +294,7 @@ void DoRequestStreaming() {
grpc::Status s = stream->Finish();

GPR_ASSERT(response.aggregated_payload_size() == aggregated_payload_size);
GPR_ASSERT(s.IsOk());
AssertOkOrPrintErrorStatus(s);
gpr_log(GPR_INFO, "Request streaming done.");
}

Expand Down Expand Up @@ -314,7 +323,7 @@ void DoResponseStreaming() {
GPR_ASSERT(response_stream_sizes.size() == i);
grpc::Status s = stream->Finish();

GPR_ASSERT(s.IsOk());
AssertOkOrPrintErrorStatus(s);
gpr_log(GPR_INFO, "Response streaming done.");
}

Expand Down Expand Up @@ -346,7 +355,7 @@ void DoResponseStreamingWithSlowConsumer() {
GPR_ASSERT(kNumResponseMessages == i);
grpc::Status s = stream->Finish();

GPR_ASSERT(s.IsOk());
AssertOkOrPrintErrorStatus(s);
gpr_log(GPR_INFO, "Response streaming done.");
}

Expand Down Expand Up @@ -379,7 +388,7 @@ void DoHalfDuplex() {
}
GPR_ASSERT(response_stream_sizes.size() == i);
grpc::Status s = stream->Finish();
GPR_ASSERT(s.IsOk());
AssertOkOrPrintErrorStatus(s);
gpr_log(GPR_INFO, "Half-duplex streaming rpc done.");
}

Expand Down Expand Up @@ -412,7 +421,7 @@ void DoPingPong() {
stream->WritesDone();
GPR_ASSERT(!stream->Read(&response));
grpc::Status s = stream->Finish();
GPR_ASSERT(s.IsOk());
AssertOkOrPrintErrorStatus(s);
gpr_log(GPR_INFO, "Ping pong streaming done.");
}

Expand Down

0 comments on commit f209397

Please sign in to comment.