Merge remote-tracking branch 'upstream/master' into spiffe1

pull/19778/head
Matthew Stevenson 5 years ago
commit e89efbc1ac
  1. 2
      BUILD
  2. 17
      bazel/grpc_build_system.bzl
  3. 9
      bazel/grpc_deps.bzl
  4. 7
      include/grpc/impl/codegen/grpc_types.h
  5. 13
      src/core/ext/filters/client_channel/client_channel.cc
  6. 2
      src/core/ext/filters/client_channel/http_connect_handshaker.cc
  7. 10
      src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc
  8. 31
      src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc
  9. 17
      src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc
  10. 962
      src/core/ext/filters/client_channel/lb_policy/xds/xds.cc
  11. 63
      src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc
  12. 71
      src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h
  13. 5
      src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc
  14. 2
      src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc
  15. 2
      src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc
  16. 3
      src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc
  17. 8
      src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc
  18. 5
      src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc
  19. 13
      src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc
  20. 5
      src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc
  21. 17
      src/core/ext/filters/client_channel/resolver_result_parsing.cc
  22. 9
      src/core/ext/filters/client_channel/resolving_lb_policy.cc
  23. 3
      src/core/ext/filters/client_channel/subchannel.cc
  24. 8
      src/core/ext/filters/message_size/message_size_filter.cc
  25. 739
      src/core/ext/transport/chttp2/transport/chttp2_transport.cc
  26. 23
      src/core/ext/transport/chttp2/transport/hpack_parser.cc
  27. 31
      src/core/ext/transport/chttp2/transport/internal.h
  28. 4
      src/core/ext/transport/chttp2/transport/writing.cc
  29. 4
      src/core/lib/gprpp/inlined_vector.h
  30. 33
      src/core/lib/gprpp/memory.h
  31. 8
      src/core/lib/gprpp/orphanable.h
  32. 39
      src/core/lib/iomgr/closure.h
  33. 4
      src/core/lib/iomgr/executor.cc
  34. 8
      src/core/lib/iomgr/python_util.h
  35. 4
      src/core/lib/security/transport/security_handshaker.cc
  36. 6
      src/core/lib/transport/connectivity_state.cc
  37. 4
      src/core/lib/transport/connectivity_state.h
  38. 3
      src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc
  39. 3
      src/core/tsi/ssl/session_cache/ssl_session_openssl.cc
  40. 1
      src/php/README.md
  41. 2
      src/python/grpcio/grpc/_cython/_cygrpc/iomgr.pxd.pxi
  42. 2
      src/ruby/ext/grpc/rb_channel.c
  43. 1
      test/core/avl/BUILD
  44. 1
      test/core/backoff/BUILD
  45. 1
      test/core/bad_ssl/generate_tests.bzl
  46. 5
      test/core/channel/BUILD
  47. 3
      test/core/client_channel/BUILD
  48. 10
      test/core/client_channel/resolvers/dns_resolver_test.cc
  49. 8
      test/core/client_channel/resolvers/sockaddr_resolver_test.cc
  50. 29
      test/core/client_channel/service_config_test.cc
  51. 4
      test/core/compression/BUILD
  52. 1
      test/core/debug/BUILD
  53. 2
      test/core/end2end/BUILD
  54. 3
      test/core/end2end/fuzzers/BUILD
  55. 51
      test/core/end2end/generate_tests.bzl
  56. 2
      test/core/fling/BUILD
  57. 12
      test/core/gpr/BUILD
  58. 12
      test/core/gprpp/BUILD
  59. 18
      test/core/gprpp/inlined_vector_test.cc
  60. 1
      test/core/handshake/BUILD
  61. 2
      test/core/handshake/readahead_handshaker_server_ssl.cc
  62. 5
      test/core/http/BUILD
  63. 8
      test/core/iomgr/BUILD
  64. 4
      test/core/json/BUILD
  65. 2
      test/core/memory_usage/BUILD
  66. 2
      test/core/nanopb/BUILD
  67. 5
      test/core/security/BUILD
  68. 9
      test/core/slice/BUILD
  69. 2
      test/core/surface/BUILD
  70. 4
      test/core/surface/lame_client_test.cc
  71. 7
      test/core/transport/BUILD
  72. 8
      test/core/transport/chttp2/BUILD
  73. 46
      test/core/transport/connectivity_state_test.cc
  74. 1
      test/core/tsi/BUILD
  75. 2
      test/core/util/BUILD
  76. 5
      test/core/util/test_lb_policies.cc
  77. 4
      test/core/util/ubsan_suppressions.txt
  78. 3
      test/cpp/codegen/BUILD
  79. 4
      test/cpp/common/BUILD
  80. 10
      test/cpp/end2end/BUILD
  81. 166
      test/cpp/end2end/xds_end2end_test.cc
  82. 1
      test/cpp/ext/filters/census/BUILD
  83. 1
      test/cpp/interop/BUILD
  84. 2
      test/cpp/qps/BUILD
  85. 7
      test/cpp/util/BUILD
  86. 13
      test/distrib/csharp/run_distrib_test_dotnetcli.sh
  87. 2
      tools/debug/core/error_ref_leak.py
  88. 28
      tools/dockerfile/distribtest/csharp_alpine_x64/Dockerfile
  89. 2
      tools/http2_interop/http2interop_test.go
  90. 2
      tools/http2_interop/s6.5.go
  91. 22
      tools/internal_ci/macos/grpc_bazel_c_cpp_dbg.cfg
  92. 22
      tools/internal_ci/macos/grpc_bazel_c_cpp_opt.cfg
  93. 2
      tools/internal_ci/macos/grpc_cfstream.cfg
  94. 2
      tools/internal_ci/macos/grpc_cfstream_asan.cfg
  95. 2
      tools/internal_ci/macos/grpc_cfstream_tsan.cfg
  96. 30
      tools/internal_ci/macos/grpc_run_bazel_c_cpp_tests.sh
  97. 0
      tools/internal_ci/macos/grpc_run_bazel_isolated_tests.sh
  98. 2
      tools/internal_ci/windows/bazel_rbe.bat
  99. 5
      tools/interop_matrix/client_matrix.py
  100. 4
      tools/remote_build/README.md
  101. Some files were not shown because too many files have changed in this diff Show More

@ -860,7 +860,7 @@ grpc_cc_library(
"src/core/lib/iomgr/executor/mpmcqueue.h",
"src/core/lib/iomgr/executor/threadpool.h",
"src/core/lib/iomgr/gethostname.h",
"src/core/lib/iomgr/gevent_util.h",
"src/core/lib/iomgr/python_util.h",
"src/core/lib/iomgr/grpc_if_nametoindex.h",
"src/core/lib/iomgr/internal_errqueue.h",
"src/core/lib/iomgr/iocp_windows.h",

@ -184,17 +184,17 @@ def grpc_cc_test(name, srcs = [], deps = [], external_deps = [], args = [], data
"exec_compatible_with": exec_compatible_with,
}
if uses_polling:
# Only run targets with pollers for non-MSVC
# TODO(yfen): Enable MSVC for poller-enabled targets without pollers
# the vanilla version of the test should run on platforms that only
# support a single poller
native.cc_test(
name = name,
testonly = True,
tags = [
"manual",
"no_windows",
],
tags = (tags + [
"no_linux", # linux supports multiple pollers
]),
**args
)
# on linux we run the same test multiple times, once for each poller
for poller in POLLERS:
native.sh_test(
name = name + "@poller=" + poller,
@ -208,11 +208,12 @@ def grpc_cc_test(name, srcs = [], deps = [], external_deps = [], args = [], data
poller,
"$(location %s)" % name,
] + args["args"],
tags = (tags + ["no_windows"]),
tags = (tags + ["no_windows", "no_mac"]),
exec_compatible_with = exec_compatible_with,
)
else:
native.cc_test(tags = tags, **args)
# the test behavior doesn't depend on polling, just generate the test
native.cc_test(name = name, tags = tags, **args)
ios_cc_test(
name = name,
tags = tags,

@ -174,13 +174,14 @@ def grpc_deps():
)
if "bazel_toolchains" not in native.existing_rules():
# list of releases is at https://releases.bazel.build/bazel-toolchains.html
http_archive(
name = "bazel_toolchains",
sha256 = "872955b658113924eb1a3594b04d43238da47f4f90c17b76e8785709490dc041",
strip_prefix = "bazel-toolchains-1083686fde6032378d52b4c98044922cebde364e",
sha256 = "22ca5b8115c8673ecb627a02b606529e813961e447933863fccdf325cc5f999f",
strip_prefix = "bazel-toolchains-0.29.5",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/1083686fde6032378d52b4c98044922cebde364e.tar.gz",
"https://github.com/bazelbuild/bazel-toolchains/archive/1083686fde6032378d52b4c98044922cebde364e.tar.gz",
"https://github.com/bazelbuild/bazel-toolchains/releases/download/0.29.5/bazel-toolchains-0.29.5.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/0.29.5.tar.gz",
],
)

@ -339,6 +339,13 @@ typedef struct {
value is 15 minutes. */
#define GRPC_ARG_LOCALITY_RETENTION_INTERVAL_MS \
"grpc.xds_locality_retention_interval_ms"
/* Timeout in milliseconds to wait for the localities of a specific priority to
complete their initial connection attempt before xDS fails over to the next
priority. Specifically, the connection attempt of a priority is considered
completed when any locality of that priority is ready or all the localities
of that priority fail to connect. If 0, failover happens immediately. Default
value is 10 seconds. */
#define GRPC_ARG_XDS_FAILOVER_TIMEOUT_MS "grpc.xds_failover_timeout_ms"
/** If non-zero, grpc server's cronet compression workaround will be enabled */
#define GRPC_ARG_WORKAROUND_CRONET_COMPRESSION \
"grpc.workaround.cronet_compression"

@ -1151,11 +1151,11 @@ void ChannelData::ExternalConnectivityWatcher::Notify(
MemoryOrder::RELAXED)) {
return; // Already done.
}
// Remove external watcher.
chand_->RemoveExternalConnectivityWatcher(on_complete_, /*cancel=*/false);
// Report new state to the user.
*state_ = state;
GRPC_CLOSURE_SCHED(on_complete_, GRPC_ERROR_NONE);
// Remove external watcher.
chand_->RemoveExternalConnectivityWatcher(on_complete_, /*cancel=*/false);
// Hop back into the combiner to clean up.
// Not needed in state SHUTDOWN, because the tracker will
// automatically remove all watchers in that case.
@ -1515,9 +1515,7 @@ void ChannelData::CreateResolvingLoadBalancingPolicyLocked() {
// Instantiate resolving LB policy.
LoadBalancingPolicy::Args lb_args;
lb_args.combiner = combiner_;
lb_args.channel_control_helper =
UniquePtr<LoadBalancingPolicy::ChannelControlHelper>(
New<ClientChannelControlHelper>(this));
lb_args.channel_control_helper = MakeUnique<ClientChannelControlHelper>(this);
lb_args.args = channel_args_;
UniquePtr<char> target_uri(gpr_strdup(target_uri_.get()));
resolving_lb_policy_.reset(New<ResolvingLoadBalancingPolicy>(
@ -1791,9 +1789,8 @@ void ChannelData::StartTransportOpLocked(void* arg, grpc_error* ignored) {
MemoryOrder::RELEASE);
chand->UpdateStateAndPickerLocked(
GRPC_CHANNEL_SHUTDOWN, "shutdown from API",
UniquePtr<LoadBalancingPolicy::SubchannelPicker>(
New<LoadBalancingPolicy::TransientFailurePicker>(
GRPC_ERROR_REF(op->disconnect_with_error))));
MakeUnique<LoadBalancingPolicy::TransientFailurePicker>(
GRPC_ERROR_REF(op->disconnect_with_error)));
}
}
GRPC_CHANNEL_STACK_UNREF(chand->owning_stack_, "start_transport_op");

@ -356,5 +356,5 @@ void grpc_http_connect_register_handshaker_factory() {
using namespace grpc_core;
HandshakerRegistry::RegisterHandshakerFactory(
true /* at_start */, HANDSHAKER_CLIENT,
UniquePtr<HandshakerFactory>(New<HttpConnectHandshakerFactory>()));
MakeUnique<HttpConnectHandshakerFactory>());
}

