blob: f5ecd1a20c15a8545d32fe3ffa49f512314bf8f3 [file] [log] [blame]
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001/*
2 *
Craig Tiller06059952015-02-18 08:34:56 -08003 * Copyright 2015, Google Inc.
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08004 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
9 *
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above
13 * copyright notice, this list of conditions and the following disclaimer
14 * in the documentation and/or other materials provided with the
15 * distribution.
16 * * Neither the name of Google Inc. nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 */
33
yangged5e7e02015-01-06 10:16:15 -080034#include <chrono>
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080035#include <thread>
yangged5e7e02015-01-06 10:16:15 -080036
Craig Tiller14e60e92015-01-13 17:26:46 -080037#include "test/core/util/test_config.h"
Craig Tiller35e39712015-01-12 16:41:24 -080038#include "test/cpp/util/echo_duplicate.pb.h"
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080039#include "test/cpp/util/echo.pb.h"
yangged5e7e02015-01-06 10:16:15 -080040#include "src/cpp/util/time.h"
Craig Tiller7418d012015-02-11 15:25:03 -080041#include "src/cpp/server/thread_pool.h"
yangg59dfc902014-12-19 14:00:14 -080042#include <grpc++/channel_arguments.h>
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080043#include <grpc++/channel_interface.h>
44#include <grpc++/client_context.h>
45#include <grpc++/create_channel.h>
yangg4105e2b2015-01-09 14:19:44 -080046#include <grpc++/credentials.h>
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080047#include <grpc++/server.h>
48#include <grpc++/server_builder.h>
yangga4b6f5d2014-12-17 15:53:12 -080049#include <grpc++/server_context.h>
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080050#include <grpc++/status.h>
nnoble0c475f02014-12-05 15:37:39 -080051#include <grpc++/stream.h>
Craig Tiller35e39712015-01-12 16:41:24 -080052#include "test/core/util/port.h"
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080053#include <gtest/gtest.h>
54
55#include <grpc/grpc.h>
56#include <grpc/support/thd.h>
yangged5e7e02015-01-06 10:16:15 -080057#include <grpc/support/time.h>
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080058
59using grpc::cpp::test::util::EchoRequest;
60using grpc::cpp::test::util::EchoResponse;
yangged5e7e02015-01-06 10:16:15 -080061using std::chrono::system_clock;
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080062
63namespace grpc {
yangged5e7e02015-01-06 10:16:15 -080064namespace testing {
65
66namespace {
67
68// When echo_deadline is requested, deadline seen in the ServerContext is set in
69// the response in seconds.
70void MaybeEchoDeadline(ServerContext* context, const EchoRequest* request,
71 EchoResponse* response) {
72 if (request->has_param() && request->param().echo_deadline()) {
73 gpr_timespec deadline = gpr_inf_future;
74 if (context->absolute_deadline() != system_clock::time_point::max()) {
75 Timepoint2Timespec(context->absolute_deadline(), &deadline);
76 }
77 response->mutable_param()->set_request_deadline(deadline.tv_sec);
78 }
79}
Craig Tiller7418d012015-02-11 15:25:03 -080080
yangged5e7e02015-01-06 10:16:15 -080081} // namespace
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080082
yangg1456d152015-01-08 15:39:58 -080083class TestServiceImpl : public ::grpc::cpp::test::util::TestService::Service {
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080084 public:
yangga4b6f5d2014-12-17 15:53:12 -080085 Status Echo(ServerContext* context, const EchoRequest* request,
yangg1456d152015-01-08 15:39:58 -080086 EchoResponse* response) override {
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080087 response->set_message(request->message());
yangged5e7e02015-01-06 10:16:15 -080088 MaybeEchoDeadline(context, request, response);
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080089 return Status::OK;
90 }
nnoble0c475f02014-12-05 15:37:39 -080091
92 // Unimplemented is left unimplemented to test the returned error.
93
yangga4b6f5d2014-12-17 15:53:12 -080094 Status RequestStream(ServerContext* context,
95 ServerReader<EchoRequest>* reader,
yangg1456d152015-01-08 15:39:58 -080096 EchoResponse* response) override {
nnoble0c475f02014-12-05 15:37:39 -080097 EchoRequest request;
98 response->set_message("");
99 while (reader->Read(&request)) {
100 response->mutable_message()->append(request.message());
101 }
102 return Status::OK;
103 }
104
105 // Return 3 messages.
106 // TODO(yangg) make it generic by adding a parameter into EchoRequest
yangga4b6f5d2014-12-17 15:53:12 -0800107 Status ResponseStream(ServerContext* context, const EchoRequest* request,
yangg1456d152015-01-08 15:39:58 -0800108 ServerWriter<EchoResponse>* writer) override {
nnoble0c475f02014-12-05 15:37:39 -0800109 EchoResponse response;
110 response.set_message(request->message() + "0");
111 writer->Write(response);
112 response.set_message(request->message() + "1");
113 writer->Write(response);
114 response.set_message(request->message() + "2");
115 writer->Write(response);
116
117 return Status::OK;
118 }
119
yangg1456d152015-01-08 15:39:58 -0800120 Status BidiStream(
121 ServerContext* context,
122 ServerReaderWriter<EchoResponse, EchoRequest>* stream) override {
nnoble0c475f02014-12-05 15:37:39 -0800123 EchoRequest request;
124 EchoResponse response;
125 while (stream->Read(&request)) {
126 gpr_log(GPR_INFO, "recv msg %s", request.message().c_str());
127 response.set_message(request.message());
128 stream->Write(response);
129 }
130 return Status::OK;
131 }
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800132};
133
yangg1456d152015-01-08 15:39:58 -0800134class TestServiceImplDupPkg
135 : public ::grpc::cpp::test::util::duplicate::TestService::Service {
136 public:
137 Status Echo(ServerContext* context, const EchoRequest* request,
138 EchoResponse* response) override {
139 response->set_message("no package");
140 return Status::OK;
141 }
142};
143
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800144class End2endTest : public ::testing::Test {
145 protected:
Craig Tiller7418d012015-02-11 15:25:03 -0800146 End2endTest() : thread_pool_(2) {}
147
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800148 void SetUp() override {
Craig Tiller35e39712015-01-12 16:41:24 -0800149 int port = grpc_pick_unused_port_or_die();
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800150 server_address_ << "localhost:" << port;
151 // Setup server
152 ServerBuilder builder;
153 builder.AddPort(server_address_.str());
Craig Tillerf8ac5d82015-02-09 16:24:20 -0800154 builder.RegisterService(&service_);
155 builder.RegisterService(&dup_pkg_service_);
Craig Tiller7418d012015-02-11 15:25:03 -0800156 builder.SetThreadPool(&thread_pool_);
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800157 server_ = builder.BuildAndStart();
158 }
159
Craig Tillerb5dcec52015-01-13 11:13:42 -0800160 void TearDown() override { server_->Shutdown(); }
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800161
yangg1456d152015-01-08 15:39:58 -0800162 void ResetStub() {
Craig Tiller47c83fd2015-02-21 22:45:35 -0800163 std::shared_ptr<ChannelInterface> channel = CreateChannel(
164 server_address_.str(), InsecureCredentials(), ChannelArguments());
yangg1456d152015-01-08 15:39:58 -0800165 stub_.reset(grpc::cpp::test::util::TestService::NewStub(channel));
166 }
167
168 std::unique_ptr<grpc::cpp::test::util::TestService::Stub> stub_;
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800169 std::unique_ptr<Server> server_;
170 std::ostringstream server_address_;
nnoble0c475f02014-12-05 15:37:39 -0800171 TestServiceImpl service_;
yangg1456d152015-01-08 15:39:58 -0800172 TestServiceImplDupPkg dup_pkg_service_;
Craig Tiller7418d012015-02-11 15:25:03 -0800173 ThreadPool thread_pool_;
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800174};
175
yangg1456d152015-01-08 15:39:58 -0800176static void SendRpc(grpc::cpp::test::util::TestService::Stub* stub,
177 int num_rpcs) {
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800178 EchoRequest request;
179 EchoResponse response;
180 request.set_message("Hello");
181
182 for (int i = 0; i < num_rpcs; ++i) {
183 ClientContext context;
184 Status s = stub->Echo(&context, request, &response);
185 EXPECT_EQ(response.message(), request.message());
186 EXPECT_TRUE(s.IsOk());
187 }
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800188}
189
190TEST_F(End2endTest, SimpleRpc) {
yangg1456d152015-01-08 15:39:58 -0800191 ResetStub();
192 SendRpc(stub_.get(), 1);
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800193}
194
195TEST_F(End2endTest, MultipleRpcs) {
yangg1456d152015-01-08 15:39:58 -0800196 ResetStub();
Craig Tiller35e39712015-01-12 16:41:24 -0800197 std::vector<std::thread*> threads;
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800198 for (int i = 0; i < 10; ++i) {
yangg1456d152015-01-08 15:39:58 -0800199 threads.push_back(new std::thread(SendRpc, stub_.get(), 10));
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800200 }
201 for (int i = 0; i < 10; ++i) {
202 threads[i]->join();
203 delete threads[i];
204 }
205}
206
yanggda029e32014-12-18 10:24:04 -0800207// Set a 10us deadline and make sure proper error is returned.
208TEST_F(End2endTest, RpcDeadlineExpires) {
yangg1456d152015-01-08 15:39:58 -0800209 ResetStub();
yanggda029e32014-12-18 10:24:04 -0800210 EchoRequest request;
211 EchoResponse response;
212 request.set_message("Hello");
213
214 ClientContext context;
215 std::chrono::system_clock::time_point deadline =
216 std::chrono::system_clock::now() + std::chrono::microseconds(10);
217 context.set_absolute_deadline(deadline);
yangg1456d152015-01-08 15:39:58 -0800218 Status s = stub_->Echo(&context, request, &response);
Craig Tiller7b018782015-01-16 09:53:39 -0800219 EXPECT_EQ(StatusCode::DEADLINE_EXCEEDED, s.code());
yanggda029e32014-12-18 10:24:04 -0800220}
221
yangged5e7e02015-01-06 10:16:15 -0800222// Set a long but finite deadline.
223TEST_F(End2endTest, RpcLongDeadline) {
yangg1456d152015-01-08 15:39:58 -0800224 ResetStub();
yangged5e7e02015-01-06 10:16:15 -0800225 EchoRequest request;
226 EchoResponse response;
227 request.set_message("Hello");
228
229 ClientContext context;
230 std::chrono::system_clock::time_point deadline =
231 std::chrono::system_clock::now() + std::chrono::hours(1);
232 context.set_absolute_deadline(deadline);
yangg1456d152015-01-08 15:39:58 -0800233 Status s = stub_->Echo(&context, request, &response);
yangged5e7e02015-01-06 10:16:15 -0800234 EXPECT_EQ(response.message(), request.message());
235 EXPECT_TRUE(s.IsOk());
yangged5e7e02015-01-06 10:16:15 -0800236}
237
238// Ask server to echo back the deadline it sees.
239TEST_F(End2endTest, EchoDeadline) {
yangg1456d152015-01-08 15:39:58 -0800240 ResetStub();
yangged5e7e02015-01-06 10:16:15 -0800241 EchoRequest request;
242 EchoResponse response;
243 request.set_message("Hello");
244 request.mutable_param()->set_echo_deadline(true);
245
246 ClientContext context;
247 std::chrono::system_clock::time_point deadline =
248 std::chrono::system_clock::now() + std::chrono::seconds(100);
249 context.set_absolute_deadline(deadline);
yangg1456d152015-01-08 15:39:58 -0800250 Status s = stub_->Echo(&context, request, &response);
yangged5e7e02015-01-06 10:16:15 -0800251 EXPECT_EQ(response.message(), request.message());
252 EXPECT_TRUE(s.IsOk());
253 gpr_timespec sent_deadline;
254 Timepoint2Timespec(deadline, &sent_deadline);
255 // Allow 1 second error.
256 EXPECT_LE(response.param().request_deadline() - sent_deadline.tv_sec, 1);
257 EXPECT_GE(response.param().request_deadline() - sent_deadline.tv_sec, -1);
yangged5e7e02015-01-06 10:16:15 -0800258}
259
260// Ask server to echo back the deadline it sees. The rpc has no deadline.
261TEST_F(End2endTest, EchoDeadlineForNoDeadlineRpc) {
yangg1456d152015-01-08 15:39:58 -0800262 ResetStub();
yangged5e7e02015-01-06 10:16:15 -0800263 EchoRequest request;
264 EchoResponse response;
265 request.set_message("Hello");
266 request.mutable_param()->set_echo_deadline(true);
267
268 ClientContext context;
yangg1456d152015-01-08 15:39:58 -0800269 Status s = stub_->Echo(&context, request, &response);
yangged5e7e02015-01-06 10:16:15 -0800270 EXPECT_EQ(response.message(), request.message());
271 EXPECT_TRUE(s.IsOk());
272 EXPECT_EQ(response.param().request_deadline(), gpr_inf_future.tv_sec);
yangged5e7e02015-01-06 10:16:15 -0800273}
274
nnoble0c475f02014-12-05 15:37:39 -0800275TEST_F(End2endTest, UnimplementedRpc) {
yangg1456d152015-01-08 15:39:58 -0800276 ResetStub();
nnoble0c475f02014-12-05 15:37:39 -0800277 EchoRequest request;
278 EchoResponse response;
279 request.set_message("Hello");
280
281 ClientContext context;
yangg1456d152015-01-08 15:39:58 -0800282 Status s = stub_->Unimplemented(&context, request, &response);
nnoble0c475f02014-12-05 15:37:39 -0800283 EXPECT_FALSE(s.IsOk());
284 EXPECT_EQ(s.code(), grpc::StatusCode::UNIMPLEMENTED);
285 EXPECT_EQ(s.details(), "");
286 EXPECT_EQ(response.message(), "");
nnoble0c475f02014-12-05 15:37:39 -0800287}
288
289TEST_F(End2endTest, RequestStreamOneRequest) {
yangg1456d152015-01-08 15:39:58 -0800290 ResetStub();
nnoble0c475f02014-12-05 15:37:39 -0800291 EchoRequest request;
292 EchoResponse response;
293 ClientContext context;
294
yangg1456d152015-01-08 15:39:58 -0800295 ClientWriter<EchoRequest>* stream = stub_->RequestStream(&context, &response);
nnoble0c475f02014-12-05 15:37:39 -0800296 request.set_message("hello");
297 EXPECT_TRUE(stream->Write(request));
298 stream->WritesDone();
Craig Tillerf8ac5d82015-02-09 16:24:20 -0800299 Status s = stream->Finish();
nnoble0c475f02014-12-05 15:37:39 -0800300 EXPECT_EQ(response.message(), request.message());
301 EXPECT_TRUE(s.IsOk());
302
303 delete stream;
nnoble0c475f02014-12-05 15:37:39 -0800304}
305
306TEST_F(End2endTest, RequestStreamTwoRequests) {
yangg1456d152015-01-08 15:39:58 -0800307 ResetStub();
nnoble0c475f02014-12-05 15:37:39 -0800308 EchoRequest request;
309 EchoResponse response;
310 ClientContext context;
311
yangg1456d152015-01-08 15:39:58 -0800312 ClientWriter<EchoRequest>* stream = stub_->RequestStream(&context, &response);
nnoble0c475f02014-12-05 15:37:39 -0800313 request.set_message("hello");
314 EXPECT_TRUE(stream->Write(request));
315 EXPECT_TRUE(stream->Write(request));
316 stream->WritesDone();
Craig Tillerf8ac5d82015-02-09 16:24:20 -0800317 Status s = stream->Finish();
nnoble0c475f02014-12-05 15:37:39 -0800318 EXPECT_EQ(response.message(), "hellohello");
319 EXPECT_TRUE(s.IsOk());
320
321 delete stream;
nnoble0c475f02014-12-05 15:37:39 -0800322}
323
324TEST_F(End2endTest, ResponseStream) {
yangg1456d152015-01-08 15:39:58 -0800325 ResetStub();
nnoble0c475f02014-12-05 15:37:39 -0800326 EchoRequest request;
327 EchoResponse response;
328 ClientContext context;
329 request.set_message("hello");
330
Craig Tiller47c83fd2015-02-21 22:45:35 -0800331 ClientReader<EchoResponse>* stream = stub_->ResponseStream(&context, request);
nnoble0c475f02014-12-05 15:37:39 -0800332 EXPECT_TRUE(stream->Read(&response));
333 EXPECT_EQ(response.message(), request.message() + "0");
334 EXPECT_TRUE(stream->Read(&response));
335 EXPECT_EQ(response.message(), request.message() + "1");
336 EXPECT_TRUE(stream->Read(&response));
337 EXPECT_EQ(response.message(), request.message() + "2");
338 EXPECT_FALSE(stream->Read(&response));
339
Craig Tiller4d0fb5f2015-02-09 16:27:22 -0800340 Status s = stream->Finish();
nnoble0c475f02014-12-05 15:37:39 -0800341 EXPECT_TRUE(s.IsOk());
342
343 delete stream;
nnoble0c475f02014-12-05 15:37:39 -0800344}
345
346TEST_F(End2endTest, BidiStream) {
yangg1456d152015-01-08 15:39:58 -0800347 ResetStub();
nnoble0c475f02014-12-05 15:37:39 -0800348 EchoRequest request;
349 EchoResponse response;
350 ClientContext context;
351 grpc::string msg("hello");
352
353 ClientReaderWriter<EchoRequest, EchoResponse>* stream =
yangg1456d152015-01-08 15:39:58 -0800354 stub_->BidiStream(&context);
nnoble0c475f02014-12-05 15:37:39 -0800355
356 request.set_message(msg + "0");
357 EXPECT_TRUE(stream->Write(request));
358 EXPECT_TRUE(stream->Read(&response));
359 EXPECT_EQ(response.message(), request.message());
360
361 request.set_message(msg + "1");
362 EXPECT_TRUE(stream->Write(request));
363 EXPECT_TRUE(stream->Read(&response));
364 EXPECT_EQ(response.message(), request.message());
365
366 request.set_message(msg + "2");
367 EXPECT_TRUE(stream->Write(request));
368 EXPECT_TRUE(stream->Read(&response));
369 EXPECT_EQ(response.message(), request.message());
370
371 stream->WritesDone();
372 EXPECT_FALSE(stream->Read(&response));
373
Craig Tiller4d0fb5f2015-02-09 16:27:22 -0800374 Status s = stream->Finish();
nnoble0c475f02014-12-05 15:37:39 -0800375 EXPECT_TRUE(s.IsOk());
376
377 delete stream;
yangg1456d152015-01-08 15:39:58 -0800378}
379
380// Talk to the two services with the same name but different package names.
381// The two stubs are created on the same channel.
382TEST_F(End2endTest, DiffPackageServices) {
Craig Tiller47c83fd2015-02-21 22:45:35 -0800383 std::shared_ptr<ChannelInterface> channel = CreateChannel(
384 server_address_.str(), InsecureCredentials(), ChannelArguments());
yangg1456d152015-01-08 15:39:58 -0800385
386 EchoRequest request;
387 EchoResponse response;
388 request.set_message("Hello");
389
390 std::unique_ptr<grpc::cpp::test::util::TestService::Stub> stub(
391 grpc::cpp::test::util::TestService::NewStub(channel));
392 ClientContext context;
393 Status s = stub->Echo(&context, request, &response);
394 EXPECT_EQ(response.message(), request.message());
395 EXPECT_TRUE(s.IsOk());
396
397 std::unique_ptr<grpc::cpp::test::util::duplicate::TestService::Stub>
398 dup_pkg_stub(
399 grpc::cpp::test::util::duplicate::TestService::NewStub(channel));
400 ClientContext context2;
401 s = dup_pkg_stub->Echo(&context2, request, &response);
402 EXPECT_EQ("no package", response.message());
403 EXPECT_TRUE(s.IsOk());
nnoble0c475f02014-12-05 15:37:39 -0800404}
405
yangg4105e2b2015-01-09 14:19:44 -0800406// rpc and stream should fail on bad credentials.
407TEST_F(End2endTest, BadCredentials) {
408 std::unique_ptr<Credentials> bad_creds =
Craig Tiller47c83fd2015-02-21 22:45:35 -0800409 ServiceAccountCredentials("", "", std::chrono::seconds(1));
yangg4105e2b2015-01-09 14:19:44 -0800410 EXPECT_EQ(nullptr, bad_creds.get());
411 std::shared_ptr<ChannelInterface> channel =
412 CreateChannel(server_address_.str(), bad_creds, ChannelArguments());
413 std::unique_ptr<grpc::cpp::test::util::TestService::Stub> stub(
414 grpc::cpp::test::util::TestService::NewStub(channel));
415 EchoRequest request;
416 EchoResponse response;
417 ClientContext context;
418 grpc::string msg("hello");
419
420 Status s = stub->Echo(&context, request, &response);
421 EXPECT_EQ("", response.message());
422 EXPECT_FALSE(s.IsOk());
423 EXPECT_EQ(StatusCode::UNKNOWN, s.code());
424 EXPECT_EQ("Rpc sent on a lame channel.", s.details());
425
426 ClientContext context2;
427 ClientReaderWriter<EchoRequest, EchoResponse>* stream =
428 stub->BidiStream(&context2);
Craig Tiller4d0fb5f2015-02-09 16:27:22 -0800429 s = stream->Finish();
yangg4105e2b2015-01-09 14:19:44 -0800430 EXPECT_FALSE(s.IsOk());
431 EXPECT_EQ(StatusCode::UNKNOWN, s.code());
432 EXPECT_EQ("Rpc sent on a lame channel.", s.details());
433
434 delete stream;
435}
436
yangged5e7e02015-01-06 10:16:15 -0800437} // namespace testing
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800438} // namespace grpc
439
440int main(int argc, char** argv) {
Craig Tiller14e60e92015-01-13 17:26:46 -0800441 grpc_test_init(argc, argv);
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800442 grpc_init();
443 ::testing::InitGoogleTest(&argc, argv);
444 int result = RUN_ALL_TESTS();
445 grpc_shutdown();
Craig Tillerec3257c2015-02-12 15:59:43 -0800446 google::protobuf::ShutdownProtobufLibrary();
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800447 return result;
Craig Tiller190d3602015-02-18 09:23:38 -0800448}