diff options
author | Yang Gao <yangg@google.com> | 2015-06-16 10:59:46 -0700 |
---|---|---|
committer | Yang Gao <yangg@google.com> | 2015-06-16 10:59:46 -0700 |
commit | c1a2c314fb45dafe73b01db23944503cf8961330 (patch) | |
tree | d4530702a7f059602e44c7c681c2a2a916af725b /test/cpp/end2end | |
parent | c1c697a89773558b31c63211bed7ef7a19759bce (diff) |
Update the Status API
Diffstat (limited to 'test/cpp/end2end')
-rw-r--r-- | test/cpp/end2end/async_end2end_test.cc | 18 | ||||
-rw-r--r-- | test/cpp/end2end/client_crash_test.cc | 4 | ||||
-rw-r--r-- | test/cpp/end2end/end2end_test.cc | 68 | ||||
-rw-r--r-- | test/cpp/end2end/generic_end2end_test.cc | 4 | ||||
-rw-r--r-- | test/cpp/end2end/mock_test.cc | 4 | ||||
-rw-r--r-- | test/cpp/end2end/thread_stress_test.cc | 6 |
6 files changed, 52 insertions, 52 deletions
diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc index 24595a820f..871f956491 100644 --- a/test/cpp/end2end/async_end2end_test.cc +++ b/test/cpp/end2end/async_end2end_test.cc @@ -157,7 +157,7 @@ class AsyncEnd2endTest : public ::testing::Test { client_ok(4); EXPECT_EQ(send_response.message(), recv_response.message()); - EXPECT_TRUE(recv_status.IsOk()); + EXPECT_TRUE(recv_status.ok()); } } @@ -218,7 +218,7 @@ TEST_F(AsyncEnd2endTest, AsyncNextRpc) { verify_timed_ok(&cli_cq_, 4, true); EXPECT_EQ(send_response.message(), recv_response.message()); - EXPECT_TRUE(recv_status.IsOk()); + EXPECT_TRUE(recv_status.ok()); } // Two pings and a final pong. @@ -272,7 +272,7 @@ TEST_F(AsyncEnd2endTest, SimpleClientStreaming) { client_ok(10); EXPECT_EQ(send_response.message(), recv_response.message()); - EXPECT_TRUE(recv_status.IsOk()); + EXPECT_TRUE(recv_status.ok()); } // One ping, two pongs. @@ -323,7 +323,7 @@ TEST_F(AsyncEnd2endTest, SimpleServerStreaming) { cli_stream->Finish(&recv_status, tag(9)); client_ok(9); - EXPECT_TRUE(recv_status.IsOk()); + EXPECT_TRUE(recv_status.ok()); } // One ping, one pong. @@ -376,7 +376,7 @@ TEST_F(AsyncEnd2endTest, SimpleBidiStreaming) { cli_stream->Finish(&recv_status, tag(10)); client_ok(10); - EXPECT_TRUE(recv_status.IsOk()); + EXPECT_TRUE(recv_status.ok()); } // Metadata tests @@ -420,7 +420,7 @@ TEST_F(AsyncEnd2endTest, ClientInitialMetadataRpc) { client_ok(4); EXPECT_EQ(send_response.message(), recv_response.message()); - EXPECT_TRUE(recv_status.IsOk()); + EXPECT_TRUE(recv_status.ok()); } TEST_F(AsyncEnd2endTest, ServerInitialMetadataRpc) { @@ -467,7 +467,7 @@ TEST_F(AsyncEnd2endTest, ServerInitialMetadataRpc) { client_ok(6); EXPECT_EQ(send_response.message(), recv_response.message()); - EXPECT_TRUE(recv_status.IsOk()); + EXPECT_TRUE(recv_status.ok()); } TEST_F(AsyncEnd2endTest, ServerTrailingMetadataRpc) { @@ -507,7 +507,7 @@ TEST_F(AsyncEnd2endTest, ServerTrailingMetadataRpc) { response_reader->Finish(&recv_response, &recv_status, tag(5)); client_ok(5); EXPECT_EQ(send_response.message(), recv_response.message()); - EXPECT_TRUE(recv_status.IsOk()); + EXPECT_TRUE(recv_status.ok()); auto server_trailing_metadata = cli_ctx.GetServerTrailingMetadata(); EXPECT_EQ(meta1.second, server_trailing_metadata.find(meta1.first)->second); EXPECT_EQ(meta2.second, server_trailing_metadata.find(meta2.first)->second); @@ -580,7 +580,7 @@ TEST_F(AsyncEnd2endTest, MetadataRpc) { response_reader->Finish(&recv_response, &recv_status, tag(6)); client_ok(6); EXPECT_EQ(send_response.message(), recv_response.message()); - EXPECT_TRUE(recv_status.IsOk()); + EXPECT_TRUE(recv_status.ok()); auto server_trailing_metadata = cli_ctx.GetServerTrailingMetadata(); EXPECT_EQ(meta5.second, server_trailing_metadata.find(meta5.first)->second); EXPECT_EQ(meta6.second, server_trailing_metadata.find(meta6.first)->second); diff --git a/test/cpp/end2end/client_crash_test.cc b/test/cpp/end2end/client_crash_test.cc index e86681f75a..aeba295947 100644 --- a/test/cpp/end2end/client_crash_test.cc +++ b/test/cpp/end2end/client_crash_test.cc @@ -119,7 +119,7 @@ TEST_F(CrashTest, KillAfterWrite) { EXPECT_FALSE(stream->Read(&response)); - EXPECT_FALSE(stream->Finish().IsOk()); + EXPECT_FALSE(stream->Finish().ok()); } TEST_F(CrashTest, KillBeforeWrite) { @@ -142,7 +142,7 @@ TEST_F(CrashTest, KillBeforeWrite) { EXPECT_FALSE(stream->Write(request)); EXPECT_FALSE(stream->Read(&response)); - EXPECT_FALSE(stream->Finish().IsOk()); + EXPECT_FALSE(stream->Finish().ok()); } } // namespace diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index f48cf953a4..45ba8b0878 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -101,13 +101,13 @@ class TestServiceImpl : public ::grpc::cpp::test::util::TestService::Service { gpr_now(), gpr_time_from_micros(request->param().client_cancel_after_us()))); } - return Status::Cancelled; + return Status::CANCELLED; } else if (request->has_param() && request->param().server_cancel_after_us()) { gpr_sleep_until(gpr_time_add( gpr_now(), gpr_time_from_micros(request->param().server_cancel_after_us()))); - return Status::Cancelled; + return Status::CANCELLED; } else { EXPECT_FALSE(context->IsCancelled()); } @@ -232,7 +232,7 @@ static void SendRpc(grpc::cpp::test::util::TestService::Stub* stub, ClientContext context; Status s = stub->Echo(&context, request, &response); EXPECT_EQ(response.message(), request.message()); - EXPECT_TRUE(s.IsOk()); + EXPECT_TRUE(s.ok()); } } @@ -265,7 +265,7 @@ TEST_F(End2endTest, RpcDeadlineExpires) { std::chrono::system_clock::now() + std::chrono::microseconds(10); context.set_deadline(deadline); Status s = stub_->Echo(&context, request, &response); - EXPECT_EQ(StatusCode::DEADLINE_EXCEEDED, s.code()); + EXPECT_EQ(StatusCode::DEADLINE_EXCEEDED, s.error_code()); } // Set a long but finite deadline. @@ -281,7 +281,7 @@ TEST_F(End2endTest, RpcLongDeadline) { context.set_deadline(deadline); Status s = stub_->Echo(&context, request, &response); EXPECT_EQ(response.message(), request.message()); - EXPECT_TRUE(s.IsOk()); + EXPECT_TRUE(s.ok()); } // Ask server to echo back the deadline it sees. @@ -298,7 +298,7 @@ TEST_F(End2endTest, EchoDeadline) { context.set_deadline(deadline); Status s = stub_->Echo(&context, request, &response); EXPECT_EQ(response.message(), request.message()); - EXPECT_TRUE(s.IsOk()); + EXPECT_TRUE(s.ok()); gpr_timespec sent_deadline; Timepoint2Timespec(deadline, &sent_deadline); // Allow 1 second error. @@ -317,7 +317,7 @@ TEST_F(End2endTest, EchoDeadlineForNoDeadlineRpc) { ClientContext context; Status s = stub_->Echo(&context, request, &response); EXPECT_EQ(response.message(), request.message()); - EXPECT_TRUE(s.IsOk()); + EXPECT_TRUE(s.ok()); EXPECT_EQ(response.param().request_deadline(), gpr_inf_future.tv_sec); } @@ -329,9 +329,9 @@ TEST_F(End2endTest, UnimplementedRpc) { ClientContext context; Status s = stub_->Unimplemented(&context, request, &response); - EXPECT_FALSE(s.IsOk()); - EXPECT_EQ(s.code(), grpc::StatusCode::UNIMPLEMENTED); - EXPECT_EQ(s.details(), ""); + EXPECT_FALSE(s.ok()); + EXPECT_EQ(s.error_code(), grpc::StatusCode::UNIMPLEMENTED); + EXPECT_EQ(s.error_message(), ""); EXPECT_EQ(response.message(), ""); } @@ -347,7 +347,7 @@ TEST_F(End2endTest, RequestStreamOneRequest) { stream->WritesDone(); Status s = stream->Finish(); EXPECT_EQ(response.message(), request.message()); - EXPECT_TRUE(s.IsOk()); + EXPECT_TRUE(s.ok()); } TEST_F(End2endTest, RequestStreamTwoRequests) { @@ -363,7 +363,7 @@ TEST_F(End2endTest, RequestStreamTwoRequests) { stream->WritesDone(); Status s = stream->Finish(); EXPECT_EQ(response.message(), "hellohello"); - EXPECT_TRUE(s.IsOk()); + EXPECT_TRUE(s.ok()); } TEST_F(End2endTest, ResponseStream) { @@ -383,7 +383,7 @@ TEST_F(End2endTest, ResponseStream) { EXPECT_FALSE(stream->Read(&response)); Status s = stream->Finish(); - EXPECT_TRUE(s.IsOk()); + EXPECT_TRUE(s.ok()); } TEST_F(End2endTest, BidiStream) { @@ -414,7 +414,7 @@ TEST_F(End2endTest, BidiStream) { EXPECT_FALSE(stream->Read(&response)); Status s = stream->Finish(); - EXPECT_TRUE(s.IsOk()); + EXPECT_TRUE(s.ok()); } // Talk to the two services with the same name but different package names. @@ -433,7 +433,7 @@ TEST_F(End2endTest, DiffPackageServices) { ClientContext context; Status s = stub->Echo(&context, request, &response); EXPECT_EQ(response.message(), request.message()); - EXPECT_TRUE(s.IsOk()); + EXPECT_TRUE(s.ok()); std::unique_ptr<grpc::cpp::test::util::duplicate::TestService::Stub> dup_pkg_stub( @@ -441,7 +441,7 @@ TEST_F(End2endTest, DiffPackageServices) { ClientContext context2; s = dup_pkg_stub->Echo(&context2, request, &response); EXPECT_EQ("no package", response.message()); - EXPECT_TRUE(s.IsOk()); + EXPECT_TRUE(s.ok()); } // rpc and stream should fail on bad credentials. @@ -459,16 +459,16 @@ TEST_F(End2endTest, BadCredentials) { Status s = stub->Echo(&context, request, &response); EXPECT_EQ("", response.message()); - EXPECT_FALSE(s.IsOk()); - EXPECT_EQ(StatusCode::UNKNOWN, s.code()); - EXPECT_EQ("Rpc sent on a lame channel.", s.details()); + EXPECT_FALSE(s.ok()); + EXPECT_EQ(StatusCode::UNKNOWN, s.error_code()); + EXPECT_EQ("Rpc sent on a lame channel.", s.error_message()); ClientContext context2; auto stream = stub->BidiStream(&context2); s = stream->Finish(); - EXPECT_FALSE(s.IsOk()); - EXPECT_EQ(StatusCode::UNKNOWN, s.code()); - EXPECT_EQ("Rpc sent on a lame channel.", s.details()); + EXPECT_FALSE(s.ok()); + EXPECT_EQ(StatusCode::UNKNOWN, s.error_code()); + EXPECT_EQ("Rpc sent on a lame channel.", s.error_message()); } void CancelRpc(ClientContext* context, int delay_us, TestServiceImpl* service) { @@ -491,8 +491,8 @@ TEST_F(End2endTest, ClientCancelsRpc) { std::thread cancel_thread(CancelRpc, &context, kCancelDelayUs, &service_); Status s = stub_->Echo(&context, request, &response); cancel_thread.join(); - EXPECT_EQ(StatusCode::CANCELLED, s.code()); - EXPECT_EQ(s.details(), "Cancelled"); + EXPECT_EQ(StatusCode::CANCELLED, s.error_code()); + EXPECT_EQ(s.error_message(), "Cancelled"); } // Server cancels rpc after 1ms @@ -505,8 +505,8 @@ TEST_F(End2endTest, ServerCancelsRpc) { ClientContext context; Status s = stub_->Echo(&context, request, &response); - EXPECT_EQ(StatusCode::CANCELLED, s.code()); - EXPECT_TRUE(s.details().empty()); + EXPECT_EQ(StatusCode::CANCELLED, s.error_code()); + EXPECT_TRUE(s.error_message().empty()); } // Client cancels request stream after sending two messages @@ -524,7 +524,7 @@ TEST_F(End2endTest, ClientCancelsRequestStream) { context.TryCancel(); Status s = stream->Finish(); - EXPECT_EQ(grpc::StatusCode::CANCELLED, s.code()); + EXPECT_EQ(grpc::StatusCode::CANCELLED, s.error_code()); EXPECT_EQ(response.message(), ""); } @@ -558,7 +558,7 @@ TEST_F(End2endTest, ClientCancelsResponseStream) { Status s = stream->Finish(); // The final status could be either of CANCELLED or OK depending on // who won the race. - EXPECT_GE(grpc::StatusCode::CANCELLED, s.code()); + EXPECT_GE(grpc::StatusCode::CANCELLED, s.error_code()); } // Client cancels bidi stream after sending some messages @@ -591,7 +591,7 @@ TEST_F(End2endTest, ClientCancelsBidi) { } Status s = stream->Finish(); - EXPECT_EQ(grpc::StatusCode::CANCELLED, s.code()); + EXPECT_EQ(grpc::StatusCode::CANCELLED, s.error_code()); } TEST_F(End2endTest, RpcMaxMessageSize) { @@ -602,7 +602,7 @@ TEST_F(End2endTest, RpcMaxMessageSize) { ClientContext context; Status s = stub_->Echo(&context, request, &response); - EXPECT_FALSE(s.IsOk()); + EXPECT_FALSE(s.ok()); } bool MetadataContains(const std::multimap<grpc::string, grpc::string>& metadata, @@ -632,7 +632,7 @@ TEST_F(End2endTest, SetPerCallCredentials) { Status s = stub_->Echo(&context, request, &response); EXPECT_EQ(request.message(), response.message()); - EXPECT_TRUE(s.IsOk()); + EXPECT_TRUE(s.ok()); EXPECT_TRUE(MetadataContains(context.GetServerTrailingMetadata(), GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY, "fake_token")); @@ -652,8 +652,8 @@ TEST_F(End2endTest, InsecurePerCallCredentials) { request.mutable_param()->set_echo_metadata(true); Status s = stub_->Echo(&context, request, &response); - EXPECT_EQ(StatusCode::CANCELLED, s.code()); - EXPECT_EQ("Failed to set credentials to rpc.", s.details()); + EXPECT_EQ(StatusCode::CANCELLED, s.error_code()); + EXPECT_EQ("Failed to set credentials to rpc.", s.error_message()); } TEST_F(End2endTest, OverridePerCallCredentials) { @@ -684,7 +684,7 @@ TEST_F(End2endTest, OverridePerCallCredentials) { GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY, "fake_selector1")); EXPECT_EQ(request.message(), response.message()); - EXPECT_TRUE(s.IsOk()); + EXPECT_TRUE(s.ok()); } } // namespace testing diff --git a/test/cpp/end2end/generic_end2end_test.cc b/test/cpp/end2end/generic_end2end_test.cc index 80e43fd854..7132b6b1f1 100644 --- a/test/cpp/end2end/generic_end2end_test.cc +++ b/test/cpp/end2end/generic_end2end_test.cc @@ -190,7 +190,7 @@ class GenericEnd2endTest : public ::testing::Test { client_ok(9); EXPECT_EQ(send_response.message(), recv_response.message()); - EXPECT_TRUE(recv_status.IsOk()); + EXPECT_TRUE(recv_status.ok()); } } @@ -273,7 +273,7 @@ TEST_F(GenericEnd2endTest, SimpleBidiStreaming) { client_ok(10); EXPECT_EQ(send_response.message(), recv_response.message()); - EXPECT_TRUE(recv_status.IsOk()); + EXPECT_TRUE(recv_status.ok()); } } // namespace diff --git a/test/cpp/end2end/mock_test.cc b/test/cpp/end2end/mock_test.cc index 0226da672c..2809ab8d3c 100644 --- a/test/cpp/end2end/mock_test.cc +++ b/test/cpp/end2end/mock_test.cc @@ -168,7 +168,7 @@ class FakeClient { request.set_message("hello world"); Status s = stub_->Echo(&context, request, &response); EXPECT_EQ(request.message(), response.message()); - EXPECT_TRUE(s.IsOk()); + EXPECT_TRUE(s.ok()); } void DoBidiStream() { @@ -199,7 +199,7 @@ class FakeClient { EXPECT_FALSE(stream->Read(&response)); Status s = stream->Finish(); - EXPECT_TRUE(s.IsOk()); + EXPECT_TRUE(s.ok()); } void ResetStub(TestService::StubInterface* stub) { stub_ = stub; } diff --git a/test/cpp/end2end/thread_stress_test.cc b/test/cpp/end2end/thread_stress_test.cc index 5ee29e40f4..0b43dfd106 100644 --- a/test/cpp/end2end/thread_stress_test.cc +++ b/test/cpp/end2end/thread_stress_test.cc @@ -99,13 +99,13 @@ class TestServiceImpl : public ::grpc::cpp::test::util::TestService::Service { gpr_now(), gpr_time_from_micros(request->param().client_cancel_after_us()))); } - return Status::Cancelled; + return Status::CANCELLED; } else if (request->has_param() && request->param().server_cancel_after_us()) { gpr_sleep_until(gpr_time_add( gpr_now(), gpr_time_from_micros(request->param().server_cancel_after_us()))); - return Status::Cancelled; + return Status::CANCELLED; } else { EXPECT_FALSE(context->IsCancelled()); } @@ -219,7 +219,7 @@ static void SendRpc(grpc::cpp::test::util::TestService::Stub* stub, ClientContext context; Status s = stub->Echo(&context, request, &response); EXPECT_EQ(response.message(), request.message()); - EXPECT_TRUE(s.IsOk()); + EXPECT_TRUE(s.ok()); } } |