remove TestOnlyCopyToVector() from LB metadata API

pull/36968/head
Mark D. Roth 5 months ago
parent 5fe11aac68
commit 2765da6121
  1. 2
      src/core/client_channel/lb_metadata.cc
  2. 3
      src/core/client_channel/lb_metadata.h
  3. 5
      src/core/load_balancing/lb_policy.h
  4. 5
      test/core/load_balancing/lb_policy_test_lib.h
  5. 2
      test/core/test_util/BUILD
  6. 8
      test/core/test_util/test_lb_policies.cc

@ -61,7 +61,7 @@ absl::optional<absl::string_view> LbMetadata::Lookup(
}
std::vector<std::pair<std::string, std::string>>
LbMetadata::TestOnlyCopyToVector() {
LbMetadata::TestOnlyCopyToVector() const {
if (batch_ == nullptr) return {};
Encoder encoder;
batch_->Encode(&encoder);

@ -33,8 +33,7 @@ class LbMetadata : public LoadBalancingPolicy::MetadataInterface {
absl::optional<absl::string_view> Lookup(absl::string_view key,
std::string* buffer) const override;
std::vector<std::pair<std::string, std::string>> TestOnlyCopyToVector()
override;
std::vector<std::pair<std::string, std::string>> TestOnlyCopyToVector() const;
private:
grpc_metadata_batch* batch_;

@ -23,7 +23,6 @@
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "absl/base/thread_annotations.h"
#include "absl/container/inlined_vector.h"
@ -120,10 +119,6 @@ class LoadBalancingPolicy : public InternallyRefCounted<LoadBalancingPolicy> {
virtual absl::optional<absl::string_view> Lookup(
absl::string_view key, std::string* buffer) const = 0;
/// Produce a vector of metadata key/value strings for tests.
virtual std::vector<std::pair<std::string, std::string>>
TestOnlyCopyToVector() = 0;
};
/// A list of metadata mutations to be returned along with a PickResult.

@ -628,11 +628,6 @@ class LoadBalancingPolicyTest : public ::testing::Test {
return it->second;
}
std::vector<std::pair<std::string, std::string>> TestOnlyCopyToVector()
override {
return {}; // Not used.
}
std::map<std::string, std::string> metadata_;
};

@ -333,10 +333,12 @@ grpc_cc_library(
"//:uri_parser",
"//src/core:channel_args",
"//src/core:delegating_helper",
"//src/core:down_cast",
"//src/core:error",
"//src/core:grpc_backend_metric_data",
"//src/core:json",
"//src/core:json_util",
"//src/core:lb_metadata",
"//src/core:lb_policy",
"//src/core:lb_policy_factory",
"//src/core:lb_policy_registry",

@ -30,9 +30,11 @@
#include <grpc/grpc.h>
#include <grpc/support/json.h>
#include "src/core/client_channel/lb_metadata.h"
#include "src/core/lib/address_utils/parse_address.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/gprpp/down_cast.h"
#include "src/core/lib/gprpp/orphanable.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h"
#include "src/core/lib/gprpp/status_helper.h"
@ -129,7 +131,8 @@ class TestPickArgsLb : public ForwardingLoadBalancingPolicy {
// Report args seen.
PickArgsSeen args_seen;
args_seen.path = std::string(args.path);
args_seen.metadata = args.initial_metadata->TestOnlyCopyToVector();
args_seen.metadata =
DownCast<LbMetadata*>(args.initial_metadata)->TestOnlyCopyToVector();
cb_(args_seen);
// Do pick.
return delegate_picker_->Pick(args);
@ -269,7 +272,8 @@ class InterceptRecvTrailingMetadataLoadBalancingPolicy
args_seen.status = args.status;
args_seen.backend_metric_data =
args.backend_metric_accessor->GetBackendMetricData();
args_seen.metadata = args.trailing_metadata->TestOnlyCopyToVector();
args_seen.metadata =
DownCast<LbMetadata*>(args.trailing_metadata)->TestOnlyCopyToVector();
cb_(args_seen);
}

Loading…
Cancel
Save