@ -716,9 +716,8 @@ void GrpcLb::Helper::UpdateState(grpc_connectivity_state state,
client_stats = parent_->lb_calld_->client_stats()->Ref();
}
parent_->channel_control_helper()->UpdateState(
state, UniquePtr<SubchannelPicker>(
New<Picker>(parent_.get(), parent_->serverlist_,
std::move(picker), std::move(client_stats))));
state, MakeUnique<Picker>(parent_.get(), parent_->serverlist_,
std::move(picker), std::move(client_stats)));
}
void GrpcLb::Helper::RequestReresolution() {
@ -1794,7 +1793,7 @@ class GrpcLbFactory : public LoadBalancingPolicyFactory {
public:
OrphanablePtr<LoadBalancingPolicy> CreateLoadBalancingPolicy(
LoadBalancingPolicy::Args args) const override {
return OrphanablePtr<LoadBalancingPolicy>(New<GrpcLb>(std::move(args)));
return MakeOrphanable<GrpcLb>(std::move(args));
}
const char* name() const override { return kGrpclb; }
@ -1869,8 +1868,7 @@ bool maybe_add_client_load_reporting_filter(grpc_channel_stack_builder* builder,
void grpc_lb_policy_grpclb_init() {
grpc_core::LoadBalancingPolicyRegistry::Builder::
RegisterLoadBalancingPolicyFactory(
grpc_core::UniquePtr<grpc_core::LoadBalancingPolicyFactory>(
grpc_core::New<grpc_core::GrpcLbFactory>()));
grpc_core::MakeUnique<grpc_core::GrpcLbFactory>());
grpc_channel_init_register_stage(GRPC_CLIENT_SUBCHANNEL,
GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
maybe_add_client_load_reporting_filter,

@ -201,7 +201,7 @@ void PickFirst::AttemptToConnectUsingLatestUpdateArgsLocked() {
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE);
channel_control_helper()->UpdateState(
GRPC_CHANNEL_TRANSIENT_FAILURE,
UniquePtr<SubchannelPicker>(New<TransientFailurePicker>(error)));
MakeUnique<TransientFailurePicker>(error));
return;
}
// If one of the subchannels in the new list is already in state
@ -319,12 +319,11 @@ void PickFirst::PickFirstSubchannelData::ProcessConnectivityChangeLocked(
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE);
p->channel_control_helper()->UpdateState(
GRPC_CHANNEL_TRANSIENT_FAILURE,
UniquePtr<SubchannelPicker>(New<TransientFailurePicker>(error)));
MakeUnique<TransientFailurePicker>(error));
} else {
p->channel_control_helper()->UpdateState(
GRPC_CHANNEL_CONNECTING,
UniquePtr<SubchannelPicker>(
New<QueuePicker>(p->Ref(DEBUG_LOCATION, "QueuePicker"))));
MakeUnique<QueuePicker>(p->Ref(DEBUG_LOCATION, "QueuePicker")));
}
} else {
if (connectivity_state == GRPC_CHANNEL_TRANSIENT_FAILURE) {
@ -339,20 +338,19 @@ void PickFirst::PickFirstSubchannelData::ProcessConnectivityChangeLocked(
p->selected_ = nullptr;
p->subchannel_list_.reset();
p->channel_control_helper()->UpdateState(
GRPC_CHANNEL_IDLE, UniquePtr<SubchannelPicker>(New<QueuePicker>(
p->Ref(DEBUG_LOCATION, "QueuePicker"))));
GRPC_CHANNEL_IDLE,
MakeUnique<QueuePicker>(p->Ref(DEBUG_LOCATION, "QueuePicker")));
} else {
// This is unlikely but can happen when a subchannel has been asked
// to reconnect by a different channel and this channel has dropped
// some connectivity state notifications.
if (connectivity_state == GRPC_CHANNEL_READY) {
p->channel_control_helper()->UpdateState(
GRPC_CHANNEL_READY,
UniquePtr<SubchannelPicker>(New<Picker>(subchannel()->Ref())));
GRPC_CHANNEL_READY, MakeUnique<Picker>(subchannel()->Ref()));
} else { // CONNECTING
p->channel_control_helper()->UpdateState(
connectivity_state, UniquePtr<SubchannelPicker>(New<QueuePicker>(
p->Ref(DEBUG_LOCATION, "QueuePicker"))));
connectivity_state,
MakeUnique<QueuePicker>(p->Ref(DEBUG_LOCATION, "QueuePicker")));
}
}
}
@ -396,7 +394,7 @@ void PickFirst::PickFirstSubchannelData::ProcessConnectivityChangeLocked(
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE);
p->channel_control_helper()->UpdateState(
GRPC_CHANNEL_TRANSIENT_FAILURE,
UniquePtr<SubchannelPicker>(New<TransientFailurePicker>(error)));
MakeUnique<TransientFailurePicker>(error));
}
}
sd->CheckConnectivityStateAndStartWatchingLocked();
@ -408,8 +406,7 @@ void PickFirst::PickFirstSubchannelData::ProcessConnectivityChangeLocked(
if (subchannel_list() == p->subchannel_list_.get()) {
p->channel_control_helper()->UpdateState(
GRPC_CHANNEL_CONNECTING,
UniquePtr<SubchannelPicker>(
New<QueuePicker>(p->Ref(DEBUG_LOCATION, "QueuePicker"))));
MakeUnique<QueuePicker>(p->Ref(DEBUG_LOCATION, "QueuePicker")));
}
break;
}
@ -448,8 +445,7 @@ void PickFirst::PickFirstSubchannelData::ProcessUnselectedReadyLocked() {
}
p->selected_ = this;
p->channel_control_helper()->UpdateState(
GRPC_CHANNEL_READY,
UniquePtr<SubchannelPicker>(New<Picker>(subchannel()->Ref())));
GRPC_CHANNEL_READY, MakeUnique<Picker>(subchannel()->Ref()));
for (size_t i = 0; i < subchannel_list()->num_subchannels(); ++i) {
if (i != Index()) {
subchannel_list()->subchannel(i)->ShutdownLocked();
@ -488,7 +484,7 @@ class PickFirstFactory : public LoadBalancingPolicyFactory {
public:
OrphanablePtr<LoadBalancingPolicy> CreateLoadBalancingPolicy(
LoadBalancingPolicy::Args args) const override {
return OrphanablePtr<LoadBalancingPolicy>(New<PickFirst>(std::move(args)));
return MakeOrphanable<PickFirst>(std::move(args));
}
const char* name() const override { return kPickFirst; }
@ -510,8 +506,7 @@ class PickFirstFactory : public LoadBalancingPolicyFactory {
void grpc_lb_policy_pick_first_init() {
grpc_core::LoadBalancingPolicyRegistry::Builder::
RegisterLoadBalancingPolicyFactory(
grpc_core::UniquePtr<grpc_core::LoadBalancingPolicyFactory>(
grpc_core::New<grpc_core::PickFirstFactory>()));
grpc_core::MakeUnique<grpc_core::PickFirstFactory>());
}
void grpc_lb_policy_pick_first_shutdown() {}

@ -321,13 +321,13 @@ void RoundRobin::RoundRobinSubchannelList::
*/
if (num_ready_ > 0) {
/* 1) READY */
p->channel_control_helper()->UpdateState(
GRPC_CHANNEL_READY, UniquePtr<SubchannelPicker>(New<Picker>(p, this)));
p->channel_control_helper()->UpdateState(GRPC_CHANNEL_READY,
MakeUnique<Picker>(p, this));
} else if (num_connecting_ > 0) {
/* 2) CONNECTING */
p->channel_control_helper()->UpdateState(
GRPC_CHANNEL_CONNECTING, UniquePtr<SubchannelPicker>(New<QueuePicker>(
p->Ref(DEBUG_LOCATION, "QueuePicker"))));
GRPC_CHANNEL_CONNECTING,
MakeUnique<QueuePicker>(p->Ref(DEBUG_LOCATION, "QueuePicker")));
} else if (num_transient_failure_ == num_subchannels()) {
/* 3) TRANSIENT_FAILURE */
grpc_error* error =
@ -336,7 +336,7 @@ void RoundRobin::RoundRobinSubchannelList::
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE);
p->channel_control_helper()->UpdateState(
GRPC_CHANNEL_TRANSIENT_FAILURE,
UniquePtr<SubchannelPicker>(New<TransientFailurePicker>(error)));
MakeUnique<TransientFailurePicker>(error));
}
}
@ -453,7 +453,7 @@ void RoundRobin::UpdateLocked(UpdateArgs args) {
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE);
channel_control_helper()->UpdateState(
GRPC_CHANNEL_TRANSIENT_FAILURE,
UniquePtr<SubchannelPicker>(New<TransientFailurePicker>(error)));
MakeUnique<TransientFailurePicker>(error));
subchannel_list_ = std::move(latest_pending_subchannel_list_);
} else if (subchannel_list_ == nullptr) {
// If there is no current list, immediately promote the new list to
@ -480,7 +480,7 @@ class RoundRobinFactory : public LoadBalancingPolicyFactory {
public:
OrphanablePtr<LoadBalancingPolicy> CreateLoadBalancingPolicy(
LoadBalancingPolicy::Args args) const override {
return OrphanablePtr<LoadBalancingPolicy>(New<RoundRobin>(std::move(args)));
return MakeOrphanable<RoundRobin>(std::move(args));
}
const char* name() const override { return kRoundRobin; }
@ -502,8 +502,7 @@ class RoundRobinFactory : public LoadBalancingPolicyFactory {
void grpc_lb_policy_round_robin_init() {
grpc_core::LoadBalancingPolicyRegistry::Builder::
RegisterLoadBalancingPolicyFactory(
grpc_core::UniquePtr<grpc_core::LoadBalancingPolicyFactory>(
grpc_core::New<grpc_core::RoundRobinFactory>()));
grpc_core::MakeUnique<grpc_core::RoundRobinFactory>());
}
void grpc_lb_policy_round_robin_shutdown() {}

File diff suppressed because it is too large Load Diff

@ -53,6 +53,42 @@ constexpr char kEndpointRequired[] = "endpointRequired";
} // namespace
bool XdsPriorityListUpdate::operator==(
const XdsPriorityListUpdate& other) const {
if (priorities_.size() != other.priorities_.size()) return false;
for (size_t i = 0; i < priorities_.size(); ++i) {
if (priorities_[i].localities != other.priorities_[i].localities) {
return false;
}
}
return true;
}
void XdsPriorityListUpdate::Add(
XdsPriorityListUpdate::LocalityMap::Locality locality) {
// Pad the missing priorities in case the localities are not ordered by
// priority.
// TODO(juanlishen): Implement InlinedVector::resize() and use that instead.
while (!Contains(locality.priority)) priorities_.emplace_back();
LocalityMap& locality_map = priorities_[locality.priority];
locality_map.localities.emplace(locality.name, std::move(locality));
}
const XdsPriorityListUpdate::LocalityMap* XdsPriorityListUpdate::Find(
uint32_t priority) const {
if (!Contains(priority)) return nullptr;
return &priorities_[priority];
}
bool XdsPriorityListUpdate::Contains(
const RefCountedPtr<XdsLocalityName>& name) {
for (size_t i = 0; i < priorities_.size(); ++i) {
const LocalityMap& locality_map = priorities_[i];
if (locality_map.Contains(name)) return true;
}
return false;
}
bool XdsDropConfig::ShouldDrop(const UniquePtr<char>** category_name) const {
for (size_t i = 0; i < drop_category_list_.size(); ++i) {
const auto& drop_category = drop_category_list_[i];
@ -136,7 +172,7 @@ UniquePtr<char> StringCopy(const upb_strview& strview) {
grpc_error* LocalityParse(
const envoy_api_v2_endpoint_LocalityLbEndpoints* locality_lb_endpoints,
XdsLocalityInfo* locality_info) {
XdsPriorityListUpdate::LocalityMap::Locality* output_locality) {
// Parse LB weight.
const google_protobuf_UInt32Value* lb_weight =
envoy_api_v2_endpoint_LocalityLbEndpoints_load_balancing_weight(
@ -144,13 +180,13 @@ grpc_error* LocalityParse(
// If LB weight is not specified, it means this locality is assigned no load.
// TODO(juanlishen): When we support CDS to configure the inter-locality
// policy, we should change the LB weight handling.
locality_info->lb_weight =
output_locality->lb_weight =
lb_weight != nullptr ? google_protobuf_UInt32Value_value(lb_weight) : 0;
if (locality_info->lb_weight == 0) return GRPC_ERROR_NONE;
if (output_locality->lb_weight == 0) return GRPC_ERROR_NONE;
// Parse locality name.
const envoy_api_v2_core_Locality* locality =
envoy_api_v2_endpoint_LocalityLbEndpoints_locality(locality_lb_endpoints);
locality_info->locality_name = MakeRefCounted<XdsLocalityName>(
output_locality->name = MakeRefCounted<XdsLocalityName>(
StringCopy(envoy_api_v2_core_Locality_region(locality)),
StringCopy(envoy_api_v2_core_Locality_zone(locality)),
StringCopy(envoy_api_v2_core_Locality_sub_zone(locality)));
@ -160,12 +196,12 @@ grpc_error* LocalityParse(
envoy_api_v2_endpoint_LocalityLbEndpoints_lb_endpoints(
locality_lb_endpoints, &size);
for (size_t i = 0; i < size; ++i) {
grpc_error* error = ServerAddressParseAndAppend(lb_endpoints[i],
&locality_info->serverlist);
grpc_error* error = ServerAddressParseAndAppend(
lb_endpoints[i], &output_locality->serverlist);
if (error != GRPC_ERROR_NONE) return error;
}
// Parse the priority.
locality_info->priority =
output_locality->priority =
envoy_api_v2_endpoint_LocalityLbEndpoints_priority(locality_lb_endpoints);
return GRPC_ERROR_NONE;
}
@ -253,18 +289,13 @@ grpc_error* XdsEdsResponseDecodeAndParse(const grpc_slice& encoded_response,
envoy_api_v2_ClusterLoadAssignment_endpoints(cluster_load_assignment,
&size);
for (size_t i = 0; i < size; ++i) {
XdsLocalityInfo locality_info;
grpc_error* error = LocalityParse(endpoints[i], &locality_info);
XdsPriorityListUpdate::LocalityMap::Locality locality;
grpc_error* error = LocalityParse(endpoints[i], &locality);
if (error != GRPC_ERROR_NONE) return error;
// Filter out locality with weight 0.
if (locality_info.lb_weight == 0) continue;
update->locality_list.push_back(std::move(locality_info));
if (locality.lb_weight == 0) continue;
update->priority_list_update.Add(locality);
}
// The locality list is sorted here into deterministic order so that it's
// easier to check if two locality lists contain the same set of localities.
std::sort(update->locality_list.data(),
update->locality_list.data() + update->locality_list.size(),
XdsLocalityInfo::Less());
// Get the drop config.
update->drop_config = MakeRefCounted<XdsDropConfig>();
const envoy_api_v2_ClusterLoadAssignment_Policy* policy =

@ -23,33 +23,66 @@
#include <grpc/slice_buffer.h>
#include <stdint.h>
#include "src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.h"
#include "src/core/ext/filters/client_channel/server_address.h"
namespace grpc_core {
struct XdsLocalityInfo {
bool operator==(const XdsLocalityInfo& other) const {
return *locality_name == *other.locality_name &&
serverlist == other.serverlist && lb_weight == other.lb_weight &&
priority == other.priority;
}
// This comparator only compares the locality names.
struct Less {
bool operator()(const XdsLocalityInfo& lhs,
const XdsLocalityInfo& rhs) const {
return XdsLocalityName::Less()(lhs.locality_name, rhs.locality_name);
class XdsPriorityListUpdate {
public:
struct LocalityMap {
struct Locality {
bool operator==(const Locality& other) const {
return *name == *other.name && serverlist == other.serverlist &&
lb_weight == other.lb_weight && priority == other.priority;
}
// This comparator only compares the locality names.
struct Less {
bool operator()(const Locality& lhs, const Locality& rhs) const {
return XdsLocalityName::Less()(lhs.name, rhs.name);
}
};
RefCountedPtr<XdsLocalityName> name;
ServerAddressList serverlist;
uint32_t lb_weight;
uint32_t priority;
};
bool Contains(const RefCountedPtr<XdsLocalityName>& name) const {
return localities.find(name) != localities.end();
}
size_t size() const { return localities.size(); }
Map<RefCountedPtr<XdsLocalityName>, Locality, XdsLocalityName::Less>
localities;
};
RefCountedPtr<XdsLocalityName> locality_name;
ServerAddressList serverlist;
uint32_t lb_weight;
uint32_t priority;
};
bool operator==(const XdsPriorityListUpdate& other) const;
void Add(LocalityMap::Locality locality);
const LocalityMap* Find(uint32_t priority) const;
using XdsLocalityList = InlinedVector<XdsLocalityInfo, 1>;
bool Contains(uint32_t priority) const {
return priority < priorities_.size();
}
bool Contains(const RefCountedPtr<XdsLocalityName>& name);
bool empty() const { return priorities_.empty(); }
size_t size() const { return priorities_.size(); }
// Callers should make sure the priority list is non-empty.
uint32_t LowestPriority() const {
return static_cast<uint32_t>(priorities_.size()) - 1;
}
private:
InlinedVector<LocalityMap, 2> priorities_;
};
// There are two phases of accessing this class's content:
// 1. to initialize in the control plane combiner;
@ -93,7 +126,7 @@ class XdsDropConfig : public RefCounted<XdsDropConfig> {
};
struct XdsUpdate {
XdsLocalityList locality_list;
XdsPriorityListUpdate priority_list_update;
RefCountedPtr<XdsDropConfig> drop_config;
bool drop_all = false;
};

@ -436,7 +436,7 @@ class AresDnsResolverFactory : public ResolverFactory {
bool IsValidUri(const grpc_uri* uri) const override { return true; }
OrphanablePtr<Resolver> CreateResolver(ResolverArgs args) const override {
return OrphanablePtr<Resolver>(New<AresDnsResolver>(std::move(args)));
return MakeOrphanable<AresDnsResolver>(std::move(args));
}
const char* scheme() const override { return "dns"; }
@ -494,8 +494,7 @@ void grpc_resolver_dns_ares_init() {
}
grpc_set_resolver_impl(&ares_resolver);
grpc_core::ResolverRegistry::Builder::RegisterResolverFactory(
grpc_core::UniquePtr<grpc_core::ResolverFactory>(
grpc_core::New<grpc_core::AresDnsResolverFactory>()));
grpc_core::MakeUnique<grpc_core::AresDnsResolverFactory>());
} else {
g_use_ares_dns_resolver = false;
}

@ -171,7 +171,7 @@ class GrpcPolledFdFactoryLibuv : public GrpcPolledFdFactory {
};
UniquePtr<GrpcPolledFdFactory> NewGrpcPolledFdFactory(grpc_combiner* combiner) {
return UniquePtr<GrpcPolledFdFactory>(New<GrpcPolledFdFactoryLibuv>());
return MakeUnique<GrpcPolledFdFactoryLibuv>();
}
} // namespace grpc_core

@ -98,7 +98,7 @@ class GrpcPolledFdFactoryPosix : public GrpcPolledFdFactory {
};
UniquePtr<GrpcPolledFdFactory> NewGrpcPolledFdFactory(grpc_combiner* combiner) {
return UniquePtr<GrpcPolledFdFactory>(New<GrpcPolledFdFactoryPosix>());
return MakeUnique<GrpcPolledFdFactoryPosix>();
}
} // namespace grpc_core

@ -904,8 +904,7 @@ class GrpcPolledFdFactoryWindows : public GrpcPolledFdFactory {
};
UniquePtr<GrpcPolledFdFactory> NewGrpcPolledFdFactory(grpc_combiner* combiner) {
return UniquePtr<GrpcPolledFdFactory>(
New<GrpcPolledFdFactoryWindows>(combiner));
return MakeUnique<GrpcPolledFdFactoryWindows>(combiner);
}
} // namespace grpc_core

@ -268,7 +268,7 @@ class NativeDnsResolverFactory : public ResolverFactory {
OrphanablePtr<Resolver> CreateResolver(ResolverArgs args) const override {
if (!IsValidUri(args.uri)) return nullptr;
return OrphanablePtr<Resolver>(New<NativeDnsResolver>(std::move(args)));
return MakeOrphanable<NativeDnsResolver>(std::move(args));
}
const char* scheme() const override { return "dns"; }
@ -284,8 +284,7 @@ void grpc_resolver_dns_native_init() {
if (gpr_stricmp(resolver.get(), "native") == 0) {
gpr_log(GPR_DEBUG, "Using native dns resolver");
grpc_core::ResolverRegistry::Builder::RegisterResolverFactory(
grpc_core::UniquePtr<grpc_core::ResolverFactory>(
grpc_core::New<grpc_core::NativeDnsResolverFactory>()));
grpc_core::MakeUnique<grpc_core::NativeDnsResolverFactory>());
} else {
grpc_core::ResolverRegistry::Builder::InitRegistry();
grpc_core::ResolverFactory* existing_factory =
@ -293,8 +292,7 @@ void grpc_resolver_dns_native_init() {
if (existing_factory == nullptr) {
gpr_log(GPR_DEBUG, "Using native dns resolver");
grpc_core::ResolverRegistry::Builder::RegisterResolverFactory(
grpc_core::UniquePtr<grpc_core::ResolverFactory>(
grpc_core::New<grpc_core::NativeDnsResolverFactory>()));
grpc_core::MakeUnique<grpc_core::NativeDnsResolverFactory>());
}
}
}

@ -382,7 +382,7 @@ class FakeResolverFactory : public ResolverFactory {
bool IsValidUri(const grpc_uri* uri) const override { return true; }
OrphanablePtr<Resolver> CreateResolver(ResolverArgs args) const override {
return OrphanablePtr<Resolver>(New<FakeResolver>(std::move(args)));
return MakeOrphanable<FakeResolver>(std::move(args));
}
const char* scheme() const override { return "fake"; }
@ -394,8 +394,7 @@ class FakeResolverFactory : public ResolverFactory {
void grpc_resolver_fake_init() {
grpc_core::ResolverRegistry::Builder::RegisterResolverFactory(
grpc_core::UniquePtr<grpc_core::ResolverFactory>(
grpc_core::New<grpc_core::FakeResolverFactory>()));
grpc_core::MakeUnique<grpc_core::FakeResolverFactory>());
}
void grpc_resolver_fake_shutdown() {}

@ -119,8 +119,8 @@ OrphanablePtr<Resolver> CreateSockaddrResolver(
ServerAddressList addresses;
if (!ParseUri(args.uri, parse, &addresses)) return nullptr;
// Instantiate resolver.
return OrphanablePtr<Resolver>(
New<SockaddrResolver>(std::move(addresses), std::move(args)));
return MakeOrphanable<SockaddrResolver>(std::move(addresses),
std::move(args));
}
class IPv4ResolverFactory : public ResolverFactory {
@ -174,15 +174,12 @@ class UnixResolverFactory : public ResolverFactory {
void grpc_resolver_sockaddr_init() {
grpc_core::ResolverRegistry::Builder::RegisterResolverFactory(
grpc_core::UniquePtr<grpc_core::ResolverFactory>(
grpc_core::New<grpc_core::IPv4ResolverFactory>()));
grpc_core::MakeUnique<grpc_core::IPv4ResolverFactory>());
grpc_core::ResolverRegistry::Builder::RegisterResolverFactory(
grpc_core::UniquePtr<grpc_core::ResolverFactory>(
grpc_core::New<grpc_core::IPv6ResolverFactory>()));
grpc_core::MakeUnique<grpc_core::IPv6ResolverFactory>());
#ifdef GRPC_HAVE_UNIX_SOCKET
grpc_core::ResolverRegistry::Builder::RegisterResolverFactory(
grpc_core::UniquePtr<grpc_core::ResolverFactory>(
grpc_core::New<grpc_core::UnixResolverFactory>()));
grpc_core::MakeUnique<grpc_core::UnixResolverFactory>());
#endif
}

@ -70,7 +70,7 @@ class XdsResolverFactory : public ResolverFactory {
OrphanablePtr<Resolver> CreateResolver(ResolverArgs args) const override {
if (!IsValidUri(args.uri)) return nullptr;
return OrphanablePtr<Resolver>(New<XdsResolver>(std::move(args)));
return MakeOrphanable<XdsResolver>(std::move(args));
}
const char* scheme() const override { return "xds-experimental"; }
@ -82,8 +82,7 @@ class XdsResolverFactory : public ResolverFactory {
void grpc_resolver_xds_init() {
grpc_core::ResolverRegistry::Builder::RegisterResolverFactory(
grpc_core::UniquePtr<grpc_core::ResolverFactory>(
grpc_core::New<grpc_core::XdsResolverFactory>()));
grpc_core::MakeUnique<grpc_core::XdsResolverFactory>());
}
void grpc_resolver_xds_shutdown() {}

@ -53,9 +53,8 @@ size_t ClientChannelServiceConfigParser::ParserIndex() {
}
void ClientChannelServiceConfigParser::Register() {
g_client_channel_service_config_parser_index =
ServiceConfig::RegisterParser(UniquePtr<ServiceConfig::Parser>(
New<ClientChannelServiceConfigParser>()));
g_client_channel_service_config_parser_index = ServiceConfig::RegisterParser(
MakeUnique<ClientChannelServiceConfigParser>());
}
namespace {
@ -439,10 +438,9 @@ ClientChannelServiceConfigParser::ParseGlobalParams(const grpc_json* json,
*error = GRPC_ERROR_CREATE_FROM_VECTOR("Client channel global parser",
&error_list);
if (*error == GRPC_ERROR_NONE) {
return UniquePtr<ServiceConfig::ParsedConfig>(
New<ClientChannelGlobalParsedConfig>(
std::move(parsed_lb_config), std::move(lb_policy_name),
retry_throttling, health_check_service_name));
return MakeUnique<ClientChannelGlobalParsedConfig>(
std::move(parsed_lb_config), std::move(lb_policy_name),
retry_throttling, health_check_service_name);
}
return nullptr;
}
@ -493,9 +491,8 @@ ClientChannelServiceConfigParser::ParsePerMethodParams(const grpc_json* json,
}
*error = GRPC_ERROR_CREATE_FROM_VECTOR("Client channel parser", &error_list);
if (*error == GRPC_ERROR_NONE) {
return UniquePtr<ServiceConfig::ParsedConfig>(
New<ClientChannelMethodParsedConfig>(timeout, wait_for_ready,
std::move(retry_policy)));
return MakeUnique<ClientChannelMethodParsedConfig>(timeout, wait_for_ready,
std::move(retry_policy));
}
return nullptr;
}

@ -187,16 +187,15 @@ ResolvingLoadBalancingPolicy::ResolvingLoadBalancingPolicy(
GPR_ASSERT(process_resolver_result != nullptr);
resolver_ = ResolverRegistry::CreateResolver(
target_uri_.get(), args.args, interested_parties(), combiner(),
UniquePtr<Resolver::ResultHandler>(New<ResolverResultHandler>(Ref())));
MakeUnique<ResolverResultHandler>(Ref()));
// Since the validity of args has been checked when create the channel,
// CreateResolver() must return a non-null result.
GPR_ASSERT(resolver_ != nullptr);
if (GRPC_TRACE_FLAG_ENABLED(*tracer_)) {
gpr_log(GPR_INFO, "resolving_lb=%p: starting name resolution", this);
}
channel_control_helper()->UpdateState(
GRPC_CHANNEL_CONNECTING,
UniquePtr<SubchannelPicker>(New<QueuePicker>(Ref())));
channel_control_helper()->UpdateState(GRPC_CHANNEL_CONNECTING,
MakeUnique<QueuePicker>(Ref()));
resolver_->StartLocked();
}
@ -262,7 +261,7 @@ void ResolvingLoadBalancingPolicy::OnResolverError(grpc_error* error) {
"Resolver transient failure", &error, 1);
channel_control_helper()->UpdateState(
GRPC_CHANNEL_TRANSIENT_FAILURE,
UniquePtr<SubchannelPicker>(New<TransientFailurePicker>(state_error)));
MakeUnique<TransientFailurePicker>(state_error));
}
GRPC_ERROR_UNREF(error);
}

@ -1071,8 +1071,7 @@ bool Subchannel::PublishTransportLocked() {
}
// Start watching connected subchannel.
connected_subchannel_->StartWatch(
pollset_set_, OrphanablePtr<grpc_core::ConnectivityStateWatcherInterface>(
New<ConnectedSubchannelStateWatcher>(this)));
pollset_set_, MakeOrphanable<ConnectedSubchannelStateWatcher>(this));
// Report initial state.
SetConnectivityStateLocked(GRPC_CHANNEL_READY);
return true;

@ -88,13 +88,13 @@ UniquePtr<ServiceConfig::ParsedConfig> MessageSizeParser::ParsePerMethodParams(
*error = GRPC_ERROR_CREATE_FROM_VECTOR("Message size parser", &error_list);
return nullptr;
}
return UniquePtr<ServiceConfig::ParsedConfig>(New<MessageSizeParsedConfig>(
max_request_message_bytes, max_response_message_bytes));
return MakeUnique<MessageSizeParsedConfig>(max_request_message_bytes,
max_response_message_bytes);
}
void MessageSizeParser::Register() {
g_message_size_parser_index = ServiceConfig::RegisterParser(
UniquePtr<ServiceConfig::Parser>(New<MessageSizeParser>()));
g_message_size_parser_index =
ServiceConfig::RegisterParser(MakeUnique<MessageSizeParser>());
}
size_t MessageSizeParser::ParserIndex() { return g_message_size_parser_index; }

File diff suppressed because it is too large Load Diff

@ -1669,11 +1669,15 @@ static const maybe_complete_func_type maybe_complete_funcs[] = {
static void force_client_rst_stream(void* sp, grpc_error* error) {
grpc_chttp2_stream* s = static_cast<grpc_chttp2_stream*>(sp);
grpc_chttp2_transport* t = s->t;
if (!s->write_closed) {
grpc_chttp2_add_rst_stream_to_next_write(t, s->id, GRPC_HTTP2_NO_ERROR,
&s->stats.outgoing);
grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_FORCE_RST_STREAM);
grpc_chttp2_mark_stream_closed(t, s, true, true, GRPC_ERROR_NONE);
{
grpc_core::MutexLock lock(&t->mu);
if (!s->write_closed) {
grpc_chttp2_add_rst_stream_to_next_write(t, s->id, GRPC_HTTP2_NO_ERROR,
&s->stats.outgoing);
grpc_chttp2_initiate_write(t,
GRPC_CHTTP2_INITIATE_WRITE_FORCE_RST_STREAM);
grpc_chttp2_mark_stream_closed(t, s, true, true, GRPC_ERROR_NONE);
}
}
GRPC_CHTTP2_STREAM_UNREF(s, "final_rst");
}
@ -1740,11 +1744,12 @@ grpc_error* grpc_chttp2_header_parser_parse(void* hpack_parser,
the stream. Wait until the combiner lock is ready to be released
however -- it might be that we receive a RST_STREAM following this
and can avoid the extra write */
// TODO(yashykt) : When we were using combiners, we were using the
// finally version. Maybe do something similar?
GRPC_CHTTP2_STREAM_REF(s, "final_rst");
GRPC_CLOSURE_SCHED(
GRPC_CLOSURE_CREATE(force_client_rst_stream, s,
grpc_combiner_finally_scheduler(t->combiner)),
GRPC_ERROR_NONE);
GRPC_CLOSURE_SCHED(GRPC_CLOSURE_CREATE(force_client_rst_stream, s,
grpc_schedule_on_exec_ctx),
GRPC_ERROR_NONE);
}
grpc_chttp2_mark_stream_closed(t, s, true, false, GRPC_ERROR_NONE);
}

@ -39,6 +39,7 @@
#include "src/core/lib/channel/channelz.h"
#include "src/core/lib/compression/stream_compression.h"
#include "src/core/lib/gprpp/manual_constructor.h"
#include "src/core/lib/gprpp/sync.h"
#include "src/core/lib/iomgr/combiner.h"
#include "src/core/lib/iomgr/endpoint.h"
#include "src/core/lib/iomgr/timer.h"
@ -253,7 +254,6 @@ class Chttp2IncomingByteStream : public ByteStream {
private:
static void NextLocked(void* arg, grpc_error* error_ignored);
static void OrphanLocked(void* arg, grpc_error* error_ignored);
void MaybeCreateStreamDecompressionCtx();
@ -275,7 +275,6 @@ class Chttp2IncomingByteStream : public ByteStream {
size_t max_size_hint;
grpc_closure* on_complete;
} next_action_;
grpc_closure destroy_action_;
};
} // namespace grpc_core
@ -294,14 +293,13 @@ struct grpc_chttp2_transport {
~grpc_chttp2_transport();
grpc_transport base; /* must be first */
grpc_core::Mutex mu;
grpc_core::RefCount refs;
grpc_endpoint* ep;
char* peer_string;
grpc_resource_user* resource_user;
grpc_combiner* combiner;
grpc_closure* notify_on_receive_settings = nullptr;
/** write execution state of the transport */
@ -327,11 +325,11 @@ struct grpc_chttp2_transport {
/** maps stream id to grpc_chttp2_stream objects */
grpc_chttp2_stream_map stream_map;
grpc_closure write_action_begin_locked;
grpc_closure write_action_begin;
grpc_closure write_action;
grpc_closure write_action_end_locked;
grpc_closure write_action_end;
grpc_closure read_action_locked;
grpc_closure read_action;
/** incoming read bytes */
grpc_slice_buffer read_buffer;
@ -392,7 +390,7 @@ struct grpc_chttp2_transport {
grpc_chttp2_repeated_ping_policy ping_policy;
grpc_chttp2_repeated_ping_state ping_state;
uint64_t ping_ctr = 0; /* unique id for pings */
grpc_closure retry_initiate_ping_locked;
grpc_closure retry_initiate_ping;
/** ping acks */
size_t ping_ack_count = 0;
@ -442,9 +440,9 @@ struct grpc_chttp2_transport {
grpc_chttp2_write_cb* write_cb_pool = nullptr;
/* bdp estimator */
grpc_closure next_bdp_ping_timer_expired_locked;
grpc_closure next_bdp_ping_timer_expired;
grpc_closure start_bdp_ping_locked;
grpc_closure finish_bdp_ping_locked;
grpc_closure finish_bdp_ping;
/* if non-NULL, close the transport with this error when writes are finished
*/
@ -459,9 +457,9 @@ struct grpc_chttp2_transport {
/** have we scheduled a destructive cleanup? */
bool destructive_reclaimer_registered = false;
/** benign cleanup closure */
grpc_closure benign_reclaimer_locked;
grpc_closure benign_reclaimer;
/** destructive cleanup closure */
grpc_closure destructive_reclaimer_locked;
grpc_closure destructive_reclaimer;
/* next bdp ping timer */
bool have_next_bdp_ping_timer = false;
@ -469,13 +467,13 @@ struct grpc_chttp2_transport {
/* keep-alive ping support */
/** Closure to initialize a keepalive ping */
grpc_closure init_keepalive_ping_locked;
grpc_closure init_keepalive_ping;
/** Closure to run when the keepalive ping is sent */
grpc_closure start_keepalive_ping_locked;
/** Cousure to run when the keepalive ping ack is received */
grpc_closure finish_keepalive_ping_locked;
grpc_closure finish_keepalive_ping;
/** Closrue to run when the keepalive ping timeouts */
grpc_closure keepalive_watchdog_fired_locked;
grpc_closure keepalive_watchdog_fired;
/** timer to initiate ping events */
grpc_timer keepalive_ping_timer;
/** watchdog to kill the transport when waiting for the keepalive ping */
@ -522,7 +520,6 @@ struct grpc_chttp2_stream {
explicit Reffer(grpc_chttp2_stream* s);
} reffer;
grpc_closure destroy_stream;
grpc_closure* destroy_stream_arg;
grpc_chttp2_stream_link links[STREAM_LIST_COUNT];
@ -543,7 +540,7 @@ struct grpc_chttp2_stream {
int64_t next_message_end_offset;
int64_t flow_controlled_bytes_written = 0;
int64_t flow_controlled_bytes_flowed = 0;
grpc_closure complete_fetch_locked;
grpc_closure complete_fetch;
grpc_closure* fetching_send_message_finished = nullptr;
grpc_metadata_batch* recv_initial_metadata;

@ -97,14 +97,14 @@ static void maybe_initiate_ping(grpc_chttp2_transport* t) {
t->ping_state.is_delayed_ping_timer_set = true;
GRPC_CHTTP2_REF_TRANSPORT(t, "retry_initiate_ping_locked");
grpc_timer_init(&t->ping_state.delayed_ping_timer, next_allowed_ping,
&t->retry_initiate_ping_locked);
&t->retry_initiate_ping);
}
return;
}
pq->inflight_id = t->ping_ctr;
t->ping_ctr++;
GRPC_CLOSURE_LIST_SCHED(&pq->lists[GRPC_CHTTP2_PCL_INITIATE]);
GRPC_CLOSURE_LIST_RUN(&pq->lists[GRPC_CHTTP2_PCL_INITIATE]);
grpc_closure_list_move(&pq->lists[GRPC_CHTTP2_PCL_NEXT],
&pq->lists[GRPC_CHTTP2_PCL_INFLIGHT]);
grpc_slice_buffer_add(&t->outbuf,

@ -107,6 +107,10 @@ class InlinedVector {
return true;
}
bool operator!=(const InlinedVector& other) const {
return !(*this == other);
}
void reserve(size_t capacity) {
if (capacity > capacity_) {
T* new_dynamic =

@ -33,10 +33,8 @@
// Should not be used in new code.
// TODO(juanlishen): Remove this macro, and instead comment that the public dtor
// should not be used directly.
#define GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE \
template <typename _Delete_T, bool _Delete_can_be_null> \
friend void ::grpc_core::Delete(_Delete_T*); \
template <typename _Delete_T> \
#define GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE \
template <typename _Delete_T> \
friend void ::grpc_core::Delete(_Delete_T*);
// Add this to a class that want to use New(), but has a private or
@ -58,33 +56,28 @@ inline T* New(Args&&... args) {
}
// Alternative to delete, since we cannot use it (for fear of libstdc++)
// We cannot add a default value for can_be_null, because they are used as
// as friend template methods where we cannot define a default value.
// Instead we simply define two variants, one with and one without the boolean
// argument.
template <typename T, bool can_be_null>
template <typename T>
inline void Delete(T* p) {
GPR_DEBUG_ASSERT(can_be_null || p != nullptr);
if (can_be_null && p == nullptr) return;
if (p == nullptr) return;
p->~T();
gpr_free(p);
}
template <typename T>
inline void Delete(T* p) {
Delete<T, /*can_be_null=*/true>(p);
}
template <typename T>
class DefaultDelete {
public:
template <typename T>
void operator()(T* p) {
// std::unique_ptr is gauranteed not to call the deleter
// if the pointer is nullptr.
Delete<T, /*can_be_null=*/false>(p);
// Delete() checks whether the value is null, but std::unique_ptr<> is
// gauranteed not to call the deleter if the pointer is nullptr
// (i.e., it already does this check for us), and we don't want to
// do the check twice. So, instead of calling Delete() here, we
// manually call the object's dtor and free it.
p->~T();
gpr_free(p);
}
};
template <typename T, typename Deleter = DefaultDelete<T>>
template <typename T, typename Deleter = DefaultDelete>
using UniquePtr = std::unique_ptr<T, Deleter>;
template <typename T, typename... Args>

@ -59,13 +59,15 @@ class Orphanable {
virtual ~Orphanable() {}
};
template <typename T>
class OrphanableDelete {
public:
void operator()(T* p) { p->Orphan(); }
template <typename T>
void operator()(T* p) {
p->Orphan();
}
};
template <typename T, typename Deleter = OrphanableDelete<T>>
template <typename T, typename Deleter = OrphanableDelete>
using OrphanablePtr = std::unique_ptr<T, Deleter>;
template <typename T, typename... Args>

@ -355,4 +355,43 @@ inline void grpc_closure_list_sched(grpc_closure_list* list) {
grpc_closure_list_sched(closure_list)
#endif
#ifndef NDEBUG
inline void grpc_closure_list_run(const char* file, int line,
grpc_closure_list* list) {
#else
inline void grpc_closure_list_run(grpc_closure_list* list) {
#endif
grpc_closure* c = list->head;
while (c != nullptr) {
grpc_closure* next = c->next_data.next;
#ifndef NDEBUG
if (c->scheduled) {
gpr_log(GPR_ERROR,
"Closure already scheduled. (closure: %p, created: [%s:%d], "
"previously scheduled at: [%s: %d] run?: %s",
c, c->file_created, c->line_created, c->file_initiated,
c->line_initiated, c->run ? "true" : "false");
abort();
}
c->scheduled = true;
c->file_initiated = file;
c->line_initiated = line;
c->run = false;
GPR_ASSERT(c->cb != nullptr);
#endif
c->scheduler->vtable->run(c, c->error_data.error);
c = next;
}
list->head = list->tail = nullptr;
}
/** Schedule all closures in a list to be run. Does not need to be run from a
* safe point. */
#ifndef NDEBUG
#define GRPC_CLOSURE_LIST_RUN(closure_list) \
grpc_closure_list_run(__FILE__, __LINE__, closure_list)
#else
#define GRPC_CLOSURE_LIST_RUN(closure_list) grpc_closure_list_run(closure_list)
#endif
#endif /* GRPC_CORE_LIB_IOMGR_CLOSURE_H */

@ -465,6 +465,10 @@ void Executor::ShutdownAll() {
bool Executor::IsThreaded(ExecutorType executor_type) {
GPR_ASSERT(executor_type < ExecutorType::NUM_EXECUTORS);
Executor* executor = executors[static_cast<size_t>(executor_type)];
if (executor == nullptr) {
return false;
}
return executors[static_cast<size_t>(executor_type)]->IsThreaded();
}

@ -16,8 +16,8 @@
*
*/
#ifndef GRPC_CORE_LIB_IOMGR_GEVENT_UTIL_H
#define GRPC_CORE_LIB_IOMGR_GEVENT_UTIL_H
#ifndef GRPC_CORE_LIB_IOMGR_PYTHON_UTIL_H
#define GRPC_CORE_LIB_IOMGR_PYTHON_UTIL_H
#include <grpc/support/port_platform.h>
@ -25,8 +25,8 @@
#include <grpc/status.h>
#include "src/core/lib/iomgr/error.h"
// These are only used by the gRPC Python extension for gevent
// support. They are easier to define here (rather than in Cython)
// These are only used by the gRPC Python extensions.
// They are easier to define here (rather than in Cython)
// because Cython doesn't handle #defines well.
grpc_error* grpc_socket_error(char* error) {

@ -515,10 +515,10 @@ RefCountedPtr<Handshaker> SecurityHandshakerCreate(
void SecurityRegisterHandshakerFactories() {
HandshakerRegistry::RegisterHandshakerFactory(
false /* at_start */, HANDSHAKER_CLIENT,
UniquePtr<HandshakerFactory>(New<ClientSecurityHandshakerFactory>()));
MakeUnique<ClientSecurityHandshakerFactory>());
HandshakerRegistry::RegisterHandshakerFactory(
false /* at_start */, HANDSHAKER_SERVER,
UniquePtr<HandshakerFactory>(New<ServerSecurityHandshakerFactory>()));
MakeUnique<ServerSecurityHandshakerFactory>());
}
} // namespace grpc_core

@ -120,7 +120,11 @@ void ConnectivityStateTracker::AddWatcher(
}
watcher->Notify(current_state);
}
watchers_.insert(MakePair(watcher.get(), std::move(watcher)));
// If we're in state SHUTDOWN, don't add the watcher, so that it will
// be orphaned immediately.
if (current_state != GRPC_CHANNEL_SHUTDOWN) {
watchers_.insert(MakePair(watcher.get(), std::move(watcher)));
}
}
void ConnectivityStateTracker::RemoveWatcher(

@ -76,6 +76,10 @@ class AsyncConnectivityStateWatcherInterface
// Tracks connectivity state. Maintains a list of watchers that are
// notified whenever the state changes.
//
// Note that once the state becomes SHUTDOWN, watchers will be notified
// and then automatically orphaned (i.e., RemoveWatcher() does not need
// to be called).
class ConnectivityStateTracker {
public:
ConnectivityStateTracker(const char* name,

@ -49,8 +49,7 @@ class BoringSslCachedSession : public SslCachedSession {
grpc_core::UniquePtr<SslCachedSession> SslCachedSession::Create(
SslSessionPtr session) {
return grpc_core::UniquePtr<SslCachedSession>(
grpc_core::New<BoringSslCachedSession>(std::move(session)));
return grpc_core::MakeUnique<BoringSslCachedSession>(std::move(session));
}
} // namespace tsi

@ -67,8 +67,7 @@ class OpenSslCachedSession : public SslCachedSession {
grpc_core::UniquePtr<SslCachedSession> SslCachedSession::Create(
SslSessionPtr session) {
return grpc_core::UniquePtr<SslCachedSession>(
grpc_core::New<OpenSslCachedSession>(std::move(session)));
return grpc_core::MakeUnique<OpenSslCachedSession>(std::move(session));
}
} // namespace tsi

@ -43,7 +43,6 @@ $ sudo yum install php56w php56w-devel php-pear phpunit gcc zlib-devel
**Install PHP and PECL on Mac:**
```sh
$ brew install homebrew/php/php56-grpc
$ curl -O http://pear.php.net/go-pear.phar
$ sudo php -d detect_unicode=0 go-pear.phar
```

@ -23,7 +23,7 @@ cdef extern from "src/core/lib/iomgr/error.h":
# TODO(https://github.com/grpc/grpc/issues/20135) Change the filename
# for something more meaningful.
cdef extern from "src/core/lib/iomgr/gevent_util.h":
cdef extern from "src/core/lib/iomgr/python_util.h":
grpc_error* grpc_socket_error(char* error)
char* grpc_slice_buffer_start(grpc_slice_buffer* buffer, int i)
int grpc_slice_buffer_length(grpc_slice_buffer* buffer, int i)

@ -119,7 +119,7 @@ static void grpc_rb_channel_watch_connection_state_op_complete(
GPR_ASSERT(!op->op.api_callback_args.called_back);
op->op.api_callback_args.called_back = 1;
op->op.api_callback_args.success = success;
// wake up the watch API call thats waiting on this op
// wake up the watch API call that's waiting on this op
gpr_cv_broadcast(&global_connection_polling_cv);
}

@ -27,4 +27,5 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)

@ -35,4 +35,5 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)

@ -46,4 +46,5 @@ def grpc_bad_ssl_tests():
deps = ['//test/core/util:grpc_test_util',
'//:gpr',
'//test/core/end2end:cq_verifier'],
tags = ["no_windows"],
)

@ -27,6 +27,7 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -38,6 +39,7 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -60,6 +62,7 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -107,6 +110,7 @@ grpc_cc_test(
"//:grpc++",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -120,4 +124,5 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)

@ -30,6 +30,7 @@ grpc_fuzzer(
"//:grpc",
"//test/core/util:grpc_test_util",
],
tags = ["no_windows"],
)
grpc_cc_test(
@ -53,6 +54,7 @@ grpc_cc_test(
"//test/core/util:grpc_test_util",
],
tags = ["no_windows"],
uses_polling = False,
)
grpc_cc_test(
@ -78,6 +80,7 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(

@ -35,12 +35,6 @@ class TestResultHandler : public grpc_core::Resolver::ResultHandler {
void ReturnError(grpc_error* error) override {}
};
static grpc_core::UniquePtr<grpc_core::Resolver::ResultHandler>
create_test_result_handler() {
return grpc_core::UniquePtr<grpc_core::Resolver::ResultHandler>(
grpc_core::New<TestResultHandler>());
}
static void test_succeeds(grpc_core::ResolverFactory* factory,
const char* string) {
gpr_log(GPR_DEBUG, "test: '%s' should be valid for '%s'", string,
@ -51,7 +45,7 @@ static void test_succeeds(grpc_core::ResolverFactory* factory,
grpc_core::ResolverArgs args;
args.uri = uri;
args.combiner = g_combiner;
args.result_handler = create_test_result_handler();
args.result_handler = grpc_core::MakeUnique<TestResultHandler>();
grpc_core::OrphanablePtr<grpc_core::Resolver> resolver =
factory->CreateResolver(std::move(args));
GPR_ASSERT(resolver != nullptr);
@ -68,7 +62,7 @@ static void test_fails(grpc_core::ResolverFactory* factory,
grpc_core::ResolverArgs args;
args.uri = uri;
args.combiner = g_combiner;
args.result_handler = create_test_result_handler();
args.result_handler = grpc_core::MakeUnique<TestResultHandler>();
grpc_core::OrphanablePtr<grpc_core::Resolver> resolver =
factory->CreateResolver(std::move(args));
GPR_ASSERT(resolver == nullptr);

@ -47,9 +47,7 @@ static void test_succeeds(grpc_core::ResolverFactory* factory,
grpc_core::ResolverArgs args;
args.uri = uri;
args.combiner = g_combiner;
args.result_handler =
grpc_core::UniquePtr<grpc_core::Resolver::ResultHandler>(
grpc_core::New<ResultHandler>());
args.result_handler = grpc_core::MakeUnique<ResultHandler>();
grpc_core::OrphanablePtr<grpc_core::Resolver> resolver =
factory->CreateResolver(std::move(args));
GPR_ASSERT(resolver != nullptr);
@ -70,9 +68,7 @@ static void test_fails(grpc_core::ResolverFactory* factory,
grpc_core::ResolverArgs args;
args.uri = uri;
args.combiner = g_combiner;
args.result_handler =
grpc_core::UniquePtr<grpc_core::Resolver::ResultHandler>(
grpc_core::New<ResultHandler>());
args.result_handler = grpc_core::MakeUnique<ResultHandler>();
grpc_core::OrphanablePtr<grpc_core::Resolver> resolver =
factory->CreateResolver(std::move(args));
GPR_ASSERT(resolver == nullptr);

@ -60,8 +60,7 @@ class TestParser1 : public ServiceConfig::Parser {
GRPC_ERROR_CREATE_FROM_STATIC_STRING(InvalidValueErrorMessage());
return nullptr;
}
return UniquePtr<ServiceConfig::ParsedConfig>(
New<TestParsedConfig1>(value));
return MakeUnique<TestParsedConfig1>(value);
}
}
return nullptr;
@ -98,8 +97,7 @@ class TestParser2 : public ServiceConfig::Parser {
GRPC_ERROR_CREATE_FROM_STATIC_STRING(InvalidValueErrorMessage());
return nullptr;
}
return UniquePtr<ServiceConfig::ParsedConfig>(
New<TestParsedConfig1>(value));
return MakeUnique<TestParsedConfig1>(value);
}
}
return nullptr;
@ -148,10 +146,8 @@ class ServiceConfigTest : public ::testing::Test {
void SetUp() override {
ServiceConfig::Shutdown();
ServiceConfig::Init();
EXPECT_TRUE(ServiceConfig::RegisterParser(
UniquePtr<ServiceConfig::Parser>(New<TestParser1>())) == 0);
EXPECT_TRUE(ServiceConfig::RegisterParser(
UniquePtr<ServiceConfig::Parser>(New<TestParser2>())) == 1);
EXPECT_TRUE(ServiceConfig::RegisterParser(MakeUnique<TestParser1>()) == 0);
EXPECT_TRUE(ServiceConfig::RegisterParser(MakeUnique<TestParser2>()) == 1);
}
};
@ -312,10 +308,8 @@ class ErroredParsersScopingTest : public ::testing::Test {
void SetUp() override {
ServiceConfig::Shutdown();
ServiceConfig::Init();
EXPECT_TRUE(ServiceConfig::RegisterParser(
UniquePtr<ServiceConfig::Parser>(New<ErrorParser>())) == 0);
EXPECT_TRUE(ServiceConfig::RegisterParser(
UniquePtr<ServiceConfig::Parser>(New<ErrorParser>())) == 1);
EXPECT_TRUE(ServiceConfig::RegisterParser(MakeUnique<ErrorParser>()) == 0);
EXPECT_TRUE(ServiceConfig::RegisterParser(MakeUnique<ErrorParser>()) == 1);
}
};
@ -359,10 +353,9 @@ class ClientChannelParserTest : public ::testing::Test {
void SetUp() override {
ServiceConfig::Shutdown();
ServiceConfig::Init();
EXPECT_TRUE(
ServiceConfig::RegisterParser(UniquePtr<ServiceConfig::Parser>(
New<grpc_core::internal::ClientChannelServiceConfigParser>())) ==
0);
EXPECT_TRUE(ServiceConfig::RegisterParser(
MakeUnique<internal::ClientChannelServiceConfigParser>()) ==
0);
}
};
@ -929,8 +922,8 @@ class MessageSizeParserTest : public ::testing::Test {
void SetUp() override {
ServiceConfig::Shutdown();
ServiceConfig::Init();
EXPECT_TRUE(ServiceConfig::RegisterParser(UniquePtr<ServiceConfig::Parser>(
New<MessageSizeParser>())) == 0);
EXPECT_TRUE(
ServiceConfig::RegisterParser(MakeUnique<MessageSizeParser>()) == 0);
}
};

@ -27,6 +27,7 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -38,6 +39,7 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -49,6 +51,7 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -60,4 +63,5 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)

@ -30,4 +30,5 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)

@ -117,6 +117,7 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
tags = ["no_windows"],
)
grpc_cc_test(
@ -141,6 +142,7 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(

@ -33,6 +33,7 @@ grpc_fuzzer(
"//test/core/end2end:ssl_test_data",
"//test/core/util:grpc_test_util",
],
tags = ["no_windows"],
)
grpc_fuzzer(
@ -45,6 +46,7 @@ grpc_fuzzer(
"//:grpc",
"//test/core/util:grpc_test_util",
],
tags = ["no_windows"],
)
grpc_fuzzer(
@ -57,4 +59,5 @@ grpc_fuzzer(
"//:grpc",
"//test/core/util:grpc_test_util",
],
tags = ["no_windows"],
)

@ -46,7 +46,7 @@ def _fixture_options(
supports_write_buffering = supports_write_buffering,
client_channel = client_channel,
supports_msvc = supports_msvc,
#_platforms=_platforms,
_platforms=_platforms,
)
# maps fixture name to whether it requires the security library
@ -368,6 +368,16 @@ def _compatible(fopt, topt):
return False
return True
def _platform_support_tags(fopt):
result = []
if not "windows" in fopt._platforms:
result += ["no_windows"]
if not "mac" in fopt._platforms:
result += ["no_mac"]
if not "linux" in fopt._platforms:
result += ["no_linux"]
return result
def grpc_end2end_tests():
grpc_cc_library(
name = "end2end_tests",
@ -386,8 +396,7 @@ def grpc_end2end_tests():
":http_proxy",
":proxy",
":local_util",
],
tags = ["no_windows"],
]
)
for f, fopt in END2END_FIXTURES.items():
@ -401,12 +410,25 @@ def grpc_end2end_tests():
"//:grpc",
"//:gpr",
],
tags = ["no_windows"],
tags = _platform_support_tags(fopt),
)
for t, topt in END2END_TESTS.items():
#print(_compatible(fopt, topt), f, t, fopt, topt)
if not _compatible(fopt, topt):
continue
native.sh_test(
name = "%s_test@%s" % (f, t),
data = [":%s_test" % f],
srcs = ["end2end_test.sh"],
args = [
"$(location %s_test)" % f,
t
],
tags = ["no_linux"] + _platform_support_tags(fopt),
)
for poller in POLLERS:
native.sh_test(
name = "%s_test@%s@poller=%s" % (f, t, poller),
@ -417,7 +439,7 @@ def grpc_end2end_tests():
t,
poller,
],
tags = ["no_windows"],
tags = ["no_mac", "no_windows"],
)
def grpc_end2end_nosec_tests():
@ -439,8 +461,7 @@ def grpc_end2end_nosec_tests():
":http_proxy",
":proxy",
":local_util",
],
tags = ["no_windows"],
]
)
for f, fopt in END2END_NOSEC_FIXTURES.items():
@ -456,7 +477,7 @@ def grpc_end2end_nosec_tests():
"//:grpc_unsecure",
"//:gpr",
],
tags = ["no_windows"],
tags = _platform_support_tags(fopt),
)
for t, topt in END2END_TESTS.items():
#print(_compatible(fopt, topt), f, t, fopt, topt)
@ -464,6 +485,18 @@ def grpc_end2end_nosec_tests():
continue
if topt.secure:
continue
native.sh_test(
name = "%s_nosec_test@%s" % (f, t),
data = [":%s_nosec_test" % f],
srcs = ["end2end_test.sh"],
args = [
"$(location %s_nosec_test)" % f,
t
],
tags = ["no_linux"] + _platform_support_tags(fopt),
)
for poller in POLLERS:
native.sh_test(
name = "%s_nosec_test@%s@poller=%s" % (f, t, poller),
@ -474,5 +507,5 @@ def grpc_end2end_nosec_tests():
t,
poller,
],
tags = ["no_windows"],
tags = ["no_mac", "no_windows"],
)

