Craig Tiller | 0220cf1 | 2015-02-12 17:39:26 -0800 | [diff] [blame] | 1 | /* |
| 2 | * |
murgatroid99 | 3466c4b | 2016-01-12 10:26:04 -0800 | [diff] [blame] | 3 | * Copyright 2015-2016, Google Inc. |
Craig Tiller | 0220cf1 | 2015-02-12 17:39:26 -0800 | [diff] [blame] | 4 | * 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 | |
Yang Gao | da699b8 | 2015-02-18 01:10:22 -0800 | [diff] [blame] | 34 | #include <memory> |
Sree Kuchibhotla | 944f4cf | 2016-01-27 14:37:26 -0800 | [diff] [blame] | 35 | #include <thread> |
Craig Tiller | 0220cf1 | 2015-02-12 17:39:26 -0800 | [diff] [blame] | 36 | |
yang-g | 8c2be9f | 2015-08-19 16:28:09 -0700 | [diff] [blame] | 37 | #include <grpc++/channel.h> |
Craig Tiller | 0220cf1 | 2015-02-12 17:39:26 -0800 | [diff] [blame] | 38 | #include <grpc++/client_context.h> |
| 39 | #include <grpc++/create_channel.h> |
Craig Tiller | 0220cf1 | 2015-02-12 17:39:26 -0800 | [diff] [blame] | 40 | #include <grpc++/server.h> |
| 41 | #include <grpc++/server_builder.h> |
| 42 | #include <grpc++/server_context.h> |
Sree Kuchibhotla | b0d0c8e | 2016-01-13 22:52:17 -0800 | [diff] [blame] | 43 | #include <grpc/grpc.h> |
| 44 | #include <grpc/support/thd.h> |
| 45 | #include <grpc/support/time.h> |
Craig Tiller | 0220cf1 | 2015-02-12 17:39:26 -0800 | [diff] [blame] | 46 | #include <gtest/gtest.h> |
| 47 | |
Craig Tiller | 1b4e330 | 2015-12-17 16:35:00 -0800 | [diff] [blame] | 48 | #include "src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h" |
| 49 | #include "src/proto/grpc/testing/echo.grpc.pb.h" |
Sree Kuchibhotla | b0d0c8e | 2016-01-13 22:52:17 -0800 | [diff] [blame] | 50 | #include "test/core/util/port.h" |
| 51 | #include "test/core/util/test_config.h" |
yang-g | e21908f | 2015-08-25 13:47:51 -0700 | [diff] [blame] | 52 | #include "test/cpp/util/string_ref_helper.h" |
Craig Tiller | 0220cf1 | 2015-02-12 17:39:26 -0800 | [diff] [blame] | 53 | |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 54 | #ifdef GPR_POSIX_SOCKET |
| 55 | #include "src/core/iomgr/pollset_posix.h" |
| 56 | #endif |
| 57 | |
Craig Tiller | 1b4e330 | 2015-12-17 16:35:00 -0800 | [diff] [blame] | 58 | using grpc::testing::EchoRequest; |
| 59 | using grpc::testing::EchoResponse; |
Craig Tiller | 0220cf1 | 2015-02-12 17:39:26 -0800 | [diff] [blame] | 60 | using std::chrono::system_clock; |
| 61 | |
| 62 | namespace grpc { |
| 63 | namespace testing { |
| 64 | |
| 65 | namespace { |
| 66 | |
Craig Tiller | 7536af0 | 2015-12-22 13:49:30 -0800 | [diff] [blame] | 67 | void* tag(int i) { return (void*)(intptr_t)i; } |
Yang Gao | c05b6cb | 2015-02-13 00:34:10 -0800 | [diff] [blame] | 68 | |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 69 | #ifdef GPR_POSIX_SOCKET |
Craig Tiller | 4c06b82 | 2015-08-06 08:41:31 -0700 | [diff] [blame] | 70 | static int assert_non_blocking_poll(struct pollfd* pfds, nfds_t nfds, |
| 71 | int timeout) { |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 72 | GPR_ASSERT(timeout == 0); |
| 73 | return poll(pfds, nfds, timeout); |
| 74 | } |
| 75 | |
| 76 | class PollOverride { |
Craig Tiller | 06cf3cc | 2015-05-13 13:11:01 -0700 | [diff] [blame] | 77 | public: |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 78 | PollOverride(grpc_poll_function_type f) { |
| 79 | prev_ = grpc_poll_function; |
| 80 | grpc_poll_function = f; |
| 81 | } |
| 82 | |
Craig Tiller | 4c06b82 | 2015-08-06 08:41:31 -0700 | [diff] [blame] | 83 | ~PollOverride() { grpc_poll_function = prev_; } |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 84 | |
| 85 | private: |
| 86 | grpc_poll_function_type prev_; |
| 87 | }; |
| 88 | |
| 89 | class PollingCheckRegion : public PollOverride { |
| 90 | public: |
Craig Tiller | 4c06b82 | 2015-08-06 08:41:31 -0700 | [diff] [blame] | 91 | explicit PollingCheckRegion(bool allow_blocking) |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 92 | : PollOverride(allow_blocking ? poll : assert_non_blocking_poll) {} |
| 93 | }; |
| 94 | #else |
| 95 | class PollingCheckRegion { |
| 96 | public: |
| 97 | explicit PollingCheckRegion(bool allow_blocking) {} |
| 98 | }; |
| 99 | #endif |
| 100 | |
| 101 | class Verifier : public PollingCheckRegion { |
| 102 | public: |
| 103 | explicit Verifier(bool spin) : PollingCheckRegion(!spin), spin_(spin) {} |
Craig Tiller | 06cf3cc | 2015-05-13 13:11:01 -0700 | [diff] [blame] | 104 | Verifier& Expect(int i, bool expect_ok) { |
| 105 | expectations_[tag(i)] = expect_ok; |
| 106 | return *this; |
vjpai | 7aadf46 | 2015-03-16 23:58:44 -0700 | [diff] [blame] | 107 | } |
Sree Kuchibhotla | 944f4cf | 2016-01-27 14:37:26 -0800 | [diff] [blame] | 108 | |
| 109 | void Verify(CompletionQueue* cq) { Verify(cq, false); } |
| 110 | |
| 111 | void Verify(CompletionQueue* cq, bool ignore_ok) { |
Craig Tiller | 06cf3cc | 2015-05-13 13:11:01 -0700 | [diff] [blame] | 112 | GPR_ASSERT(!expectations_.empty()); |
| 113 | while (!expectations_.empty()) { |
| 114 | bool ok; |
| 115 | void* got_tag; |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 116 | if (spin_) { |
| 117 | for (;;) { |
| 118 | auto r = cq->AsyncNext(&got_tag, &ok, gpr_time_0(GPR_CLOCK_REALTIME)); |
| 119 | if (r == CompletionQueue::TIMEOUT) continue; |
| 120 | if (r == CompletionQueue::GOT_EVENT) break; |
| 121 | gpr_log(GPR_ERROR, "unexpected result from AsyncNext"); |
| 122 | abort(); |
| 123 | } |
| 124 | } else { |
| 125 | EXPECT_TRUE(cq->Next(&got_tag, &ok)); |
| 126 | } |
Craig Tiller | 06cf3cc | 2015-05-13 13:11:01 -0700 | [diff] [blame] | 127 | auto it = expectations_.find(got_tag); |
| 128 | EXPECT_TRUE(it != expectations_.end()); |
Sree Kuchibhotla | 944f4cf | 2016-01-27 14:37:26 -0800 | [diff] [blame] | 129 | if (!ignore_ok) { |
| 130 | EXPECT_EQ(it->second, ok); |
| 131 | } |
Craig Tiller | 06cf3cc | 2015-05-13 13:11:01 -0700 | [diff] [blame] | 132 | expectations_.erase(it); |
| 133 | } |
| 134 | } |
Craig Tiller | d6c98df | 2015-08-18 09:33:44 -0700 | [diff] [blame] | 135 | void Verify(CompletionQueue* cq, |
| 136 | std::chrono::system_clock::time_point deadline) { |
Craig Tiller | 06cf3cc | 2015-05-13 13:11:01 -0700 | [diff] [blame] | 137 | if (expectations_.empty()) { |
| 138 | bool ok; |
Craig Tiller | d6c98df | 2015-08-18 09:33:44 -0700 | [diff] [blame] | 139 | void* got_tag; |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 140 | if (spin_) { |
| 141 | while (std::chrono::system_clock::now() < deadline) { |
Craig Tiller | 4c06b82 | 2015-08-06 08:41:31 -0700 | [diff] [blame] | 142 | EXPECT_EQ( |
| 143 | cq->AsyncNext(&got_tag, &ok, gpr_time_0(GPR_CLOCK_REALTIME)), |
| 144 | CompletionQueue::TIMEOUT); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 145 | } |
| 146 | } else { |
Craig Tiller | 4c06b82 | 2015-08-06 08:41:31 -0700 | [diff] [blame] | 147 | EXPECT_EQ(cq->AsyncNext(&got_tag, &ok, deadline), |
| 148 | CompletionQueue::TIMEOUT); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 149 | } |
Craig Tiller | 06cf3cc | 2015-05-13 13:11:01 -0700 | [diff] [blame] | 150 | } else { |
| 151 | while (!expectations_.empty()) { |
| 152 | bool ok; |
Craig Tiller | d6c98df | 2015-08-18 09:33:44 -0700 | [diff] [blame] | 153 | void* got_tag; |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 154 | if (spin_) { |
| 155 | for (;;) { |
| 156 | GPR_ASSERT(std::chrono::system_clock::now() < deadline); |
Craig Tiller | 4c06b82 | 2015-08-06 08:41:31 -0700 | [diff] [blame] | 157 | auto r = |
| 158 | cq->AsyncNext(&got_tag, &ok, gpr_time_0(GPR_CLOCK_REALTIME)); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 159 | if (r == CompletionQueue::TIMEOUT) continue; |
| 160 | if (r == CompletionQueue::GOT_EVENT) break; |
| 161 | gpr_log(GPR_ERROR, "unexpected result from AsyncNext"); |
| 162 | abort(); |
Craig Tiller | 4c06b82 | 2015-08-06 08:41:31 -0700 | [diff] [blame] | 163 | } |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 164 | } else { |
Craig Tiller | 4c06b82 | 2015-08-06 08:41:31 -0700 | [diff] [blame] | 165 | EXPECT_EQ(cq->AsyncNext(&got_tag, &ok, deadline), |
| 166 | CompletionQueue::GOT_EVENT); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 167 | } |
Craig Tiller | 06cf3cc | 2015-05-13 13:11:01 -0700 | [diff] [blame] | 168 | auto it = expectations_.find(got_tag); |
| 169 | EXPECT_TRUE(it != expectations_.end()); |
| 170 | EXPECT_EQ(it->second, ok); |
| 171 | expectations_.erase(it); |
| 172 | } |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | private: |
| 177 | std::map<void*, bool> expectations_; |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 178 | bool spin_; |
Craig Tiller | 06cf3cc | 2015-05-13 13:11:01 -0700 | [diff] [blame] | 179 | }; |
vjpai | 7aadf46 | 2015-03-16 23:58:44 -0700 | [diff] [blame] | 180 | |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 181 | class AsyncEnd2endTest : public ::testing::TestWithParam<bool> { |
Craig Tiller | 0220cf1 | 2015-02-12 17:39:26 -0800 | [diff] [blame] | 182 | protected: |
Craig Tiller | f9e6adf | 2015-05-06 11:45:59 -0700 | [diff] [blame] | 183 | AsyncEnd2endTest() {} |
Craig Tiller | 0220cf1 | 2015-02-12 17:39:26 -0800 | [diff] [blame] | 184 | |
Craig Tiller | cf133f4 | 2015-02-26 14:05:56 -0800 | [diff] [blame] | 185 | void SetUp() GRPC_OVERRIDE { |
Craig Tiller | 0220cf1 | 2015-02-12 17:39:26 -0800 | [diff] [blame] | 186 | int port = grpc_pick_unused_port_or_die(); |
| 187 | server_address_ << "localhost:" << port; |
vjpai | 017ed62 | 2015-12-09 10:42:54 -0800 | [diff] [blame] | 188 | |
Craig Tiller | 0220cf1 | 2015-02-12 17:39:26 -0800 | [diff] [blame] | 189 | // Setup server |
| 190 | ServerBuilder builder; |
Craig Tiller | d6c98df | 2015-08-18 09:33:44 -0700 | [diff] [blame] | 191 | builder.AddListeningPort(server_address_.str(), |
| 192 | grpc::InsecureServerCredentials()); |
Craig Tiller | 15f383c | 2016-01-07 12:45:32 -0800 | [diff] [blame] | 193 | builder.RegisterService(&service_); |
Craig Tiller | 06cf3cc | 2015-05-13 13:11:01 -0700 | [diff] [blame] | 194 | cq_ = builder.AddCompletionQueue(); |
Craig Tiller | 0220cf1 | 2015-02-12 17:39:26 -0800 | [diff] [blame] | 195 | server_ = builder.BuildAndStart(); |
| 196 | } |
| 197 | |
Craig Tiller | cf133f4 | 2015-02-26 14:05:56 -0800 | [diff] [blame] | 198 | void TearDown() GRPC_OVERRIDE { |
Craig Tiller | 492968f | 2015-02-18 13:14:03 -0800 | [diff] [blame] | 199 | server_->Shutdown(); |
| 200 | void* ignored_tag; |
| 201 | bool ignored_ok; |
Craig Tiller | 06cf3cc | 2015-05-13 13:11:01 -0700 | [diff] [blame] | 202 | cq_->Shutdown(); |
| 203 | while (cq_->Next(&ignored_tag, &ignored_ok)) |
Craig Tiller | 492968f | 2015-02-18 13:14:03 -0800 | [diff] [blame] | 204 | ; |
| 205 | } |
Craig Tiller | 0220cf1 | 2015-02-12 17:39:26 -0800 | [diff] [blame] | 206 | |
| 207 | void ResetStub() { |
yang-g | 730055d | 2015-08-27 12:29:45 -0700 | [diff] [blame] | 208 | std::shared_ptr<Channel> channel = |
Julien Boeuf | e5adc0e | 2015-10-12 14:08:10 -0700 | [diff] [blame] | 209 | CreateChannel(server_address_.str(), InsecureChannelCredentials()); |
Sree Kuchibhotla | 5a05f51 | 2016-01-13 22:43:20 -0800 | [diff] [blame] | 210 | stub_ = grpc::testing::EchoTestService::NewStub(channel); |
Craig Tiller | 0220cf1 | 2015-02-12 17:39:26 -0800 | [diff] [blame] | 211 | } |
| 212 | |
Yang Gao | 406b32f | 2015-02-13 16:25:33 -0800 | [diff] [blame] | 213 | void SendRpc(int num_rpcs) { |
| 214 | for (int i = 0; i < num_rpcs; i++) { |
| 215 | EchoRequest send_request; |
| 216 | EchoRequest recv_request; |
| 217 | EchoResponse send_response; |
| 218 | EchoResponse recv_response; |
| 219 | Status recv_status; |
| 220 | |
| 221 | ClientContext cli_ctx; |
| 222 | ServerContext srv_ctx; |
| 223 | grpc::ServerAsyncResponseWriter<EchoResponse> response_writer(&srv_ctx); |
| 224 | |
| 225 | send_request.set_message("Hello"); |
Sree Kuchibhotla | 944f4cf | 2016-01-27 14:37:26 -0800 | [diff] [blame] | 226 | std::unique_ptr<ClientAsyncResponseReader<EchoResponse>> response_reader( |
Craig Tiller | 06cf3cc | 2015-05-13 13:11:01 -0700 | [diff] [blame] | 227 | stub_->AsyncEcho(&cli_ctx, send_request, cq_.get())); |
Yang Gao | 406b32f | 2015-02-13 16:25:33 -0800 | [diff] [blame] | 228 | |
Craig Tiller | d6c98df | 2015-08-18 09:33:44 -0700 | [diff] [blame] | 229 | service_.RequestEcho(&srv_ctx, &recv_request, &response_writer, cq_.get(), |
| 230 | cq_.get(), tag(2)); |
Yang Gao | 406b32f | 2015-02-13 16:25:33 -0800 | [diff] [blame] | 231 | |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 232 | Verifier(GetParam()).Expect(2, true).Verify(cq_.get()); |
Yang Gao | 406b32f | 2015-02-13 16:25:33 -0800 | [diff] [blame] | 233 | EXPECT_EQ(send_request.message(), recv_request.message()); |
| 234 | |
| 235 | send_response.set_message(recv_request.message()); |
| 236 | response_writer.Finish(send_response, Status::OK, tag(3)); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 237 | Verifier(GetParam()).Expect(3, true).Verify(cq_.get()); |
Yang Gao | 406b32f | 2015-02-13 16:25:33 -0800 | [diff] [blame] | 238 | |
Yang Gao | 3a5e549 | 2015-02-18 14:32:38 -0800 | [diff] [blame] | 239 | response_reader->Finish(&recv_response, &recv_status, tag(4)); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 240 | Verifier(GetParam()).Expect(4, true).Verify(cq_.get()); |
Yang Gao | 406b32f | 2015-02-13 16:25:33 -0800 | [diff] [blame] | 241 | |
| 242 | EXPECT_EQ(send_response.message(), recv_response.message()); |
Yang Gao | c1a2c31 | 2015-06-16 10:59:46 -0700 | [diff] [blame] | 243 | EXPECT_TRUE(recv_status.ok()); |
Yang Gao | 406b32f | 2015-02-13 16:25:33 -0800 | [diff] [blame] | 244 | } |
| 245 | } |
| 246 | |
Craig Tiller | 06cf3cc | 2015-05-13 13:11:01 -0700 | [diff] [blame] | 247 | std::unique_ptr<ServerCompletionQueue> cq_; |
Sree Kuchibhotla | 5a05f51 | 2016-01-13 22:43:20 -0800 | [diff] [blame] | 248 | std::unique_ptr<grpc::testing::EchoTestService::Stub> stub_; |
Craig Tiller | 0220cf1 | 2015-02-12 17:39:26 -0800 | [diff] [blame] | 249 | std::unique_ptr<Server> server_; |
Sree Kuchibhotla | 5a05f51 | 2016-01-13 22:43:20 -0800 | [diff] [blame] | 250 | grpc::testing::EchoTestService::AsyncService service_; |
Craig Tiller | 0220cf1 | 2015-02-12 17:39:26 -0800 | [diff] [blame] | 251 | std::ostringstream server_address_; |
| 252 | }; |
| 253 | |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 254 | TEST_P(AsyncEnd2endTest, SimpleRpc) { |
Craig Tiller | 0220cf1 | 2015-02-12 17:39:26 -0800 | [diff] [blame] | 255 | ResetStub(); |
Yang Gao | 406b32f | 2015-02-13 16:25:33 -0800 | [diff] [blame] | 256 | SendRpc(1); |
| 257 | } |
Yang Gao | bb84a30 | 2015-02-12 23:30:12 -0800 | [diff] [blame] | 258 | |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 259 | TEST_P(AsyncEnd2endTest, SequentialRpcs) { |
Yang Gao | 406b32f | 2015-02-13 16:25:33 -0800 | [diff] [blame] | 260 | ResetStub(); |
| 261 | SendRpc(10); |
Craig Tiller | 0220cf1 | 2015-02-12 17:39:26 -0800 | [diff] [blame] | 262 | } |
| 263 | |
vjpai | 7aadf46 | 2015-03-16 23:58:44 -0700 | [diff] [blame] | 264 | // Test a simple RPC using the async version of Next |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 265 | TEST_P(AsyncEnd2endTest, AsyncNextRpc) { |
vjpai | 7aadf46 | 2015-03-16 23:58:44 -0700 | [diff] [blame] | 266 | ResetStub(); |
| 267 | |
| 268 | EchoRequest send_request; |
| 269 | EchoRequest recv_request; |
| 270 | EchoResponse send_response; |
| 271 | EchoResponse recv_response; |
| 272 | Status recv_status; |
| 273 | |
| 274 | ClientContext cli_ctx; |
| 275 | ServerContext srv_ctx; |
| 276 | grpc::ServerAsyncResponseWriter<EchoResponse> response_writer(&srv_ctx); |
| 277 | |
| 278 | send_request.set_message("Hello"); |
Sree Kuchibhotla | 944f4cf | 2016-01-27 14:37:26 -0800 | [diff] [blame] | 279 | std::unique_ptr<ClientAsyncResponseReader<EchoResponse>> response_reader( |
Craig Tiller | 06cf3cc | 2015-05-13 13:11:01 -0700 | [diff] [blame] | 280 | stub_->AsyncEcho(&cli_ctx, send_request, cq_.get())); |
vjpai | 7aadf46 | 2015-03-16 23:58:44 -0700 | [diff] [blame] | 281 | |
Yang Gao | 757afae | 2015-03-17 15:49:26 -0700 | [diff] [blame] | 282 | std::chrono::system_clock::time_point time_now( |
Craig Tiller | f51199f | 2015-05-08 09:32:53 -0700 | [diff] [blame] | 283 | std::chrono::system_clock::now()); |
| 284 | std::chrono::system_clock::time_point time_limit( |
| 285 | std::chrono::system_clock::now() + std::chrono::seconds(10)); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 286 | Verifier(GetParam()).Verify(cq_.get(), time_now); |
| 287 | Verifier(GetParam()).Verify(cq_.get(), time_now); |
vjpai | 7aadf46 | 2015-03-16 23:58:44 -0700 | [diff] [blame] | 288 | |
Craig Tiller | 06cf3cc | 2015-05-13 13:11:01 -0700 | [diff] [blame] | 289 | service_.RequestEcho(&srv_ctx, &recv_request, &response_writer, cq_.get(), |
| 290 | cq_.get(), tag(2)); |
vjpai | 7aadf46 | 2015-03-16 23:58:44 -0700 | [diff] [blame] | 291 | |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 292 | Verifier(GetParam()).Expect(2, true).Verify(cq_.get(), time_limit); |
vjpai | 7aadf46 | 2015-03-16 23:58:44 -0700 | [diff] [blame] | 293 | EXPECT_EQ(send_request.message(), recv_request.message()); |
vjpai | 7aadf46 | 2015-03-16 23:58:44 -0700 | [diff] [blame] | 294 | |
| 295 | send_response.set_message(recv_request.message()); |
| 296 | response_writer.Finish(send_response, Status::OK, tag(3)); |
Craig Tiller | 4c06b82 | 2015-08-06 08:41:31 -0700 | [diff] [blame] | 297 | Verifier(GetParam()) |
| 298 | .Expect(3, true) |
| 299 | .Verify(cq_.get(), std::chrono::system_clock::time_point::max()); |
vjpai | 7aadf46 | 2015-03-16 23:58:44 -0700 | [diff] [blame] | 300 | |
| 301 | response_reader->Finish(&recv_response, &recv_status, tag(4)); |
Craig Tiller | 4c06b82 | 2015-08-06 08:41:31 -0700 | [diff] [blame] | 302 | Verifier(GetParam()) |
| 303 | .Expect(4, true) |
| 304 | .Verify(cq_.get(), std::chrono::system_clock::time_point::max()); |
vjpai | 7aadf46 | 2015-03-16 23:58:44 -0700 | [diff] [blame] | 305 | |
| 306 | EXPECT_EQ(send_response.message(), recv_response.message()); |
Yang Gao | c1a2c31 | 2015-06-16 10:59:46 -0700 | [diff] [blame] | 307 | EXPECT_TRUE(recv_status.ok()); |
vjpai | 7aadf46 | 2015-03-16 23:58:44 -0700 | [diff] [blame] | 308 | } |
Yang Gao | 757afae | 2015-03-17 15:49:26 -0700 | [diff] [blame] | 309 | |
Yang Gao | 0e0d8e1 | 2015-02-13 14:40:41 -0800 | [diff] [blame] | 310 | // Two pings and a final pong. |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 311 | TEST_P(AsyncEnd2endTest, SimpleClientStreaming) { |
Yang Gao | 005f18a | 2015-02-13 10:22:33 -0800 | [diff] [blame] | 312 | ResetStub(); |
| 313 | |
| 314 | EchoRequest send_request; |
| 315 | EchoRequest recv_request; |
| 316 | EchoResponse send_response; |
| 317 | EchoResponse recv_response; |
| 318 | Status recv_status; |
| 319 | ClientContext cli_ctx; |
| 320 | ServerContext srv_ctx; |
| 321 | ServerAsyncReader<EchoResponse, EchoRequest> srv_stream(&srv_ctx); |
| 322 | |
| 323 | send_request.set_message("Hello"); |
Sree Kuchibhotla | 944f4cf | 2016-01-27 14:37:26 -0800 | [diff] [blame] | 324 | std::unique_ptr<ClientAsyncWriter<EchoRequest>> cli_stream( |
Craig Tiller | 06cf3cc | 2015-05-13 13:11:01 -0700 | [diff] [blame] | 325 | stub_->AsyncRequestStream(&cli_ctx, &recv_response, cq_.get(), tag(1))); |
Yang Gao | 005f18a | 2015-02-13 10:22:33 -0800 | [diff] [blame] | 326 | |
Craig Tiller | d6c98df | 2015-08-18 09:33:44 -0700 | [diff] [blame] | 327 | service_.RequestRequestStream(&srv_ctx, &srv_stream, cq_.get(), cq_.get(), |
| 328 | tag(2)); |
Yang Gao | 005f18a | 2015-02-13 10:22:33 -0800 | [diff] [blame] | 329 | |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 330 | Verifier(GetParam()).Expect(2, true).Expect(1, true).Verify(cq_.get()); |
Yang Gao | 005f18a | 2015-02-13 10:22:33 -0800 | [diff] [blame] | 331 | |
| 332 | cli_stream->Write(send_request, tag(3)); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 333 | Verifier(GetParam()).Expect(3, true).Verify(cq_.get()); |
Yang Gao | 005f18a | 2015-02-13 10:22:33 -0800 | [diff] [blame] | 334 | |
| 335 | srv_stream.Read(&recv_request, tag(4)); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 336 | Verifier(GetParam()).Expect(4, true).Verify(cq_.get()); |
Yang Gao | 005f18a | 2015-02-13 10:22:33 -0800 | [diff] [blame] | 337 | EXPECT_EQ(send_request.message(), recv_request.message()); |
| 338 | |
| 339 | cli_stream->Write(send_request, tag(5)); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 340 | Verifier(GetParam()).Expect(5, true).Verify(cq_.get()); |
Yang Gao | 005f18a | 2015-02-13 10:22:33 -0800 | [diff] [blame] | 341 | |
| 342 | srv_stream.Read(&recv_request, tag(6)); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 343 | Verifier(GetParam()).Expect(6, true).Verify(cq_.get()); |
Yang Gao | 005f18a | 2015-02-13 10:22:33 -0800 | [diff] [blame] | 344 | |
| 345 | EXPECT_EQ(send_request.message(), recv_request.message()); |
| 346 | cli_stream->WritesDone(tag(7)); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 347 | Verifier(GetParam()).Expect(7, true).Verify(cq_.get()); |
Yang Gao | 005f18a | 2015-02-13 10:22:33 -0800 | [diff] [blame] | 348 | |
| 349 | srv_stream.Read(&recv_request, tag(8)); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 350 | Verifier(GetParam()).Expect(8, false).Verify(cq_.get()); |
Yang Gao | 005f18a | 2015-02-13 10:22:33 -0800 | [diff] [blame] | 351 | |
| 352 | send_response.set_message(recv_request.message()); |
| 353 | srv_stream.Finish(send_response, Status::OK, tag(9)); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 354 | Verifier(GetParam()).Expect(9, true).Verify(cq_.get()); |
Yang Gao | 005f18a | 2015-02-13 10:22:33 -0800 | [diff] [blame] | 355 | |
| 356 | cli_stream->Finish(&recv_status, tag(10)); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 357 | Verifier(GetParam()).Expect(10, true).Verify(cq_.get()); |
Yang Gao | 005f18a | 2015-02-13 10:22:33 -0800 | [diff] [blame] | 358 | |
| 359 | EXPECT_EQ(send_response.message(), recv_response.message()); |
Yang Gao | c1a2c31 | 2015-06-16 10:59:46 -0700 | [diff] [blame] | 360 | EXPECT_TRUE(recv_status.ok()); |
Yang Gao | 005f18a | 2015-02-13 10:22:33 -0800 | [diff] [blame] | 361 | } |
| 362 | |
Yang Gao | 0e0d8e1 | 2015-02-13 14:40:41 -0800 | [diff] [blame] | 363 | // One ping, two pongs. |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 364 | TEST_P(AsyncEnd2endTest, SimpleServerStreaming) { |
Yang Gao | 0e0d8e1 | 2015-02-13 14:40:41 -0800 | [diff] [blame] | 365 | ResetStub(); |
| 366 | |
| 367 | EchoRequest send_request; |
| 368 | EchoRequest recv_request; |
| 369 | EchoResponse send_response; |
| 370 | EchoResponse recv_response; |
| 371 | Status recv_status; |
| 372 | ClientContext cli_ctx; |
| 373 | ServerContext srv_ctx; |
| 374 | ServerAsyncWriter<EchoResponse> srv_stream(&srv_ctx); |
| 375 | |
| 376 | send_request.set_message("Hello"); |
Sree Kuchibhotla | 944f4cf | 2016-01-27 14:37:26 -0800 | [diff] [blame] | 377 | std::unique_ptr<ClientAsyncReader<EchoResponse>> cli_stream( |
Craig Tiller | 06cf3cc | 2015-05-13 13:11:01 -0700 | [diff] [blame] | 378 | stub_->AsyncResponseStream(&cli_ctx, send_request, cq_.get(), tag(1))); |
Yang Gao | 0e0d8e1 | 2015-02-13 14:40:41 -0800 | [diff] [blame] | 379 | |
Craig Tiller | f9e6adf | 2015-05-06 11:45:59 -0700 | [diff] [blame] | 380 | service_.RequestResponseStream(&srv_ctx, &recv_request, &srv_stream, |
Craig Tiller | 06cf3cc | 2015-05-13 13:11:01 -0700 | [diff] [blame] | 381 | cq_.get(), cq_.get(), tag(2)); |
Yang Gao | 0e0d8e1 | 2015-02-13 14:40:41 -0800 | [diff] [blame] | 382 | |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 383 | Verifier(GetParam()).Expect(1, true).Expect(2, true).Verify(cq_.get()); |
Yang Gao | 0e0d8e1 | 2015-02-13 14:40:41 -0800 | [diff] [blame] | 384 | EXPECT_EQ(send_request.message(), recv_request.message()); |
| 385 | |
| 386 | send_response.set_message(recv_request.message()); |
| 387 | srv_stream.Write(send_response, tag(3)); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 388 | Verifier(GetParam()).Expect(3, true).Verify(cq_.get()); |
Yang Gao | 0e0d8e1 | 2015-02-13 14:40:41 -0800 | [diff] [blame] | 389 | |
| 390 | cli_stream->Read(&recv_response, tag(4)); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 391 | Verifier(GetParam()).Expect(4, true).Verify(cq_.get()); |
Yang Gao | 0e0d8e1 | 2015-02-13 14:40:41 -0800 | [diff] [blame] | 392 | EXPECT_EQ(send_response.message(), recv_response.message()); |
| 393 | |
| 394 | srv_stream.Write(send_response, tag(5)); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 395 | Verifier(GetParam()).Expect(5, true).Verify(cq_.get()); |
Yang Gao | 0e0d8e1 | 2015-02-13 14:40:41 -0800 | [diff] [blame] | 396 | |
| 397 | cli_stream->Read(&recv_response, tag(6)); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 398 | Verifier(GetParam()).Expect(6, true).Verify(cq_.get()); |
Yang Gao | 0e0d8e1 | 2015-02-13 14:40:41 -0800 | [diff] [blame] | 399 | EXPECT_EQ(send_response.message(), recv_response.message()); |
| 400 | |
| 401 | srv_stream.Finish(Status::OK, tag(7)); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 402 | Verifier(GetParam()).Expect(7, true).Verify(cq_.get()); |
Yang Gao | 0e0d8e1 | 2015-02-13 14:40:41 -0800 | [diff] [blame] | 403 | |
| 404 | cli_stream->Read(&recv_response, tag(8)); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 405 | Verifier(GetParam()).Expect(8, false).Verify(cq_.get()); |
Yang Gao | 0e0d8e1 | 2015-02-13 14:40:41 -0800 | [diff] [blame] | 406 | |
| 407 | cli_stream->Finish(&recv_status, tag(9)); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 408 | Verifier(GetParam()).Expect(9, true).Verify(cq_.get()); |
Yang Gao | 0e0d8e1 | 2015-02-13 14:40:41 -0800 | [diff] [blame] | 409 | |
Yang Gao | c1a2c31 | 2015-06-16 10:59:46 -0700 | [diff] [blame] | 410 | EXPECT_TRUE(recv_status.ok()); |
Yang Gao | 0e0d8e1 | 2015-02-13 14:40:41 -0800 | [diff] [blame] | 411 | } |
| 412 | |
| 413 | // One ping, one pong. |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 414 | TEST_P(AsyncEnd2endTest, SimpleBidiStreaming) { |
Yang Gao | c05b6cb | 2015-02-13 00:34:10 -0800 | [diff] [blame] | 415 | ResetStub(); |
| 416 | |
| 417 | EchoRequest send_request; |
| 418 | EchoRequest recv_request; |
| 419 | EchoResponse send_response; |
| 420 | EchoResponse recv_response; |
| 421 | Status recv_status; |
| 422 | ClientContext cli_ctx; |
| 423 | ServerContext srv_ctx; |
| 424 | ServerAsyncReaderWriter<EchoResponse, EchoRequest> srv_stream(&srv_ctx); |
| 425 | |
| 426 | send_request.set_message("Hello"); |
Sree Kuchibhotla | 944f4cf | 2016-01-27 14:37:26 -0800 | [diff] [blame] | 427 | std::unique_ptr<ClientAsyncReaderWriter<EchoRequest, EchoResponse>> |
Craig Tiller | 06cf3cc | 2015-05-13 13:11:01 -0700 | [diff] [blame] | 428 | cli_stream(stub_->AsyncBidiStream(&cli_ctx, cq_.get(), tag(1))); |
Yang Gao | c05b6cb | 2015-02-13 00:34:10 -0800 | [diff] [blame] | 429 | |
Craig Tiller | d6c98df | 2015-08-18 09:33:44 -0700 | [diff] [blame] | 430 | service_.RequestBidiStream(&srv_ctx, &srv_stream, cq_.get(), cq_.get(), |
| 431 | tag(2)); |
Yang Gao | c05b6cb | 2015-02-13 00:34:10 -0800 | [diff] [blame] | 432 | |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 433 | Verifier(GetParam()).Expect(1, true).Expect(2, true).Verify(cq_.get()); |
Yang Gao | c05b6cb | 2015-02-13 00:34:10 -0800 | [diff] [blame] | 434 | |
| 435 | cli_stream->Write(send_request, tag(3)); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 436 | Verifier(GetParam()).Expect(3, true).Verify(cq_.get()); |
Yang Gao | c05b6cb | 2015-02-13 00:34:10 -0800 | [diff] [blame] | 437 | |
| 438 | srv_stream.Read(&recv_request, tag(4)); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 439 | Verifier(GetParam()).Expect(4, true).Verify(cq_.get()); |
Yang Gao | c05b6cb | 2015-02-13 00:34:10 -0800 | [diff] [blame] | 440 | EXPECT_EQ(send_request.message(), recv_request.message()); |
| 441 | |
| 442 | send_response.set_message(recv_request.message()); |
| 443 | srv_stream.Write(send_response, tag(5)); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 444 | Verifier(GetParam()).Expect(5, true).Verify(cq_.get()); |
Yang Gao | c05b6cb | 2015-02-13 00:34:10 -0800 | [diff] [blame] | 445 | |
| 446 | cli_stream->Read(&recv_response, tag(6)); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 447 | Verifier(GetParam()).Expect(6, true).Verify(cq_.get()); |
Yang Gao | c05b6cb | 2015-02-13 00:34:10 -0800 | [diff] [blame] | 448 | EXPECT_EQ(send_response.message(), recv_response.message()); |
| 449 | |
| 450 | cli_stream->WritesDone(tag(7)); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 451 | Verifier(GetParam()).Expect(7, true).Verify(cq_.get()); |
Yang Gao | c05b6cb | 2015-02-13 00:34:10 -0800 | [diff] [blame] | 452 | |
| 453 | srv_stream.Read(&recv_request, tag(8)); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 454 | Verifier(GetParam()).Expect(8, false).Verify(cq_.get()); |
Yang Gao | c05b6cb | 2015-02-13 00:34:10 -0800 | [diff] [blame] | 455 | |
| 456 | srv_stream.Finish(Status::OK, tag(9)); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 457 | Verifier(GetParam()).Expect(9, true).Verify(cq_.get()); |
Yang Gao | c05b6cb | 2015-02-13 00:34:10 -0800 | [diff] [blame] | 458 | |
| 459 | cli_stream->Finish(&recv_status, tag(10)); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 460 | Verifier(GetParam()).Expect(10, true).Verify(cq_.get()); |
Yang Gao | c05b6cb | 2015-02-13 00:34:10 -0800 | [diff] [blame] | 461 | |
Yang Gao | c1a2c31 | 2015-06-16 10:59:46 -0700 | [diff] [blame] | 462 | EXPECT_TRUE(recv_status.ok()); |
Yang Gao | c05b6cb | 2015-02-13 00:34:10 -0800 | [diff] [blame] | 463 | } |
| 464 | |
Yang Gao | 406b32f | 2015-02-13 16:25:33 -0800 | [diff] [blame] | 465 | // Metadata tests |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 466 | TEST_P(AsyncEnd2endTest, ClientInitialMetadataRpc) { |
Yang Gao | 406b32f | 2015-02-13 16:25:33 -0800 | [diff] [blame] | 467 | ResetStub(); |
| 468 | |
| 469 | EchoRequest send_request; |
| 470 | EchoRequest recv_request; |
| 471 | EchoResponse send_response; |
| 472 | EchoResponse recv_response; |
| 473 | Status recv_status; |
| 474 | |
| 475 | ClientContext cli_ctx; |
| 476 | ServerContext srv_ctx; |
| 477 | grpc::ServerAsyncResponseWriter<EchoResponse> response_writer(&srv_ctx); |
| 478 | |
| 479 | send_request.set_message("Hello"); |
| 480 | std::pair<grpc::string, grpc::string> meta1("key1", "val1"); |
| 481 | std::pair<grpc::string, grpc::string> meta2("key2", "val2"); |
| 482 | cli_ctx.AddMetadata(meta1.first, meta1.second); |
| 483 | cli_ctx.AddMetadata(meta2.first, meta2.second); |
| 484 | |
Sree Kuchibhotla | 944f4cf | 2016-01-27 14:37:26 -0800 | [diff] [blame] | 485 | std::unique_ptr<ClientAsyncResponseReader<EchoResponse>> response_reader( |
Craig Tiller | 06cf3cc | 2015-05-13 13:11:01 -0700 | [diff] [blame] | 486 | stub_->AsyncEcho(&cli_ctx, send_request, cq_.get())); |
Yang Gao | 406b32f | 2015-02-13 16:25:33 -0800 | [diff] [blame] | 487 | |
Craig Tiller | 06cf3cc | 2015-05-13 13:11:01 -0700 | [diff] [blame] | 488 | service_.RequestEcho(&srv_ctx, &recv_request, &response_writer, cq_.get(), |
| 489 | cq_.get(), tag(2)); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 490 | Verifier(GetParam()).Expect(2, true).Verify(cq_.get()); |
Yang Gao | 406b32f | 2015-02-13 16:25:33 -0800 | [diff] [blame] | 491 | EXPECT_EQ(send_request.message(), recv_request.message()); |
| 492 | auto client_initial_metadata = srv_ctx.client_metadata(); |
yang-g | e21908f | 2015-08-25 13:47:51 -0700 | [diff] [blame] | 493 | EXPECT_EQ(meta1.second, |
| 494 | ToString(client_initial_metadata.find(meta1.first)->second)); |
| 495 | EXPECT_EQ(meta2.second, |
| 496 | ToString(client_initial_metadata.find(meta2.first)->second)); |
Craig Tiller | 8bf2dca | 2015-07-10 13:08:41 -0700 | [diff] [blame] | 497 | EXPECT_GE(client_initial_metadata.size(), static_cast<size_t>(2)); |
Yang Gao | 406b32f | 2015-02-13 16:25:33 -0800 | [diff] [blame] | 498 | |
| 499 | send_response.set_message(recv_request.message()); |
| 500 | response_writer.Finish(send_response, Status::OK, tag(3)); |
| 501 | |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 502 | Verifier(GetParam()).Expect(3, true).Verify(cq_.get()); |
Yang Gao | 406b32f | 2015-02-13 16:25:33 -0800 | [diff] [blame] | 503 | |
Yang Gao | 3a5e549 | 2015-02-18 14:32:38 -0800 | [diff] [blame] | 504 | response_reader->Finish(&recv_response, &recv_status, tag(4)); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 505 | Verifier(GetParam()).Expect(4, true).Verify(cq_.get()); |
Yang Gao | 406b32f | 2015-02-13 16:25:33 -0800 | [diff] [blame] | 506 | |
| 507 | EXPECT_EQ(send_response.message(), recv_response.message()); |
Yang Gao | c1a2c31 | 2015-06-16 10:59:46 -0700 | [diff] [blame] | 508 | EXPECT_TRUE(recv_status.ok()); |
Yang Gao | 406b32f | 2015-02-13 16:25:33 -0800 | [diff] [blame] | 509 | } |
| 510 | |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 511 | TEST_P(AsyncEnd2endTest, ServerInitialMetadataRpc) { |
Yang Gao | 2b7f537 | 2015-02-18 00:45:53 -0800 | [diff] [blame] | 512 | ResetStub(); |
| 513 | |
| 514 | EchoRequest send_request; |
| 515 | EchoRequest recv_request; |
| 516 | EchoResponse send_response; |
| 517 | EchoResponse recv_response; |
| 518 | Status recv_status; |
| 519 | |
| 520 | ClientContext cli_ctx; |
| 521 | ServerContext srv_ctx; |
| 522 | grpc::ServerAsyncResponseWriter<EchoResponse> response_writer(&srv_ctx); |
| 523 | |
| 524 | send_request.set_message("Hello"); |
| 525 | std::pair<grpc::string, grpc::string> meta1("key1", "val1"); |
| 526 | std::pair<grpc::string, grpc::string> meta2("key2", "val2"); |
| 527 | |
Sree Kuchibhotla | 944f4cf | 2016-01-27 14:37:26 -0800 | [diff] [blame] | 528 | std::unique_ptr<ClientAsyncResponseReader<EchoResponse>> response_reader( |
Craig Tiller | 06cf3cc | 2015-05-13 13:11:01 -0700 | [diff] [blame] | 529 | stub_->AsyncEcho(&cli_ctx, send_request, cq_.get())); |
Yang Gao | 2b7f537 | 2015-02-18 00:45:53 -0800 | [diff] [blame] | 530 | |
Craig Tiller | 06cf3cc | 2015-05-13 13:11:01 -0700 | [diff] [blame] | 531 | service_.RequestEcho(&srv_ctx, &recv_request, &response_writer, cq_.get(), |
| 532 | cq_.get(), tag(2)); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 533 | Verifier(GetParam()).Expect(2, true).Verify(cq_.get()); |
Yang Gao | 2b7f537 | 2015-02-18 00:45:53 -0800 | [diff] [blame] | 534 | EXPECT_EQ(send_request.message(), recv_request.message()); |
| 535 | srv_ctx.AddInitialMetadata(meta1.first, meta1.second); |
| 536 | srv_ctx.AddInitialMetadata(meta2.first, meta2.second); |
| 537 | response_writer.SendInitialMetadata(tag(3)); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 538 | Verifier(GetParam()).Expect(3, true).Verify(cq_.get()); |
Yang Gao | 2b7f537 | 2015-02-18 00:45:53 -0800 | [diff] [blame] | 539 | |
Yang Gao | 3a5e549 | 2015-02-18 14:32:38 -0800 | [diff] [blame] | 540 | response_reader->ReadInitialMetadata(tag(4)); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 541 | Verifier(GetParam()).Expect(4, true).Verify(cq_.get()); |
Yang Gao | 2b7f537 | 2015-02-18 00:45:53 -0800 | [diff] [blame] | 542 | auto server_initial_metadata = cli_ctx.GetServerInitialMetadata(); |
yang-g | e21908f | 2015-08-25 13:47:51 -0700 | [diff] [blame] | 543 | EXPECT_EQ(meta1.second, |
| 544 | ToString(server_initial_metadata.find(meta1.first)->second)); |
| 545 | EXPECT_EQ(meta2.second, |
| 546 | ToString(server_initial_metadata.find(meta2.first)->second)); |
vjpai | d5577aa | 2015-02-18 22:26:48 -0800 | [diff] [blame] | 547 | EXPECT_EQ(static_cast<size_t>(2), server_initial_metadata.size()); |
Yang Gao | 3a5e549 | 2015-02-18 14:32:38 -0800 | [diff] [blame] | 548 | |
| 549 | send_response.set_message(recv_request.message()); |
| 550 | response_writer.Finish(send_response, Status::OK, tag(5)); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 551 | Verifier(GetParam()).Expect(5, true).Verify(cq_.get()); |
Yang Gao | 3a5e549 | 2015-02-18 14:32:38 -0800 | [diff] [blame] | 552 | |
| 553 | response_reader->Finish(&recv_response, &recv_status, tag(6)); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 554 | Verifier(GetParam()).Expect(6, true).Verify(cq_.get()); |
Yang Gao | 3a5e549 | 2015-02-18 14:32:38 -0800 | [diff] [blame] | 555 | |
| 556 | EXPECT_EQ(send_response.message(), recv_response.message()); |
Yang Gao | c1a2c31 | 2015-06-16 10:59:46 -0700 | [diff] [blame] | 557 | EXPECT_TRUE(recv_status.ok()); |
Yang Gao | 2b7f537 | 2015-02-18 00:45:53 -0800 | [diff] [blame] | 558 | } |
| 559 | |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 560 | TEST_P(AsyncEnd2endTest, ServerTrailingMetadataRpc) { |
Yang Gao | 2b7f537 | 2015-02-18 00:45:53 -0800 | [diff] [blame] | 561 | ResetStub(); |
| 562 | |
| 563 | EchoRequest send_request; |
| 564 | EchoRequest recv_request; |
| 565 | EchoResponse send_response; |
| 566 | EchoResponse recv_response; |
| 567 | Status recv_status; |
| 568 | |
| 569 | ClientContext cli_ctx; |
| 570 | ServerContext srv_ctx; |
| 571 | grpc::ServerAsyncResponseWriter<EchoResponse> response_writer(&srv_ctx); |
| 572 | |
| 573 | send_request.set_message("Hello"); |
| 574 | std::pair<grpc::string, grpc::string> meta1("key1", "val1"); |
| 575 | std::pair<grpc::string, grpc::string> meta2("key2", "val2"); |
| 576 | |
Sree Kuchibhotla | 944f4cf | 2016-01-27 14:37:26 -0800 | [diff] [blame] | 577 | std::unique_ptr<ClientAsyncResponseReader<EchoResponse>> response_reader( |
Craig Tiller | 06cf3cc | 2015-05-13 13:11:01 -0700 | [diff] [blame] | 578 | stub_->AsyncEcho(&cli_ctx, send_request, cq_.get())); |
Yang Gao | 2b7f537 | 2015-02-18 00:45:53 -0800 | [diff] [blame] | 579 | |
Craig Tiller | 06cf3cc | 2015-05-13 13:11:01 -0700 | [diff] [blame] | 580 | service_.RequestEcho(&srv_ctx, &recv_request, &response_writer, cq_.get(), |
| 581 | cq_.get(), tag(2)); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 582 | Verifier(GetParam()).Expect(2, true).Verify(cq_.get()); |
Yang Gao | 2b7f537 | 2015-02-18 00:45:53 -0800 | [diff] [blame] | 583 | EXPECT_EQ(send_request.message(), recv_request.message()); |
| 584 | response_writer.SendInitialMetadata(tag(3)); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 585 | Verifier(GetParam()).Expect(3, true).Verify(cq_.get()); |
Yang Gao | 2b7f537 | 2015-02-18 00:45:53 -0800 | [diff] [blame] | 586 | |
| 587 | send_response.set_message(recv_request.message()); |
| 588 | srv_ctx.AddTrailingMetadata(meta1.first, meta1.second); |
| 589 | srv_ctx.AddTrailingMetadata(meta2.first, meta2.second); |
| 590 | response_writer.Finish(send_response, Status::OK, tag(4)); |
| 591 | |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 592 | Verifier(GetParam()).Expect(4, true).Verify(cq_.get()); |
Yang Gao | 2b7f537 | 2015-02-18 00:45:53 -0800 | [diff] [blame] | 593 | |
Yang Gao | 3a5e549 | 2015-02-18 14:32:38 -0800 | [diff] [blame] | 594 | response_reader->Finish(&recv_response, &recv_status, tag(5)); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 595 | Verifier(GetParam()).Expect(5, true).Verify(cq_.get()); |
Yang Gao | 2b7f537 | 2015-02-18 00:45:53 -0800 | [diff] [blame] | 596 | EXPECT_EQ(send_response.message(), recv_response.message()); |
Yang Gao | c1a2c31 | 2015-06-16 10:59:46 -0700 | [diff] [blame] | 597 | EXPECT_TRUE(recv_status.ok()); |
Yang Gao | 2b7f537 | 2015-02-18 00:45:53 -0800 | [diff] [blame] | 598 | auto server_trailing_metadata = cli_ctx.GetServerTrailingMetadata(); |
yang-g | e21908f | 2015-08-25 13:47:51 -0700 | [diff] [blame] | 599 | EXPECT_EQ(meta1.second, |
| 600 | ToString(server_trailing_metadata.find(meta1.first)->second)); |
| 601 | EXPECT_EQ(meta2.second, |
| 602 | ToString(server_trailing_metadata.find(meta2.first)->second)); |
vjpai | d5577aa | 2015-02-18 22:26:48 -0800 | [diff] [blame] | 603 | EXPECT_EQ(static_cast<size_t>(2), server_trailing_metadata.size()); |
Yang Gao | 2b7f537 | 2015-02-18 00:45:53 -0800 | [diff] [blame] | 604 | } |
| 605 | |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 606 | TEST_P(AsyncEnd2endTest, MetadataRpc) { |
Yang Gao | 2b7f537 | 2015-02-18 00:45:53 -0800 | [diff] [blame] | 607 | ResetStub(); |
| 608 | |
| 609 | EchoRequest send_request; |
| 610 | EchoRequest recv_request; |
| 611 | EchoResponse send_response; |
| 612 | EchoResponse recv_response; |
| 613 | Status recv_status; |
| 614 | |
| 615 | ClientContext cli_ctx; |
| 616 | ServerContext srv_ctx; |
| 617 | grpc::ServerAsyncResponseWriter<EchoResponse> response_writer(&srv_ctx); |
| 618 | |
| 619 | send_request.set_message("Hello"); |
| 620 | std::pair<grpc::string, grpc::string> meta1("key1", "val1"); |
Yang Gao | 3a5e549 | 2015-02-18 14:32:38 -0800 | [diff] [blame] | 621 | std::pair<grpc::string, grpc::string> meta2( |
Vijay Pai | 92a928f | 2015-03-26 16:30:22 -0400 | [diff] [blame] | 622 | "key2-bin", |
Craig Tiller | d6c98df | 2015-08-18 09:33:44 -0700 | [diff] [blame] | 623 | grpc::string("\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc", 13)); |
Yang Gao | 2b7f537 | 2015-02-18 00:45:53 -0800 | [diff] [blame] | 624 | std::pair<grpc::string, grpc::string> meta3("key3", "val3"); |
Craig Tiller | 47c83fd | 2015-02-21 22:45:35 -0800 | [diff] [blame] | 625 | std::pair<grpc::string, grpc::string> meta6( |
| 626 | "key4-bin", |
Vijay Pai | 92a928f | 2015-03-26 16:30:22 -0400 | [diff] [blame] | 627 | grpc::string("\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d", |
Craig Tiller | d6c98df | 2015-08-18 09:33:44 -0700 | [diff] [blame] | 628 | 14)); |
Yang Gao | 2b7f537 | 2015-02-18 00:45:53 -0800 | [diff] [blame] | 629 | std::pair<grpc::string, grpc::string> meta5("key5", "val5"); |
Craig Tiller | 47c83fd | 2015-02-21 22:45:35 -0800 | [diff] [blame] | 630 | std::pair<grpc::string, grpc::string> meta4( |
| 631 | "key6-bin", |
Craig Tiller | d6c98df | 2015-08-18 09:33:44 -0700 | [diff] [blame] | 632 | grpc::string( |
| 633 | "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee", 15)); |
Yang Gao | 2b7f537 | 2015-02-18 00:45:53 -0800 | [diff] [blame] | 634 | |
| 635 | cli_ctx.AddMetadata(meta1.first, meta1.second); |
| 636 | cli_ctx.AddMetadata(meta2.first, meta2.second); |
| 637 | |
Sree Kuchibhotla | 944f4cf | 2016-01-27 14:37:26 -0800 | [diff] [blame] | 638 | std::unique_ptr<ClientAsyncResponseReader<EchoResponse>> response_reader( |
Craig Tiller | 06cf3cc | 2015-05-13 13:11:01 -0700 | [diff] [blame] | 639 | stub_->AsyncEcho(&cli_ctx, send_request, cq_.get())); |
Yang Gao | 2b7f537 | 2015-02-18 00:45:53 -0800 | [diff] [blame] | 640 | |
Craig Tiller | 06cf3cc | 2015-05-13 13:11:01 -0700 | [diff] [blame] | 641 | service_.RequestEcho(&srv_ctx, &recv_request, &response_writer, cq_.get(), |
| 642 | cq_.get(), tag(2)); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 643 | Verifier(GetParam()).Expect(2, true).Verify(cq_.get()); |
Yang Gao | 2b7f537 | 2015-02-18 00:45:53 -0800 | [diff] [blame] | 644 | EXPECT_EQ(send_request.message(), recv_request.message()); |
| 645 | auto client_initial_metadata = srv_ctx.client_metadata(); |
yang-g | e21908f | 2015-08-25 13:47:51 -0700 | [diff] [blame] | 646 | EXPECT_EQ(meta1.second, |
| 647 | ToString(client_initial_metadata.find(meta1.first)->second)); |
| 648 | EXPECT_EQ(meta2.second, |
| 649 | ToString(client_initial_metadata.find(meta2.first)->second)); |
Craig Tiller | 8bf2dca | 2015-07-10 13:08:41 -0700 | [diff] [blame] | 650 | EXPECT_GE(client_initial_metadata.size(), static_cast<size_t>(2)); |
Yang Gao | 2b7f537 | 2015-02-18 00:45:53 -0800 | [diff] [blame] | 651 | |
| 652 | srv_ctx.AddInitialMetadata(meta3.first, meta3.second); |
| 653 | srv_ctx.AddInitialMetadata(meta4.first, meta4.second); |
| 654 | response_writer.SendInitialMetadata(tag(3)); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 655 | Verifier(GetParam()).Expect(3, true).Verify(cq_.get()); |
Yang Gao | 3a5e549 | 2015-02-18 14:32:38 -0800 | [diff] [blame] | 656 | response_reader->ReadInitialMetadata(tag(4)); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 657 | Verifier(GetParam()).Expect(4, true).Verify(cq_.get()); |
Yang Gao | 2b7f537 | 2015-02-18 00:45:53 -0800 | [diff] [blame] | 658 | auto server_initial_metadata = cli_ctx.GetServerInitialMetadata(); |
yang-g | e21908f | 2015-08-25 13:47:51 -0700 | [diff] [blame] | 659 | EXPECT_EQ(meta3.second, |
| 660 | ToString(server_initial_metadata.find(meta3.first)->second)); |
| 661 | EXPECT_EQ(meta4.second, |
| 662 | ToString(server_initial_metadata.find(meta4.first)->second)); |
Craig Tiller | 8bf2dca | 2015-07-10 13:08:41 -0700 | [diff] [blame] | 663 | EXPECT_GE(server_initial_metadata.size(), static_cast<size_t>(2)); |
Yang Gao | 3a5e549 | 2015-02-18 14:32:38 -0800 | [diff] [blame] | 664 | |
| 665 | send_response.set_message(recv_request.message()); |
| 666 | srv_ctx.AddTrailingMetadata(meta5.first, meta5.second); |
| 667 | srv_ctx.AddTrailingMetadata(meta6.first, meta6.second); |
| 668 | response_writer.Finish(send_response, Status::OK, tag(5)); |
| 669 | |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 670 | Verifier(GetParam()).Expect(5, true).Verify(cq_.get()); |
Yang Gao | 3a5e549 | 2015-02-18 14:32:38 -0800 | [diff] [blame] | 671 | |
Yang Gao | 3a5e549 | 2015-02-18 14:32:38 -0800 | [diff] [blame] | 672 | response_reader->Finish(&recv_response, &recv_status, tag(6)); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 673 | Verifier(GetParam()).Expect(6, true).Verify(cq_.get()); |
Yang Gao | 3a5e549 | 2015-02-18 14:32:38 -0800 | [diff] [blame] | 674 | EXPECT_EQ(send_response.message(), recv_response.message()); |
Yang Gao | c1a2c31 | 2015-06-16 10:59:46 -0700 | [diff] [blame] | 675 | EXPECT_TRUE(recv_status.ok()); |
Yang Gao | 2b7f537 | 2015-02-18 00:45:53 -0800 | [diff] [blame] | 676 | auto server_trailing_metadata = cli_ctx.GetServerTrailingMetadata(); |
yang-g | e21908f | 2015-08-25 13:47:51 -0700 | [diff] [blame] | 677 | EXPECT_EQ(meta5.second, |
| 678 | ToString(server_trailing_metadata.find(meta5.first)->second)); |
| 679 | EXPECT_EQ(meta6.second, |
| 680 | ToString(server_trailing_metadata.find(meta6.first)->second)); |
Craig Tiller | 8bf2dca | 2015-07-10 13:08:41 -0700 | [diff] [blame] | 681 | EXPECT_GE(server_trailing_metadata.size(), static_cast<size_t>(2)); |
Yang Gao | 2b7f537 | 2015-02-18 00:45:53 -0800 | [diff] [blame] | 682 | } |
yang-g | b335256 | 2015-08-04 14:42:06 -0700 | [diff] [blame] | 683 | |
| 684 | // Server uses AsyncNotifyWhenDone API to check for cancellation |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 685 | TEST_P(AsyncEnd2endTest, ServerCheckCancellation) { |
yang-g | b335256 | 2015-08-04 14:42:06 -0700 | [diff] [blame] | 686 | ResetStub(); |
| 687 | |
| 688 | EchoRequest send_request; |
| 689 | EchoRequest recv_request; |
| 690 | EchoResponse send_response; |
| 691 | EchoResponse recv_response; |
| 692 | Status recv_status; |
| 693 | |
| 694 | ClientContext cli_ctx; |
| 695 | ServerContext srv_ctx; |
| 696 | grpc::ServerAsyncResponseWriter<EchoResponse> response_writer(&srv_ctx); |
| 697 | |
| 698 | send_request.set_message("Hello"); |
Sree Kuchibhotla | 944f4cf | 2016-01-27 14:37:26 -0800 | [diff] [blame] | 699 | std::unique_ptr<ClientAsyncResponseReader<EchoResponse>> response_reader( |
yang-g | b335256 | 2015-08-04 14:42:06 -0700 | [diff] [blame] | 700 | stub_->AsyncEcho(&cli_ctx, send_request, cq_.get())); |
| 701 | |
| 702 | srv_ctx.AsyncNotifyWhenDone(tag(5)); |
| 703 | service_.RequestEcho(&srv_ctx, &recv_request, &response_writer, cq_.get(), |
| 704 | cq_.get(), tag(2)); |
| 705 | |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 706 | Verifier(GetParam()).Expect(2, true).Verify(cq_.get()); |
yang-g | b335256 | 2015-08-04 14:42:06 -0700 | [diff] [blame] | 707 | EXPECT_EQ(send_request.message(), recv_request.message()); |
| 708 | |
| 709 | cli_ctx.TryCancel(); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 710 | Verifier(GetParam()).Expect(5, true).Verify(cq_.get()); |
yang-g | b335256 | 2015-08-04 14:42:06 -0700 | [diff] [blame] | 711 | EXPECT_TRUE(srv_ctx.IsCancelled()); |
| 712 | |
| 713 | response_reader->Finish(&recv_response, &recv_status, tag(4)); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 714 | Verifier(GetParam()).Expect(4, false).Verify(cq_.get()); |
yang-g | b335256 | 2015-08-04 14:42:06 -0700 | [diff] [blame] | 715 | |
| 716 | EXPECT_EQ(StatusCode::CANCELLED, recv_status.error_code()); |
| 717 | } |
| 718 | |
| 719 | // Server uses AsyncNotifyWhenDone API to check for normal finish |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 720 | TEST_P(AsyncEnd2endTest, ServerCheckDone) { |
yang-g | b335256 | 2015-08-04 14:42:06 -0700 | [diff] [blame] | 721 | ResetStub(); |
| 722 | |
| 723 | EchoRequest send_request; |
| 724 | EchoRequest recv_request; |
| 725 | EchoResponse send_response; |
| 726 | EchoResponse recv_response; |
| 727 | Status recv_status; |
| 728 | |
| 729 | ClientContext cli_ctx; |
| 730 | ServerContext srv_ctx; |
| 731 | grpc::ServerAsyncResponseWriter<EchoResponse> response_writer(&srv_ctx); |
| 732 | |
| 733 | send_request.set_message("Hello"); |
Sree Kuchibhotla | 944f4cf | 2016-01-27 14:37:26 -0800 | [diff] [blame] | 734 | std::unique_ptr<ClientAsyncResponseReader<EchoResponse>> response_reader( |
yang-g | b335256 | 2015-08-04 14:42:06 -0700 | [diff] [blame] | 735 | stub_->AsyncEcho(&cli_ctx, send_request, cq_.get())); |
| 736 | |
| 737 | srv_ctx.AsyncNotifyWhenDone(tag(5)); |
| 738 | service_.RequestEcho(&srv_ctx, &recv_request, &response_writer, cq_.get(), |
| 739 | cq_.get(), tag(2)); |
| 740 | |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 741 | Verifier(GetParam()).Expect(2, true).Verify(cq_.get()); |
yang-g | b335256 | 2015-08-04 14:42:06 -0700 | [diff] [blame] | 742 | EXPECT_EQ(send_request.message(), recv_request.message()); |
| 743 | |
| 744 | send_response.set_message(recv_request.message()); |
| 745 | response_writer.Finish(send_response, Status::OK, tag(3)); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 746 | Verifier(GetParam()).Expect(3, true).Verify(cq_.get()); |
| 747 | Verifier(GetParam()).Expect(5, true).Verify(cq_.get()); |
yang-g | b335256 | 2015-08-04 14:42:06 -0700 | [diff] [blame] | 748 | EXPECT_FALSE(srv_ctx.IsCancelled()); |
| 749 | |
| 750 | response_reader->Finish(&recv_response, &recv_status, tag(4)); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 751 | Verifier(GetParam()).Expect(4, true).Verify(cq_.get()); |
yang-g | b335256 | 2015-08-04 14:42:06 -0700 | [diff] [blame] | 752 | |
| 753 | EXPECT_EQ(send_response.message(), recv_response.message()); |
| 754 | EXPECT_TRUE(recv_status.ok()); |
| 755 | } |
| 756 | |
Craig Tiller | 8f7bff7 | 2015-08-17 13:23:14 -0700 | [diff] [blame] | 757 | TEST_P(AsyncEnd2endTest, UnimplementedRpc) { |
yang-g | 730055d | 2015-08-27 12:29:45 -0700 | [diff] [blame] | 758 | std::shared_ptr<Channel> channel = |
Julien Boeuf | e5adc0e | 2015-10-12 14:08:10 -0700 | [diff] [blame] | 759 | CreateChannel(server_address_.str(), InsecureChannelCredentials()); |
Craig Tiller | 1b4e330 | 2015-12-17 16:35:00 -0800 | [diff] [blame] | 760 | std::unique_ptr<grpc::testing::UnimplementedService::Stub> stub; |
| 761 | stub = grpc::testing::UnimplementedService::NewStub(channel); |
yang-g | 9b7757d | 2015-08-13 11:15:53 -0700 | [diff] [blame] | 762 | EchoRequest send_request; |
| 763 | EchoResponse recv_response; |
| 764 | Status recv_status; |
| 765 | |
| 766 | ClientContext cli_ctx; |
| 767 | send_request.set_message("Hello"); |
Sree Kuchibhotla | 944f4cf | 2016-01-27 14:37:26 -0800 | [diff] [blame] | 768 | std::unique_ptr<ClientAsyncResponseReader<EchoResponse>> response_reader( |
yang-g | 9b7757d | 2015-08-13 11:15:53 -0700 | [diff] [blame] | 769 | stub->AsyncUnimplemented(&cli_ctx, send_request, cq_.get())); |
| 770 | |
| 771 | response_reader->Finish(&recv_response, &recv_status, tag(4)); |
Craig Tiller | 8f7bff7 | 2015-08-17 13:23:14 -0700 | [diff] [blame] | 772 | Verifier(GetParam()).Expect(4, false).Verify(cq_.get()); |
yang-g | 9b7757d | 2015-08-13 11:15:53 -0700 | [diff] [blame] | 773 | |
| 774 | EXPECT_EQ(StatusCode::UNIMPLEMENTED, recv_status.error_code()); |
| 775 | EXPECT_EQ("", recv_status.error_message()); |
| 776 | } |
| 777 | |
Sree Kuchibhotla | 944f4cf | 2016-01-27 14:37:26 -0800 | [diff] [blame] | 778 | class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest { |
| 779 | protected: |
| 780 | typedef enum { |
| 781 | DO_NOT_CANCEL = 0, |
| 782 | CANCEL_BEFORE_PROCESSING, |
| 783 | CANCEL_DURING_PROCESSING, |
| 784 | CANCEL_AFTER_PROCESSING |
| 785 | } ServerTryCancelRequestPhase; |
| 786 | |
| 787 | void ServerTryCancel(ServerContext* context) { |
| 788 | EXPECT_FALSE(context->IsCancelled()); |
| 789 | context->TryCancel(); |
| 790 | gpr_log(GPR_INFO, "Server called TryCancel()"); |
| 791 | EXPECT_TRUE(context->IsCancelled()); |
| 792 | } |
| 793 | |
| 794 | void TestClientStreamingServerCancel( |
| 795 | ServerTryCancelRequestPhase server_try_cancel) { |
| 796 | ResetStub(); |
| 797 | |
| 798 | EchoRequest send_request; |
| 799 | EchoRequest recv_request; |
| 800 | EchoResponse send_response; |
| 801 | EchoResponse recv_response; |
| 802 | Status recv_status; |
| 803 | |
Sree Kuchibhotla | 944f4cf | 2016-01-27 14:37:26 -0800 | [diff] [blame] | 804 | ClientContext cli_ctx; |
| 805 | ServerContext srv_ctx; |
| 806 | ServerAsyncReader<EchoResponse, EchoRequest> srv_stream(&srv_ctx); |
| 807 | |
| 808 | // Initiate the 'RequestStream' call on client |
| 809 | std::unique_ptr<ClientAsyncWriter<EchoRequest>> cli_stream( |
Sree Kuchibhotla | 4fb5908 | 2016-01-29 11:16:24 -0800 | [diff] [blame^] | 810 | stub_->AsyncRequestStream(&cli_ctx, &recv_response, cq_.get(), tag(1))); |
| 811 | Verifier(GetParam()).Expect(1, true).Verify(cq_.get()); |
Sree Kuchibhotla | 944f4cf | 2016-01-27 14:37:26 -0800 | [diff] [blame] | 812 | |
| 813 | // On the server, request to be notified of 'RequestStream' calls |
| 814 | // and receive the 'RequestStream' call just made by the client |
| 815 | service_.RequestRequestStream(&srv_ctx, &srv_stream, cq_.get(), cq_.get(), |
| 816 | tag(2)); |
| 817 | Verifier(GetParam()).Expect(2, true).Verify(cq_.get()); |
| 818 | |
| 819 | // Client sends 3 messages (tags 3, 4 and 5) |
| 820 | for (int tag_idx = 3; tag_idx <= 5; tag_idx++) { |
| 821 | send_request.set_message("Ping " + std::to_string(tag_idx)); |
| 822 | cli_stream->Write(send_request, tag(tag_idx)); |
Sree Kuchibhotla | 4fb5908 | 2016-01-29 11:16:24 -0800 | [diff] [blame^] | 823 | Verifier(GetParam()).Expect(tag_idx, true).Verify(cq_.get()); |
Sree Kuchibhotla | 944f4cf | 2016-01-27 14:37:26 -0800 | [diff] [blame] | 824 | } |
| 825 | cli_stream->WritesDone(tag(6)); |
Sree Kuchibhotla | 4fb5908 | 2016-01-29 11:16:24 -0800 | [diff] [blame^] | 826 | Verifier(GetParam()).Expect(6, true).Verify(cq_.get()); |
Sree Kuchibhotla | 944f4cf | 2016-01-27 14:37:26 -0800 | [diff] [blame] | 827 | |
| 828 | bool expected_server_cq_result = true; |
| 829 | bool ignore_cq_result = false; |
| 830 | |
| 831 | if (server_try_cancel == CANCEL_BEFORE_PROCESSING) { |
| 832 | ServerTryCancel(&srv_ctx); |
| 833 | |
| 834 | // Since cancellation is done before server reads any results, we know |
| 835 | // for sure that all cq results will return false from this point forward |
| 836 | expected_server_cq_result = false; |
| 837 | } |
| 838 | |
| 839 | std::thread* server_try_cancel_thd = NULL; |
| 840 | if (server_try_cancel == CANCEL_DURING_PROCESSING) { |
| 841 | server_try_cancel_thd = new std::thread( |
| 842 | &AsyncEnd2endServerTryCancelTest::ServerTryCancel, this, &srv_ctx); |
| 843 | // Server will cancel the RPC in a parallel thread while reading the |
| 844 | // requests from the client. Since the cancellation can happen at anytime, |
| 845 | // some of the cq results (i.e those until cancellation) might be true but |
| 846 | // its non deterministic. So better to ignore the cq results |
| 847 | ignore_cq_result = true; |
| 848 | } |
| 849 | |
| 850 | // Server reads 3 messages (tags 6, 7 and 8) |
| 851 | for (int tag_idx = 6; tag_idx <= 8; tag_idx++) { |
| 852 | srv_stream.Read(&recv_request, tag(tag_idx)); |
| 853 | Verifier(GetParam()) |
| 854 | .Expect(tag_idx, expected_server_cq_result) |
| 855 | .Verify(cq_.get(), ignore_cq_result); |
| 856 | } |
| 857 | |
| 858 | if (server_try_cancel_thd != NULL) { |
| 859 | server_try_cancel_thd->join(); |
| 860 | delete server_try_cancel_thd; |
| 861 | } |
| 862 | |
| 863 | if (server_try_cancel == CANCEL_AFTER_PROCESSING) { |
| 864 | ServerTryCancel(&srv_ctx); |
| 865 | } |
| 866 | |
| 867 | // Note: The RPC has been cancelled at this point for sure. So, from this |
| 868 | // point forward, we know that cq results are supposed to return false on |
| 869 | // server. |
| 870 | |
| 871 | send_response.set_message("Pong"); |
| 872 | srv_stream.Finish(send_response, Status::CANCELLED, tag(9)); |
| 873 | Verifier(GetParam()).Expect(9, false).Verify(cq_.get()); |
| 874 | |
| 875 | cli_stream->Finish(&recv_status, tag(10)); |
| 876 | // TODO: sreek: The expectation here should be true. This seems like a bug. |
| 877 | // Investigating |
Sree Kuchibhotla | 4fb5908 | 2016-01-29 11:16:24 -0800 | [diff] [blame^] | 878 | Verifier(GetParam()).Expect(10, false).Verify(cq_.get()); |
Sree Kuchibhotla | 944f4cf | 2016-01-27 14:37:26 -0800 | [diff] [blame] | 879 | EXPECT_FALSE(recv_status.ok()); |
| 880 | EXPECT_EQ(::grpc::StatusCode::CANCELLED, recv_status.error_code()); |
| 881 | } |
| 882 | |
| 883 | void TestServerStreamingServerCancel( |
| 884 | ServerTryCancelRequestPhase server_try_cancel) { |
| 885 | ResetStub(); |
| 886 | |
| 887 | EchoRequest send_request; |
| 888 | EchoRequest recv_request; |
| 889 | EchoResponse send_response; |
| 890 | EchoResponse recv_response; |
| 891 | Status recv_status; |
| 892 | ClientContext cli_ctx; |
| 893 | ServerContext srv_ctx; |
Sree Kuchibhotla | 944f4cf | 2016-01-27 14:37:26 -0800 | [diff] [blame] | 894 | ServerAsyncWriter<EchoResponse> srv_stream(&srv_ctx); |
| 895 | |
| 896 | send_request.set_message("Ping"); |
| 897 | // Initiate the 'ResponseStream' call on the client |
| 898 | std::unique_ptr<ClientAsyncReader<EchoResponse>> cli_stream( |
Sree Kuchibhotla | 4fb5908 | 2016-01-29 11:16:24 -0800 | [diff] [blame^] | 899 | stub_->AsyncResponseStream(&cli_ctx, send_request, cq_.get(), tag(1))); |
| 900 | Verifier(GetParam()).Expect(1, true).Verify(cq_.get()); |
Sree Kuchibhotla | 944f4cf | 2016-01-27 14:37:26 -0800 | [diff] [blame] | 901 | |
| 902 | // On the server, request to be notified of 'ResponseStream' calls and |
| 903 | // receive the call just made by the client |
| 904 | service_.RequestResponseStream(&srv_ctx, &recv_request, &srv_stream, |
| 905 | cq_.get(), cq_.get(), tag(2)); |
| 906 | Verifier(GetParam()).Expect(2, true).Verify(cq_.get()); |
| 907 | EXPECT_EQ(send_request.message(), recv_request.message()); |
| 908 | |
| 909 | bool expected_cq_result = true; |
| 910 | bool ignore_cq_result = false; |
| 911 | |
| 912 | if (server_try_cancel == CANCEL_BEFORE_PROCESSING) { |
| 913 | ServerTryCancel(&srv_ctx); |
| 914 | |
| 915 | // We know for sure that all cq results will be false from this point |
| 916 | // since the server cancelled the RPC |
| 917 | expected_cq_result = false; |
| 918 | } |
| 919 | |
| 920 | std::thread* server_try_cancel_thd = NULL; |
| 921 | if (server_try_cancel == CANCEL_DURING_PROCESSING) { |
| 922 | server_try_cancel_thd = new std::thread( |
| 923 | &AsyncEnd2endServerTryCancelTest::ServerTryCancel, this, &srv_ctx); |
| 924 | |
| 925 | // Server will cancel the RPC in a parallel thread while writing responses |
| 926 | // to the client. Since the cancellation can happen at anytime, some of |
| 927 | // the cq results (i.e those until cancellation) might be true but |
| 928 | // its non deterministic. So better to ignore the cq results |
| 929 | ignore_cq_result = true; |
| 930 | } |
| 931 | |
| 932 | // Server sends three messages (tags 3, 4 and 5) |
| 933 | for (int tag_idx = 3; tag_idx <= 5; tag_idx++) { |
| 934 | send_response.set_message("Pong " + std::to_string(tag_idx)); |
| 935 | srv_stream.Write(send_response, tag(tag_idx)); |
| 936 | Verifier(GetParam()) |
| 937 | .Expect(tag_idx, expected_cq_result) |
| 938 | .Verify(cq_.get(), ignore_cq_result); |
| 939 | } |
| 940 | |
| 941 | if (server_try_cancel == CANCEL_AFTER_PROCESSING) { |
| 942 | ServerTryCancel(&srv_ctx); |
| 943 | } |
| 944 | |
| 945 | // Client attemts to read the three messages |
| 946 | for (int tag_idx = 6; tag_idx <= 8; tag_idx++) { |
| 947 | cli_stream->Read(&recv_response, tag(tag_idx)); |
| 948 | Verifier(GetParam()) |
| 949 | .Expect(tag_idx, expected_cq_result) |
Sree Kuchibhotla | 4fb5908 | 2016-01-29 11:16:24 -0800 | [diff] [blame^] | 950 | .Verify(cq_.get(), ignore_cq_result); |
Sree Kuchibhotla | 944f4cf | 2016-01-27 14:37:26 -0800 | [diff] [blame] | 951 | } |
| 952 | |
| 953 | if (server_try_cancel_thd != NULL) { |
| 954 | server_try_cancel_thd->join(); |
| 955 | delete server_try_cancel_thd; |
| 956 | } |
| 957 | |
| 958 | // Note: At this point, we know that server has cancelled the request for |
| 959 | // sure. |
| 960 | |
| 961 | // Server finishes the stream |
| 962 | srv_stream.Finish(Status::CANCELLED, tag(9)); |
| 963 | Verifier(GetParam()).Expect(9, false).Verify(cq_.get()); |
| 964 | |
| 965 | // Client receives the cancellation |
| 966 | cli_stream->Finish(&recv_status, tag(10)); |
Sree Kuchibhotla | 4fb5908 | 2016-01-29 11:16:24 -0800 | [diff] [blame^] | 967 | Verifier(GetParam()).Expect(10, true).Verify(cq_.get()); |
Sree Kuchibhotla | 944f4cf | 2016-01-27 14:37:26 -0800 | [diff] [blame] | 968 | EXPECT_FALSE(recv_status.ok()); |
| 969 | EXPECT_EQ(::grpc::StatusCode::CANCELLED, recv_status.error_code()); |
| 970 | } |
| 971 | |
| 972 | void TestBidiStreamingServerCancel( |
| 973 | ServerTryCancelRequestPhase server_try_cancel) { |
| 974 | ResetStub(); |
| 975 | |
| 976 | EchoRequest send_request; |
| 977 | EchoRequest recv_request; |
| 978 | EchoResponse send_response; |
| 979 | EchoResponse recv_response; |
| 980 | Status recv_status; |
Sree Kuchibhotla | 944f4cf | 2016-01-27 14:37:26 -0800 | [diff] [blame] | 981 | ClientContext cli_ctx; |
| 982 | ServerContext srv_ctx; |
| 983 | ServerAsyncReaderWriter<EchoResponse, EchoRequest> srv_stream(&srv_ctx); |
| 984 | |
| 985 | // Initiate the call from the client side |
| 986 | std::unique_ptr<ClientAsyncReaderWriter<EchoRequest, EchoResponse>> |
Sree Kuchibhotla | 4fb5908 | 2016-01-29 11:16:24 -0800 | [diff] [blame^] | 987 | cli_stream(stub_->AsyncBidiStream(&cli_ctx, cq_.get(), tag(1))); |
| 988 | Verifier(GetParam()).Expect(1, true).Verify(cq_.get()); |
Sree Kuchibhotla | 944f4cf | 2016-01-27 14:37:26 -0800 | [diff] [blame] | 989 | |
| 990 | // On the server, request to be notified of the 'BidiStream' call and |
| 991 | // receive the call just made by the client |
| 992 | service_.RequestBidiStream(&srv_ctx, &srv_stream, cq_.get(), cq_.get(), |
| 993 | tag(2)); |
| 994 | Verifier(GetParam()).Expect(2, true).Verify(cq_.get()); |
| 995 | |
| 996 | send_request.set_message("Ping"); |
| 997 | cli_stream->Write(send_request, tag(3)); |
Sree Kuchibhotla | 4fb5908 | 2016-01-29 11:16:24 -0800 | [diff] [blame^] | 998 | Verifier(GetParam()).Expect(3, true).Verify(cq_.get()); |
Sree Kuchibhotla | 944f4cf | 2016-01-27 14:37:26 -0800 | [diff] [blame] | 999 | |
| 1000 | bool expected_cq_result = true; |
| 1001 | bool ignore_cq_result = false; |
| 1002 | if (server_try_cancel == CANCEL_BEFORE_PROCESSING) { |
| 1003 | ServerTryCancel(&srv_ctx); |
| 1004 | |
| 1005 | // We know for sure that all cq results will be false from this point |
| 1006 | // since the server cancelled the RPC |
| 1007 | expected_cq_result = false; |
| 1008 | } |
| 1009 | |
| 1010 | std::thread* server_try_cancel_thd = NULL; |
| 1011 | if (server_try_cancel == CANCEL_DURING_PROCESSING) { |
| 1012 | server_try_cancel_thd = new std::thread( |
| 1013 | &AsyncEnd2endServerTryCancelTest::ServerTryCancel, this, &srv_ctx); |
| 1014 | |
| 1015 | // Since server is going to cancel the RPC in a parallel thread, some of |
| 1016 | // the cq results (i.e those until the cancellation) might be true. Since |
| 1017 | // that number is non-deterministic, it is better to ignore the cq results |
| 1018 | ignore_cq_result = true; |
| 1019 | } |
| 1020 | |
| 1021 | srv_stream.Read(&recv_request, tag(4)); |
| 1022 | Verifier(GetParam()) |
| 1023 | .Expect(4, expected_cq_result) |
| 1024 | .Verify(cq_.get(), ignore_cq_result); |
| 1025 | |
| 1026 | send_response.set_message("Pong"); |
| 1027 | srv_stream.Write(send_response, tag(5)); |
| 1028 | Verifier(GetParam()) |
| 1029 | .Expect(5, expected_cq_result) |
| 1030 | .Verify(cq_.get(), ignore_cq_result); |
| 1031 | |
| 1032 | cli_stream->Read(&recv_response, tag(6)); |
| 1033 | Verifier(GetParam()) |
| 1034 | .Expect(6, expected_cq_result) |
Sree Kuchibhotla | 4fb5908 | 2016-01-29 11:16:24 -0800 | [diff] [blame^] | 1035 | .Verify(cq_.get(), ignore_cq_result); |
Sree Kuchibhotla | 944f4cf | 2016-01-27 14:37:26 -0800 | [diff] [blame] | 1036 | |
| 1037 | // This is expected to succeed in all cases |
| 1038 | cli_stream->WritesDone(tag(7)); |
Sree Kuchibhotla | 4fb5908 | 2016-01-29 11:16:24 -0800 | [diff] [blame^] | 1039 | Verifier(GetParam()).Expect(7, true).Verify(cq_.get()); |
Sree Kuchibhotla | 944f4cf | 2016-01-27 14:37:26 -0800 | [diff] [blame] | 1040 | |
| 1041 | // This is expected to fail in all cases (Either there are no more msgs from |
| 1042 | // the client or the RPC is cancelled on the server) |
| 1043 | srv_stream.Read(&recv_request, tag(8)); |
| 1044 | Verifier(GetParam()).Expect(8, false).Verify(cq_.get()); |
| 1045 | |
| 1046 | if (server_try_cancel_thd != NULL) { |
| 1047 | server_try_cancel_thd->join(); |
| 1048 | delete server_try_cancel_thd; |
| 1049 | } |
| 1050 | |
| 1051 | if (server_try_cancel == CANCEL_AFTER_PROCESSING) { |
| 1052 | ServerTryCancel(&srv_ctx); |
| 1053 | } |
| 1054 | |
| 1055 | // At this point, we know that the server cancelled the request for sure |
| 1056 | |
| 1057 | srv_stream.Finish(Status::CANCELLED, tag(9)); |
| 1058 | Verifier(GetParam()).Expect(9, false).Verify(cq_.get()); |
| 1059 | |
| 1060 | cli_stream->Finish(&recv_status, tag(10)); |
Sree Kuchibhotla | 4fb5908 | 2016-01-29 11:16:24 -0800 | [diff] [blame^] | 1061 | Verifier(GetParam()).Expect(10, true).Verify(cq_.get()); |
Sree Kuchibhotla | 944f4cf | 2016-01-27 14:37:26 -0800 | [diff] [blame] | 1062 | EXPECT_FALSE(recv_status.ok()); |
| 1063 | EXPECT_EQ(grpc::StatusCode::CANCELLED, recv_status.error_code()); |
| 1064 | } |
| 1065 | }; |
| 1066 | |
| 1067 | TEST_P(AsyncEnd2endServerTryCancelTest, ClientStreamingServerTryCancelBefore) { |
| 1068 | TestClientStreamingServerCancel(CANCEL_BEFORE_PROCESSING); |
| 1069 | } |
| 1070 | |
| 1071 | TEST_P(AsyncEnd2endServerTryCancelTest, ClientStreamingServerTryCancelDuring) { |
| 1072 | TestClientStreamingServerCancel(CANCEL_DURING_PROCESSING); |
| 1073 | } |
| 1074 | |
| 1075 | TEST_P(AsyncEnd2endServerTryCancelTest, ClientStreamingServerTryCancelAfter) { |
| 1076 | TestClientStreamingServerCancel(CANCEL_AFTER_PROCESSING); |
| 1077 | } |
| 1078 | |
| 1079 | TEST_P(AsyncEnd2endServerTryCancelTest, ServerStreamingServerTryCancelBefore) { |
| 1080 | TestServerStreamingServerCancel(CANCEL_BEFORE_PROCESSING); |
| 1081 | } |
| 1082 | |
| 1083 | TEST_P(AsyncEnd2endServerTryCancelTest, ServerStreamingServerTryCancelDuring) { |
| 1084 | TestServerStreamingServerCancel(CANCEL_DURING_PROCESSING); |
| 1085 | } |
| 1086 | |
| 1087 | TEST_P(AsyncEnd2endServerTryCancelTest, ServerStreamingServerTryCancelAfter) { |
| 1088 | TestServerStreamingServerCancel(CANCEL_AFTER_PROCESSING); |
| 1089 | } |
| 1090 | |
| 1091 | TEST_P(AsyncEnd2endServerTryCancelTest, ServerBidiStreamingTryCancelBefore) { |
| 1092 | TestBidiStreamingServerCancel(CANCEL_BEFORE_PROCESSING); |
| 1093 | } |
| 1094 | |
| 1095 | TEST_P(AsyncEnd2endServerTryCancelTest, ServerBidiStreamingTryCancelDuring) { |
| 1096 | TestBidiStreamingServerCancel(CANCEL_DURING_PROCESSING); |
| 1097 | } |
| 1098 | |
| 1099 | TEST_P(AsyncEnd2endServerTryCancelTest, ServerBidiStreamingTryCancelAfter) { |
| 1100 | TestBidiStreamingServerCancel(CANCEL_AFTER_PROCESSING); |
| 1101 | } |
| 1102 | |
Craig Tiller | 4c06b82 | 2015-08-06 08:41:31 -0700 | [diff] [blame] | 1103 | INSTANTIATE_TEST_CASE_P(AsyncEnd2end, AsyncEnd2endTest, |
| 1104 | ::testing::Values(false, true)); |
Sree Kuchibhotla | 944f4cf | 2016-01-27 14:37:26 -0800 | [diff] [blame] | 1105 | INSTANTIATE_TEST_CASE_P(AsyncEnd2endServerTryCancel, |
| 1106 | AsyncEnd2endServerTryCancelTest, |
| 1107 | ::testing::Values(false)); |
Craig Tiller | 69f90e6 | 2015-08-06 08:32:35 -0700 | [diff] [blame] | 1108 | |
Craig Tiller | 0220cf1 | 2015-02-12 17:39:26 -0800 | [diff] [blame] | 1109 | } // namespace |
| 1110 | } // namespace testing |
| 1111 | } // namespace grpc |
| 1112 | |
| 1113 | int main(int argc, char** argv) { |
| 1114 | grpc_test_init(argc, argv); |
Craig Tiller | 0220cf1 | 2015-02-12 17:39:26 -0800 | [diff] [blame] | 1115 | ::testing::InitGoogleTest(&argc, argv); |
Yang Gao | c4b6ffb | 2015-04-23 16:35:24 -0700 | [diff] [blame] | 1116 | return RUN_ALL_TESTS(); |
Craig Tiller | 0220cf1 | 2015-02-12 17:39:26 -0800 | [diff] [blame] | 1117 | } |