rls_end2end_test.cc
Go to the documentation of this file.
1 //
2 // Copyright 2020 gRPC authors.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
17 // FIXME: add tests:
18 // - cache eviction via cleanup timer (based on age)
19 // - RLS channel is down; wait_for_ready request is sent and RLS request fails
20 // and goes into backoff; RLS channel comes back up before backoff timer
21 // fires; request is processed at that point
22 // - find some deterministic way to exercise adaptive throttler code
23 
24 #include <deque>
25 #include <map>
26 #include <thread>
27 
28 #include <gmock/gmock.h>
29 #include <gtest/gtest.h>
30 
31 #include "absl/strings/str_format.h"
32 #include "absl/strings/str_join.h"
33 #include "absl/types/optional.h"
34 
35 #include <grpcpp/channel.h>
36 #include <grpcpp/create_channel.h>
38 #include <grpcpp/server.h>
39 #include <grpcpp/server_builder.h>
41 
46 #include "src/core/lib/gpr/env.h"
55 #include "src/proto/grpc/lookup/v1/rls.grpc.pb.h"
56 #include "src/proto/grpc/lookup/v1/rls.pb.h"
57 #include "src/proto/grpc/testing/echo.grpc.pb.h"
58 #include "test/core/util/port.h"
66 
67 using ::grpc::lookup::v1::RouteLookupRequest;
68 
69 namespace grpc {
70 namespace testing {
71 namespace {
72 
73 const char* kServerName = "test.google.fr";
74 const char* kRequestMessage = "Live long and prosper.";
75 
76 const char* kCallCredsMdKey = "call_cred_name";
77 const char* kCallCredsMdValue = "call_cred_value";
78 
79 const char* kTestKey = "test_key";
80 const char* kTestValue = "test_value";
81 const char* kHostKey = "host_key";
82 const char* kServiceKey = "service_key";
83 const char* kServiceValue = "grpc.testing.EchoTestService";
84 const char* kMethodKey = "method_key";
85 const char* kMethodValue = "Echo";
86 const char* kConstantKey = "constant_key";
87 const char* kConstantValue = "constant_value";
88 
89 using BackendService = CountedService<TestServiceImpl>;
90 
91 // Subclass of TestServiceImpl that increments a request counter for
92 // every call to the Echo Rpc.
93 class MyTestServiceImpl : public BackendService {
94  public:
95  Status Echo(ServerContext* context, const EchoRequest* request,
96  EchoResponse* response) override {
97  // Backend should see call creds.
98  EXPECT_THAT(context->client_metadata(),
100  ::testing::Pair(kCallCredsMdKey, kCallCredsMdValue)));
101  IncreaseRequestCount();
102  auto client_metadata = context->client_metadata();
103  auto range = client_metadata.equal_range("X-Google-RLS-Data");
104  {
106  for (auto it = range.first; it != range.second; ++it) {
107  rls_header_data_.insert(
108  std::string(it->second.begin(), it->second.length()));
109  }
110  }
111  IncreaseResponseCount();
113  }
114 
115  std::set<std::string> rls_data() {
117  return std::move(rls_header_data_);
118  }
119 
120  void Start() {}
121 
122  void Shutdown() {}
123 
124  private:
126  std::set<std::string> rls_header_data_ ABSL_GUARDED_BY(&mu_);
127 };
128 
129 class FakeResolverResponseGeneratorWrapper {
130  public:
131  FakeResolverResponseGeneratorWrapper()
133  grpc_core::FakeResolverResponseGenerator>()) {}
134 
135  void SetNextResolution(absl::string_view service_config_json) {
137  response_generator_->SetResponse(BuildFakeResults(service_config_json));
138  }
139 
141  return response_generator_.get();
142  }
143 
144  private:
145  static grpc_core::Resolver::Result BuildFakeResults(
146  absl::string_view service_config_json) {
150  result.args, service_config_json, &error);
152  << "JSON: " << service_config_json
153  << "Error: " << grpc_error_std_string(error);
154  EXPECT_NE(*result.service_config, nullptr);
155  return result;
156  }
157 
160 };
161 
162 class RlsEnd2endTest : public ::testing::Test {
163  protected:
164  static void SetUpTestSuite() {
165  gpr_setenv("GRPC_EXPERIMENTAL_ENABLE_RLS_LB_POLICY", "true");
166  GPR_GLOBAL_CONFIG_SET(grpc_client_channel_backup_poll_interval_ms, 1);
167  grpc_init();
169  }
170 
171  static void TearDownTestSuite() {
173  gpr_unsetenv("GRPC_EXPERIMENTAL_ENABLE_RLS_LB_POLICY");
174  }
175 
176  void SetUp() override {
177  bool localhost_resolves_to_ipv4 = false;
178  bool localhost_resolves_to_ipv6 = false;
179  grpc_core::LocalhostResolves(&localhost_resolves_to_ipv4,
180  &localhost_resolves_to_ipv6);
181  ipv6_only_ = !localhost_resolves_to_ipv4 && localhost_resolves_to_ipv6;
182  rls_server_ = absl::make_unique<ServerThread<RlsServiceImpl>>(
183  "rls", [](grpc::ServerContext* ctx) {
184  EXPECT_THAT(ctx->client_metadata(),
186  ::testing::Pair(kCallCredsMdKey, kCallCredsMdValue)));
187  });
188  rls_server_->Start();
190  absl::make_unique<FakeResolverResponseGeneratorWrapper>();
191  ResetStub();
192  }
193 
194  void TearDown() override {
195  ShutdownBackends();
196  rls_server_->Shutdown();
197  }
198 
199  void ResetStub(const char* expected_authority = kServerName) {
200  ChannelArguments args;
203  args.SetString(GRPC_ARG_FAKE_SECURITY_EXPECTED_TARGETS, expected_authority);
204  grpc_channel_credentials* channel_creds =
207  kCallCredsMdKey, kCallCredsMdValue);
208  auto creds = std::make_shared<SecureChannelCredentials>(
210  nullptr));
211  call_creds->Unref();
212  channel_creds->Unref();
214  absl::StrCat("fake:///", kServerName).c_str(), std::move(creds), args);
215  stub_ = grpc::testing::EchoTestService::NewStub(channel_);
216  }
217 
218  void ShutdownBackends() {
219  for (auto& server : backends_) {
220  server->Shutdown();
221  }
222  }
223 
224  void StartBackends(size_t num_servers) {
225  backends_.clear();
226  for (size_t i = 0; i < num_servers; ++i) {
227  backends_.push_back(
228  absl::make_unique<ServerThread<MyTestServiceImpl>>("backend"));
229  backends_.back()->Start();
230  }
231  }
232 
233  std::string TargetStringForPort(int port) {
234  if (ipv6_only_) return absl::StrCat("ipv6:[::1]:", port);
235  return absl::StrCat("ipv4:127.0.0.1:", port);
236  }
237 
238  struct RpcOptions {
239  int timeout_ms = 1000;
240  bool wait_for_ready = false;
241  std::vector<std::pair<std::string, std::string>> metadata;
242 
243  RpcOptions() {}
244 
245  RpcOptions& set_timeout_ms(int rpc_timeout_ms) {
246  timeout_ms = rpc_timeout_ms;
247  return *this;
248  }
249 
250  RpcOptions& set_wait_for_ready(bool rpc_wait_for_ready) {
251  wait_for_ready = rpc_wait_for_ready;
252  return *this;
253  }
254 
255  RpcOptions& set_metadata(
256  std::vector<std::pair<std::string, std::string>> rpc_metadata) {
257  metadata = std::move(rpc_metadata);
258  return *this;
259  }
260 
261  // Populates context.
262  void SetupRpc(ClientContext* context) const {
263  for (const auto& item : metadata) {
264  context->AddMetadata(item.first, item.second);
265  }
266  if (timeout_ms != 0) {
269  }
271  }
272  };
273 
274  Status SendRpc(const RpcOptions& rpc_options = RpcOptions(),
275  EchoResponse* response = nullptr) {
276  EchoResponse local_response;
277  if (response == nullptr) response = &local_response;
278  ClientContext context;
279  rpc_options.SetupRpc(&context);
280  EchoRequest request;
281  request.set_message(kRequestMessage);
282  return stub_->Echo(&context, request, response);
283  }
284 
285  void CheckRpcSendOk(const grpc_core::DebugLocation& location,
286  const RpcOptions& rpc_options = RpcOptions()) {
287  EchoResponse response;
288  Status status = SendRpc(rpc_options, &response);
289  ASSERT_TRUE(status.ok()) << location.file() << ":" << location.line()
290  << ": RPC failed: " << status.error_code() << ": "
291  << status.error_message();
292  EXPECT_EQ(response.message(), kRequestMessage)
293  << location.file() << ":" << location.line();
294  }
295 
296  void CheckRpcSendFailure(const grpc_core::DebugLocation& location,
297  StatusCode expected_code,
298  absl::string_view expected_message,
299  const RpcOptions& rpc_options = RpcOptions()) {
300  Status status = SendRpc(rpc_options);
301  ASSERT_FALSE(status.ok()) << location.file() << ":" << location.line();
302  EXPECT_EQ(expected_code, status.error_code())
303  << location.file() << ":" << location.line();
304  EXPECT_EQ(expected_message, status.error_message())
305  << location.file() << ":" << location.line();
306  }
307 
308  class ServiceConfigBuilder {
309  public:
310  explicit ServiceConfigBuilder(int rls_server_port)
311  : rls_server_port_(rls_server_port) {}
312 
313  ServiceConfigBuilder& set_lookup_service_timeout(
316  return *this;
317  }
318 
319  ServiceConfigBuilder& set_default_target(std::string default_target) {
321  return *this;
322  }
323 
324  ServiceConfigBuilder& set_max_age(grpc_core::Duration max_age) {
326  return *this;
327  }
328 
329  ServiceConfigBuilder& set_stale_age(grpc_core::Duration stale_age) {
331  return *this;
332  }
333 
334  ServiceConfigBuilder& set_cache_size_bytes(int64_t size) {
336  return *this;
337  }
338 
339  ServiceConfigBuilder& AddKeyBuilder(absl::string_view key_builder) {
340  key_builders_.push_back(absl::StrCat("{", key_builder, "}"));
341  return *this;
342  }
343 
344  std::string Build() {
345  // First build parts of routeLookupConfig.
346  std::vector<std::string> route_lookup_config_parts;
347  route_lookup_config_parts.push_back(absl::StrFormat(
348  " \"lookupService\":\"localhost:%d\"", rls_server_port_));
350  route_lookup_config_parts.push_back(
351  absl::StrFormat(" \"lookupServiceTimeout\":\"%fs\"",
353  }
354  if (!default_target_.empty()) {
355  route_lookup_config_parts.push_back(absl::StrFormat(
356  " \"defaultTarget\":\"%s\"", default_target_));
357  }
358  route_lookup_config_parts.push_back(absl::StrFormat(
359  " \"cacheSizeBytes\":%" PRId64, cache_size_bytes_));
361  route_lookup_config_parts.push_back(
362  absl::StrFormat(" \"maxAge\":\"%fs\"", max_age_.seconds()));
363  }
365  route_lookup_config_parts.push_back(absl::StrFormat(
366  " \"staleAge\":\"%fs\"", stale_age_.seconds()));
367  }
368  if (!key_builders_.empty()) {
369  route_lookup_config_parts.push_back(
370  absl::StrFormat(" \"grpcKeybuilders\":[%s]",
372  }
373  // Now build parts of RLS LB policy config.
374  std::vector<std::string> rls_config_parts;
375  if (!route_lookup_config_parts.empty()) {
376  rls_config_parts.push_back(absl::StrCat(
377  " \"routeLookupConfig\":{",
378  absl::StrJoin(route_lookup_config_parts, ","), " }"));
379  }
380  rls_config_parts.push_back(
381  " \"childPolicy\":[{"
382  " \"fixed_address_lb\":{}\n"
383  " }],\n"
384  " \"childPolicyConfigTargetFieldName\":\"address\"\n");
385  // Put it all together.
386  return absl::StrCat(
387  "{"
388  " \"loadBalancingConfig\":[{"
389  " \"rls_experimental\":{",
390  absl::StrJoin(rls_config_parts, ","),
391  " }"
392  " }]"
393  "}");
394  }
395 
396  private:
403  std::vector<std::string> key_builders_;
404  };
405 
406  ServiceConfigBuilder MakeServiceConfigBuilder() {
407  return ServiceConfigBuilder(rls_server_->port_);
408  }
409 
410  void SetNextResolution(absl::string_view service_config_json) {
411  resolver_response_generator_->SetNextResolution(service_config_json);
412  }
413 
414  template <typename T>
415  struct ServerThread {
416  template <typename... Args>
417  explicit ServerThread(const grpc::string& type, Args&&... args)
419  type_(type),
420  service_(std::forward<Args>(args)...) {}
421 
422  void Start() {
423  gpr_log(GPR_INFO, "starting %s server on port %d", type_.c_str(), port_);
425  running_ = true;
426  service_.Start();
428  // We need to acquire the lock here in order to prevent the notify_one
429  // by ServerThread::Serve from firing before the wait below is hit.
432  thread_ = absl::make_unique<std::thread>(
433  std::bind(&ServerThread::Serve, this, &mu, &cond));
434  cond.Wait(&mu);
435  gpr_log(GPR_INFO, "%s server startup complete", type_.c_str());
436  }
437 
439  // We need to acquire the lock here in order to prevent the notify_one
440  // below from firing before its corresponding wait is executed.
442  ServerBuilder builder;
443  auto creds = std::make_shared<SecureServerCredentials>(
445  builder.AddListeningPort(absl::StrCat("localhost:", port_),
446  std::move(creds));
447  builder.RegisterService(&service_);
448  server_ = builder.BuildAndStart();
449  cond->Signal();
450  }
451 
452  void Shutdown() {
453  if (!running_) return;
454  gpr_log(GPR_INFO, "%s about to shutdown", type_.c_str());
455  service_.Shutdown();
457  thread_->join();
458  gpr_log(GPR_INFO, "%s shutdown completed", type_.c_str());
459  running_ = false;
460  }
461 
462  const int port_;
465  std::unique_ptr<Server> server_;
466  std::unique_ptr<std::thread> thread_;
467  bool running_ = false;
468  };
469 
471  std::vector<std::unique_ptr<ServerThread<MyTestServiceImpl>>> backends_;
472  std::unique_ptr<ServerThread<RlsServiceImpl>> rls_server_;
473  std::unique_ptr<FakeResolverResponseGeneratorWrapper>
475  std::shared_ptr<grpc::Channel> channel_;
476  std::unique_ptr<grpc::testing::EchoTestService::Stub> stub_;
477 };
478 
479 TEST_F(RlsEnd2endTest, Basic) {
480  StartBackends(1);
481  SetNextResolution(
482  MakeServiceConfigBuilder()
483  .AddKeyBuilder(absl::StrFormat("\"names\":[{"
484  " \"service\":\"%s\","
485  " \"method\":\"%s\""
486  "}],"
487  "\"headers\":["
488  " {"
489  " \"key\":\"%s\","
490  " \"names\":["
491  " \"key1\""
492  " ]"
493  " }"
494  "]",
495  kServiceValue, kMethodValue, kTestKey))
496  .Build());
497  rls_server_->service_.SetResponse(
498  BuildRlsRequest({{kTestKey, kTestValue}}),
499  BuildRlsResponse({TargetStringForPort(backends_[0]->port_)}));
500  CheckRpcSendOk(DEBUG_LOCATION,
501  RpcOptions().set_metadata({{"key1", kTestValue}}));
502  EXPECT_EQ(rls_server_->service_.request_count(), 1);
503  EXPECT_EQ(rls_server_->service_.response_count(), 1);
504  EXPECT_EQ(backends_[0]->service_.request_count(), 1);
505  // No RLS header seen by the backend, since the RLS response didn't set any.
506  EXPECT_THAT(backends_[0]->service_.rls_data(), ::testing::ElementsAre());
507 }
508 
509 TEST_F(RlsEnd2endTest, DuplicateHeadersAreMerged) {
510  const char* kTestValue2 = "test_value_2";
511  StartBackends(1);
512  SetNextResolution(
513  MakeServiceConfigBuilder()
514  .AddKeyBuilder(absl::StrFormat("\"names\":[{"
515  " \"service\":\"%s\","
516  " \"method\":\"%s\""
517  "}],"
518  "\"headers\":["
519  " {"
520  " \"key\":\"%s\","
521  " \"names\":["
522  " \"key1\""
523  " ]"
524  " }"
525  "]",
526  kServiceValue, kMethodValue, kTestKey))
527  .Build());
528  rls_server_->service_.SetResponse(
529  BuildRlsRequest({{kTestKey, absl::StrCat(kTestValue, ",", kTestValue2)}}),
530  BuildRlsResponse({TargetStringForPort(backends_[0]->port_)}));
531  // Same header present twice in the request. Values should be merged.
532  CheckRpcSendOk(
534  RpcOptions().set_metadata({{"key1", kTestValue}, {"key1", kTestValue2}}));
535  EXPECT_EQ(rls_server_->service_.request_count(), 1);
536  EXPECT_EQ(rls_server_->service_.response_count(), 1);
537  EXPECT_EQ(backends_[0]->service_.request_count(), 1);
538 }
539 
540 TEST_F(RlsEnd2endTest, SecondHeaderUsed) {
541  StartBackends(1);
542  SetNextResolution(
543  MakeServiceConfigBuilder()
544  .AddKeyBuilder(absl::StrFormat("\"names\":[{"
545  " \"service\":\"%s\","
546  " \"method\":\"%s\""
547  "}],"
548  "\"headers\":["
549  " {"
550  " \"key\":\"%s\","
551  " \"names\":["
552  " \"key1\", \"key2\""
553  " ]"
554  " }"
555  "]",
556  kServiceValue, kMethodValue, kTestKey))
557  .Build());
558  rls_server_->service_.SetResponse(
559  BuildRlsRequest({{kTestKey, kTestValue}}),
560  BuildRlsResponse({TargetStringForPort(backends_[0]->port_)}));
561  CheckRpcSendOk(DEBUG_LOCATION,
562  RpcOptions().set_metadata({{"key2", kTestValue}}));
563  EXPECT_EQ(rls_server_->service_.request_count(), 1);
564  EXPECT_EQ(rls_server_->service_.response_count(), 1);
565  EXPECT_EQ(backends_[0]->service_.request_count(), 1);
566 }
567 
568 TEST_F(RlsEnd2endTest, MultipleHeaderKeys) {
569  const char* kTestKey2 = "test_key_2";
570  const char* kTestValue2 = "test_value_2";
571  StartBackends(1);
572  SetNextResolution(MakeServiceConfigBuilder()
573  .AddKeyBuilder(absl::StrFormat(
574  "\"names\":[{"
575  " \"service\":\"%s\","
576  " \"method\":\"%s\""
577  "}],"
578  "\"headers\":["
579  " {"
580  " \"key\":\"%s\","
581  " \"names\":["
582  " \"key1\""
583  " ]"
584  " },"
585  " {"
586  " \"key\":\"%s\","
587  " \"names\":["
588  " \"key2\""
589  " ]"
590  " }"
591  "]",
592  kServiceValue, kMethodValue, kTestKey, kTestKey2))
593  .Build());
594  rls_server_->service_.SetResponse(
596  {kTestKey, kTestValue},
597  {kTestKey2, kTestValue2},
598  }),
599  BuildRlsResponse({TargetStringForPort(backends_[0]->port_)}));
600  CheckRpcSendOk(
602  RpcOptions().set_metadata({{"key1", kTestValue}, {"key2", kTestValue2}}));
603  EXPECT_EQ(rls_server_->service_.request_count(), 1);
604  EXPECT_EQ(rls_server_->service_.response_count(), 1);
605  EXPECT_EQ(backends_[0]->service_.request_count(), 1);
606  // No RLS header seen by the backend, since the RLS response didn't set any.
607  EXPECT_THAT(backends_[0]->service_.rls_data(), ::testing::ElementsAre());
608 }
609 
610 TEST_F(RlsEnd2endTest, NoHeaderMatch) {
611  StartBackends(1);
612  SetNextResolution(
613  MakeServiceConfigBuilder()
614  .AddKeyBuilder(absl::StrFormat("\"names\":[{"
615  " \"service\":\"%s\","
616  " \"method\":\"%s\""
617  "}],"
618  "\"headers\":["
619  " {"
620  " \"key\":\"%s\","
621  " \"names\":["
622  " \"key1\""
623  " ]"
624  " }"
625  "]",
626  kServiceValue, kMethodValue, kTestKey))
627  .Build());
628  rls_server_->service_.SetResponse(
629  BuildRlsRequest({}),
630  BuildRlsResponse({TargetStringForPort(backends_[0]->port_)}));
631  // Request does not have header "key1", so kTestKey will not be added.
632  CheckRpcSendOk(DEBUG_LOCATION);
633  EXPECT_EQ(rls_server_->service_.request_count(), 1);
634  EXPECT_EQ(rls_server_->service_.response_count(), 1);
635  EXPECT_EQ(backends_[0]->service_.request_count(), 1);
636 }
637 
638 TEST_F(RlsEnd2endTest, WildcardMethod) {
639  StartBackends(1);
640  SetNextResolution(MakeServiceConfigBuilder()
641  .AddKeyBuilder(absl::StrFormat("\"names\":[{"
642  " \"service\":\"%s\""
643  "}],"
644  "\"headers\":["
645  " {"
646  " \"key\":\"%s\","
647  " \"names\":["
648  " \"key1\""
649  " ]"
650  " }"
651  "]",
652  kServiceValue, kTestKey))
653  .Build());
654  rls_server_->service_.SetResponse(
655  BuildRlsRequest({{kTestKey, kTestValue}}),
656  BuildRlsResponse({TargetStringForPort(backends_[0]->port_)}));
657  CheckRpcSendOk(DEBUG_LOCATION,
658  RpcOptions().set_metadata({{"key1", kTestValue}}));
659  EXPECT_EQ(rls_server_->service_.request_count(), 1);
660  EXPECT_EQ(rls_server_->service_.response_count(), 1);
661  EXPECT_EQ(backends_[0]->service_.request_count(), 1);
662 }
663 
664 TEST_F(RlsEnd2endTest, NoKeyBuilderForMethod) {
665  StartBackends(1);
666  SetNextResolution(
667  MakeServiceConfigBuilder()
668  .AddKeyBuilder(absl::StrFormat("\"names\":[{"
669  " \"service\":\"%s\","
670  " \"method\":\"some_other_method\""
671  "}],"
672  "\"headers\":["
673  " {"
674  " \"key\":\"%s\","
675  " \"names\":["
676  " \"key1\""
677  " ]"
678  " }"
679  "]",
680  kServiceValue, kTestKey))
681  .Build());
682  rls_server_->service_.SetResponse(
683  BuildRlsRequest({}),
684  BuildRlsResponse({TargetStringForPort(backends_[0]->port_)}));
685  CheckRpcSendOk(DEBUG_LOCATION);
686  EXPECT_EQ(rls_server_->service_.request_count(), 1);
687  EXPECT_EQ(rls_server_->service_.response_count(), 1);
688  EXPECT_EQ(backends_[0]->service_.request_count(), 1);
689 }
690 
691 TEST_F(RlsEnd2endTest, HeaderData) {
692  const char* kHeaderData = "header_data";
693  StartBackends(1);
694  SetNextResolution(
695  MakeServiceConfigBuilder()
696  .AddKeyBuilder(absl::StrFormat("\"names\":[{"
697  " \"service\":\"%s\","
698  " \"method\":\"%s\""
699  "}],"
700  "\"headers\":["
701  " {"
702  " \"key\":\"%s\","
703  " \"names\":["
704  " \"key1\""
705  " ]"
706  " }"
707  "]",
708  kServiceValue, kMethodValue, kTestKey))
709  .Build());
710  rls_server_->service_.SetResponse(
711  BuildRlsRequest({{kTestKey, kTestValue}}),
712  BuildRlsResponse({TargetStringForPort(backends_[0]->port_)},
713  kHeaderData));
714  CheckRpcSendOk(DEBUG_LOCATION,
715  RpcOptions().set_metadata({{"key1", kTestValue}}));
716  EXPECT_EQ(rls_server_->service_.request_count(), 1);
717  EXPECT_EQ(rls_server_->service_.response_count(), 1);
718  EXPECT_EQ(backends_[0]->service_.request_count(), 1);
719  EXPECT_THAT(backends_[0]->service_.rls_data(),
720  ::testing::ElementsAre(kHeaderData));
721 }
722 
723 TEST_F(RlsEnd2endTest, ExtraKeysAndConstantKeys) {
724  StartBackends(1);
725  SetNextResolution(
726  MakeServiceConfigBuilder()
727  .AddKeyBuilder(absl::StrFormat("\"names\":[{"
728  " \"service\":\"%s\","
729  " \"method\":\"%s\""
730  "}],"
731  "\"headers\":["
732  " {"
733  " \"key\":\"%s\","
734  " \"names\":["
735  " \"key1\",\"key2\",\"key3\""
736  " ]"
737  " }"
738  "],"
739  "\"extraKeys\":{"
740  " \"host\":\"%s\","
741  " \"service\":\"%s\","
742  " \"method\":\"%s\""
743  "},"
744  "\"constantKeys\":{"
745  " \"%s\":\"%s\""
746  "}",
747  kServiceValue, kMethodValue, kTestKey,
748  kHostKey, kServiceKey, kMethodKey,
749  kConstantKey, kConstantValue))
750  .Build());
751  rls_server_->service_.SetResponse(
753  {kTestKey, kTestValue},
754  {kHostKey, kServerName},
755  {kServiceKey, kServiceValue},
756  {kMethodKey, kMethodValue},
757  {kConstantKey, kConstantValue},
758  }),
759  BuildRlsResponse({TargetStringForPort(backends_[0]->port_)}));
760  CheckRpcSendOk(DEBUG_LOCATION,
761  RpcOptions().set_metadata({{"key1", kTestValue}}));
762  EXPECT_EQ(rls_server_->service_.request_count(), 1);
763  EXPECT_EQ(rls_server_->service_.response_count(), 1);
764  EXPECT_EQ(backends_[0]->service_.request_count(), 1);
765 }
766 
767 TEST_F(RlsEnd2endTest, TwoCacheEntriesWithSameTarget) {
768  const char* kTestValue2 = "test_value2";
769  StartBackends(1);
770  SetNextResolution(
771  MakeServiceConfigBuilder()
772  .AddKeyBuilder(absl::StrFormat("\"names\":[{"
773  " \"service\":\"%s\","
774  " \"method\":\"%s\""
775  "}],"
776  "\"headers\":["
777  " {"
778  " \"key\":\"%s\","
779  " \"names\":["
780  " \"key1\""
781  " ]"
782  " }"
783  "]",
784  kServiceValue, kMethodValue, kTestKey))
785  .Build());
786  rls_server_->service_.SetResponse(
787  BuildRlsRequest({{kTestKey, kTestValue}}),
788  BuildRlsResponse({TargetStringForPort(backends_[0]->port_)}));
789  rls_server_->service_.SetResponse(
790  BuildRlsRequest({{kTestKey, kTestValue2}}),
791  BuildRlsResponse({TargetStringForPort(backends_[0]->port_)}));
792  CheckRpcSendOk(DEBUG_LOCATION,
793  RpcOptions().set_metadata({{"key1", kTestValue}}));
794  EXPECT_EQ(rls_server_->service_.request_count(), 1);
795  EXPECT_EQ(rls_server_->service_.response_count(), 1);
796  EXPECT_EQ(backends_[0]->service_.request_count(), 1);
797  CheckRpcSendOk(DEBUG_LOCATION,
798  RpcOptions().set_metadata({{"key1", kTestValue2}}));
799  EXPECT_EQ(rls_server_->service_.request_count(), 2);
800  EXPECT_EQ(rls_server_->service_.response_count(), 2);
801  EXPECT_EQ(backends_[0]->service_.request_count(), 2);
802 }
803 
804 TEST_F(RlsEnd2endTest, FailedRlsRequestWithoutDefaultTarget) {
805  StartBackends(1);
806  SetNextResolution(
807  MakeServiceConfigBuilder()
808  .AddKeyBuilder(absl::StrFormat("\"names\":[{"
809  " \"service\":\"%s\","
810  " \"method\":\"%s\""
811  "}],"
812  "\"headers\":["
813  " {"
814  " \"key\":\"%s\","
815  " \"names\":["
816  " \"key1\""
817  " ]"
818  " }"
819  "]",
820  kServiceValue, kMethodValue, kTestKey))
821  .Build());
822  // The test below has one RLS RPC fail and then a subsequent one that
823  // should succeed. However, once the first RPC fails, the adaptive
824  // throttling code will throttle the second RPC with about 11% probability,
825  // which would cause the test to be flaky. To avoid that, we seed the
826  // throttling state by sending two successful RPCs before we start the
827  // real test, which ensures that the second RPC of the real test will
828  // not be throttled (with 3 successes and 1 failure, the throttling
829  // probability will be negative, so the subsequent request will never be
830  // throttled).
831  const char* kTestValue2 = "test_value_2";
832  const char* kTestValue3 = "test_value_3";
833  rls_server_->service_.SetResponse(
834  BuildRlsRequest({{kTestKey, kTestValue2}}),
835  BuildRlsResponse({TargetStringForPort(backends_[0]->port_)}));
836  rls_server_->service_.SetResponse(
837  BuildRlsRequest({{kTestKey, kTestValue3}}),
838  BuildRlsResponse({TargetStringForPort(backends_[0]->port_)}));
839  CheckRpcSendOk(DEBUG_LOCATION,
840  RpcOptions().set_metadata({{"key1", kTestValue2}}));
841  CheckRpcSendOk(DEBUG_LOCATION,
842  RpcOptions().set_metadata({{"key1", kTestValue3}}));
843  // Now start the real test.
844  // Send an RPC before we give the RLS server a response.
845  // The RLS request will fail, and thus so will the data plane RPC.
846  CheckRpcSendFailure(DEBUG_LOCATION, StatusCode::UNAVAILABLE,
847  "RLS request failed: INTERNAL: no response entry",
848  RpcOptions().set_metadata({{"key1", kTestValue}}));
849  EXPECT_THAT(
850  rls_server_->service_.GetUnmatchedRequests(),
852  // TODO(roth): Change this to use ::testing::ProtoEquals()
853  // once that becomes available in OSS.
856  BuildRlsRequest({{kTestKey, kTestValue}}).DebugString())));
857  // Now give the RLS server the right response.
858  rls_server_->service_.SetResponse(
859  BuildRlsRequest({{kTestKey, kTestValue}}),
860  BuildRlsResponse({TargetStringForPort(backends_[0]->port_)}));
861  // Sleep long enough for backoff to elapse, then try another RPC.
863  CheckRpcSendOk(DEBUG_LOCATION,
864  RpcOptions().set_metadata({{"key1", kTestValue}}));
865  EXPECT_EQ(rls_server_->service_.request_count(), 4);
866  EXPECT_EQ(rls_server_->service_.response_count(), 3);
867  EXPECT_EQ(backends_[0]->service_.request_count(), 3);
868 }
869 
870 TEST_F(RlsEnd2endTest, FailedRlsRequestWithDefaultTarget) {
871  StartBackends(1);
872  SetNextResolution(
873  MakeServiceConfigBuilder()
874  .AddKeyBuilder(absl::StrFormat("\"names\":[{"
875  " \"service\":\"%s\","
876  " \"method\":\"%s\""
877  "}],"
878  "\"headers\":["
879  " {"
880  " \"key\":\"%s\","
881  " \"names\":["
882  " \"key1\""
883  " ]"
884  " }"
885  "]",
886  kServiceValue, kMethodValue, kTestKey))
887  .set_default_target(TargetStringForPort(backends_[0]->port_))
888  .Build());
889  // Don't give the RLS server a response, so the RLS request will fail.
890  // The data plane RPC should be sent to the default target.
891  CheckRpcSendOk(DEBUG_LOCATION,
892  RpcOptions().set_metadata({{"key1", kTestValue}}));
893  EXPECT_THAT(
894  rls_server_->service_.GetUnmatchedRequests(),
896  // TODO(roth): Change this to use ::testing::ProtoEquals()
897  // once that becomes available in OSS.
900  BuildRlsRequest({{kTestKey, kTestValue}}).DebugString())));
901  EXPECT_EQ(rls_server_->service_.request_count(), 1);
902  EXPECT_EQ(rls_server_->service_.response_count(), 0);
903  EXPECT_EQ(backends_[0]->service_.request_count(), 1);
904 }
905 
906 TEST_F(RlsEnd2endTest, RlsRequestTimeout) {
907  StartBackends(2);
908  SetNextResolution(
909  MakeServiceConfigBuilder()
910  .AddKeyBuilder(absl::StrFormat("\"names\":[{"
911  " \"service\":\"%s\","
912  " \"method\":\"%s\""
913  "}],"
914  "\"headers\":["
915  " {"
916  " \"key\":\"%s\","
917  " \"names\":["
918  " \"key1\""
919  " ]"
920  " }"
921  "]",
922  kServiceValue, kMethodValue, kTestKey))
923  .set_default_target(TargetStringForPort(backends_[1]->port_))
924  .set_lookup_service_timeout(grpc_core::Duration::Seconds(2))
925  .Build());
926  // RLS server will send a response, but it's longer than the timeout.
927  rls_server_->service_.SetResponse(
928  BuildRlsRequest({{kTestKey, kTestValue}}),
929  BuildRlsResponse({TargetStringForPort(backends_[0]->port_)}),
930  /*response_delay=*/grpc_core::Duration::Seconds(3));
931  // The data plane RPC should be sent to the default target.
932  CheckRpcSendOk(DEBUG_LOCATION, RpcOptions().set_timeout_ms(4000).set_metadata(
933  {{"key1", kTestValue}}));
934  EXPECT_EQ(rls_server_->service_.request_count(), 1);
935  EXPECT_EQ(backends_[0]->service_.request_count(), 0);
936  EXPECT_EQ(backends_[1]->service_.request_count(), 1);
937 }
938 
939 TEST_F(RlsEnd2endTest, UpdateConfig) {
940  StartBackends(2);
941  auto service_config_builder =
942  MakeServiceConfigBuilder()
943  .AddKeyBuilder(absl::StrFormat("\"names\":[{"
944  " \"service\":\"%s\","
945  " \"method\":\"%s\""
946  "}],"
947  "\"headers\":["
948  " {"
949  " \"key\":\"%s\","
950  " \"names\":["
951  " \"key1\""
952  " ]"
953  " }"
954  "]",
955  kServiceValue, kMethodValue, kTestKey))
956  .set_default_target(TargetStringForPort(backends_[0]->port_));
957  SetNextResolution(service_config_builder.Build());
958  // Don't give the RLS server a response, so the RLS request will fail.
959  // The data plane RPC should be sent to the default target.
960  CheckRpcSendOk(DEBUG_LOCATION,
961  RpcOptions().set_metadata({{"key1", kTestValue}}));
962  EXPECT_THAT(
963  rls_server_->service_.GetUnmatchedRequests(),
965  // TODO(roth): Change this to use ::testing::ProtoEquals()
966  // once that becomes available in OSS.
969  BuildRlsRequest({{kTestKey, kTestValue}}).DebugString())));
970  EXPECT_EQ(rls_server_->service_.request_count(), 1);
971  EXPECT_EQ(rls_server_->service_.response_count(), 0);
972  EXPECT_EQ(backends_[0]->service_.request_count(), 1);
973  EXPECT_EQ(backends_[1]->service_.request_count(), 0);
974  // Now update the config to point to a new default target.
975  service_config_builder.set_default_target(
976  TargetStringForPort(backends_[1]->port_));
977  SetNextResolution(service_config_builder.Build());
978  // Send another RPC, which should go to the new default target.
979  // The RLS server will *not* see another request, because the cache
980  // entry is still in backoff.
981  CheckRpcSendOk(DEBUG_LOCATION,
982  RpcOptions().set_metadata({{"key1", kTestValue}}));
983  EXPECT_EQ(rls_server_->service_.request_count(), 1);
984  EXPECT_EQ(rls_server_->service_.response_count(), 0);
985  EXPECT_EQ(backends_[0]->service_.request_count(), 1);
986  EXPECT_EQ(backends_[1]->service_.request_count(), 1);
987 }
988 
989 TEST_F(RlsEnd2endTest, CachedResponse) {
990  StartBackends(1);
991  SetNextResolution(
992  MakeServiceConfigBuilder()
993  .AddKeyBuilder(absl::StrFormat("\"names\":[{"
994  " \"service\":\"%s\","
995  " \"method\":\"%s\""
996  "}],"
997  "\"headers\":["
998  " {"
999  " \"key\":\"%s\","
1000  " \"names\":["
1001  " \"key1\""
1002  " ]"
1003  " }"
1004  "]",
1005  kServiceValue, kMethodValue, kTestKey))
1006  .Build());
1007  rls_server_->service_.SetResponse(
1008  BuildRlsRequest({{kTestKey, kTestValue}}),
1009  BuildRlsResponse({TargetStringForPort(backends_[0]->port_)}));
1010  // Send two RPCs.
1011  CheckRpcSendOk(DEBUG_LOCATION,
1012  RpcOptions().set_metadata({{"key1", kTestValue}}));
1013  CheckRpcSendOk(DEBUG_LOCATION,
1014  RpcOptions().set_metadata({{"key1", kTestValue}}));
1015  // The RLS server should have seen only one request.
1016  EXPECT_EQ(rls_server_->service_.request_count(), 1);
1017  EXPECT_EQ(rls_server_->service_.response_count(), 1);
1018  EXPECT_EQ(backends_[0]->service_.request_count(), 2);
1019 }
1020 
1021 TEST_F(RlsEnd2endTest, StaleCacheEntry) {
1022  StartBackends(1);
1023  SetNextResolution(
1024  MakeServiceConfigBuilder()
1025  .AddKeyBuilder(absl::StrFormat("\"names\":[{"
1026  " \"service\":\"%s\","
1027  " \"method\":\"%s\""
1028  "}],"
1029  "\"headers\":["
1030  " {"
1031  " \"key\":\"%s\","
1032  " \"names\":["
1033  " \"key1\""
1034  " ]"
1035  " }"
1036  "]",
1037  kServiceValue, kMethodValue, kTestKey))
1038  .set_max_age(grpc_core::Duration::Seconds(5))
1039  .set_stale_age(grpc_core::Duration::Seconds(1))
1040  .Build());
1041  rls_server_->service_.SetResponse(
1042  BuildRlsRequest({{kTestKey, kTestValue}}),
1043  BuildRlsResponse({TargetStringForPort(backends_[0]->port_)}));
1044  // Send one RPC. RLS server gets a request, and RPC goes to backend.
1045  CheckRpcSendOk(DEBUG_LOCATION,
1046  RpcOptions().set_metadata({{"key1", kTestValue}}));
1047  EXPECT_EQ(rls_server_->service_.request_count(), 1);
1048  EXPECT_EQ(rls_server_->service_.response_count(), 1);
1049  EXPECT_EQ(backends_[0]->service_.request_count(), 1);
1050  // Update RLS server to expect stale request.
1051  rls_server_->service_.RemoveResponse(
1052  BuildRlsRequest({{kTestKey, kTestValue}}));
1053  rls_server_->service_.SetResponse(
1054  BuildRlsRequest({{kTestKey, kTestValue}},
1055  RouteLookupRequest::REASON_STALE),
1056  BuildRlsResponse({TargetStringForPort(backends_[0]->port_)}));
1057  // Wait longer than stale age.
1059  // Send another RPC. This should use the stale value but should
1060  // dispatch a second RLS request.
1061  CheckRpcSendOk(DEBUG_LOCATION,
1062  RpcOptions().set_metadata({{"key1", kTestValue}}));
1063  EXPECT_EQ(backends_[0]->service_.request_count(), 2);
1064  // Wait for RLS server to receive the second request.
1066  EXPECT_EQ(rls_server_->service_.request_count(), 2);
1067  EXPECT_EQ(rls_server_->service_.response_count(), 2);
1068 }
1069 
1070 TEST_F(RlsEnd2endTest, StaleCacheEntryWithHeaderData) {
1071  const char* kHeaderData = "header_data";
1072  StartBackends(1);
1073  SetNextResolution(
1074  MakeServiceConfigBuilder()
1075  .AddKeyBuilder(absl::StrFormat("\"names\":[{"
1076  " \"service\":\"%s\","
1077  " \"method\":\"%s\""
1078  "}],"
1079  "\"headers\":["
1080  " {"
1081  " \"key\":\"%s\","
1082  " \"names\":["
1083  " \"key1\""
1084  " ]"
1085  " }"
1086  "]",
1087  kServiceValue, kMethodValue, kTestKey))
1088  .set_max_age(grpc_core::Duration::Seconds(5))
1089  .set_stale_age(grpc_core::Duration::Seconds(1))
1090  .Build());
1091  rls_server_->service_.SetResponse(
1092  BuildRlsRequest({{kTestKey, kTestValue}}),
1093  BuildRlsResponse({TargetStringForPort(backends_[0]->port_)},
1094  kHeaderData));
1095  // Send one RPC. RLS server gets a request, and RPC goes to backend.
1096  CheckRpcSendOk(DEBUG_LOCATION,
1097  RpcOptions().set_metadata({{"key1", kTestValue}}));
1098  EXPECT_EQ(rls_server_->service_.request_count(), 1);
1099  EXPECT_EQ(rls_server_->service_.response_count(), 1);
1100  EXPECT_EQ(backends_[0]->service_.request_count(), 1);
1101  // Update RLS server to expect stale request.
1102  rls_server_->service_.RemoveResponse(
1103  BuildRlsRequest({{kTestKey, kTestValue}}));
1104  rls_server_->service_.SetResponse(
1105  BuildRlsRequest({{kTestKey, kTestValue}},
1106  RouteLookupRequest::REASON_STALE, kHeaderData),
1107  BuildRlsResponse({TargetStringForPort(backends_[0]->port_)},
1108  kHeaderData));
1109  // Wait longer than stale age.
1111  // Send another RPC. This should use the stale value but should
1112  // dispatch a second RLS request.
1113  CheckRpcSendOk(DEBUG_LOCATION,
1114  RpcOptions().set_metadata({{"key1", kTestValue}}));
1115  EXPECT_EQ(backends_[0]->service_.request_count(), 2);
1116  // Wait for RLS server to receive the second request.
1118  EXPECT_EQ(rls_server_->service_.request_count(), 2);
1119  EXPECT_EQ(rls_server_->service_.response_count(), 2);
1120 }
1121 
1122 TEST_F(RlsEnd2endTest, ExpiredCacheEntry) {
1123  StartBackends(1);
1124  SetNextResolution(
1125  MakeServiceConfigBuilder()
1126  .AddKeyBuilder(absl::StrFormat("\"names\":[{"
1127  " \"service\":\"%s\","
1128  " \"method\":\"%s\""
1129  "}],"
1130  "\"headers\":["
1131  " {"
1132  " \"key\":\"%s\","
1133  " \"names\":["
1134  " \"key1\""
1135  " ]"
1136  " }"
1137  "]",
1138  kServiceValue, kMethodValue, kTestKey))
1139  .set_max_age(grpc_core::Duration::Seconds(1))
1140  .set_lookup_service_timeout(grpc_core::Duration::Seconds(1))
1141  .Build());
1142  rls_server_->service_.SetResponse(
1143  BuildRlsRequest({{kTestKey, kTestValue}}),
1144  BuildRlsResponse({TargetStringForPort(backends_[0]->port_)}));
1145  // Send one RPC. RLS server gets a request, and RPC goes to backend.
1146  CheckRpcSendOk(DEBUG_LOCATION,
1147  RpcOptions().set_metadata({{"key1", kTestValue}}));
1148  EXPECT_EQ(rls_server_->service_.request_count(), 1);
1149  EXPECT_EQ(rls_server_->service_.response_count(), 1);
1150  EXPECT_EQ(backends_[0]->service_.request_count(), 1);
1151  // Remove response from RLS server so that the next RLS request fails.
1152  rls_server_->service_.RemoveResponse(
1153  BuildRlsRequest({{kTestKey, kTestValue}}));
1154  // Wait for cache to be expired.
1156  // Send another RPC. This should trigger a second RLS request, but
1157  // that fails, so the RPC fails.
1158  CheckRpcSendFailure(DEBUG_LOCATION, StatusCode::UNAVAILABLE,
1159  "RLS request failed: INTERNAL: no response entry",
1160  RpcOptions().set_metadata({{"key1", kTestValue}}));
1161  EXPECT_EQ(rls_server_->service_.request_count(), 2);
1162  EXPECT_EQ(rls_server_->service_.response_count(), 1);
1163  EXPECT_EQ(backends_[0]->service_.request_count(), 1);
1164 }
1165 
1166 TEST_F(RlsEnd2endTest, CacheSizeLimit) {
1167  const char* kTestValue2 = "test_value_2";
1168  StartBackends(2);
1169  SetNextResolution(
1170  MakeServiceConfigBuilder()
1171  .AddKeyBuilder(absl::StrFormat("\"names\":[{"
1172  " \"service\":\"%s\","
1173  " \"method\":\"%s\""
1174  "}],"
1175  "\"headers\":["
1176  " {"
1177  " \"key\":\"%s\","
1178  " \"names\":["
1179  " \"key1\""
1180  " ]"
1181  " }"
1182  "]",
1183  kServiceValue, kMethodValue,
1184  kTestKey))
1185  .set_cache_size_bytes(1) // Not even big enough for one entry.
1186  .Build());
1187  // Set RLS responses for both kTestValue and kTestValue2.
1188  rls_server_->service_.SetResponse(
1189  BuildRlsRequest({{kTestKey, kTestValue}}),
1190  BuildRlsResponse({TargetStringForPort(backends_[0]->port_)}));
1191  rls_server_->service_.SetResponse(
1192  BuildRlsRequest({{kTestKey, kTestValue2}}),
1193  BuildRlsResponse({TargetStringForPort(backends_[1]->port_)}));
1194  // Send an RPC for kTestValue.
1195  // RLS server gets a request, and RPC goes to backend.
1196  CheckRpcSendOk(DEBUG_LOCATION,
1197  RpcOptions().set_metadata({{"key1", kTestValue}}));
1198  EXPECT_EQ(rls_server_->service_.request_count(), 1);
1199  EXPECT_EQ(rls_server_->service_.response_count(), 1);
1200  EXPECT_EQ(backends_[0]->service_.request_count(), 1);
1201  EXPECT_EQ(backends_[1]->service_.request_count(), 0);
1202  // A second RPC for kTestValue should not generate another RLS
1203  // request, because the cache entry is held by min_eviction_time.
1204  CheckRpcSendOk(DEBUG_LOCATION,
1205  RpcOptions().set_metadata({{"key1", kTestValue}}));
1206  EXPECT_EQ(rls_server_->service_.request_count(), 1);
1207  EXPECT_EQ(rls_server_->service_.response_count(), 1);
1208  EXPECT_EQ(backends_[0]->service_.request_count(), 2);
1209  EXPECT_EQ(backends_[1]->service_.request_count(), 0);
1210  // Wait for min_eviction_time to elapse.
1212  // Send a request for kTestValue2.
1213  // RLS server gets a request, and RPC goes to backend.
1214  // This causes the entry for kTestValue to be evicted.
1215  CheckRpcSendOk(DEBUG_LOCATION,
1216  RpcOptions().set_metadata({{"key1", kTestValue2}}));
1217  EXPECT_EQ(rls_server_->service_.request_count(), 2);
1218  EXPECT_EQ(rls_server_->service_.response_count(), 2);
1219  EXPECT_EQ(backends_[0]->service_.request_count(), 2);
1220  EXPECT_EQ(backends_[1]->service_.request_count(), 1);
1221  // Send another RPC for kTestValue.
1222  // This should now trigger a new RLS request.
1223  CheckRpcSendOk(DEBUG_LOCATION,
1224  RpcOptions().set_metadata({{"key1", kTestValue}}));
1225  EXPECT_EQ(rls_server_->service_.request_count(), 3);
1226  EXPECT_EQ(rls_server_->service_.response_count(), 3);
1227  EXPECT_EQ(backends_[0]->service_.request_count(), 3);
1228  EXPECT_EQ(backends_[1]->service_.request_count(), 1);
1229  // Another RPC for kTestValue2 should still work due to min_eviction_time.
1230  CheckRpcSendOk(DEBUG_LOCATION,
1231  RpcOptions().set_metadata({{"key1", kTestValue2}}));
1232  EXPECT_EQ(rls_server_->service_.request_count(), 3);
1233  EXPECT_EQ(rls_server_->service_.response_count(), 3);
1234  EXPECT_EQ(backends_[0]->service_.request_count(), 3);
1235  EXPECT_EQ(backends_[1]->service_.request_count(), 2);
1236 }
1237 
1238 TEST_F(RlsEnd2endTest, MultipleTargets) {
1239  StartBackends(1);
1240  SetNextResolution(
1241  MakeServiceConfigBuilder()
1242  .AddKeyBuilder(absl::StrFormat("\"names\":[{"
1243  " \"service\":\"%s\","
1244  " \"method\":\"%s\""
1245  "}],"
1246  "\"headers\":["
1247  " {"
1248  " \"key\":\"%s\","
1249  " \"names\":["
1250  " \"key1\""
1251  " ]"
1252  " }"
1253  "]",
1254  kServiceValue, kMethodValue, kTestKey))
1255  .Build());
1256  rls_server_->service_.SetResponse(
1257  BuildRlsRequest({{kTestKey, kTestValue}}),
1259  // Second target will report TRANSIENT_FAILURE, but should
1260  // never be used.
1261  {TargetStringForPort(backends_[0]->port_), "invalid_target"}));
1262  CheckRpcSendOk(DEBUG_LOCATION,
1263  RpcOptions().set_metadata({{"key1", kTestValue}}));
1264  EXPECT_EQ(rls_server_->service_.request_count(), 1);
1265  EXPECT_EQ(rls_server_->service_.response_count(), 1);
1266  EXPECT_EQ(backends_[0]->service_.request_count(), 1);
1267 }
1268 
1269 TEST_F(RlsEnd2endTest, MultipleTargetsFirstInTransientFailure) {
1270  StartBackends(1);
1271  SetNextResolution(
1272  MakeServiceConfigBuilder()
1273  .AddKeyBuilder(absl::StrFormat("\"names\":[{"
1274  " \"service\":\"%s\","
1275  " \"method\":\"%s\""
1276  "}],"
1277  "\"headers\":["
1278  " {"
1279  " \"key\":\"%s\","
1280  " \"names\":["
1281  " \"key1\""
1282  " ]"
1283  " }"
1284  "]",
1285  kServiceValue, kMethodValue, kTestKey))
1286  .Build());
1287  rls_server_->service_.SetResponse(
1288  BuildRlsRequest({{kTestKey, kTestValue}}),
1290  // First target will report TRANSIENT_FAILURE.
1291  {"invalid_target", TargetStringForPort(backends_[0]->port_)}));
1292  CheckRpcSendOk(DEBUG_LOCATION,
1293  RpcOptions().set_metadata({{"key1", kTestValue}}));
1294  EXPECT_EQ(rls_server_->service_.request_count(), 1);
1295  EXPECT_EQ(rls_server_->service_.response_count(), 1);
1296  EXPECT_EQ(backends_[0]->service_.request_count(), 1);
1297 }
1298 
1299 TEST_F(RlsEnd2endTest, ConnectivityStateReady) {
1300  StartBackends(1);
1301  SetNextResolution(
1302  MakeServiceConfigBuilder()
1303  .AddKeyBuilder(absl::StrFormat("\"names\":[{"
1304  " \"service\":\"%s\","
1305  " \"method\":\"%s\""
1306  "}],"
1307  "\"headers\":["
1308  " {"
1309  " \"key\":\"%s\","
1310  " \"names\":["
1311  " \"key1\""
1312  " ]"
1313  " }"
1314  "]",
1315  kServiceValue, kMethodValue, kTestKey))
1316  .Build());
1317  EXPECT_EQ(GRPC_CHANNEL_IDLE, channel_->GetState(/*try_to_connect=*/false));
1318  rls_server_->service_.SetResponse(
1319  BuildRlsRequest({{kTestKey, kTestValue}}),
1321  // One target in TRANSIENT_FAILURE, the other in READY.
1322  {"invalid_target", TargetStringForPort(backends_[0]->port_)}));
1323  CheckRpcSendOk(DEBUG_LOCATION,
1324  RpcOptions().set_metadata({{"key1", kTestValue}}));
1325  EXPECT_EQ(rls_server_->service_.request_count(), 1);
1326  EXPECT_EQ(rls_server_->service_.response_count(), 1);
1327  EXPECT_EQ(backends_[0]->service_.request_count(), 1);
1328  EXPECT_EQ(GRPC_CHANNEL_READY, channel_->GetState(/*try_to_connect=*/false));
1329 }
1330 
1331 TEST_F(RlsEnd2endTest, ConnectivityStateIdle) {
1332  SetNextResolution(
1333  MakeServiceConfigBuilder()
1334  .AddKeyBuilder(absl::StrFormat("\"names\":[{"
1335  " \"service\":\"%s\","
1336  " \"method\":\"%s\""
1337  "}],"
1338  "\"headers\":["
1339  " {"
1340  " \"key\":\"%s\","
1341  " \"names\":["
1342  " \"key1\""
1343  " ]"
1344  " }"
1345  "]",
1346  kServiceValue, kMethodValue, kTestKey))
1347  .Build());
1348  EXPECT_EQ(GRPC_CHANNEL_IDLE, channel_->GetState(/*try_to_connect=*/false));
1349  // RLS server not given any responses, so the request will fail.
1350  CheckRpcSendFailure(DEBUG_LOCATION, StatusCode::UNAVAILABLE,
1351  "RLS request failed: INTERNAL: no response entry");
1352  // No child policies, so should be IDLE.
1353  EXPECT_EQ(GRPC_CHANNEL_IDLE, channel_->GetState(/*try_to_connect=*/false));
1354 }
1355 
1356 TEST_F(RlsEnd2endTest, ConnectivityStateTransientFailure) {
1357  SetNextResolution(
1358  MakeServiceConfigBuilder()
1359  .AddKeyBuilder(absl::StrFormat("\"names\":[{"
1360  " \"service\":\"%s\","
1361  " \"method\":\"%s\""
1362  "}],"
1363  "\"headers\":["
1364  " {"
1365  " \"key\":\"%s\","
1366  " \"names\":["
1367  " \"key1\""
1368  " ]"
1369  " }"
1370  "]",
1371  kServiceValue, kMethodValue, kTestKey))
1372  .Build());
1373  EXPECT_EQ(GRPC_CHANNEL_IDLE, channel_->GetState(/*try_to_connect=*/false));
1374  rls_server_->service_.SetResponse(BuildRlsRequest({{kTestKey, kTestValue}}),
1375  BuildRlsResponse({"invalid_target"}));
1376  CheckRpcSendFailure(
1378  "empty address list: no address in fixed_address_lb policy",
1379  RpcOptions().set_metadata({{"key1", kTestValue}}));
1380  EXPECT_EQ(rls_server_->service_.request_count(), 1);
1381  EXPECT_EQ(rls_server_->service_.response_count(), 1);
1383  channel_->GetState(/*try_to_connect=*/false));
1384 }
1385 
1386 TEST_F(RlsEnd2endTest, RlsAuthorityDeathTest) {
1387  GTEST_FLAG_SET(death_test_style, "threadsafe");
1388  ResetStub("incorrect_authority");
1389  SetNextResolution(
1390  MakeServiceConfigBuilder()
1391  .AddKeyBuilder(absl::StrFormat("\"names\":[{"
1392  " \"service\":\"%s\","
1393  " \"method\":\"%s\""
1394  "}],"
1395  "\"headers\":["
1396  " {"
1397  " \"key\":\"%s\","
1398  " \"names\":["
1399  " \"key1\""
1400  " ]"
1401  " }"
1402  "]",
1403  kServiceValue, kMethodValue, kTestKey))
1404  .Build());
1405  // Make sure that we blow up (via abort() from the security connector) when
1406  // the authority for the RLS channel doesn't match expectations.
1408  {
1409  CheckRpcSendOk(DEBUG_LOCATION,
1410  RpcOptions().set_metadata({{"key1", kTestValue}}));
1411  },
1412  "");
1413 }
1414 
1415 } // namespace
1416 } // namespace testing
1417 } // namespace grpc
1418 
1419 int main(int argc, char** argv) {
1420  ::testing::InitGoogleTest(&argc, argv);
1421  grpc::testing::TestEnvironment env(&argc, argv);
1422  return RUN_ALL_TESTS();
1423 }
kTestKey
static const uint8_t kTestKey[]
Definition: pkcs12_test.cc:184
grpc::EXPECT_THAT
EXPECT_THAT(status.error_message(), ::testing::HasSubstr("subject_token_type"))
grpc_core::Duration::seconds
double seconds() const
Definition: src/core/lib/gprpp/time.h:209
running_
bool running_
Definition: rls_end2end_test.cc:467
grpc::gpr_setenv
gpr_setenv("STS_CREDENTIALS", creds_file_name)
_gevent_test_main.result
result
Definition: _gevent_test_main.py:96
GPR_INFO
#define GPR_INFO
Definition: include/grpc/impl/codegen/log.h:56
testing
Definition: aws_request_signer_test.cc:25
grpc::status
auto status
Definition: cpp/client/credentials_test.cc:200
GRPC_CHANNEL_READY
@ GRPC_CHANNEL_READY
Definition: include/grpc/impl/codegen/connectivity_state.h:36
GTEST_FLAG_SET
#define GTEST_FLAG_SET(name, value)
Definition: googletest/googletest/include/gtest/internal/gtest-port.h:2219
grpc_core::MakeRefCounted
RefCountedPtr< T > MakeRefCounted(Args &&... args)
Definition: ref_counted_ptr.h:335
grpc_core::LocalhostResolves
void LocalhostResolves(bool *ipv4, bool *ipv6)
Definition: resolve_localhost_ip46.cc:50
regen-readme.it
it
Definition: regen-readme.py:15
fake_credentials.h
GRPC_ERROR_NONE
#define GRPC_ERROR_NONE
Definition: error.h:234
grpc_timeout_seconds_to_deadline
gpr_timespec grpc_timeout_seconds_to_deadline(int64_t time_s)
Definition: test/core/util/test_config.cc:81
grpc::ServerContext
Definition: grpcpp/impl/codegen/server_context.h:566
port.h
ctx
Definition: benchmark-async.c:30
grpc_core::DebugLocation
Definition: debug_location.h:31
resolve_localhost_ip46.h
generate.env
env
Definition: generate.py:37
absl::StrCat
std::string StrCat(const AlphaNum &a, const AlphaNum &b)
Definition: abseil-cpp/absl/strings/str_cat.cc:98
metadata
Definition: cq_verifier.cc:48
grpc_md_only_test_credentials_create
grpc_call_credentials * grpc_md_only_test_credentials_create(const char *md_key, const char *md_value)
Definition: fake_credentials.cc:118
grpc::internal::Mutex
Definition: include/grpcpp/impl/codegen/sync.h:59
absl::StrFormat
ABSL_MUST_USE_RESULT std::string StrFormat(const FormatSpec< Args... > &format, const Args &... args)
Definition: abseil-cpp/absl/strings/str_format.h:338
grpc
Definition: grpcpp/alarm.h:33
grpc_core::RefCountedPtr::get
T * get() const
Definition: ref_counted_ptr.h:146
grpc_core::FakeResolverResponseGenerator::SetResponse
void SetResponse(Resolver::Result result)
Definition: fake_resolver.cc:229
grpc_shutdown_blocking
GRPCAPI void grpc_shutdown_blocking(void)
Definition: init.cc:238
ipv6_only_
bool ipv6_only_
Definition: rls_end2end_test.cc:470
capstone.range
range
Definition: third_party/bloaty/third_party/capstone/bindings/python/capstone/__init__.py:6
grpc_core
Definition: call_metric_recorder.h:31
TestServiceImpl::Echo
grpc::Status Echo(grpc::ServerContext *context, const grpc::testing::EchoRequest *request, grpc::testing::EchoResponse *response)
grpc::ClientContext::set_wait_for_ready
void set_wait_for_ready(bool wait_for_ready)
Definition: grpcpp/impl/codegen/client_context.h:285
default_target_
std::string default_target_
Definition: rls_end2end_test.cc:399
benchmark.request
request
Definition: benchmark.py:77
absl::string_view
Definition: abseil-cpp/absl/strings/string_view.h:167
DebugString
std::string DebugString(const google::protobuf::Message &message)
Definition: bloaty/tests/test.h:60
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
fake_resolver.h
secure_credentials.h
GRPC_CHANNEL_TRANSIENT_FAILURE
@ GRPC_CHANNEL_TRANSIENT_FAILURE
Definition: include/grpc/impl/codegen/connectivity_state.h:38
grpc::ClientContext::set_deadline
void set_deadline(const T &deadline)
Definition: grpcpp/impl/codegen/client_context.h:274
grpc_call_credentials
Definition: src/core/lib/security/credentials/credentials.h:189
ABSL_GUARDED_BY
#define ABSL_GUARDED_BY(x)
Definition: abseil-cpp/absl/base/thread_annotations.h:62
resolver_response_generator_
std::unique_ptr< FakeResolverResponseGeneratorWrapper > resolver_response_generator_
Definition: rls_end2end_test.cc:474
ctx
static struct test_ctx ctx
Definition: test-ipc-send-recv.c:65
service_
T service_
Definition: rls_end2end_test.cc:464
env.h
absl::make_unique
memory_internal::MakeUniqueResult< T >::scalar make_unique(Args &&... args)
Definition: third_party/abseil-cpp/absl/memory/memory.h:168
port_
const int port_
Definition: rls_end2end_test.cc:462
grpc_core::DebugLocation::file
const char * file() const
Definition: debug_location.h:34
stub_
std::unique_ptr< grpc::testing::EchoTestService::Stub > stub_
Definition: rls_end2end_test.cc:476
sockaddr.h
grpc::ClientContext::AddMetadata
void AddMetadata(const std::string &meta_key, const std::string &meta_value)
Definition: client_context.cc:121
grpc::internal::MutexLock
Definition: include/grpcpp/impl/codegen/sync.h:86
T
#define T(upbtypeconst, upbtype, ctype, default_value)
cache_size_bytes_
int64_t cache_size_bytes_
Definition: rls_end2end_test.cc:402
testing::Test
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:402
test_service_impl.h
test_lb_policies.h
testing::ElementsAre
internal::ElementsAreMatcher< ::testing::tuple<> > ElementsAre()
Definition: cares/cares/test/gmock-1.8.0/gmock/gmock.h:13040
absl::synchronization_internal::Get
static GraphId Get(const IdMap &id, int num)
Definition: abseil-cpp/absl/synchronization/internal/graphcycles_test.cc:44
testing::Property
PolymorphicMatcher< internal::PropertyMatcher< Class, PropertyType > > Property(PropertyType(Class::*property)() const, const PropertyMatcher &matcher)
Definition: cares/cares/test/gmock-1.8.0/gmock/gmock.h:8732
DEBUG_LOCATION
#define DEBUG_LOCATION
Definition: debug_location.h:41
grpc_core::RefCounted::Unref
void Unref()
Definition: ref_counted.h:302
parse_address.h
profile_analyzer.builder
builder
Definition: profile_analyzer.py:159
asyncio_get_stats.args
args
Definition: asyncio_get_stats.py:40
grpc_core::RefCountedPtr< grpc_core::FakeResolverResponseGenerator >
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
channel_arguments.h
thread_
std::unique_ptr< std::thread > thread_
Definition: rls_end2end_test.cc:466
absl::StrJoin
std::string StrJoin(Iterator start, Iterator end, absl::string_view sep, Formatter &&fmt)
Definition: abseil-cpp/absl/strings/str_join.h:239
int64_t
signed __int64 int64_t
Definition: stdint-msvc2008.h:89
main
int main(int argc, char **argv)
Definition: rls_end2end_test.cc:1419
grpc_core::DebugLocation::line
int line() const
Definition: debug_location.h:35
gen_stats_data.c_str
def c_str(s, encoding='ascii')
Definition: gen_stats_data.py:38
ASSERT_DEATH_IF_SUPPORTED
#define ASSERT_DEATH_IF_SUPPORTED(statement, regex)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest-death-test.h:337
EXPECT_NE
#define EXPECT_NE(val1, val2)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:2028
grpc_timeout_milliseconds_to_deadline
gpr_timespec grpc_timeout_milliseconds_to_deadline(int64_t time_ms)
Definition: test/core/util/test_config.cc:89
gpr_log
GPRAPI void gpr_log(const char *file, int line, gpr_log_severity severity, const char *format,...) GPR_PRINT_FORMAT_CHECK(4
grpc_core::Resolver::Result
Results returned by the resolver.
Definition: resolver/resolver.h:56
gpr_sleep_until
GPRAPI void gpr_sleep_until(gpr_timespec until)
GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR
#define GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR
Definition: fake_resolver.h:31
cond
static uv_cond_t cond
Definition: threadpool.c:33
grpc_fake_transport_security_credentials_create
grpc_channel_credentials * grpc_fake_transport_security_credentials_create()
Definition: fake_credentials.cc:79
call_creds
void call_creds(grpc_end2end_test_config config)
Definition: call_creds.cc:523
channel_
std::shared_ptr< grpc::Channel > channel_
Definition: rls_end2end_test.cc:475
grpc_test_slowdown_factor
int64_t grpc_test_slowdown_factor()
Definition: test/core/util/test_config.cc:76
GRPC_CHANNEL_IDLE
@ GRPC_CHANNEL_IDLE
Definition: include/grpc/impl/codegen/connectivity_state.h:32
grpc::gpr_unsetenv
gpr_unsetenv("STS_CREDENTIALS")
channel.h
time.h
backup_poller.h
max_age
Duration max_age
Definition: rls.cc:147
grpc_fake_transport_security_server_credentials_create
grpc_server_credentials * grpc_fake_transport_security_server_credentials_create()
Definition: fake_credentials.cc:84
host_port.h
grpc::StatusCode
StatusCode
Definition: grpcpp/impl/codegen/status_code_enum.h:26
benchmark::Shutdown
void Shutdown()
Definition: benchmark/src/benchmark.cc:607
grpc_composite_channel_credentials_create
GRPCAPI grpc_channel_credentials * grpc_composite_channel_credentials_create(grpc_channel_credentials *channel_creds, grpc_call_credentials *call_creds, void *reserved)
Definition: composite_credentials.cc:164
RUN_ALL_TESTS
int RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:2471
response_generator_
grpc_core::RefCountedPtr< grpc_core::FakeResolverResponseGenerator > response_generator_
Definition: rls_end2end_test.cc:159
stale_age
Duration stale_age
Definition: rls.cc:148
grpc_pick_unused_port_or_die
int grpc_pick_unused_port_or_die(void)
grpc_core::ExecCtx
Definition: exec_ctx.h:97
GPR_GLOBAL_CONFIG_SET
#define GPR_GLOBAL_CONFIG_SET(name, value)
Definition: global_config_generic.h:26
grpc_core::ServiceConfigImpl::Create
static RefCountedPtr< ServiceConfig > Create(const grpc_channel_args *args, absl::string_view json_string, grpc_error_handle *error)
Definition: service_config_impl.cc:41
testing::Pair
internal::PairMatcher< FirstMatcher, SecondMatcher > Pair(FirstMatcher first_matcher, SecondMatcher second_matcher)
Definition: cares/cares/test/gmock-1.8.0/gmock/gmock.h:9152
grpc::testing::BuildRlsRequest
grpc::lookup::v1::RouteLookupRequest BuildRlsRequest(std::map< std::string, std::string > key, grpc::lookup::v1::RouteLookupRequest::Reason reason, const char *stale_header_data)
Definition: rls_server.cc:82
lookup_service_timeout_
grpc_core::Duration lookup_service_timeout_
Definition: rls_end2end_test.cc:398
backends_
std::vector< std::unique_ptr< ServerThread< MyTestServiceImpl > > > backends_
Definition: rls_end2end_test.cc:471
tests.unit._exit_scenarios.port
port
Definition: _exit_scenarios.py:179
test_config.h
grpc_core::Duration::Zero
static constexpr Duration Zero()
Definition: src/core/lib/gprpp/time.h:130
type_
grpc::string type_
Definition: rls_end2end_test.cc:463
default_target
std::string default_target
Definition: rls.cc:150
mu_
grpc::internal::Mutex mu_
Definition: rls_end2end_test.cc:125
secure_server_credentials.h
wait_for_ready
bool wait_for_ready
Definition: rls_end2end_test.cc:240
testing::InitGoogleTest
GTEST_API_ void InitGoogleTest(int *argc, char **argv)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:6106
credentials.h
server_
std::unique_ptr< Server > server_
Definition: rls_end2end_test.cc:465
grpc::testing::TEST_F
TEST_F(ChannelArgumentsTest, SetInt)
Definition: channel_arguments_test.cc:134
server
Definition: examples/python/async_streaming/server.py:1
exec_ctx
grpc_core::ExecCtx exec_ctx
Definition: end2end_binder_transport_test.cc:75
grpc_error_std_string
std::string grpc_error_std_string(grpc_error_handle error)
Definition: error.cc:944
asyncio_get_stats.response
response
Definition: asyncio_get_stats.py:28
std
Definition: grpcpp/impl/codegen/async_unary_call.h:407
grpc::testing::TestEnvironment
Definition: test/core/util/test_config.h:54
service_config_impl.h
grpc_core::Duration::Seconds
static constexpr Duration Seconds(int64_t seconds)
Definition: src/core/lib/gprpp/time.h:151
grpc::CreateCustomChannel
std::shared_ptr< Channel > CreateCustomChannel(const grpc::string &target, const std::shared_ptr< ChannelCredentials > &creds, const ChannelArguments &args)
timeout_ms
int timeout_ms
Definition: rls_end2end_test.cc:239
grpc::protobuf::util::Status
GRPC_CUSTOM_UTIL_STATUS Status
Definition: include/grpcpp/impl/codegen/config_protobuf.h:93
rls_server_
std::unique_ptr< ServerThread< RlsServiceImpl > > rls_server_
Definition: rls_end2end_test.cc:472
ASSERT_TRUE
#define ASSERT_TRUE(condition)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1973
ASSERT_FALSE
#define ASSERT_FALSE(condition)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1976
grpc_core::RegisterFixedAddressLoadBalancingPolicy
void RegisterFixedAddressLoadBalancingPolicy()
Definition: test_lb_policies.cc:665
metadata
std::vector< std::pair< std::string, std::string > > metadata
Definition: rls_end2end_test.cc:241
test_config.h
grpc::testing::EXPECT_EQ
EXPECT_EQ(options.token_exchange_service_uri, "https://foo/exchange")
grpc.StatusCode.UNAVAILABLE
tuple UNAVAILABLE
Definition: src/python/grpcio/grpc/__init__.py:278
channel_args.h
GRPC_ARG_FAKE_SECURITY_EXPECTED_TARGETS
#define GRPC_ARG_FAKE_SECURITY_EXPECTED_TARGETS
Definition: fake_credentials.h:40
rls_server.h
stale_age_
grpc_core::Duration stale_age_
Definition: rls_end2end_test.cc:401
grpc::internal::CondVar
Definition: include/grpcpp/impl/codegen/sync.h:124
context
grpc::ClientContext context
Definition: istio_echo_server_lib.cc:61
grpc::testing::BuildRlsResponse
grpc::lookup::v1::RouteLookupResponse BuildRlsResponse(std::vector< std::string > targets, const char *header_data)
Definition: rls_server.cc:94
max_age_
grpc_core::Duration max_age_
Definition: rls_end2end_test.cc:400
absl::forward
constexpr T && forward(absl::remove_reference_t< T > &t) noexcept
Definition: abseil-cpp/absl/utility/utility.h:230
asyncio_get_stats.type
type
Definition: asyncio_get_stats.py:37
uri_parser.h
server.h
grpc_init
GRPCAPI void grpc_init(void)
Definition: init.cc:146
grpc_error
Definition: error_internal.h:42
size
voidpf void uLong size
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
grpc_core::FakeResolverResponseGenerator
Definition: fake_resolver.h:46
grpc_core::Duration
Definition: src/core/lib/gprpp/time.h:122
grpc::testing::SendRpc
static void SendRpc(grpc::testing::EchoTestService::Stub *stub, int num_rpcs, bool allow_exhaustion, gpr_atm *errors)
Definition: thread_stress_test.cc:277
testing::Contains
internal::ContainsMatcher< M > Contains(M matcher)
Definition: cares/cares/test/gmock-1.8.0/gmock/gmock.h:9101
key_builders_
std::vector< std::string > key_builders_
Definition: rls_end2end_test.cc:403
counted_service.h
grpc_channel_credentials
Definition: src/core/lib/security/credentials/credentials.h:96
grpc::testing::Args
Args({0, 0})
rls_server_port_
int rls_server_port_
Definition: rls_end2end_test.cc:397
server_builder.h
timeout
uv_timer_t timeout
Definition: libuv/docs/code/uvwget/main.c:9
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230
create_channel.h
grpc::testing::mu
static gpr_mu mu
Definition: bm_cq.cc:162


grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:06