@ -59,6 +59,7 @@ grpc_cc_test(
"//test/core/end2end:ssl_test_data",
"//test/core/util:grpc_test_util",
],
tags = ["no_windows"],
)
grpc_cc_test(
@ -74,4 +75,5 @@ grpc_cc_test(
"//test/core/end2end:ssl_test_data",
"//test/core/util:grpc_test_util",
],
tags = ["no_windows"],
)

@ -26,6 +26,7 @@ grpc_cc_test(
"//:gpr",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -36,6 +37,7 @@ grpc_cc_test(
"//:gpr",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -46,6 +48,7 @@ grpc_cc_test(
"//:gpr",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -56,6 +59,7 @@ grpc_cc_test(
"//:gpr",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -66,6 +70,7 @@ grpc_cc_test(
"//:gpr",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -76,6 +81,7 @@ grpc_cc_test(
"//:gpr",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -86,6 +92,7 @@ grpc_cc_test(
"//:gpr",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -96,6 +103,7 @@ grpc_cc_test(
"//:gpr",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -106,6 +114,7 @@ grpc_cc_test(
"//:gpr",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -116,6 +125,7 @@ grpc_cc_test(
"//:gpr",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -126,6 +136,7 @@ grpc_cc_test(
"//:gpr",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -136,4 +147,5 @@ grpc_cc_test(
"//:gpr",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)

@ -22,10 +22,12 @@ grpc_cc_test(
name = "fork_test",
srcs = ["fork_test.cc"],
language = "C++",
tags = ["no_windows"],
deps = [
"//:gpr",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -39,6 +41,7 @@ grpc_cc_test(
"//:gpr",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -48,10 +51,12 @@ grpc_cc_test(
"gtest",
],
language = "C++",
tags = ["no_windows"], # TODO(jtattermusch): fix the failure on windows
deps = [
"//:gpr",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -62,6 +67,7 @@ grpc_cc_test(
"//:gpr",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -72,6 +78,7 @@ grpc_cc_test(
"//:gpr",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -85,6 +92,7 @@ grpc_cc_test(
"//:gpr_base",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -98,6 +106,7 @@ grpc_cc_test(
"//:gpr_base",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -118,10 +127,12 @@ grpc_cc_test(
srcs = ["mpscq_test.cc"],
exec_compatible_with = ["//third_party/toolchains/machine_size:large"],
language = "C++",
tags = ["no_windows"], # machine_size:large is not configured for windows RBE
deps = [
"//:gpr",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -198,4 +209,5 @@ grpc_cc_test(
"//:gpr",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)

@ -127,6 +127,24 @@ TEST(InlinedVectorTest, EqualOperator) {
EXPECT_FALSE(v1 == v2);
}
TEST(InlinedVectorTest, NotEqualOperator) {
constexpr int kNumElements = 10;
// Both v1 and v2 are empty.
InlinedVector<int, 5> v1;
InlinedVector<int, 5> v2;
EXPECT_FALSE(v1 != v2);
// Both v1 and v2 contains the same data.
FillVector(&v1, kNumElements);
FillVector(&v2, kNumElements);
EXPECT_FALSE(v1 != v2);
// The sizes of v1 and v2 are different.
v1.push_back(0);
EXPECT_TRUE(v1 != v2);
// The contents of v1 and v2 are different although their sizes are the same.
v2.push_back(1);
EXPECT_TRUE(v1 != v2);
}
// the following constants and typedefs are used for copy/move
// construction/assignment
const size_t kInlinedLength = 8;

@ -97,4 +97,5 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
tags = ["no_windows"],
)

@ -81,7 +81,7 @@ int main(int argc, char* argv[]) {
grpc_init();
HandshakerRegistry::RegisterHandshakerFactory(
true /* at_start */, HANDSHAKER_SERVER,
UniquePtr<HandshakerFactory>(New<ReadAheadHandshakerFactory>()));
MakeUnique<ReadAheadHandshakerFactory>());
const char* full_alpn_list[] = {"grpc-exp", "h2"};
GPR_ASSERT(server_ssl_test(full_alpn_list, 2, "grpc-exp"));
grpc_shutdown_blocking();

@ -30,6 +30,7 @@ grpc_fuzzer(
"//:grpc",
"//test/core/util:grpc_test_util",
],
tags = ["no_windows"],
)
grpc_fuzzer(
@ -42,6 +43,7 @@ grpc_fuzzer(
"//:grpc",
"//test/core/util:grpc_test_util",
],
tags = ["no_windows"],
)
# Copyright 2017 gRPC authors.
@ -78,6 +80,7 @@ grpc_cc_test(
"//test/core/end2end:ssl_test_data",
"//test/core/util:grpc_test_util",
],
tags = ["no_windows"],
)
grpc_cc_test(
@ -97,6 +100,7 @@ grpc_cc_test(
"//test/core/end2end:ssl_test_data",
"//test/core/util:grpc_test_util",
],
tags = ["no_windows"],
)
grpc_cc_test(
@ -109,6 +113,7 @@ grpc_cc_test(
"//test/core/end2end:ssl_test_data",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(

@ -41,6 +41,7 @@ grpc_cc_test(
srcs = ["combiner_test.cc"],
exec_compatible_with = ["//third_party/toolchains/machine_size:large"],
language = "C++",
tags = ["no_windows"], # machine_size:large is not configured for windows RBE
deps = [
"//:gpr",
"//:grpc",
@ -70,6 +71,7 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -128,6 +130,7 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -139,6 +142,7 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -290,6 +294,7 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -301,6 +306,7 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -312,6 +318,7 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -323,6 +330,7 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(

@ -30,6 +30,7 @@ grpc_fuzzer(
"//:grpc",
"//test/core/util:grpc_test_util",
],
tags = ["no_windows"],
)
grpc_cc_binary(
@ -59,6 +60,7 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -70,6 +72,7 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -81,4 +84,5 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)

@ -49,9 +49,11 @@ grpc_cc_test(
":memory_usage_server",
],
language = "C++",
tags = ["no_windows"], # TODO(jtattermusch): breaks windows RBE build if enabled
deps = [
"//:gpr",
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)

@ -30,6 +30,7 @@ grpc_fuzzer(
"//:grpc",
"//test/core/util:grpc_test_util",
],
tags = ["no_windows"],
)
grpc_fuzzer(
@ -42,4 +43,5 @@ grpc_fuzzer(
"//:grpc",
"//test/core/util:grpc_test_util",
],
tags = ["no_windows"],
)

@ -30,6 +30,7 @@ grpc_fuzzer(
"//:grpc",
"//test/core/util:grpc_test_util",
],
tags = ["no_windows"],
)
grpc_fuzzer(
@ -43,6 +44,7 @@ grpc_fuzzer(
"//test/core/end2end:ssl_test_data",
"//test/core/util:grpc_test_util",
],
tags = ["no_windows"],
)
grpc_cc_library(
@ -63,6 +65,7 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -98,6 +101,7 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -109,6 +113,7 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(

@ -30,6 +30,7 @@ grpc_fuzzer(
"//:grpc",
"//test/core/util:grpc_test_util",
],
tags = ["no_windows"],
)
grpc_fuzzer(
@ -42,6 +43,7 @@ grpc_fuzzer(
"//:grpc",
"//test/core/util:grpc_test_util",
],
tags = ["no_windows"],
)
grpc_cc_test(
@ -53,6 +55,7 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -64,6 +67,7 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -75,6 +79,7 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -86,6 +91,7 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -100,6 +106,7 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -114,6 +121,7 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -125,4 +133,5 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)

@ -27,6 +27,7 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -82,6 +83,7 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(

@ -44,9 +44,7 @@ static void do_nothing(void* arg, grpc_error* error) {}
void test_transport_op(grpc_channel* channel) {
grpc_core::ExecCtx exec_ctx;
grpc_transport_op* op = grpc_make_transport_op(nullptr);
op->start_connectivity_watch =
grpc_core::OrphanablePtr<grpc_core::ConnectivityStateWatcherInterface>(
grpc_core::New<Watcher>());
op->start_connectivity_watch = grpc_core::MakeOrphanable<Watcher>();
grpc_channel_element* elem =
grpc_channel_stack_element(grpc_channel_get_channel_stack(channel), 0);
elem->filter->start_transport_op(elem, op);

@ -25,11 +25,13 @@ grpc_cc_test(
"gtest",
],
language = "C++",
tags = ["no_windows"], # TODO(jtattermusch): investigate the timeout on windows
deps = [
"//:gpr",
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -44,6 +46,7 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -108,6 +111,7 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -119,6 +123,7 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -130,6 +135,7 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -143,4 +149,5 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)

@ -28,6 +28,7 @@ grpc_fuzzer(
"//:grpc",
"//test/core/util:grpc_test_util",
],
tags = ["no_windows"],
)
grpc_cc_test(
@ -50,6 +51,7 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -61,6 +63,7 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -75,6 +78,7 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -86,6 +90,7 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -97,6 +102,7 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -108,6 +114,7 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -144,4 +151,5 @@ grpc_cc_test(
"//:grpc",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)

@ -73,8 +73,7 @@ TEST(StateTracker, NotificationUponAddingWatcher) {
grpc_connectivity_state state = GRPC_CHANNEL_IDLE;
ConnectivityStateTracker tracker("xxx", GRPC_CHANNEL_CONNECTING);
tracker.AddWatcher(GRPC_CHANNEL_IDLE,
OrphanablePtr<ConnectivityStateWatcherInterface>(
New<Watcher>(&count, &state)));
MakeOrphanable<Watcher>(&count, &state));
EXPECT_EQ(count, 1);
EXPECT_EQ(state, GRPC_CHANNEL_CONNECTING);
}
@ -84,8 +83,7 @@ TEST(StateTracker, NotificationUponStateChange) {
grpc_connectivity_state state = GRPC_CHANNEL_IDLE;
ConnectivityStateTracker tracker("xxx", GRPC_CHANNEL_IDLE);
tracker.AddWatcher(GRPC_CHANNEL_IDLE,
OrphanablePtr<ConnectivityStateWatcherInterface>(
New<Watcher>(&count, &state)));
MakeOrphanable<Watcher>(&count, &state));
EXPECT_EQ(count, 0);
EXPECT_EQ(state, GRPC_CHANNEL_IDLE);
tracker.SetState(GRPC_CHANNEL_CONNECTING, "whee");
@ -113,14 +111,47 @@ TEST(StateTracker, SubscribeThenUnsubscribe) {
EXPECT_EQ(state, GRPC_CHANNEL_IDLE);
}
TEST(StateTracker, OrphanUponShutdown) {
int count = 0;
grpc_connectivity_state state = GRPC_CHANNEL_IDLE;
bool destroyed = false;
ConnectivityStateTracker tracker("xxx", GRPC_CHANNEL_IDLE);
ConnectivityStateWatcherInterface* watcher =
New<Watcher>(&count, &state, &destroyed);
tracker.AddWatcher(GRPC_CHANNEL_IDLE,
OrphanablePtr<ConnectivityStateWatcherInterface>(watcher));
// No initial notification, since we started the watch from the
// current state.
EXPECT_EQ(count, 0);
EXPECT_EQ(state, GRPC_CHANNEL_IDLE);
// Set state to SHUTDOWN.
tracker.SetState(GRPC_CHANNEL_SHUTDOWN, "shutting down");
EXPECT_TRUE(destroyed);
EXPECT_EQ(count, 1);
EXPECT_EQ(state, GRPC_CHANNEL_SHUTDOWN);
}
TEST(StateTracker, AddWhenAlreadyShutdown) {
int count = 0;
grpc_connectivity_state state = GRPC_CHANNEL_IDLE;
bool destroyed = false;
ConnectivityStateTracker tracker("xxx", GRPC_CHANNEL_SHUTDOWN);
ConnectivityStateWatcherInterface* watcher =
New<Watcher>(&count, &state, &destroyed);
tracker.AddWatcher(GRPC_CHANNEL_IDLE,
OrphanablePtr<ConnectivityStateWatcherInterface>(watcher));
EXPECT_TRUE(destroyed);
EXPECT_EQ(count, 1);
EXPECT_EQ(state, GRPC_CHANNEL_SHUTDOWN);
}
TEST(StateTracker, NotifyShutdownAtDestruction) {
int count = 0;
grpc_connectivity_state state = GRPC_CHANNEL_IDLE;
{
ConnectivityStateTracker tracker("xxx", GRPC_CHANNEL_IDLE);
tracker.AddWatcher(GRPC_CHANNEL_IDLE,
OrphanablePtr<ConnectivityStateWatcherInterface>(
New<Watcher>(&count, &state)));
MakeOrphanable<Watcher>(&count, &state));
// No initial notification, since we started the watch from the
// current state.
EXPECT_EQ(count, 0);
@ -137,8 +168,7 @@ TEST(StateTracker, DoNotNotifyShutdownAtDestructionIfAlreadyInShutdown) {
{
ConnectivityStateTracker tracker("xxx", GRPC_CHANNEL_SHUTDOWN);
tracker.AddWatcher(GRPC_CHANNEL_SHUTDOWN,
OrphanablePtr<ConnectivityStateWatcherInterface>(
New<Watcher>(&count, &state)));
MakeOrphanable<Watcher>(&count, &state));
// No initial notification, since we started the watch from the
// current state.
EXPECT_EQ(count, 0);

@ -85,6 +85,7 @@ grpc_cc_test(
"//:tsi",
"//test/core/util:grpc_test_util",
],
tags = ["no_windows"],
)
grpc_cc_test(

@ -119,6 +119,7 @@ grpc_cc_test(
":grpc_test_util",
"//:gpr",
],
uses_polling = False,
)
grpc_cc_library(
@ -145,6 +146,7 @@ grpc_cc_test(
":grpc_test_util",
"//:gpr",
],
uses_polling = False,
)
sh_library(

@ -219,9 +219,8 @@ class InterceptTrailingFactory : public LoadBalancingPolicyFactory {
OrphanablePtr<LoadBalancingPolicy> CreateLoadBalancingPolicy(
LoadBalancingPolicy::Args args) const override {
return OrphanablePtr<LoadBalancingPolicy>(
New<InterceptRecvTrailingMetadataLoadBalancingPolicy>(std::move(args),
cb_, user_data_));
return MakeOrphanable<InterceptRecvTrailingMetadataLoadBalancingPolicy>(
std::move(args), cb_, user_data_);
}
const char* name() const override {

@ -22,3 +22,7 @@ signed-integer-overflow:chrono
enum:grpc_http2_error_to_grpc_status
enum:grpc_chttp2_cancel_stream
enum:api_fuzzer
# TODO(juanlishen): Remove this supression after
# https://github.com/GoogleCloudPlatform/layer-definitions/issues/531 is
# addressed.
alignment:grpc_core::XdsPriorityListUpdate::*

@ -28,6 +28,7 @@ grpc_cc_test(
"//:grpc++",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -40,6 +41,7 @@ grpc_cc_test(
"//:grpc++",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -53,6 +55,7 @@ grpc_cc_test(
"//:grpc++",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_binary(

@ -24,6 +24,7 @@ grpc_cc_test(
external_deps = [
"gtest",
],
tags = ["no_windows"], # TODO(jtattermusch): fix test on windows RBE
deps = [
"//:grpc++_unsecure",
"//test/core/util:grpc_test_util_unsecure",
@ -66,6 +67,7 @@ grpc_cc_test(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -78,6 +80,7 @@ grpc_cc_test(
"//:grpc++",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -90,6 +93,7 @@ grpc_cc_test(
"//:grpc++",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(

@ -122,7 +122,7 @@ grpc_cc_test(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
tags = ["no_test_ios"],
tags = ["no_test_ios", "no_windows"],
)
grpc_cc_binary(
@ -442,6 +442,7 @@ grpc_cc_test(
"//test/core/util:test_lb_policies",
"//test/cpp/util:test_util",
],
tags = ["no_windows"], # TODO(jtattermusch): fix test on windows
)
grpc_cc_test(
@ -482,6 +483,7 @@ grpc_cc_test(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
tags = ["no_windows"], # TODO(jtattermusch): fix test on windows
)
grpc_cc_test(
@ -505,6 +507,7 @@ grpc_cc_test(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
tags = ["no_windows"], # TODO(jtattermusch): fix test on windows
)
grpc_cc_test(
@ -567,7 +570,7 @@ grpc_cc_test(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
tags = ["no_test_ios"],
tags = ["no_test_ios", "no_windows"],
)
grpc_cc_binary(
@ -621,7 +624,7 @@ grpc_cc_test(
"//src/proto/grpc/testing:echo_proto",
"//test/cpp/util:test_util",
],
tags = ["no_test_ios"],
tags = ["no_test_ios", "no_windows"],
)
grpc_cc_test(
@ -687,6 +690,7 @@ grpc_cc_test(
external_deps = [
"gtest",
],
tags = ["no_windows"], # TODO(jtattermusch): fix test on windows
deps = [
"//:gpr",
"//:grpc",

@ -99,6 +99,7 @@ constexpr char kDefaultLocalityZone[] = "xds_default_locality_zone";
constexpr char kLbDropType[] = "lb";
constexpr char kThrottleDropType[] = "throttle";
constexpr int kDefaultLocalityWeight = 3;
constexpr int kDefaultLocalityPriority = 0;
template <typename ServiceType>
class CountedService : public ServiceType {
@ -262,7 +263,8 @@ class EdsServiceImpl : public EdsService {
struct ResponseArgs {
struct Locality {
Locality(const grpc::string& sub_zone, std::vector<int> ports,
int lb_weight = kDefaultLocalityWeight, int priority = 0)
int lb_weight = kDefaultLocalityWeight,
int priority = kDefaultLocalityPriority)
: sub_zone(std::move(sub_zone)),
ports(std::move(ports)),
lb_weight(lb_weight),
@ -566,7 +568,7 @@ class XdsEnd2endTest : public ::testing::Test {
void ShutdownBackend(size_t index) { backends_[index]->Shutdown(); }
void ResetStub(int fallback_timeout = 0,
void ResetStub(int fallback_timeout = 0, int failover_timeout = 0,
const grpc::string& expected_targets = "",
grpc::string scheme = "") {
ChannelArguments args;
@ -574,6 +576,9 @@ class XdsEnd2endTest : public ::testing::Test {
if (fallback_timeout > 0) {
args.SetInt(GRPC_ARG_XDS_FALLBACK_TIMEOUT_MS, fallback_timeout);
}
if (failover_timeout > 0) {
args.SetInt(GRPC_ARG_XDS_FAILOVER_TIMEOUT_MS, failover_timeout);
}
args.SetPointer(GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR,
response_generator_.get());
if (!expected_targets.empty()) {
@ -922,7 +927,7 @@ class XdsResolverTest : public XdsEnd2endTest {
// used.
TEST_F(XdsResolverTest, XdsResolverIsUsed) {
// Use xds-experimental scheme in URI.
ResetStub(0, "", "xds-experimental");
ResetStub(0, 0, "", "xds-experimental");
// Send an RPC to trigger resolution.
auto unused_result = SendRpc();
// Xds resolver returns xds_experimental as the LB policy.
@ -1067,7 +1072,7 @@ using SecureNamingTest = BasicTest;
// Tests that secure naming check passes if target name is expected.
TEST_F(SecureNamingTest, TargetNameIsExpected) {
// TODO(juanlishen): Use separate fake creds for the balancer channel.
ResetStub(0, kApplicationTargetName_ + ";lb");
ResetStub(0, 0, kApplicationTargetName_ + ";lb");
SetNextResolution({}, kDefaultServiceConfig_.c_str());
SetNextResolutionForLbChannel({balancers_[0]->port()});
const size_t kNumRpcsPerAddress = 100;
@ -1098,7 +1103,7 @@ TEST_F(SecureNamingTest, TargetNameIsUnexpected) {
// the name from the balancer doesn't match expectations.
ASSERT_DEATH_IF_SUPPORTED(
{
ResetStub(0, kApplicationTargetName_ + ";lb");
ResetStub(0, 0, kApplicationTargetName_ + ";lb");
SetNextResolution({},
"{\n"
" \"loadBalancingConfig\":[\n"
@ -1287,6 +1292,151 @@ TEST_F(LocalityMapTest, UpdateMap) {
EXPECT_EQ(2U, balancers_[0]->eds_service()->response_count());
}
class FailoverTest : public BasicTest {
public:
FailoverTest() { ResetStub(0, 100, "", ""); }
};
// Localities with the highest priority are used when multiple priority exist.
TEST_F(FailoverTest, ChooseHighestPriority) {
SetNextResolution({}, kDefaultServiceConfig_.c_str());
SetNextResolutionForLbChannelAllBalancers();
EdsServiceImpl::ResponseArgs args({
{"locality0", GetBackendPorts(0, 1), kDefaultLocalityWeight, 1},
{"locality1", GetBackendPorts(1, 2), kDefaultLocalityWeight, 2},
{"locality2", GetBackendPorts(2, 3), kDefaultLocalityWeight, 3},
{"locality3", GetBackendPorts(3, 4), kDefaultLocalityWeight, 0},
});
ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), 0);
WaitForBackend(3, false);
for (size_t i = 0; i < 3; ++i) {
EXPECT_EQ(0, backends_[i]->backend_service()->request_count());
}
// The EDS service got a single request, and sent a single response.
EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count());
EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count());
}
// If the higher priority localities are not reachable, failover to the highest
// priority among the rest.
TEST_F(FailoverTest, Failover) {
SetNextResolution({}, kDefaultServiceConfig_.c_str());
SetNextResolutionForLbChannelAllBalancers();
EdsServiceImpl::ResponseArgs args({
{"locality0", GetBackendPorts(0, 1), kDefaultLocalityWeight, 1},
{"locality1", GetBackendPorts(1, 2), kDefaultLocalityWeight, 2},
{"locality2", GetBackendPorts(2, 3), kDefaultLocalityWeight, 3},
{"locality3", GetBackendPorts(3, 4), kDefaultLocalityWeight, 0},
});
ShutdownBackend(3);
ShutdownBackend(0);
ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), 0);
WaitForBackend(1, false);
for (size_t i = 0; i < 4; ++i) {
if (i == 1) continue;
EXPECT_EQ(0, backends_[i]->backend_service()->request_count());
}
// The EDS service got a single request, and sent a single response.
EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count());
EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count());
}
// If a locality with higher priority than the current one becomes ready,
// switch to it.
TEST_F(FailoverTest, SwitchBackToHigherPriority) {
SetNextResolution({}, kDefaultServiceConfig_.c_str());
SetNextResolutionForLbChannelAllBalancers();
const size_t kNumRpcs = 100;
EdsServiceImpl::ResponseArgs args({
{"locality0", GetBackendPorts(0, 1), kDefaultLocalityWeight, 1},
{"locality1", GetBackendPorts(1, 2), kDefaultLocalityWeight, 2},
{"locality2", GetBackendPorts(2, 3), kDefaultLocalityWeight, 3},
{"locality3", GetBackendPorts(3, 4), kDefaultLocalityWeight, 0},
});
ShutdownBackend(3);
ShutdownBackend(0);
ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), 0);
WaitForBackend(1, false);
for (size_t i = 0; i < 4; ++i) {
if (i == 1) continue;
EXPECT_EQ(0, backends_[i]->backend_service()->request_count());
}
StartBackend(0);
WaitForBackend(0);
CheckRpcSendOk(kNumRpcs);
EXPECT_EQ(kNumRpcs, backends_[0]->backend_service()->request_count());
// The EDS service got a single request, and sent a single response.
EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count());
EXPECT_EQ(1U, balancers_[0]->eds_service()->response_count());
}
// The first update only contains unavailable priorities. The second update
// contains available priorities.
TEST_F(FailoverTest, UpdateInitialUnavailable) {
SetNextResolution({}, kDefaultServiceConfig_.c_str());
SetNextResolutionForLbChannelAllBalancers();
EdsServiceImpl::ResponseArgs args({
{"locality0", GetBackendPorts(0, 1), kDefaultLocalityWeight, 0},
{"locality1", GetBackendPorts(1, 2), kDefaultLocalityWeight, 1},
});
ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), 0);
args = EdsServiceImpl::ResponseArgs({
{"locality0", GetBackendPorts(0, 1), kDefaultLocalityWeight, 0},
{"locality1", GetBackendPorts(1, 2), kDefaultLocalityWeight, 1},
{"locality2", GetBackendPorts(2, 3), kDefaultLocalityWeight, 2},
{"locality3", GetBackendPorts(3, 4), kDefaultLocalityWeight, 3},
});
ShutdownBackend(0);
ShutdownBackend(1);
ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), 1000);
gpr_timespec deadline = gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
gpr_time_from_millis(500, GPR_TIMESPAN));
// Send 0.5 second worth of RPCs.
do {
CheckRpcSendFailure();
} while (gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), deadline) < 0);
WaitForBackend(2, false);
for (size_t i = 0; i < 4; ++i) {
if (i == 2) continue;
EXPECT_EQ(0, backends_[i]->backend_service()->request_count());
}
// The EDS service got a single request, and sent a single response.
EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count());
EXPECT_EQ(2U, balancers_[0]->eds_service()->response_count());
}
// Tests that after the localities' priorities are updated, we still choose the
// highest READY priority with the updated localities.
TEST_F(FailoverTest, UpdatePriority) {
SetNextResolution({}, kDefaultServiceConfig_.c_str());
SetNextResolutionForLbChannelAllBalancers();
const size_t kNumRpcs = 100;
EdsServiceImpl::ResponseArgs args({
{"locality0", GetBackendPorts(0, 1), kDefaultLocalityWeight, 1},
{"locality1", GetBackendPorts(1, 2), kDefaultLocalityWeight, 2},
{"locality2", GetBackendPorts(2, 3), kDefaultLocalityWeight, 3},
{"locality3", GetBackendPorts(3, 4), kDefaultLocalityWeight, 0},
});
ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), 0);
args = EdsServiceImpl::ResponseArgs({
{"locality0", GetBackendPorts(0, 1), kDefaultLocalityWeight, 2},
{"locality1", GetBackendPorts(1, 2), kDefaultLocalityWeight, 0},
{"locality2", GetBackendPorts(2, 3), kDefaultLocalityWeight, 1},
{"locality3", GetBackendPorts(3, 4), kDefaultLocalityWeight, 3},
});
ScheduleResponseForBalancer(0, EdsServiceImpl::BuildResponse(args), 1000);
WaitForBackend(3, false);
for (size_t i = 0; i < 3; ++i) {
EXPECT_EQ(0, backends_[i]->backend_service()->request_count());
}
WaitForBackend(1);
CheckRpcSendOk(kNumRpcs);
EXPECT_EQ(kNumRpcs, backends_[1]->backend_service()->request_count());
// The EDS service got a single request, and sent a single response.
EXPECT_EQ(1U, balancers_[0]->eds_service()->request_count());
EXPECT_EQ(2U, balancers_[0]->eds_service()->response_count());
}
using DropTest = BasicTest;
// Tests that RPCs are dropped according to the drop config.
@ -1760,9 +1910,9 @@ TEST_F(FallbackTest, FallbackModeIsExitedAfterChildRready) {
SetNextResolutionForLbChannelAllBalancers();
// The state (TRANSIENT_FAILURE) update from the child policy will be ignored
// because we are still in fallback mode.
gpr_timespec deadline = gpr_time_add(
gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_millis(5000, GPR_TIMESPAN));
// Send 5 seconds worth of RPCs.
gpr_timespec deadline = gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
gpr_time_from_millis(500, GPR_TIMESPAN));
// Send 0.5 second worth of RPCs.
do {
CheckRpcSendOk();
} while (gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), deadline) < 0);

@ -37,4 +37,5 @@ grpc_cc_test(
"//test/cpp/util:test_config",
"//test/cpp/util:test_util",
],
tags = ["no_windows"], # TODO(jtattermusch): fix test on windows
)

@ -44,6 +44,7 @@ grpc_cc_binary(
"grpclb_fallback_test.cc",
],
language = "C++",
tags = ["no_windows"],
deps = [
"//src/proto/grpc/testing:empty_proto",
"//src/proto/grpc/testing:messages_proto",

@ -163,12 +163,14 @@ grpc_cc_test(
":interarrival",
"//test/cpp/util:test_config",
],
uses_polling = False,
)
grpc_cc_test(
name = "qps_openloop_test",
srcs = ["qps_openloop_test.cc"],
exec_compatible_with = ["//third_party/toolchains/machine_size:large"],
tags = ["no_windows"], # machine_size:large is not configured for windows RBE
deps = [
":benchmark_config",
":driver_impl",

@ -188,7 +188,8 @@ grpc_cc_test(
"gtest",
],
tags = ["nomsan", # death tests seem to be incompatible with msan
"no_test_ios"
"no_test_ios",
"no_windows",
],
deps = [
":grpc_cli_libs",
@ -213,6 +214,7 @@ grpc_cc_test(
deps = [
":test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -226,6 +228,7 @@ grpc_cc_test(
deps = [
":test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -240,6 +243,7 @@ grpc_cc_test(
"//:grpc++",
"//test/core/util:grpc_test_util",
],
uses_polling = False,
)
grpc_cc_test(
@ -253,6 +257,7 @@ grpc_cc_test(
deps = [
":test_util",
],
uses_polling = False,
)
grpc_cc_test(

@ -33,11 +33,14 @@ dotnet publish -f net45 DistribTestDotNet.csproj
ls -R bin
# .NET 4.5 target after dotnet build
mono bin/Debug/net45/publish/DistribTestDotNet.exe
# .NET 4.5 target after dotnet publish
mono bin/Debug/net45/publish/DistribTestDotNet.exe
if [ "${SKIP_MONO_DISTRIBTEST}" != "1" ]
then
# .NET 4.5 target after dotnet build
mono bin/Debug/net45/publish/DistribTestDotNet.exe
# .NET 4.5 target after dotnet publish
mono bin/Debug/net45/publish/DistribTestDotNet.exe
fi
# .NET Core target after dotnet build
dotnet exec bin/Debug/netcoreapp2.1/DistribTestDotNet.dll

@ -17,7 +17,7 @@
# Reads stdin to find error_refcount log lines, and prints reference leaks
# to stdout
# usege: python error_ref_leak < logfile.txt
# usage: python error_ref_leak < logfile.txt
import sys
import re

@ -0,0 +1,28 @@
# Copyright 2019 The gRPC Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FROM mcr.microsoft.com/dotnet/core/sdk:2.1-alpine3.9
RUN apk update && apk add bash
RUN apk update && apk add unzip
# Workaround for https://github.com/grpc/grpc/issues/18428
# Also see https://github.com/sgerrand/alpine-pkg-glibc
RUN apk update && apk --no-cache add ca-certificates wget
RUN wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub
RUN wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.30-r0/glibc-2.30-r0.apk
RUN apk add glibc-2.30-r0.apk
# installing mono on alpine is hard and we don't really need it
ENV SKIP_MONO_DISTRIBTEST=1

@ -145,7 +145,7 @@ func TestSoonTLSMaxVersion(t *testing.T) {
ctx := InteropCtx(t)
err := testTLSMaxVersion(ctx, tls.VersionTLS11)
// TODO(carl-mastrangelo): maybe this should be some other error. If the server picks
// the wrong protocol version, thats bad too.
// the wrong protocol version, that's bad too.
matchError(t, err, "EOF", "server selected unsupported protocol")
}

@ -72,7 +72,7 @@ func testAllSettingsFramesAcked(ctx *HTTP2InteropCtx) error {
var settingsFramesReceived = 0
// The server by default sends a settings frame as part of the handshake, and another
// after the receipt of the initial settings frame as part of our conneection preface.
// after the receipt of the initial settings frame as part of our connection preface.
// This means we expected 1 + 1 + 10 = 12 settings frames in return, with all but the
// first having the ack bit.
for settingsFramesReceived < 12 {

@ -0,0 +1,22 @@
# Copyright 2019 The gRPC Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Config file for the internal CI (in protobuf text format)
# Location of the continuous shell script in repository.
build_file: "grpc/tools/internal_ci/macos/grpc_run_bazel_c_cpp_tests.sh"
env_vars {
key: "RUN_TESTS_FLAGS"
value: "--config=dbg"
}

@ -0,0 +1,22 @@
# Copyright 2019 The gRPC Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Config file for the internal CI (in protobuf text format)
# Location of the continuous shell script in repository.
build_file: "grpc/tools/internal_ci/macos/grpc_run_bazel_c_cpp_tests.sh"
env_vars {
key: "RUN_TESTS_FLAGS"
value: "--config=opt"
}

@ -15,5 +15,5 @@
# Config file for the internal CI (in protobuf text format)
# Location of the continuous shell script in repository.
build_file: "grpc/tools/internal_ci/macos/grpc_run_bazel_tests.sh"
build_file: "grpc/tools/internal_ci/macos/grpc_run_bazel_isolated_tests.sh"

@ -15,7 +15,7 @@
# Config file for the internal CI (in protobuf text format)
# Location of the continuous shell script in repository.
build_file: "grpc/tools/internal_ci/macos/grpc_run_bazel_tests.sh"
build_file: "grpc/tools/internal_ci/macos/grpc_run_bazel_isolated_tests.sh"
env_vars {
key: "RUN_TESTS_FLAGS"
value: "--config=asan_macos"

@ -15,7 +15,7 @@
# Config file for the internal CI (in protobuf text format)
# Location of the continuous shell script in repository.
build_file: "grpc/tools/internal_ci/macos/grpc_run_bazel_tests.sh"
build_file: "grpc/tools/internal_ci/macos/grpc_run_bazel_isolated_tests.sh"
env_vars {
key: "RUN_TESTS_FLAGS"
value: "--config=tsan"

@ -0,0 +1,30 @@
#!/usr/bin/env bash
# Copyright 2019 The gRPC Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -ex
# change to grpc repo root
cd $(dirname $0)/../../..
./tools/run_tests/start_port_server.py
# run all C/C++ tests
# TODO(jtattermusch): try using Bazel RBE remote cache
# TODO(jtattermusch): upload bazel test results to resultstore
tools/bazel test $RUN_TESTS_FLAGS //test/...
# kill port_server.py to prevent the build from hanging
ps aux | grep port_server\\.py | awk '{print $2}' | xargs kill -9

@ -24,7 +24,7 @@ powershell -Command "[guid]::NewGuid().ToString()" >%KOKORO_ARTIFACTS_DIR%/bazel
set /p BAZEL_INVOCATION_ID=<%KOKORO_ARTIFACTS_DIR%/bazel_invocation_ids
@rem TODO(jtattermusch): windows RBE should be able to use the same credentials as Linux RBE.
bazel --bazelrc=tools/remote_build/windows.bazelrc build --invocation_id="%BAZEL_INVOCATION_ID%" --workspace_status_command=tools/remote_build/workspace_status_kokoro.sh :all --google_credentials=%KOKORO_GFILE_DIR%/rbe-windows-credentials.json
bazel --bazelrc=tools/remote_build/windows.bazelrc test --invocation_id="%BAZEL_INVOCATION_ID%" --workspace_status_command=tools/remote_build/workspace_status_kokoro.sh --google_credentials=%KOKORO_GFILE_DIR%/rbe-windows-credentials.json //test/...
set BAZEL_EXITCODE=%errorlevel%
@rem TODO(jtattermusch): upload results to bigquery

@ -101,6 +101,7 @@ LANG_RELEASE_MATRIX = {
('v1.22.0', ReleaseInfo()),
('v1.22.1', ReleaseInfo()),
('v1.23.0', ReleaseInfo()),
('v1.24.0', ReleaseInfo()),
]),
'go':
OrderedDict(
@ -218,6 +219,7 @@ LANG_RELEASE_MATRIX = {
('v1.22.0', ReleaseInfo()),
('v1.22.1', ReleaseInfo()),
('v1.23.0', ReleaseInfo()),
('v1.24.0', ReleaseInfo()),
]),
'node':
OrderedDict([
@ -270,6 +272,7 @@ LANG_RELEASE_MATRIX = {
('v1.22.0', ReleaseInfo()),
('v1.22.1', ReleaseInfo()),
('v1.23.0', ReleaseInfo()),
('v1.24.0', ReleaseInfo()),
# TODO: https://github.com/grpc/grpc/issues/18262.
# If you are not encountering the error in above issue
# go ahead and upload the docker image for new releases.
@ -300,6 +303,7 @@ LANG_RELEASE_MATRIX = {
('v1.22.0', ReleaseInfo()),
('v1.22.1', ReleaseInfo()),
('v1.23.0', ReleaseInfo()),
('v1.24.0', ReleaseInfo()),
]),
'csharp':
OrderedDict([
@ -333,5 +337,6 @@ LANG_RELEASE_MATRIX = {
('v1.22.0', ReleaseInfo()),
('v1.22.1', ReleaseInfo()),
('v1.23.0', ReleaseInfo()),
('v1.24.0', ReleaseInfo()),
]),
}

@ -31,8 +31,8 @@ bazel --bazelrc=tools/remote_build/manual.bazelrc test --config=asan //test/...
Run on Windows MSVC:
```
# RBE manual run only for c-core (must be run on a Windows host machine)
bazel --bazelrc=tools/remote_build/windows.bazelrc build :all
# manual run of bazel tests remotely on RBE Windows (must be run from Windows machine)
bazel --bazelrc=tools/remote_build/windows.bazelrc test //test/...
```
Available command line options can be found in

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save