test_service_impl.cc
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2016 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
20 
21 #include <string>
22 #include <thread>
23 
24 #include <gtest/gtest.h>
25 
26 #include <grpc/support/log.h>
27 #include <grpcpp/alarm.h>
29 #include <grpcpp/server_context.h>
30 
31 #include "src/proto/grpc/testing/echo.grpc.pb.h"
33 
34 using std::chrono::system_clock;
35 
36 namespace grpc {
37 namespace testing {
38 namespace internal {
39 
40 // When echo_deadline is requested, deadline seen in the ServerContext is set in
41 // the response in seconds.
43  EchoResponse* response) {
44  if (request->has_param() && request->param().echo_deadline()) {
47  Timepoint2Timespec(context->deadline(), &deadline);
48  }
49  response->mutable_param()->set_request_deadline(deadline.tv_sec);
50  }
51 }
52 
54  const std::string& expected_transport_security_type,
55  const std::string& expected_client_identity) {
56  std::shared_ptr<const AuthContext> auth_ctx = context->auth_context();
57  std::vector<grpc::string_ref> tst =
58  auth_ctx->FindPropertyValues("transport_security_type");
59  EXPECT_EQ(1u, tst.size());
60  EXPECT_EQ(expected_transport_security_type, ToString(tst[0]));
61  if (expected_client_identity.empty()) {
62  EXPECT_TRUE(auth_ctx->GetPeerIdentityPropertyName().empty());
63  EXPECT_TRUE(auth_ctx->GetPeerIdentity().empty());
64  EXPECT_FALSE(auth_ctx->IsPeerAuthenticated());
65  } else {
66  auto identity = auth_ctx->GetPeerIdentity();
67  EXPECT_TRUE(auth_ctx->IsPeerAuthenticated());
68  EXPECT_EQ(1u, identity.size());
69  EXPECT_EQ(expected_client_identity, identity[0]);
70  }
71 }
72 
73 // Returns the number of pairs in metadata that exactly match the given
74 // key-value pair. Returns -1 if the pair wasn't found.
76  const std::multimap<grpc::string_ref, grpc::string_ref>& metadata,
77  const std::string& key, const std::string& value) {
78  int count = 0;
79  for (const auto& metadatum : metadata) {
80  if (ToString(metadatum.first) == key &&
81  ToString(metadatum.second) == value) {
82  count++;
83  }
84  }
85  return count;
86 }
87 
89  const char* key,
90  const std::multimap<grpc::string_ref, grpc::string_ref>& metadata,
91  int default_value) {
92  if (metadata.find(key) != metadata.end()) {
93  std::istringstream iss(ToString(metadata.find(key)->second));
94  iss >> default_value;
95  gpr_log(GPR_INFO, "%s : %d", key, default_value);
96  }
97 
98  return default_value;
99 }
100 
102  const char* key,
103  const std::multimap<grpc::string_ref, grpc::string_ref>& metadata,
104  int default_value) {
105  return GetIntValueFromMetadataHelper(key, metadata, default_value);
106 }
107 
109  EXPECT_FALSE(context->IsCancelled());
110  context->TryCancel();
111  gpr_log(GPR_INFO, "Server called TryCancel() to cancel the request");
112  // Now wait until it's really canceled
113  while (!context->IsCancelled()) {
116  }
117 }
118 
120  EXPECT_FALSE(context->IsCancelled());
121  context->TryCancel();
123  "Server called TryCancelNonblocking() to cancel the request");
124 }
125 
126 } // namespace internal
127 
128 ServerUnaryReactor* CallbackTestServiceImpl::Echo(
129  CallbackServerContext* context, const EchoRequest* request,
130  EchoResponse* response) {
131  class Reactor : public grpc::ServerUnaryReactor {
132  public:
133  Reactor(CallbackTestServiceImpl* service, CallbackServerContext* ctx,
134  const EchoRequest* request, EchoResponse* response)
136  // It should be safe to call IsCancelled here, even though we don't know
137  // the result. Call it asynchronously to see if we trigger any data races.
138  // Join it in OnDone (technically that could be blocking but shouldn't be
139  // for very long).
140  async_cancel_check_ = std::thread([this] { (void)ctx_->IsCancelled(); });
141 
142  started_ = true;
143 
144  if (request->has_param() &&
145  request->param().server_notify_client_when_started()) {
146  service->signaller_.SignalClientThatRpcStarted();
147  // Block on the "wait to continue" decision in a different thread since
148  // we can't tie up an EM thread with blocking events. We can join it in
149  // OnDone since it would definitely be done by then.
150  rpc_wait_thread_ = std::thread([this] {
151  service_->signaller_.ServerWaitToContinue();
152  StartRpc();
153  });
154  } else {
155  StartRpc();
156  }
157  }
158 
159  void StartRpc() {
160  if (req_->has_param() && req_->param().server_sleep_us() > 0) {
161  // Set an alarm for that much time
162  alarm_.Set(
164  gpr_time_from_micros(req_->param().server_sleep_us(),
165  GPR_TIMESPAN)),
166  [this](bool ok) { NonDelayed(ok); });
167  return;
168  }
169  NonDelayed(true);
170  }
171  void OnSendInitialMetadataDone(bool ok) override {
172  EXPECT_TRUE(ok);
173  initial_metadata_sent_ = true;
174  }
175  void OnCancel() override {
177  EXPECT_TRUE(ctx_->IsCancelled());
178  on_cancel_invoked_ = true;
179  std::lock_guard<std::mutex> l(cancel_mu_);
180  cancel_cv_.notify_one();
181  }
182  void OnDone() override {
183  if (req_->has_param() && req_->param().echo_metadata_initially()) {
184  EXPECT_TRUE(initial_metadata_sent_);
185  }
186  EXPECT_EQ(ctx_->IsCancelled(), on_cancel_invoked_);
187  // Validate that finishing with a non-OK status doesn't cause cancellation
188  if (req_->has_param() && req_->param().has_expected_error()) {
189  EXPECT_FALSE(on_cancel_invoked_);
190  }
191  async_cancel_check_.join();
192  if (rpc_wait_thread_.joinable()) {
193  rpc_wait_thread_.join();
194  }
195  if (finish_when_cancelled_.joinable()) {
196  finish_when_cancelled_.join();
197  }
198  delete this;
199  }
200 
201  private:
202  void NonDelayed(bool ok) {
203  if (!ok) {
204  EXPECT_TRUE(ctx_->IsCancelled());
206  return;
207  }
208  if (req_->has_param() && req_->param().server_die()) {
209  gpr_log(GPR_ERROR, "The request should not reach application handler.");
210  GPR_ASSERT(0);
211  }
212  if (req_->has_param() && req_->param().has_expected_error()) {
213  const auto& error = req_->param().expected_error();
214  Finish(Status(static_cast<StatusCode>(error.code()),
215  error.error_message(), error.binary_error_details()));
216  return;
217  }
218  int server_try_cancel = internal::GetIntValueFromMetadata(
219  kServerTryCancelRequest, ctx_->client_metadata(), DO_NOT_CANCEL);
220  if (server_try_cancel != DO_NOT_CANCEL) {
221  // Since this is a unary RPC, by the time this server handler is called,
222  // the 'request' message is already read from the client. So the
223  // scenarios in server_try_cancel don't make much sense. Just cancel the
224  // RPC as long as server_try_cancel is not DO_NOT_CANCEL
225  EXPECT_FALSE(ctx_->IsCancelled());
226  ctx_->TryCancel();
227  gpr_log(GPR_INFO, "Server called TryCancel() to cancel the request");
228  FinishWhenCancelledAsync();
229  return;
230  }
231  resp_->set_message(req_->message());
233  if (service_->host_) {
234  resp_->mutable_param()->set_host(*service_->host_);
235  } else if (req_->has_param() &&
236  req_->param().echo_host_from_authority_header()) {
237  auto authority = ctx_->ExperimentalGetAuthority();
238  std::string authority_str(authority.data(), authority.size());
239  resp_->mutable_param()->set_host(std::move(authority_str));
240  }
241  if (req_->has_param() && req_->param().client_cancel_after_us()) {
242  {
243  std::unique_lock<std::mutex> lock(service_->mu_);
244  service_->signal_client_ = true;
245  }
246  FinishWhenCancelledAsync();
247  return;
248  } else if (req_->has_param() && req_->param().server_cancel_after_us()) {
251  req_->param().server_cancel_after_us(),
252  GPR_TIMESPAN)),
253  [this](bool) { Finish(Status::CANCELLED); });
254  return;
255  } else if (!req_->has_param() || !req_->param().skip_cancelled_check()) {
256  EXPECT_FALSE(ctx_->IsCancelled());
257  }
258 
259  if (req_->has_param() && req_->param().echo_metadata_initially()) {
260  const std::multimap<grpc::string_ref, grpc::string_ref>&
261  client_metadata = ctx_->client_metadata();
262  for (const auto& metadatum : client_metadata) {
263  ctx_->AddInitialMetadata(ToString(metadatum.first),
264  ToString(metadatum.second));
265  }
266  StartSendInitialMetadata();
267  }
268 
269  if (req_->has_param() && req_->param().echo_metadata()) {
270  const std::multimap<grpc::string_ref, grpc::string_ref>&
271  client_metadata = ctx_->client_metadata();
272  for (const auto& metadatum : client_metadata) {
273  ctx_->AddTrailingMetadata(ToString(metadatum.first),
274  ToString(metadatum.second));
275  }
276  // Terminate rpc with error and debug info in trailer.
277  if (req_->param().debug_info().stack_entries_size() ||
278  !req_->param().debug_info().detail().empty()) {
279  std::string serialized_debug_info =
280  req_->param().debug_info().SerializeAsString();
281  ctx_->AddTrailingMetadata(kDebugInfoTrailerKey,
282  serialized_debug_info);
284  return;
285  }
286  }
287  if (req_->has_param() &&
288  (req_->param().expected_client_identity().length() > 0 ||
289  req_->param().check_auth_context())) {
291  ctx_, req_->param().expected_transport_security_type(),
292  req_->param().expected_client_identity());
293  }
294  if (req_->has_param() && req_->param().response_message_length() > 0) {
295  resp_->set_message(
296  std::string(req_->param().response_message_length(), '\0'));
297  }
298  if (req_->has_param() && req_->param().echo_peer()) {
299  resp_->mutable_param()->set_peer(ctx_->peer());
300  }
302  }
303  void FinishWhenCancelledAsync() {
304  finish_when_cancelled_ = std::thread([this] {
305  std::unique_lock<std::mutex> l(cancel_mu_);
306  cancel_cv_.wait(l, [this] { return ctx_->IsCancelled(); });
308  });
309  }
310 
311  CallbackTestServiceImpl* const service_;
313  const EchoRequest* const req_;
314  EchoResponse* const resp_;
315  Alarm alarm_;
316  std::mutex cancel_mu_;
317  std::condition_variable cancel_cv_;
318  bool initial_metadata_sent_ = false;
319  bool started_ = false;
320  bool on_cancel_invoked_ = false;
321  std::thread async_cancel_check_;
322  std::thread rpc_wait_thread_;
323  std::thread finish_when_cancelled_;
324  };
325 
326  return new Reactor(this, context, request, response);
327 }
328 
329 ServerUnaryReactor* CallbackTestServiceImpl::CheckClientInitialMetadata(
331  class Reactor : public grpc::ServerUnaryReactor {
332  public:
333  explicit Reactor(CallbackServerContext* ctx) {
334  EXPECT_EQ(internal::MetadataMatchCount(ctx->client_metadata(),
337  1);
338  EXPECT_EQ(ctx->client_metadata().count(kCheckClientInitialMetadataKey),
339  1u);
341  }
342  void OnDone() override { delete this; }
343  };
344 
345  return new Reactor(context);
346 }
347 
348 ServerReadReactor<EchoRequest>* CallbackTestServiceImpl::RequestStream(
349  CallbackServerContext* context, EchoResponse* response) {
350  // If 'server_try_cancel' is set in the metadata, the RPC is cancelled by
351  // the server by calling ServerContext::TryCancel() depending on the
352  // value:
353  // CANCEL_BEFORE_PROCESSING: The RPC is cancelled before the server
354  // reads any message from the client CANCEL_DURING_PROCESSING: The RPC
355  // is cancelled while the server is reading messages from the client
356  // CANCEL_AFTER_PROCESSING: The RPC is cancelled after the server reads
357  // all the messages from the client
358  int server_try_cancel = internal::GetIntValueFromMetadata(
359  kServerTryCancelRequest, context->client_metadata(), DO_NOT_CANCEL);
360  if (server_try_cancel == CANCEL_BEFORE_PROCESSING) {
362  // Don't need to provide a reactor since the RPC is canceled
363  return nullptr;
364  }
365 
366  class Reactor : public grpc::ServerReadReactor<EchoRequest> {
367  public:
368  Reactor(CallbackServerContext* ctx, EchoResponse* response,
369  int server_try_cancel)
370  : ctx_(ctx),
372  server_try_cancel_(server_try_cancel) {
373  EXPECT_NE(server_try_cancel, CANCEL_BEFORE_PROCESSING);
374  response->set_message("");
375 
377  ctx->TryCancel();
378  // Don't wait for it here
379  }
380  StartRead(&request_);
381  setup_done_ = true;
382  }
383  void OnDone() override { delete this; }
384  void OnCancel() override {
385  EXPECT_TRUE(setup_done_);
386  EXPECT_TRUE(ctx_->IsCancelled());
387  FinishOnce(Status::CANCELLED);
388  }
389  void OnReadDone(bool ok) override {
390  if (ok) {
391  response_->mutable_message()->append(request_.message());
392  num_msgs_read_++;
393  StartRead(&request_);
394  } else {
395  gpr_log(GPR_INFO, "Read: %d messages", num_msgs_read_);
396 
398  // Let OnCancel recover this
399  return;
400  }
403  return;
404  }
405  FinishOnce(Status::OK);
406  }
407  }
408 
409  private:
410  void FinishOnce(const Status& s) {
411  std::lock_guard<std::mutex> l(finish_mu_);
412  if (!finished_) {
413  Finish(s);
414  finished_ = true;
415  }
416  }
417 
419  EchoResponse* const response_;
420  EchoRequest request_;
421  int num_msgs_read_{0};
422  int server_try_cancel_;
423  std::mutex finish_mu_;
424  bool finished_{false};
425  bool setup_done_{false};
426  };
427 
428  return new Reactor(context, response, server_try_cancel);
429 }
430 
431 // Return 'kNumResponseStreamMsgs' messages.
432 // TODO(yangg) make it generic by adding a parameter into EchoRequest
433 ServerWriteReactor<EchoResponse>* CallbackTestServiceImpl::ResponseStream(
434  CallbackServerContext* context, const EchoRequest* request) {
435  // If 'server_try_cancel' is set in the metadata, the RPC is cancelled by
436  // the server by calling ServerContext::TryCancel() depending on the
437  // value:
438  // CANCEL_BEFORE_PROCESSING: The RPC is cancelled before the server
439  // reads any message from the client CANCEL_DURING_PROCESSING: The RPC
440  // is cancelled while the server is reading messages from the client
441  // CANCEL_AFTER_PROCESSING: The RPC is cancelled after the server reads
442  // all the messages from the client
443  int server_try_cancel = internal::GetIntValueFromMetadata(
444  kServerTryCancelRequest, context->client_metadata(), DO_NOT_CANCEL);
445  if (server_try_cancel == CANCEL_BEFORE_PROCESSING) {
447  }
448 
449  class Reactor : public grpc::ServerWriteReactor<EchoResponse> {
450  public:
451  Reactor(CallbackServerContext* ctx, const EchoRequest* request,
452  int server_try_cancel)
453  : ctx_(ctx), request_(request), server_try_cancel_(server_try_cancel) {
454  server_coalescing_api_ = internal::GetIntValueFromMetadata(
455  kServerUseCoalescingApi, ctx->client_metadata(), 0);
456  server_responses_to_send_ = internal::GetIntValueFromMetadata(
457  kServerResponseStreamsToSend, ctx->client_metadata(),
460  ctx->TryCancel();
461  }
463  if (num_msgs_sent_ < server_responses_to_send_) {
464  NextWrite();
465  }
466  }
467  setup_done_ = true;
468  }
469  void OnDone() override { delete this; }
470  void OnCancel() override {
471  EXPECT_TRUE(setup_done_);
472  EXPECT_TRUE(ctx_->IsCancelled());
473  FinishOnce(Status::CANCELLED);
474  }
475  void OnWriteDone(bool /*ok*/) override {
476  if (num_msgs_sent_ < server_responses_to_send_) {
477  NextWrite();
478  } else if (server_coalescing_api_ != 0) {
479  // We would have already done Finish just after the WriteLast
481  // Let OnCancel recover this
484  } else {
485  FinishOnce(Status::OK);
486  }
487  }
488 
489  private:
490  void FinishOnce(const Status& s) {
491  std::lock_guard<std::mutex> l(finish_mu_);
492  if (!finished_) {
493  Finish(s);
494  finished_ = true;
495  }
496  }
497 
498  void NextWrite() {
499  response_.set_message(request_->message() +
501  if (num_msgs_sent_ == server_responses_to_send_ - 1 &&
502  server_coalescing_api_ != 0) {
503  {
504  std::lock_guard<std::mutex> l(finish_mu_);
505  if (!finished_) {
506  num_msgs_sent_++;
507  StartWriteLast(&response_, WriteOptions());
508  }
509  }
510  // If we use WriteLast, we shouldn't wait before attempting Finish
511  FinishOnce(Status::OK);
512  } else {
513  std::lock_guard<std::mutex> l(finish_mu_);
514  if (!finished_) {
515  num_msgs_sent_++;
516  StartWrite(&response_);
517  }
518  }
519  }
521  const EchoRequest* const request_;
522  EchoResponse response_;
523  int num_msgs_sent_{0};
524  int server_try_cancel_;
525  int server_coalescing_api_;
526  int server_responses_to_send_;
527  std::mutex finish_mu_;
528  bool finished_{false};
529  bool setup_done_{false};
530  };
531  return new Reactor(context, request, server_try_cancel);
532 }
533 
535 CallbackTestServiceImpl::BidiStream(CallbackServerContext* context) {
536  class Reactor : public grpc::ServerBidiReactor<EchoRequest, EchoResponse> {
537  public:
538  explicit Reactor(CallbackServerContext* ctx) : ctx_(ctx) {
539  // If 'server_try_cancel' is set in the metadata, the RPC is cancelled by
540  // the server by calling ServerContext::TryCancel() depending on the
541  // value:
542  // CANCEL_BEFORE_PROCESSING: The RPC is cancelled before the server
543  // reads any message from the client CANCEL_DURING_PROCESSING: The RPC
544  // is cancelled while the server is reading messages from the client
545  // CANCEL_AFTER_PROCESSING: The RPC is cancelled after the server reads
546  // all the messages from the client
548  kServerTryCancelRequest, ctx->client_metadata(), DO_NOT_CANCEL);
549  server_write_last_ = internal::GetIntValueFromMetadata(
550  kServerFinishAfterNReads, ctx->client_metadata(), 0);
551  client_try_cancel_ = static_cast<bool>(internal::GetIntValueFromMetadata(
552  kClientTryCancelRequest, ctx->client_metadata(), 0));
555  } else {
557  ctx->TryCancel();
558  }
559  StartRead(&request_);
560  }
561  setup_done_ = true;
562  }
563  void OnDone() override {
564  {
565  // Use the same lock as finish to make sure that OnDone isn't inlined.
566  std::lock_guard<std::mutex> l(finish_mu_);
567  EXPECT_TRUE(finished_);
568  finish_thread_.join();
569  }
570  delete this;
571  }
572  void OnCancel() override {
573  EXPECT_TRUE(setup_done_);
574  EXPECT_TRUE(ctx_->IsCancelled());
575  FinishOnce(Status::CANCELLED);
576  }
577  void OnReadDone(bool ok) override {
578  if (ok) {
579  num_msgs_read_++;
580  response_.set_message(request_.message());
581  std::lock_guard<std::mutex> l(finish_mu_);
582  if (!finished_) {
583  if (num_msgs_read_ == server_write_last_) {
584  StartWriteLast(&response_, WriteOptions());
585  // If we use WriteLast, we shouldn't wait before attempting Finish
586  } else {
587  StartWrite(&response_);
588  return;
589  }
590  }
591  } else if (client_try_cancel_) {
592  EXPECT_TRUE(ctx_->IsCancelled());
593  }
594 
596  // Let OnCancel handle this
599  } else {
600  FinishOnce(Status::OK);
601  }
602  }
603  void OnWriteDone(bool /*ok*/) override {
604  std::lock_guard<std::mutex> l(finish_mu_);
605  if (!finished_) {
606  StartRead(&request_);
607  }
608  }
609 
610  private:
611  void FinishOnce(const Status& s) {
612  std::lock_guard<std::mutex> l(finish_mu_);
613  if (!finished_) {
614  finished_ = true;
615  // Finish asynchronously to make sure that there are no deadlocks.
616  finish_thread_ = std::thread([this, s] {
617  std::lock_guard<std::mutex> l(finish_mu_);
618  Finish(s);
619  });
620  }
621  }
622 
624  EchoRequest request_;
625  EchoResponse response_;
626  int num_msgs_read_{0};
627  int server_try_cancel_;
628  int server_write_last_;
629  std::mutex finish_mu_;
630  bool finished_{false};
631  bool setup_done_{false};
632  std::thread finish_thread_;
633  bool client_try_cancel_ = false;
634  };
635 
636  return new Reactor(context);
637 }
638 
639 } // namespace testing
640 } // namespace grpc
EXPECT_FALSE
#define EXPECT_FALSE(condition)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1970
GPR_TIMESPAN
@ GPR_TIMESPAN
Definition: gpr_types.h:45
messages_pb2.SimpleRequest
SimpleRequest
Definition: messages_pb2.py:597
gpr_timespec::tv_sec
int64_t tv_sec
Definition: gpr_types.h:51
GPR_INFO
#define GPR_INFO
Definition: include/grpc/impl/codegen/log.h:56
testing
Definition: aws_request_signer_test.cc:25
grpc::ServerContext
Definition: grpcpp/impl/codegen/server_context.h:566
log.h
ctx
Definition: benchmark-async.c:30
grpc::Status::CANCELLED
static const Status & CANCELLED
A CANCELLED pre-defined instance.
Definition: include/grpcpp/impl/codegen/status.h:115
metadata
Definition: cq_verifier.cc:48
response_
grpc_http_response response_
Definition: google_c2p_resolver.cc:101
grpc
Definition: grpcpp/alarm.h:33
grpc::ServerReadReactor
ServerReadReactor is the interface for a client-streaming RPC.
Definition: impl/codegen/server_callback.h:184
req_
EchoRequest req_
Definition: client_interceptors_end2end_test.cc:290
grpc::testing::kClientTryCancelRequest
const char *const kClientTryCancelRequest
Definition: test_service_impl.h:45
mutex
static uv_mutex_t mutex
Definition: threadpool.c:34
benchmark.request
request
Definition: benchmark.py:77
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
error
grpc_error_handle error
Definition: retry_filter.cc:499
grpc::testing::CANCEL_AFTER_PROCESSING
@ CANCEL_AFTER_PROCESSING
Definition: test_service_impl.h:56
u
OPENSSL_EXPORT pem_password_cb void * u
Definition: pem.h:351
grpc::testing::internal::MetadataMatchCount
int MetadataMatchCount(const std::multimap< grpc::string_ref, grpc::string_ref > &metadata, const std::string &key, const std::string &value)
Definition: test_service_impl.cc:75
gpr_inf_future
GPRAPI gpr_timespec gpr_inf_future(gpr_clock_type type)
Definition: src/core/lib/gpr/time.cc:55
grpc::testing::DO_NOT_CANCEL
@ DO_NOT_CANCEL
Definition: test_service_impl.h:53
ctx_
ClientContext ctx_
Definition: client_interceptors_end2end_test.cc:289
alarm.h
grpc::ServerBidiReactor
ServerBidiReactor is the interface for a bidirectional streaming RPC.
Definition: impl/codegen/server_callback.h:188
grpc::testing::internal::CheckServerAuthContext
void CheckServerAuthContext(const ServerContextBase *context, const std::string &expected_transport_security_type, const std::string &expected_client_identity)
Definition: test_service_impl.cc:53
test_service_impl.h
grpc::WriteOptions
Per-message write options.
Definition: call_op_set.h:81
grpc::testing::kCheckClientInitialMetadataKey
const char *const kCheckClientInitialMetadataKey
Definition: test_service_impl.h:49
grpc::testing::internal::MaybeEchoDeadline
void MaybeEchoDeadline(ServerContextBase *context, const EchoRequest *request, EchoResponse *response)
Definition: test_service_impl.cc:42
grpc::testing::kServerDefaultResponseStreamsToSend
const int kServerDefaultResponseStreamsToSend
Definition: test_service_impl.h:42
resp_
EchoResponse resp_
Definition: client_interceptors_end2end_test.cc:291
absl::move
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
Definition: abseil-cpp/absl/utility/utility.h:221
GPR_ASSERT
#define GPR_ASSERT(x)
Definition: include/grpc/impl/codegen/log.h:94
grpc::ServerContextBase
Base class of ServerContext.
Definition: grpcpp/impl/codegen/server_context.h:126
max
int max
Definition: bloaty/third_party/zlib/examples/enough.c:170
grpc.StatusCode
Definition: src/python/grpcio/grpc/__init__.py:232
EXPECT_NE
#define EXPECT_NE(val1, val2)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:2028
gpr_log
GPRAPI void gpr_log(const char *file, int line, gpr_log_severity severity, const char *format,...) GPR_PRINT_FORMAT_CHECK(4
grpc::testing::kServerResponseStreamsToSend
const char *const kServerResponseStreamsToSend
Definition: test_service_impl.h:43
gpr_sleep_until
GPRAPI void gpr_sleep_until(gpr_timespec until)
started_
bool started_
Definition: xds_cluster_impl.cc:357
grpc::testing::internal::ServerTryCancelNonblocking
void ServerTryCancelNonblocking(CallbackServerContext *context)
Definition: test_service_impl.cc:119
GPR_CLOCK_MONOTONIC
@ GPR_CLOCK_MONOTONIC
Definition: gpr_types.h:36
grpc::ClientContext::auth_context
std::shared_ptr< const grpc::AuthContext > auth_context() const
Definition: grpcpp/impl/codegen/client_context.h:309
num_msgs_sent_
int num_msgs_sent_
Definition: client_callback_end2end_test.cc:728
grpc::Status::OK
static const Status & OK
An OK pre-defined instance.
Definition: include/grpcpp/impl/codegen/status.h:113
grpc::testing::internal::ServerTryCancel
void ServerTryCancel(ServerContext *context)
Definition: test_service_impl.cc:108
GPR_ERROR
#define GPR_ERROR
Definition: include/grpc/impl/codegen/log.h:57
gpr_now
GPRAPI gpr_timespec gpr_now(gpr_clock_type clock)
grpc::CallbackServerContext
Definition: grpcpp/impl/codegen/server_context.h:606
request_
EchoRequest request_
Definition: client_callback_end2end_test.cc:724
value
const char * value
Definition: hpack_parser_table.cc:165
grpc::testing::kServerTryCancelRequest
const char *const kServerTryCancelRequest
Definition: test_service_impl.h:44
credentials.h
key
const char * key
Definition: hpack_parser_table.cc:164
grpc::testing::kCheckClientInitialMetadataVal
const char *const kCheckClientInitialMetadataVal
Definition: test_service_impl.h:50
gpr_time_add
GPRAPI gpr_timespec gpr_time_add(gpr_timespec a, gpr_timespec b)
Definition: src/core/lib/gpr/time.cc:135
count
int * count
Definition: bloaty/third_party/googletest/googlemock/test/gmock_stress_test.cc:96
grpc::ClientContext::deadline
std::chrono::system_clock::time_point deadline() const
Return the deadline for the client call.
Definition: grpcpp/impl/codegen/client_context.h:294
benchmark::internal::Finish
double Finish(Counter const &c, IterationCount iterations, double cpu_time, double num_threads)
Definition: benchmark/src/counter.cc:20
grpc::testing::ToString
std::string ToString(const grpc::string_ref &r)
Definition: string_ref_helper.cc:24
gpr_time_from_micros
GPRAPI gpr_timespec gpr_time_from_micros(int64_t us, gpr_clock_type clock_type)
Definition: src/core/lib/gpr/time.cc:115
grpc::ClientContext::TryCancel
void TryCancel()
Definition: client_context.cc:157
server_context.h
asyncio_get_stats.response
response
Definition: asyncio_get_stats.py:28
grpc::testing::internal::GetIntValueFromMetadata
int GetIntValueFromMetadata(const char *key, const std::multimap< grpc::string_ref, grpc::string_ref > &metadata, int default_value)
Definition: test_service_impl.cc:101
grpc::Timepoint2Timespec
void Timepoint2Timespec(const std::chrono::system_clock::time_point &from, gpr_timespec *to)
grpc::protobuf::util::Status
GRPC_CUSTOM_UTIL_STATUS Status
Definition: include/grpcpp/impl/codegen/config_protobuf.h:93
grpc::testing::kServerUseCoalescingApi
const char *const kServerUseCoalescingApi
Definition: test_service_impl.h:48
grpc::Status
Definition: include/grpcpp/impl/codegen/status.h:35
ok
bool ok
Definition: async_end2end_test.cc:197
grpc::testing::internal::GetIntValueFromMetadataHelper
int GetIntValueFromMetadataHelper(const char *key, const std::multimap< grpc::string_ref, grpc::string_ref > &metadata, int default_value)
Definition: test_service_impl.cc:88
grpc::testing::EXPECT_EQ
EXPECT_EQ(options.token_exchange_service_uri, "https://foo/exchange")
grpc::testing::CANCEL_DURING_PROCESSING
@ CANCEL_DURING_PROCESSING
Definition: test_service_impl.h:55
grpc::ServerUnaryReactor
Definition: impl/codegen/server_callback.h:699
grpc::testing::kServerFinishAfterNReads
const char *const kServerFinishAfterNReads
Definition: test_service_impl.h:47
internal
Definition: benchmark/test/output_test_helper.cc:20
context
grpc::ClientContext context
Definition: istio_echo_server_lib.cc:61
grpc::testing::EXPECT_TRUE
EXPECT_TRUE(grpc::experimental::StsCredentialsOptionsFromJson(minimum_valid_json, &options) .ok())
grpc::testing::kDebugInfoTrailerKey
const char *const kDebugInfoTrailerKey
Definition: test_service_impl.h:46
gpr_timespec
Definition: gpr_types.h:50
service
__attribute__((deprecated("Please use GRPCProtoMethod."))) @interface ProtoMethod NSString * service
Definition: ProtoMethod.h:25
messages_pb2.SimpleResponse
SimpleResponse
Definition: messages_pb2.py:604
grpc::Alarm
Definition: grpcpp/alarm.h:35
server_try_cancel_
const ServerTryCancelRequestPhase server_try_cancel_
Definition: client_callback_end2end_test.cc:727
GPR_CLOCK_REALTIME
@ GPR_CLOCK_REALTIME
Definition: gpr_types.h:39
string_ref_helper.h
to_string
static bool to_string(zval *from)
Definition: protobuf/php/ext/google/protobuf/convert.c:333
grpc::ServerWriteReactor
ServerWriteReactor is the interface for a server-streaming RPC.
Definition: impl/codegen/server_callback.h:186
grpc::testing::CANCEL_BEFORE_PROCESSING
@ CANCEL_BEFORE_PROCESSING
Definition: test_service_impl.h:54
thread
static uv_thread_t thread
Definition: test-async-null-cb.c:29
service_
std::unique_ptr< grpc::testing::TestServiceImpl > service_
Definition: end2end_binder_transport_test.cc:71


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:01:31