diff options
author | vjpai <vpai@google.com> | 2015-05-05 17:11:02 -0700 |
---|---|---|
committer | vjpai <vpai@google.com> | 2015-05-05 17:11:02 -0700 |
commit | 4f1a75f0aaa0ab7b064ae7c985e90552b8832c74 (patch) | |
tree | b03daa3d7c27dc8e848100654b72e64fcdcfd1fd /test/cpp | |
parent | dfe83deb2c91c710ae51435689372eb67b641061 (diff) | |
parent | 234e62ce97d229141d3a1eea28103abbaa3d34d9 (diff) |
Merge branch 'master' into stream_ctx
Diffstat (limited to 'test/cpp')
-rw-r--r-- | test/cpp/end2end/end2end_test.cc | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index 93d7ace9a2..0945ed269d 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -172,7 +172,7 @@ class TestServiceImplDupPkg class End2endTest : public ::testing::Test { protected: - End2endTest() : thread_pool_(2) {} + End2endTest() : kMaxMessageSize_(8192), thread_pool_(2) {} void SetUp() GRPC_OVERRIDE { int port = grpc_pick_unused_port_or_die(); @@ -182,6 +182,8 @@ class End2endTest : public ::testing::Test { builder.AddListeningPort(server_address_.str(), InsecureServerCredentials()); builder.RegisterService(&service_); + builder.SetMaxMessageSize( + kMaxMessageSize_); // For testing max message size. builder.RegisterService(&dup_pkg_service_); builder.SetThreadPool(&thread_pool_); server_ = builder.BuildAndStart(); @@ -198,6 +200,7 @@ class End2endTest : public ::testing::Test { std::unique_ptr<grpc::cpp::test::util::TestService::Stub> stub_; std::unique_ptr<Server> server_; std::ostringstream server_address_; + const int kMaxMessageSize_; TestServiceImpl service_; TestServiceImplDupPkg dup_pkg_service_; ThreadPool thread_pool_; @@ -426,8 +429,7 @@ TEST_F(End2endTest, DiffPackageServices) { // rpc and stream should fail on bad credentials. TEST_F(End2endTest, BadCredentials) { - std::unique_ptr<Credentials> bad_creds = - ServiceAccountCredentials("", "", 1); + std::unique_ptr<Credentials> bad_creds = ServiceAccountCredentials("", "", 1); EXPECT_EQ(nullptr, bad_creds.get()); std::shared_ptr<ChannelInterface> channel = CreateChannel(server_address_.str(), bad_creds, ChannelArguments()); @@ -501,14 +503,13 @@ TEST_F(End2endTest, ClientCancelsRequestStream) { auto stream = stub_->RequestStream(&context, &response); EXPECT_TRUE(stream->Write(request)); EXPECT_TRUE(stream->Write(request)); - + context.TryCancel(); Status s = stream->Finish(); EXPECT_EQ(grpc::StatusCode::CANCELLED, s.code()); - - EXPECT_EQ(response.message(), ""); + EXPECT_EQ(response.message(), ""); } // Client cancels server stream after sending some messages @@ -588,6 +589,17 @@ TEST_F(End2endTest, ThreadStress) { } } +TEST_F(End2endTest, RpcMaxMessageSize) { + ResetStub(); + EchoRequest request; + EchoResponse response; + request.set_message(string(kMaxMessageSize_ * 2, 'a')); + + ClientContext context; + Status s = stub_->Echo(&context, request, &response); + EXPECT_FALSE(s.IsOk()); +} + } // namespace testing } // namespace grpc |