Merge remote-tracking branch 'upstream/master' into no-logging

pull/36131/head
yijiem 1 year ago
commit f3f638176f
  1. 2
      .bazelversion
  2. 2
      .gitattributes
  3. 28
      BUILD
  4. 1
      CMakeLists.txt
  5. 1
      Package.swift
  6. 31
      WORKSPACE
  7. 4
      bazel/supported_versions.txt
  8. 12
      bazel/update_mirror.sh
  9. 7
      build_autogenerated.yaml
  10. 4
      doc/bazel_support.md
  11. 25
      examples/android/binder/java/io/grpc/binder/cpp/README.md
  12. 2
      examples/android/binder/java/io/grpc/binder/cpp/exampleclient/BUILD
  13. 2
      examples/android/binder/java/io/grpc/binder/cpp/exampleserver/BUILD
  14. 2
      gRPC-C++.podspec
  15. 2
      gRPC-Core.podspec
  16. 1
      grpc.gemspec
  17. 2702
      grpc.gyp
  18. 1
      package.xml
  19. 1
      src/core/BUILD
  20. 26
      src/core/ext/transport/binder/client/channel_create.cc
  21. 11
      src/core/ext/transport/binder/client/channel_create_impl.cc
  22. 3
      src/core/ext/transport/binder/client/channel_create_impl.h
  23. 2
      src/core/ext/transport/binder/java/io/grpc/binder/cpp/BUILD
  24. 4
      src/core/ext/transport/chaotic_good/client/chaotic_good_connector.cc
  25. 7
      src/core/ext/transport/chttp2/client/chttp2_connector.cc
  26. 28
      src/core/ext/xds/xds_bootstrap_grpc.cc
  27. 2
      src/core/ext/xds/xds_bootstrap_grpc.h
  28. 92
      src/core/ext/xds/xds_client.cc
  29. 27
      src/core/ext/xds/xds_client.h
  30. 210
      src/core/ext/xds/xds_client_grpc.cc
  31. 16
      src/core/ext/xds/xds_client_grpc.h
  32. 39
      src/core/ext/xds/xds_metrics.h
  33. 5
      src/core/ext/xds/xds_server_config_fetcher.cc
  34. 10
      src/core/lib/channel/metrics.cc
  35. 4
      src/core/lib/channel/metrics.h
  36. 2
      src/core/lib/event_engine/posix_engine/posix_engine_listener.cc
  37. 2
      src/core/lib/event_engine/tcp_socket_utils.cc
  38. 4
      src/core/lib/event_engine/tcp_socket_utils.h
  39. 2
      src/core/lib/event_engine/windows/windows_listener.cc
  40. 4
      src/core/lib/gprpp/load_file.cc
  41. 34
      src/core/lib/promise/party.cc
  42. 9
      src/core/lib/surface/channel_create.cc
  43. 14
      src/core/tsi/ssl_transport_security.cc
  44. 11
      src/core/tsi/ssl_transport_security_utils.cc
  45. 2
      src/php/tests/unit_tests/CallInvokerTest.php
  46. 2
      src/python/grpcio_tests/tests_aio/channelz/channelz_servicer_test.py
  47. 162
      templates/grpc.gyp.template
  48. 4
      templates/tools/dockerfile/oss_fuzz_base.include
  49. 33
      templates/tools/dockerfile/test/binder_transport_apk/Dockerfile.template
  50. 16
      test/core/end2end/fuzzers/fuzzing_common.cc
  51. 3
      test/core/end2end/fuzzers/fuzzing_common.h
  52. 15
      test/core/event_engine/tcp_socket_utils_test.cc
  53. 57
      test/core/promise/party_test.cc
  54. 10
      test/core/tsi/BUILD
  55. 7
      test/core/tsi/crl_ssl_transport_security_test.cc
  56. 4
      test/core/tsi/ssl_transport_security_utils_test.cc
  57. 3
      test/core/tsi/test_creds/crl_data/README
  58. 21
      test/core/tsi/test_creds/crl_data/bad_crls/BUILD
  59. 0
      test/core/tsi/test_creds/crl_data/bad_crls/evil.crl
  60. 0
      test/core/tsi/test_creds/crl_data/bad_crls/invalid_content.crl
  61. 0
      test/core/tsi/test_creds/crl_data/bad_crls/invalid_signature.crl
  62. 3
      test/core/tsi/test_creds/crl_data/crls/BUILD
  63. 15
      test/core/xds/BUILD
  64. 96
      test/core/xds/xds_bootstrap_test.cc
  65. 47
      test/core/xds/xds_client_fuzzer.cc
  66. 7
      test/core/xds/xds_client_fuzzer.proto
  67. 982
      test/core/xds/xds_client_test.cc
  68. 80
      test/core/xds/xds_client_test_peer.h
  69. 3
      test/core/xds/xds_cluster_resource_type_test.cc
  70. 3
      test/core/xds/xds_common_types_test.cc
  71. 3
      test/core/xds/xds_endpoint_resource_type_test.cc
  72. 3
      test/core/xds/xds_http_filters_test.cc
  73. 3
      test/core/xds/xds_listener_resource_type_test.cc
  74. 3
      test/core/xds/xds_route_config_resource_type_test.cc
  75. 3
      test/cpp/end2end/crl_provider_test.cc
  76. 1
      test/cpp/end2end/xds/BUILD
  77. 167
      test/cpp/end2end/xds/xds_core_end2end_test.cc
  78. 3
      third_party/android/BUILD
  79. 62
      third_party/android/android_configure.bzl
  80. 6
      third_party/cares/cares.BUILD
  81. 1
      tools/bazel.rc
  82. 8
      tools/bazelify_tests/dockerimage_current_versions.bzl
  83. 4
      tools/bazelify_tests/test/supported_bazel_versions.bzl
  84. 25
      tools/distrib/python/grpcio_tools/setup.py
  85. 2
      tools/dockerfile/test/bazel.current_version
  86. 6
      tools/dockerfile/test/bazel/Dockerfile
  87. 2
      tools/dockerfile/test/bazel_arm64.current_version
  88. 2
      tools/dockerfile/test/bazel_arm64/Dockerfile
  89. 2
      tools/dockerfile/test/binder_transport_apk.current_version
  90. 29
      tools/dockerfile/test/binder_transport_apk/Dockerfile
  91. 2
      tools/dockerfile/test/sanity.current_version
  92. 2
      tools/dockerfile/test/sanity/Dockerfile
  93. 1
      tools/doxygen/Doxyfile.c++.internal
  94. 1
      tools/doxygen/Doxyfile.core.internal
  95. 14
      tools/internal_ci/linux/grpc_binder_transport_apk_build_in_docker.sh
  96. 2
      tools/interop_matrix/client_matrix.py

@ -1 +1 @@
6.4.0
6.5.0

2
.gitattributes vendored

@ -12,10 +12,8 @@ gRPC-ProtoRPC.podspec linguist-generated=true
gRPC-RxLibrary.podspec linguist-generated=true
gRPC.podspec linguist-generated=true
grpc.gemspec linguist-generated=true
grpc.gyp linguist-generated=true
grpc.def linguist-generated=true
package.xml linguist-generated=true
binding.gyp linguist-generated=true
Package.swift linguist-generated=true
src/python/grpcio/grpc_core_dependencies.py linguist-generated=true
src/ruby/ext/grpc/rb_grpc_imports.generated.h linguist-generated=true

28
BUILD

@ -65,6 +65,30 @@ bool_flag(
build_setting_default = False,
)
platform(
name = "android_x86_64",
constraint_values = [
"@platforms//os:android",
"@platforms//cpu:x86_64",
],
)
platform(
name = "android_arm64",
constraint_values = [
"@platforms//os:android",
"@platforms//cpu:arm64",
],
)
platform(
name = "android_armv7",
constraint_values = [
"@platforms//os:android",
"@platforms//cpu:armv7",
],
)
config_setting(
name = "grpc_no_rls_flag",
flag_values = {":disable_grpc_rls": "true"},
@ -84,6 +108,8 @@ config_setting(
config_setting(
name = "android",
values = {"crosstool_top": "//external:android/crosstool"},
# TODO: Use constraint_values to detect android after Bazel 7.0 platforms migration is finished
# constraint_values = [ "@platforms//os:android" ],
)
config_setting(
@ -1790,6 +1816,7 @@ grpc_cc_library(
"channel",
"channel_arg_names",
"channelz",
"config",
"gpr",
"grpc_base",
"grpc_public_hdrs",
@ -4247,6 +4274,7 @@ grpc_cc_library(
"//src/core:ext/xds/xds_channel_args.h",
"//src/core:ext/xds/xds_client.h",
"//src/core:ext/xds/xds_client_stats.h",
"//src/core:ext/xds/xds_metrics.h",
"//src/core:ext/xds/xds_resource_type.h",
"//src/core:ext/xds/xds_resource_type_impl.h",
"//src/core:ext/xds/xds_transport.h",

1
CMakeLists.txt generated

@ -33582,6 +33582,7 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/string.grpc.pb.cc
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/string.pb.h
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/string.grpc.pb.h
test/core/util/fake_stats_plugin.cc
test/cpp/end2end/test_service_impl.cc
test/cpp/end2end/xds/xds_core_end2end_test.cc
test/cpp/end2end/xds/xds_end2end_test_lib.cc

1
Package.swift generated

@ -1110,6 +1110,7 @@ let package = Package(
"src/core/ext/xds/xds_lb_policy_registry.h",
"src/core/ext/xds/xds_listener.cc",
"src/core/ext/xds/xds_listener.h",
"src/core/ext/xds/xds_metrics.h",
"src/core/ext/xds/xds_resource_type.h",
"src/core/ext/xds/xds_resource_type_impl.h",
"src/core/ext/xds/xds_route_config.cc",

@ -27,19 +27,34 @@ custom_exec_properties(
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "build_bazel_rules_android",
sha256 = "cd06d15dd8bb59926e4d65f9003bfc20f9da4b2519985c27e190cddc8b7a7806",
strip_prefix = "rules_android-0.1.1",
urls = ["https://github.com/bazelbuild/rules_android/archive/v0.1.1.zip"],
name = "platforms",
sha256 = "8150406605389ececb6da07cbcb509d5637a3ab9a24bc69b1101531367d89d74",
urls = ["https://github.com/bazelbuild/platforms/releases/download/0.0.8/platforms-0.0.8.tar.gz"],
)
load("//third_party/android:android_configure.bzl", "android_configure")
RULES_ANDROID_NDK_COMMIT = "010f4f17dd13a8baaaacc28ba6c8c2c75f54c68b"
android_configure(name = "local_config_android")
RULES_ANDROID_NDK_SHA = "2ab6a97748772f289331d75caaaee0593825935d1d9d982231a437fb8ab5a14d"
load("@local_config_android//:android_configure.bzl", "android_workspace")
http_archive(
name = "rules_android_ndk",
sha256 = RULES_ANDROID_NDK_SHA,
strip_prefix = "rules_android_ndk-%s" % RULES_ANDROID_NDK_COMMIT,
url = "https://github.com/bazelbuild/rules_android_ndk/archive/%s.zip" % RULES_ANDROID_NDK_COMMIT,
)
android_sdk_repository(
name = "androidsdk",
build_tools_version = "34.0.0",
)
load("@rules_android_ndk//:rules.bzl", "android_ndk_repository")
android_ndk_repository(name = "androidndk")
android_workspace()
# Note that we intentionally avoid calling `register_toolchains("@androidndk//:all")`
# here, because the toolchain rule fails when $ANDROID_NDK_HOME is not set.
# Use `--extra_toolchains=@androidndk//:all` to manually register it when building for Android.
# Prevents bazel's '...' expansion from including the following folder.
# This is required because the BUILD file in the following folder

@ -1,2 +1,2 @@
6.4.0
7.0.0
6.5.0
7.1.0

@ -57,12 +57,12 @@ function upload {
# upload "github.com/google/boringssl/archive/1c2769383f027befac5b75b6cedd25daf3bf4dcf.tar.gz"
# bazel binaries used by the tools/bazel wrapper script
upload github.com/bazelbuild/bazel/releases/download/6.4.0/bazel-6.4.0-linux-x86_64
upload github.com/bazelbuild/bazel/releases/download/6.4.0/bazel-6.4.0-darwin-x86_64
upload github.com/bazelbuild/bazel/releases/download/6.4.0/bazel-6.4.0-windows-x86_64.exe
upload github.com/bazelbuild/bazel/releases/download/7.0.0/bazel-7.0.0-linux-x86_64
upload github.com/bazelbuild/bazel/releases/download/7.0.0/bazel-7.0.0-darwin-x86_64
upload github.com/bazelbuild/bazel/releases/download/7.0.0/bazel-7.0.0-windows-x86_64.exe
upload github.com/bazelbuild/bazel/releases/download/6.5.0/bazel-6.5.0-linux-x86_64
upload github.com/bazelbuild/bazel/releases/download/6.5.0/bazel-6.5.0-darwin-x86_64
upload github.com/bazelbuild/bazel/releases/download/6.5.0/bazel-6.5.0-windows-x86_64.exe
upload github.com/bazelbuild/bazel/releases/download/7.1.0/bazel-7.1.0-linux-x86_64
upload github.com/bazelbuild/bazel/releases/download/7.1.0/bazel-7.1.0-darwin-x86_64
upload github.com/bazelbuild/bazel/releases/download/7.1.0/bazel-7.1.0-windows-x86_64.exe
# Collect the github archives to mirror from grpc_deps.bzl
grep -o '"https://github.com/[^"]*"' bazel/grpc_deps.bzl | sed 's/^"https:\/\///' | sed 's/"$//' | while read -r line ; do

@ -800,6 +800,7 @@ libs:
- src/core/ext/xds/xds_http_stateful_session_filter.h
- src/core/ext/xds/xds_lb_policy_registry.h
- src/core/ext/xds/xds_listener.h
- src/core/ext/xds/xds_metrics.h
- src/core/ext/xds/xds_resource_type.h
- src/core/ext/xds/xds_resource_type_impl.h
- src/core/ext/xds/xds_route_config.h
@ -20187,7 +20188,8 @@ targets:
gtest: true
build: test
language: c++
headers: []
headers:
- test/core/util/scoped_env_var.h
src:
- test/core/xds/xds_bootstrap_test.cc
deps:
@ -20211,6 +20213,7 @@ targets:
language: c++
headers:
- test/core/util/scoped_env_var.h
- test/core/xds/xds_client_test_peer.h
- test/core/xds/xds_transport_fake.h
src:
- src/proto/grpc/testing/xds/v3/base.proto
@ -20417,6 +20420,7 @@ targets:
run: false
language: c++
headers:
- test/core/util/fake_stats_plugin.h
- test/core/util/scoped_env_var.h
- test/cpp/end2end/counted_service.h
- test/cpp/end2end/test_service_impl.h
@ -20456,6 +20460,7 @@ targets:
- src/proto/grpc/testing/xds/v3/route.proto
- src/proto/grpc/testing/xds/v3/router.proto
- src/proto/grpc/testing/xds/v3/string.proto
- test/core/util/fake_stats_plugin.cc
- test/cpp/end2end/test_service_impl.cc
- test/cpp/end2end/xds/xds_core_end2end_test.cc
- test/cpp/end2end/xds/xds_end2end_test_lib.cc

@ -43,7 +43,7 @@ However individual releases may have a broader
compatibility range. The currently supported versions are captured by the
following list:
- [`6.4.0`](https://github.com/bazelbuild/bazel/releases/tag/6.4.0)
- [`7.0.0`](https://github.com/bazelbuild/bazel/releases/tag/7.0.0)
- [`6.5.0`](https://github.com/bazelbuild/bazel/releases/tag/6.5.0)
- [`7.1.0`](https://github.com/bazelbuild/bazel/releases/tag/7.1.0)
NOTE: gRPC doesn't support bzlmod yet.

@ -1,20 +1,23 @@
# gRPC-core BinderTransport example apps
WIP.
## Build Instruction
1. Install Android SDK and NDK. Currently we only support SDK version 30.0.3 and
NDK version 21.4.7075529 . Make sure you get these exact versions otherwise
Bazel might complain.
2. Point environment variables to install locations of SDK and NDK
1. Install Android SDK and NDK. Only NDK version >= 25 is supported. We tested against SDK Platform `33` and NDK `26.2.11394342`.
2. Make sure Bazel is at least `7.0`. Use `export OVERRIDE_BAZEL_VERSION=7.1.0` to selected a supported version listed in `bazel/supported_versions.txt` if necessary.
3. Point environment variables to install locations of SDK and NDK
```
export ANDROID_HOME=$HOME/android-sdk
export ANDROID_NDK_HOME=$HOME/android-sdk/ndk/26.2.11394342
```
4. To build a fat APK that supports `x86_64`, `armv7`, and `arm64`:
```
export ANDROID_HOME=$HOME/Android/Sdk/
export ANDROID_NDK_HOME=$HOME/Android/Sdk/ndk/21.4.7075529
bazel build \
--extra_toolchains=@androidndk//:all \
--android_platforms=//:android_x86_64,//:android_armv7,//:android_arm64 \
--copt=-Wno-unknown-warning-option \
//examples/android/binder/java/io/grpc/binder/cpp/exampleserver:app \
//examples/android/binder/java/io/grpc/binder/cpp/exampleclient:app
```
3. `bazel build //examples/android/binder/java/io/grpc/binder/cpp/exampleclient:app`
4. `bazel build //examples/android/binder/java/io/grpc/binder/cpp/exampleserver:app`
5. `adb install
bazel-bin/examples/android/binder/java/io/grpc/binder/cpp/exampleclient/app.apk`
6. `adb install

@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
load("@build_bazel_rules_android//android:rules.bzl", "android_binary", "android_library")
cc_library(
name = "jni_lib",
srcs = ["native.cc"],

@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
load("@build_bazel_rules_android//android:rules.bzl", "android_binary", "android_library")
cc_library(
name = "jni_lib",
srcs = ["native.cc"],

2
gRPC-C++.podspec generated

@ -881,6 +881,7 @@ Pod::Spec.new do |s|
'src/core/ext/xds/xds_http_stateful_session_filter.h',
'src/core/ext/xds/xds_lb_policy_registry.h',
'src/core/ext/xds/xds_listener.h',
'src/core/ext/xds/xds_metrics.h',
'src/core/ext/xds/xds_resource_type.h',
'src/core/ext/xds/xds_resource_type_impl.h',
'src/core/ext/xds/xds_route_config.h',
@ -2145,6 +2146,7 @@ Pod::Spec.new do |s|
'src/core/ext/xds/xds_http_stateful_session_filter.h',
'src/core/ext/xds/xds_lb_policy_registry.h',
'src/core/ext/xds/xds_listener.h',
'src/core/ext/xds/xds_metrics.h',
'src/core/ext/xds/xds_resource_type.h',
'src/core/ext/xds/xds_resource_type_impl.h',
'src/core/ext/xds/xds_route_config.h',

2
gRPC-Core.podspec generated

@ -1226,6 +1226,7 @@ Pod::Spec.new do |s|
'src/core/ext/xds/xds_lb_policy_registry.h',
'src/core/ext/xds/xds_listener.cc',
'src/core/ext/xds/xds_listener.h',
'src/core/ext/xds/xds_metrics.h',
'src/core/ext/xds/xds_resource_type.h',
'src/core/ext/xds/xds_resource_type_impl.h',
'src/core/ext/xds/xds_route_config.cc',
@ -2927,6 +2928,7 @@ Pod::Spec.new do |s|
'src/core/ext/xds/xds_http_stateful_session_filter.h',
'src/core/ext/xds/xds_lb_policy_registry.h',
'src/core/ext/xds/xds_listener.h',
'src/core/ext/xds/xds_metrics.h',
'src/core/ext/xds/xds_resource_type.h',
'src/core/ext/xds/xds_resource_type_impl.h',
'src/core/ext/xds/xds_route_config.h',

1
grpc.gemspec generated

@ -1116,6 +1116,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/ext/xds/xds_lb_policy_registry.h )
s.files += %w( src/core/ext/xds/xds_listener.cc )
s.files += %w( src/core/ext/xds/xds_listener.h )
s.files += %w( src/core/ext/xds/xds_metrics.h )
s.files += %w( src/core/ext/xds/xds_resource_type.h )
s.files += %w( src/core/ext/xds/xds_resource_type_impl.h )
s.files += %w( src/core/ext/xds/xds_route_config.cc )

2702
grpc.gyp

File diff suppressed because it is too large Load Diff

1
package.xml generated

@ -1098,6 +1098,7 @@
<file baseinstalldir="/" name="src/core/ext/xds/xds_lb_policy_registry.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/xds/xds_listener.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/xds/xds_listener.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/xds/xds_metrics.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/xds/xds_resource_type.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/xds/xds_resource_type_impl.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/xds/xds_route_config.cc" role="src" />

@ -5060,6 +5060,7 @@ grpc_cc_library(
"load_file",
"match",
"metadata_batch",
"metrics",
"pollset_set",
"protobuf_any_upb",
"protobuf_duration_upb",

@ -121,33 +121,21 @@ std::shared_ptr<grpc::Channel> CreateCustomBinderChannel(
grpc_binder::TryEstablishConnectionWithUri(static_cast<JNIEnv*>(jni_env_void),
context, uri, connection_id);
grpc_channel_args channel_args;
args.SetChannelArgs(&channel_args);
grpc_binder::GetSecurityPolicySetting()->Set(connection_id, security_policy);
// Set server URI to a URI that contains connection id. The URI will be used
// by subchannel connector to obtain correct endpoint binder from
// `EndpointBinderPool`.
grpc_channel_args* new_args;
{
string server_uri = "binder:" + connection_id;
grpc_arg server_uri_arg =
grpc_channel_arg_string_create(const_cast<char*>(GRPC_ARG_SERVER_URI),
const_cast<char*>(server_uri.c_str()));
const char* to_remove[] = {GRPC_ARG_SERVER_URI};
new_args = grpc_channel_args_copy_and_add_and_remove(
&channel_args, to_remove, 1, &server_uri_arg, 1);
}
string server_uri = "binder:" + connection_id;
grpc_binder::GetSecurityPolicySetting()->Set(connection_id, security_policy);
grpc_channel_args channel_args;
args.SetChannelArgs(&channel_args);
auto channel = CreateChannelInternal(
"", grpc::internal::CreateClientBinderChannelImpl(new_args),
return CreateChannelInternal(
"",
grpc::internal::CreateClientBinderChannelImpl(server_uri, &channel_args),
std::vector<
std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>());
grpc_channel_args_destroy(new_args);
return channel;
}
bool InitializeBinderChannelJavaClass(void* jni_env_void) {

@ -65,7 +65,8 @@ grpc_channel* CreateDirectBinderChannelImplForTesting(
return channel->release()->c_ptr();
}
grpc_channel* CreateClientBinderChannelImpl(const grpc_channel_args* args) {
grpc_channel* CreateClientBinderChannelImpl(std::string target,
const grpc_channel_args* args) {
grpc_core::ExecCtx exec_ctx;
gpr_once_init(&g_factory_once, FactoryInit);
@ -75,14 +76,12 @@ grpc_channel* CreateClientBinderChannelImpl(const grpc_channel_args* args) {
.PreconditionChannelArgs(args)
.SetObject(g_factory);
auto channel =
grpc_core::ChannelCreate("binder_channel_target_placeholder",
channel_args, GRPC_CLIENT_CHANNEL, nullptr);
auto channel = grpc_core::ChannelCreate(target, channel_args,
GRPC_CLIENT_CHANNEL, nullptr);
if (!channel.ok()) {
return grpc_lame_client_channel_create(
"binder_channel_target_placeholder",
static_cast<grpc_status_code>(channel.status().code()),
target.c_str(), static_cast<grpc_status_code>(channel.status().code()),
"Failed to create binder channel");
}

@ -34,7 +34,8 @@ grpc_channel* CreateDirectBinderChannelImplForTesting(
security_policy);
// Creates a GRPC_CLIENT_CHANNEL channel
grpc_channel* CreateClientBinderChannelImpl(const grpc_channel_args* args);
grpc_channel* CreateClientBinderChannelImpl(std::string target,
const grpc_channel_args* args);
} // namespace internal
} // namespace grpc

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
load("@build_bazel_rules_android//android:rules.bzl", "android_library")
# copybara: Import internal android_library rule here
licenses(["notice"])

@ -370,15 +370,11 @@ grpc_channel* grpc_chaotic_good_channel_create(const char* target,
grpc_channel* channel = nullptr;
grpc_error_handle error;
// Create channel.
std::string canonical_target = grpc_core::CoreConfiguration::Get()
.resolver_registry()
.AddDefaultPrefixIfNeeded(target);
auto r = grpc_core::ChannelCreate(
target,
grpc_core::CoreConfiguration::Get()
.channel_args_preconditioning()
.PreconditionChannelArgs(args)
.Set(GRPC_ARG_SERVER_URI, canonical_target)
.SetObject(
grpc_core::NoDestructSingleton<
grpc_core::chaotic_good::ChaoticGoodChannelFactory>::Get()),

@ -314,12 +314,7 @@ absl::StatusOr<OrphanablePtr<Channel>> CreateChannel(const char* target,
gpr_log(GPR_ERROR, "cannot create channel with NULL target name");
return absl::InvalidArgumentError("channel target is NULL");
}
// Add channel arg containing the server URI.
std::string canonical_target =
CoreConfiguration::Get().resolver_registry().AddDefaultPrefixIfNeeded(
target);
return ChannelCreate(target, args.Set(GRPC_ARG_SERVER_URI, canonical_target),
GRPC_CLIENT_CHANNEL, nullptr);
return ChannelCreate(target, args, GRPC_CLIENT_CHANNEL, nullptr);
}
} // namespace

@ -38,6 +38,8 @@
#include <grpc/support/json.h>
#include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/gpr/string.h"
#include "src/core/lib/gprpp/env.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h"
#include "src/core/lib/json/json.h"
#include "src/core/lib/json/json_object_loader.h"
@ -47,6 +49,17 @@
namespace grpc_core {
namespace {
bool IsFallbackExperimentEnabled() {
auto fallback_enabled = GetEnv("GRPC_EXPERIMENTAL_XDS_FALLBACK");
bool enabled = false;
return gpr_parse_bool_value(fallback_enabled.value_or("0").c_str(),
&enabled) &&
enabled;
}
} // namespace
//
// GrpcXdsBootstrap::GrpcNode::Locality
//
@ -219,6 +232,16 @@ const JsonLoaderInterface* GrpcXdsBootstrap::GrpcAuthority::JsonLoader(
return loader;
}
void GrpcXdsBootstrap::GrpcAuthority::JsonPostLoad(
const Json& /*json*/, const JsonArgs& /*args*/,
ValidationErrors* /*errors*/) {
if (!IsFallbackExperimentEnabled()) {
if (servers_.size() > 1) {
servers_.resize(1);
}
}
}
//
// GrpcXdsBootstrap
//
@ -293,6 +316,11 @@ void GrpcXdsBootstrap::JsonPostLoad(const Json& /*json*/,
}
}
}
if (!IsFallbackExperimentEnabled()) {
if (servers_.size() > 1) {
servers_.resize(1);
}
}
}
std::string GrpcXdsBootstrap::ToString() const {

@ -118,6 +118,8 @@ class GrpcXdsBootstrap : public XdsBootstrap {
}
static const JsonLoaderInterface* JsonLoader(const JsonArgs&);
void JsonPostLoad(const Json& json, const JsonArgs& args,
ValidationErrors* errors);
private:
std::vector<GrpcXdsServer> servers_;

@ -150,7 +150,8 @@ class XdsClient::XdsChannel::AdsCall : public InternallyRefCounted<AdsCall> {
std::vector<std::string> errors;
std::map<std::string /*authority*/, std::set<XdsResourceKey>>
resources_seen;
bool have_valid_resources = false;
uint64_t num_valid_resources = 0;
uint64_t num_invalid_resources = 0;
RefCountedPtr<ReadDelayHandle> read_delay_handle;
};
@ -783,6 +784,7 @@ void XdsClient::XdsChannel::AdsCall::AdsResponseParser::ParseResource(
result_.errors.emplace_back(
absl::StrCat(error_prefix, "incorrect resource type \"", type_url,
"\" (should be \"", result_.type_url, "\")"));
++result_.num_invalid_resources;
return;
}
// Parse the resource.
@ -803,6 +805,7 @@ void XdsClient::XdsChannel::AdsCall::AdsResponseParser::ParseResource(
// there's nothing more we can do here.
result_.errors.emplace_back(absl::StrCat(
error_prefix, decode_result.resource.status().ToString()));
++result_.num_invalid_resources;
return;
}
}
@ -818,6 +821,7 @@ void XdsClient::XdsChannel::AdsCall::AdsResponseParser::ParseResource(
if (!parsed_resource_name.ok()) {
result_.errors.emplace_back(
absl::StrCat(error_prefix, "Cannot parse xDS resource name"));
++result_.num_invalid_resources;
return;
}
// Cancel resource-does-not-exist timer, if needed.
@ -877,10 +881,11 @@ void XdsClient::XdsChannel::AdsCall::AdsResponseParser::ParseResource(
result_.read_delay_handle);
UpdateResourceMetadataNacked(result_.version, decode_status.ToString(),
update_time_, &resource_state.meta);
++result_.num_invalid_resources;
return;
}
// Resource is valid.
result_.have_valid_resources = true;
++result_.num_valid_resources;
// If it didn't change, ignore it.
if (resource_state.resource != nullptr &&
result_.type->ResourcesEqual(resource_state.resource.get(),
@ -914,6 +919,7 @@ void XdsClient::XdsChannel::AdsCall::AdsResponseParser::
ResourceWrapperParsingFailed(size_t idx, absl::string_view message) {
result_.errors.emplace_back(
absl::StrCat("resource index ", idx, ": ", message));
++result_.num_invalid_resources;
}
//
@ -1157,13 +1163,19 @@ void XdsClient::XdsChannel::AdsCall::OnRecvMessage(absl::string_view payload) {
}
}
// If we had valid resources or the update was empty, update the version.
if (result.have_valid_resources || result.errors.empty()) {
if (result.num_valid_resources > 0 || result.errors.empty()) {
xds_channel()->resource_type_version_map_[result.type] =
std::move(result.version);
}
// Send ACK or NACK.
SendMessageLocked(result.type);
}
// Update metrics.
if (xds_client()->metrics_reporter_ != nullptr) {
xds_client()->metrics_reporter_->ReportResourceUpdates(
xds_channel()->server_.server_uri(), result.type_url,
result.num_valid_resources, result.num_invalid_resources);
}
}
xds_client()->work_serializer_.DrainQueue();
}
@ -1484,10 +1496,13 @@ bool XdsClient::XdsChannel::LrsCall::IsCurrentCallOnChannel() const {
// XdsClient
//
constexpr absl::string_view XdsClient::kOldStyleAuthority;
XdsClient::XdsClient(
std::unique_ptr<XdsBootstrap> bootstrap,
OrphanablePtr<XdsTransportFactory> transport_factory,
std::shared_ptr<grpc_event_engine::experimental::EventEngine> engine,
std::unique_ptr<XdsMetricsReporter> metrics_reporter,
std::string user_agent_name, std::string user_agent_version,
Duration resource_request_timeout)
: DualRefCounted<XdsClient>(
@ -1500,7 +1515,8 @@ XdsClient::XdsClient(
api_(this, &grpc_xds_client_trace, bootstrap_->node(), &def_pool_,
std::move(user_agent_name), std::move(user_agent_version)),
work_serializer_(engine),
engine_(std::move(engine)) {
engine_(std::move(engine)),
metrics_reporter_(std::move(metrics_reporter)) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
gpr_log(GPR_INFO, "[xds_client %p] creating xds client", this);
}
@ -1575,12 +1591,12 @@ void XdsClient::WatchResource(const XdsResourceType* type,
}
// Find server to use.
const XdsBootstrap::XdsServer* xds_server = nullptr;
absl::string_view authority_name = resource_name->authority;
if (absl::ConsumePrefix(&authority_name, "xdstp:")) {
auto* authority = bootstrap_->LookupAuthority(std::string(authority_name));
if (resource_name->authority != kOldStyleAuthority) {
auto* authority =
bootstrap_->LookupAuthority(std::string(resource_name->authority));
if (authority == nullptr) {
fail(absl::UnavailableError(
absl::StrCat("authority \"", authority_name,
absl::StrCat("authority \"", resource_name->authority,
"\" not present in bootstrap config")));
return;
}
@ -1738,10 +1754,11 @@ const XdsResourceType* XdsClient::GetResourceTypeLocked(
absl::StatusOr<XdsClient::XdsResourceName> XdsClient::ParseXdsResourceName(
absl::string_view name, const XdsResourceType* type) {
// Old-style names use the empty string for authority.
// authority is prefixed with "old:" to indicate that it's an old-style
// name.
// authority is set to kOldStyleAuthority to indicate that it's an
// old-style name.
if (!xds_federation_enabled_ || !absl::StartsWith(name, "xdstp:")) {
return XdsResourceName{"old:", {std::string(name), {}}};
return XdsResourceName{std::string(kOldStyleAuthority),
{std::string(name), {}}};
}
// New style name. Parse URI.
auto uri = URI::Parse(name);
@ -1760,14 +1777,14 @@ absl::StatusOr<XdsClient::XdsResourceName> XdsClient::ParseXdsResourceName(
URI::QueryParam{std::string(p.first), std::string(p.second)});
}
return XdsResourceName{
absl::StrCat("xdstp:", uri->authority()),
uri->authority(),
{std::string(path_parts.second), std::move(query_params)}};
}
std::string XdsClient::ConstructFullXdsResourceName(
absl::string_view authority, absl::string_view resource_type,
const XdsResourceKey& key) {
if (absl::ConsumePrefix(&authority, "xdstp:")) {
if (authority != kOldStyleAuthority) {
auto uri = URI::Create("xdstp", std::string(authority),
absl::StrCat("/", resource_type, "/", key.id),
key.query_params, /*fragment=*/"");
@ -2121,4 +2138,53 @@ void XdsClient::DumpClientConfig(
}
}
namespace {
absl::string_view CacheStateForEntry(const XdsApi::ResourceMetadata& metadata,
bool resource_cached) {
switch (metadata.client_status) {
case XdsApi::ResourceMetadata::REQUESTED:
return "requested";
case XdsApi::ResourceMetadata::DOES_NOT_EXIST:
return "does_not_exist";
case XdsApi::ResourceMetadata::ACKED:
return "acked";
case XdsApi::ResourceMetadata::NACKED:
return resource_cached ? "nacked_but_cached" : "nacked";
}
Crash("unknown resource state");
}
} // namespace
void XdsClient::ReportResourceCounts(
absl::FunctionRef<void(const ResourceCountLabels&, uint64_t)> func) {
ResourceCountLabels labels;
for (const auto& a : authority_state_map_) { // authority
labels.xds_authority = a.first;
for (const auto& t : a.second.resource_map) { // type
labels.resource_type = t.first->type_url();
// Count the number of entries in each state.
std::map<absl::string_view, uint64_t> counts;
for (const auto& r : t.second) { // resource id
absl::string_view cache_state =
CacheStateForEntry(r.second.meta, r.second.resource != nullptr);
++counts[cache_state];
}
// Report the count for each state.
for (const auto& c : counts) {
labels.cache_state = c.first;
func(labels, c.second);
}
}
}
}
void XdsClient::ReportServerConnections(
absl::FunctionRef<void(absl::string_view, bool)> func) {
for (const auto& p : xds_channel_map_) {
func(p.second->server_uri(), p.second->status().ok());
}
}
} // namespace grpc_core

@ -37,6 +37,7 @@
#include "src/core/ext/xds/xds_api.h"
#include "src/core/ext/xds/xds_bootstrap.h"
#include "src/core/ext/xds/xds_client_stats.h"
#include "src/core/ext/xds/xds_metrics.h"
#include "src/core/ext/xds/xds_resource_type.h"
#include "src/core/ext/xds/xds_transport.h"
#include "src/core/lib/debug/trace.h"
@ -60,6 +61,9 @@ extern TraceFlag grpc_xds_client_refcount_trace;
class XdsClient : public DualRefCounted<XdsClient> {
public:
// The authority reported for old-style (non-xdstp) resource names.
static constexpr absl::string_view kOldStyleAuthority = "#old";
class ReadDelayHandle : public RefCounted<ReadDelayHandle> {
public:
static RefCountedPtr<ReadDelayHandle> NoWait() { return nullptr; }
@ -87,6 +91,7 @@ class XdsClient : public DualRefCounted<XdsClient> {
std::unique_ptr<XdsBootstrap> bootstrap,
OrphanablePtr<XdsTransportFactory> transport_factory,
std::shared_ptr<grpc_event_engine::experimental::EventEngine> engine,
std::unique_ptr<XdsMetricsReporter> metrics_reporter,
std::string user_agent_name, std::string user_agent_version,
Duration resource_request_timeout = Duration::Seconds(15));
~XdsClient() override;
@ -156,6 +161,8 @@ class XdsClient : public DualRefCounted<XdsClient> {
}
protected:
Mutex* mu() ABSL_LOCK_RETURNED(&mu_) { return &mu_; }
// Dumps the active xDS config to the provided
// envoy.service.status.v3.ClientConfig message including the config status
// (e.g., CLIENT_REQUESTED, CLIENT_ACKED, CLIENT_NACKED).
@ -163,7 +170,22 @@ class XdsClient : public DualRefCounted<XdsClient> {
envoy_service_status_v3_ClientConfig* client_config)
ABSL_EXCLUSIVE_LOCKS_REQUIRED(&mu_);
Mutex* mu() ABSL_LOCK_RETURNED(&mu_) { return &mu_; }
// Invokes func once for each combination of labels to report the
// resource count for those labels.
struct ResourceCountLabels {
absl::string_view xds_authority;
absl::string_view resource_type;
absl::string_view cache_state;
};
void ReportResourceCounts(
absl::FunctionRef<void(const ResourceCountLabels&, uint64_t)> func)
ABSL_EXCLUSIVE_LOCKS_REQUIRED(&mu_);
// Invokes func once for each xDS server to report whether the
// connection to that server is working.
void ReportServerConnections(
absl::FunctionRef<void(absl::string_view /*xds_server*/, bool)> func)
ABSL_EXCLUSIVE_LOCKS_REQUIRED(&mu_);
private:
friend testing::XdsClientTestPeer;
@ -221,6 +243,8 @@ class XdsClient : public DualRefCounted<XdsClient> {
bool delay_unsubscription)
ABSL_EXCLUSIVE_LOCKS_REQUIRED(&XdsClient::mu_);
absl::string_view server_uri() const { return server_.server_uri(); }
private:
void OnConnectivityFailure(absl::Status status);
@ -327,6 +351,7 @@ class XdsClient : public DualRefCounted<XdsClient> {
XdsApi api_;
WorkSerializer work_serializer_;
std::shared_ptr<grpc_event_engine::experimental::EventEngine> engine_;
std::unique_ptr<XdsMetricsReporter> metrics_reporter_;
Mutex mu_;

@ -49,6 +49,7 @@
#include "src/core/ext/xds/xds_transport.h"
#include "src/core/ext/xds/xds_transport_grpc.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/metrics.h"
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/event_engine/default_event_engine.h"
#include "src/core/lib/gprpp/debug_location.h"
@ -64,8 +65,6 @@
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/transport/error_utils.h"
namespace grpc_core {
// If gRPC is built with -DGRPC_XDS_USER_AGENT_NAME_SUFFIX="...", that string
// will be appended to the user agent name reported to the xDS server.
#ifdef GRPC_XDS_USER_AGENT_NAME_SUFFIX
@ -84,10 +83,90 @@ namespace grpc_core {
#define GRPC_XDS_USER_AGENT_VERSION_SUFFIX_STRING ""
#endif
namespace grpc_core {
namespace {
// Metric labels.
constexpr absl::string_view kMetricLabelXdsServer = "grpc.xds.server";
constexpr absl::string_view kMetricLabelXdsAuthority = "grpc.xds.authority";
constexpr absl::string_view kMetricLabelXdsResourceType =
"grpc.xds.resource_type";
constexpr absl::string_view kMetricLabelXdsCacheState = "grpc.xds.cache_state";
const auto kMetricResourceUpdatesValid =
GlobalInstrumentsRegistry::RegisterUInt64Counter(
"grpc.xds_client.resource_updates_valid",
"EXPERIMENTAL. A counter of resources received that were considered "
"valid. The counter will be incremented even for resources that "
"have not changed.",
"{resource}",
{kMetricLabelTarget, kMetricLabelXdsServer,
kMetricLabelXdsResourceType},
{}, false);
const auto kMetricResourceUpdatesInvalid =
GlobalInstrumentsRegistry::RegisterUInt64Counter(
"grpc.xds_client.resource_updates_invalid",
"EXPERIMENTAL. A counter of resources received that were considered "
"invalid.",
"{resource}",
{kMetricLabelTarget, kMetricLabelXdsServer,
kMetricLabelXdsResourceType},
{}, false);
const auto kMetricConnected =
GlobalInstrumentsRegistry::RegisterCallbackInt64Gauge(
"grpc.xds_client.connected",
"EXPERIMENTAL. Whether or not the xDS client currently has a "
"working ADS stream to the xDS server. For a given server, this "
"will be set to 0 when we have a connectivity failure or when the "
"ADS stream fails without seeing a response message, as per gRFC "
"A57. It will be set to 1 when we receive the first response on "
"an ADS stream.",
"{bool}", {kMetricLabelTarget, kMetricLabelXdsServer}, {}, false);
const auto kMetricResources =
GlobalInstrumentsRegistry::RegisterCallbackInt64Gauge(
"grpc.xds_client.resources", "EXPERIMENTAL. Number of xDS resources.",
"{resource}",
{kMetricLabelTarget, kMetricLabelXdsAuthority,
kMetricLabelXdsResourceType, kMetricLabelXdsCacheState},
{}, false);
} // namespace
//
// GrpcXdsClient::MetricsReporter
//
class GrpcXdsClient::MetricsReporter : public XdsMetricsReporter {
public:
explicit MetricsReporter(GrpcXdsClient& xds_client)
: xds_client_(xds_client) {}
void ReportResourceUpdates(absl::string_view xds_server,
absl::string_view resource_type,
uint64_t num_valid_resources,
uint64_t num_invalid_resources) override {
xds_client_.stats_plugin_group_.AddCounter(
kMetricResourceUpdatesValid, num_valid_resources,
{xds_client_.key_, xds_server, resource_type}, {});
xds_client_.stats_plugin_group_.AddCounter(
kMetricResourceUpdatesInvalid, num_invalid_resources,
{xds_client_.key_, xds_server, resource_type}, {});
}
private:
GrpcXdsClient& xds_client_;
};
//
// GrpcXdsClient
//
constexpr absl::string_view GrpcXdsClient::kServerKey;
namespace {
Mutex* g_mu = new Mutex;
@ -97,10 +176,6 @@ NoDestruct<std::map<absl::string_view, GrpcXdsClient*>> g_xds_client_map
ABSL_GUARDED_BY(*g_mu);
char* g_fallback_bootstrap_config ABSL_GUARDED_BY(*g_mu) = nullptr;
} // namespace
namespace {
absl::StatusOr<std::string> GetBootstrapContents(const char* fallback_config) {
// First, try GRPC_XDS_BOOTSTRAP env var.
auto path = GetEnv("GRPC_XDS_BOOTSTRAP");
@ -138,19 +213,6 @@ absl::StatusOr<std::string> GetBootstrapContents(const char* fallback_config) {
"not defined");
}
std::vector<RefCountedPtr<GrpcXdsClient>> GetAllXdsClients() {
MutexLock lock(g_mu);
std::vector<RefCountedPtr<GrpcXdsClient>> xds_clients;
for (const auto& key_client : *g_xds_client_map) {
auto xds_client =
key_client.second->RefIfNonZero(DEBUG_LOCATION, "DumpAllClientConfigs");
if (xds_client != nullptr) {
xds_clients.emplace_back(xds_client.TakeAsSubclass<GrpcXdsClient>());
}
}
return xds_clients;
}
} // namespace
absl::StatusOr<RefCountedPtr<GrpcXdsClient>> GrpcXdsClient::GetOrCreate(
@ -201,36 +263,20 @@ absl::StatusOr<RefCountedPtr<GrpcXdsClient>> GrpcXdsClient::GetOrCreate(
return xds_client;
}
// ABSL_NO_THREAD_SAFETY_ANALYSIS because we have to manually manage locks for
// individual XdsClients and compiler struggles with checking the validity
grpc_slice GrpcXdsClient::DumpAllClientConfigs()
ABSL_NO_THREAD_SAFETY_ANALYSIS {
auto xds_clients = GetAllXdsClients();
upb::Arena arena;
// Contains strings that should survive till serialization
std::set<std::string> string_pool;
auto response = envoy_service_status_v3_ClientStatusResponse_new(arena.ptr());
// We lock each XdsClient mutex till we are done with the serialization to
// ensure that all data referenced from the UPB proto message stays alive.
for (const auto& xds_client : xds_clients) {
auto client_config =
envoy_service_status_v3_ClientStatusResponse_add_config(response,
arena.ptr());
xds_client->mu()->Lock();
xds_client->DumpClientConfig(&string_pool, arena.ptr(), client_config);
envoy_service_status_v3_ClientConfig_set_client_scope(
client_config, StdStringToUpbString(xds_client->key()));
}
// Serialize the upb message to bytes
size_t output_length;
char* output = envoy_service_status_v3_ClientStatusResponse_serialize(
response, arena.ptr(), &output_length);
for (const auto& xds_client : xds_clients) {
xds_client->mu()->Unlock();
namespace {
GlobalStatsPluginRegistry::StatsPluginGroup GetStatsPluginGroupForKey(
absl::string_view key) {
if (key == GrpcXdsClient::kServerKey) {
return GlobalStatsPluginRegistry::GetAllStatsPlugins();
}
return grpc_slice_from_cpp_string(std::string(output, output_length));
// TODO(roth): How do we set the authority here?
StatsPlugin::ChannelScope scope(key, "");
return GlobalStatsPluginRegistry::GetStatsPluginsForChannel(scope);
}
} // namespace
GrpcXdsClient::GrpcXdsClient(
absl::string_view key, std::unique_ptr<GrpcXdsBootstrap> bootstrap,
const ChannelArgs& args,
@ -238,6 +284,7 @@ GrpcXdsClient::GrpcXdsClient(
: XdsClient(
std::move(bootstrap), std::move(transport_factory),
grpc_event_engine::experimental::GetDefaultEventEngine(),
std::make_unique<MetricsReporter>(*this),
absl::StrCat("gRPC C-core ", GPR_PLATFORM_STRING,
GRPC_XDS_USER_AGENT_NAME_SUFFIX_STRING),
absl::StrCat("C-core ", grpc_version_string(),
@ -250,15 +297,22 @@ GrpcXdsClient::GrpcXdsClient(
key_(key),
certificate_provider_store_(MakeOrphanable<CertificateProviderStore>(
static_cast<const GrpcXdsBootstrap&>(this->bootstrap())
.certificate_providers())) {}
.certificate_providers())),
stats_plugin_group_(GetStatsPluginGroupForKey(key_)),
registered_metric_callback_(stats_plugin_group_.RegisterCallback(
[this](CallbackMetricReporter& reporter) {
ReportCallbackMetrics(reporter);
},
{kMetricConnected, kMetricResources})) {}
void GrpcXdsClient::Orphan() {
registered_metric_callback_.reset();
XdsClient::Orphan();
MutexLock lock(g_mu);
auto it = g_xds_client_map->find(key_);
if (it != g_xds_client_map->end() && it->second == this) {
g_xds_client_map->erase(it);
}
XdsClient::Orphan();
}
grpc_pollset_set* GrpcXdsClient::interested_parties() const {
@ -266,6 +320,66 @@ grpc_pollset_set* GrpcXdsClient::interested_parties() const {
->interested_parties();
}
namespace {
std::vector<RefCountedPtr<GrpcXdsClient>> GetAllXdsClients() {
MutexLock lock(g_mu);
std::vector<RefCountedPtr<GrpcXdsClient>> xds_clients;
for (const auto& key_client : *g_xds_client_map) {
auto xds_client =
key_client.second->RefIfNonZero(DEBUG_LOCATION, "DumpAllClientConfigs");
if (xds_client != nullptr) {
xds_clients.emplace_back(xds_client.TakeAsSubclass<GrpcXdsClient>());
}
}
return xds_clients;
}
} // namespace
// ABSL_NO_THREAD_SAFETY_ANALYSIS because we have to manually manage locks for
// individual XdsClients and compiler struggles with checking the validity
grpc_slice GrpcXdsClient::DumpAllClientConfigs()
ABSL_NO_THREAD_SAFETY_ANALYSIS {
auto xds_clients = GetAllXdsClients();
upb::Arena arena;
// Contains strings that should survive till serialization
std::set<std::string> string_pool;
auto response = envoy_service_status_v3_ClientStatusResponse_new(arena.ptr());
// We lock each XdsClient mutex till we are done with the serialization to
// ensure that all data referenced from the UPB proto message stays alive.
for (const auto& xds_client : xds_clients) {
auto client_config =
envoy_service_status_v3_ClientStatusResponse_add_config(response,
arena.ptr());
xds_client->mu()->Lock();
xds_client->DumpClientConfig(&string_pool, arena.ptr(), client_config);
envoy_service_status_v3_ClientConfig_set_client_scope(
client_config, StdStringToUpbString(xds_client->key()));
}
// Serialize the upb message to bytes
size_t output_length;
char* output = envoy_service_status_v3_ClientStatusResponse_serialize(
response, arena.ptr(), &output_length);
for (const auto& xds_client : xds_clients) {
xds_client->mu()->Unlock();
}
return grpc_slice_from_cpp_string(std::string(output, output_length));
}
void GrpcXdsClient::ReportCallbackMetrics(CallbackMetricReporter& reporter) {
MutexLock lock(mu());
ReportResourceCounts([&](const ResourceCountLabels& labels, uint64_t count) {
reporter.Report(
kMetricResources, count,
{key_, labels.xds_authority, labels.resource_type, labels.cache_state},
{});
});
ReportServerConnections([&](absl::string_view xds_server, bool connected) {
reporter.Report(kMetricConnected, connected, {key_, xds_server}, {});
});
}
namespace internal {
void SetXdsChannelArgsForTest(grpc_channel_args* args) {

@ -31,6 +31,7 @@
#include "src/core/ext/xds/xds_client.h"
#include "src/core/ext/xds/xds_transport.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/metrics.h"
#include "src/core/lib/gpr/useful.h"
#include "src/core/lib/gprpp/orphanable.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h"
@ -41,13 +42,13 @@ namespace grpc_core {
class GrpcXdsClient : public XdsClient {
public:
// The key to pass to GetOrCreate() for gRPC servers.
static constexpr absl::string_view kServerKey = "#server";
// Factory function to get or create the global XdsClient instance.
static absl::StatusOr<RefCountedPtr<GrpcXdsClient>> GetOrCreate(
absl::string_view key, const ChannelArgs& args, const char* reason);
// Builds ClientStatusResponse containing all resources from all XdsClients
static grpc_slice DumpAllClientConfigs();
// Do not instantiate directly -- use GetOrCreate() instead.
// TODO(roth): The transport factory is injectable here to support
// tests that want to use a fake transport factory with code that
@ -83,9 +84,18 @@ class GrpcXdsClient : public XdsClient {
absl::string_view key() const { return key_; }
// Builds ClientStatusResponse containing all resources from all XdsClients
static grpc_slice DumpAllClientConfigs();
private:
class MetricsReporter;
void ReportCallbackMetrics(CallbackMetricReporter& reporter);
std::string key_;
OrphanablePtr<CertificateProviderStore> certificate_provider_store_;
GlobalStatsPluginRegistry::StatsPluginGroup stats_plugin_group_;
std::unique_ptr<RegisteredMetricCallback> registered_metric_callback_;
};
namespace internal {

@ -0,0 +1,39 @@
//
// Copyright 2024 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.
//
#ifndef GRPC_SRC_CORE_EXT_XDS_XDS_METRICS_H
#define GRPC_SRC_CORE_EXT_XDS_XDS_METRICS_H
#include <grpc/support/port_platform.h>
#include "absl/strings/string_view.h"
namespace grpc_core {
// An interface for XdsClient to report metrics.
class XdsMetricsReporter {
public:
virtual ~XdsMetricsReporter() = default;
virtual void ReportResourceUpdates(absl::string_view xds_server,
absl::string_view resource_type,
uint64_t num_valid,
uint64_t num_invalid) = 0;
};
} // namespace grpc_core
#endif // GRPC_SRC_CORE_EXT_XDS_XDS_METRICS_H

@ -94,8 +94,6 @@ namespace {
using ReadDelayHandle = XdsClient::ReadDelayHandle;
constexpr absl::string_view kServerXdsClientKey = "#server";
TraceFlag grpc_xds_server_config_fetcher_trace(false,
"xds_server_config_fetcher");
@ -1374,7 +1372,8 @@ grpc_server_config_fetcher* grpc_server_config_fetcher_xds_create(
"update=%p, user_data=%p}, args=%p)",
3, (notifier.on_serving_status_update, notifier.user_data, args));
auto xds_client = grpc_core::GrpcXdsClient::GetOrCreate(
grpc_core::kServerXdsClientKey, channel_args, "XdsServerConfigFetcher");
grpc_core::GrpcXdsClient::kServerKey, channel_args,
"XdsServerConfigFetcher");
if (!xds_client.ok()) {
gpr_log(GPR_ERROR, "Failed to create xds client: %s",
xds_client.status().ToString().c_str());

@ -311,6 +311,16 @@ void GlobalStatsPluginRegistry::RegisterStatsPlugin(
plugins_->push_back(std::move(plugin));
}
GlobalStatsPluginRegistry::StatsPluginGroup
GlobalStatsPluginRegistry::GetAllStatsPlugins() {
MutexLock lock(&*mutex_);
StatsPluginGroup group;
for (const auto& plugin : *plugins_) {
group.push_back(plugin);
}
return group;
}
GlobalStatsPluginRegistry::StatsPluginGroup
GlobalStatsPluginRegistry::GetStatsPluginsForChannel(
const StatsPlugin::ChannelScope& scope) {

@ -310,8 +310,10 @@ class GlobalStatsPluginRegistry {
};
static void RegisterStatsPlugin(std::shared_ptr<StatsPlugin> plugin);
// The following two functions can be invoked to get a StatsPluginGroup for
// The following functions can be invoked to get a StatsPluginGroup for
// a specified scope.
static StatsPluginGroup GetAllStatsPlugins();
static StatsPluginGroup GetStatsPluginsForChannel(
const StatsPlugin::ChannelScope& scope);
// TODO(yijiem): Implement this.

@ -100,7 +100,7 @@ absl::StatusOr<int> PosixEngineListenerImpl::Bind(
}
}
auto used_port = ResolvedAddressIsWildcard(res_addr);
auto used_port = MaybeGetWildcardPortFromAddress(res_addr);
// Update the callback. Any subsequent new sockets created and added to
// acceptors_ in this function will invoke the new callback.
acceptors_.UpdateOnAppendCallback(std::move(on_bind_new_fd));

@ -311,7 +311,7 @@ void ResolvedAddressSetPort(EventEngine::ResolvedAddress& resolved_addr,
}
}
absl::optional<int> ResolvedAddressIsWildcard(
absl::optional<int> MaybeGetWildcardPortFromAddress(
const EventEngine::ResolvedAddress& addr) {
const EventEngine::ResolvedAddress* resolved_addr = &addr;
EventEngine::ResolvedAddress addr4_normalized;

@ -57,8 +57,8 @@ void ResolvedAddressSetPort(EventEngine::ResolvedAddress& resolved_addr,
int port);
// Returns the port number associated with the address if the given address is
// not a wildcard ipv6 or ipv6 address. Otherwise returns absl::nullopt
absl::optional<int> ResolvedAddressIsWildcard(
// a wildcard ipv4 or ipv6 address. Otherwise returns absl::nullopt
absl::optional<int> MaybeGetWildcardPortFromAddress(
const EventEngine::ResolvedAddress& addr);
// Returns true if resolved_addr is an VSOCK address. Otherwise returns false.

@ -354,7 +354,7 @@ absl::StatusOr<int> WindowsEventEngineListener::Bind(
out_addr = tmp_addr;
}
// Treat :: or 0.0.0.0 as a family-agnostic wildcard.
if (ResolvedAddressIsWildcard(out_addr)) {
if (MaybeGetWildcardPortFromAddress(out_addr).has_value()) {
out_addr = ResolvedAddressMakeWild6(out_port);
}
// open the socket

@ -32,6 +32,9 @@ namespace grpc_core {
// Loads the content of a file into a slice. add_null_terminator will add a NULL
// terminator if true.
// This API is NOT thread-safe and requires proper synchronization when used by
// multiple threads, especially when they can happen to be reading from the same
// file.
absl::StatusOr<Slice> LoadFile(const std::string& filename,
bool add_null_terminator) {
unsigned char* contents = nullptr;
@ -61,7 +64,6 @@ absl::StatusOr<Slice> LoadFile(const std::string& filename,
bytes_read = fread(contents, 1, contents_size, file);
if (bytes_read < contents_size) {
gpr_free(contents);
GPR_ASSERT(ferror(file));
error = absl::InternalError(
absl::StrCat("Failed to load file: ", filename,
" due to error(fread): ", strerror(errno)));

@ -37,6 +37,11 @@ grpc_core::DebugOnlyTraceFlag grpc_trace_party_state(false, "party_state");
namespace grpc_core {
namespace {
// TODO(ctiller): Once all activities are parties we can remove this.
thread_local Party** g_current_party_run_next = nullptr;
} // namespace
///////////////////////////////////////////////////////////////////////////////
// PartySyncUsingAtomics
@ -210,11 +215,38 @@ void Party::ForceImmediateRepoll(WakeupMask mask) {
}
void Party::RunLocked() {
// If there is a party running, then we don't run it immediately
// but instead add it to the end of the list of parties to run.
// This enables a fairly straightforward batching of work from a
// call to a transport (or back again).
if (g_current_party_run_next != nullptr) {
if (*g_current_party_run_next == nullptr) {
*g_current_party_run_next = this;
} else {
// But if there's already a party queued, we're better off asking event
// engine to run it so we can spread load.
event_engine()->Run([this]() {
ApplicationCallbackExecCtx app_exec_ctx;
ExecCtx exec_ctx;
RunLocked();
});
}
return;
}
auto body = [this]() {
if (RunParty()) {
GPR_DEBUG_ASSERT(g_current_party_run_next == nullptr);
Party* run_next = nullptr;
g_current_party_run_next = &run_next;
const bool done = RunParty();
GPR_DEBUG_ASSERT(g_current_party_run_next == &run_next);
g_current_party_run_next = nullptr;
if (done) {
ScopedActivity activity(this);
PartyOver();
}
if (run_next != nullptr) {
run_next->RunLocked();
}
};
#ifdef GRPC_MAXIMIZE_THREADYNESS
Thread thd(

@ -22,6 +22,7 @@
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/channelz.h"
#include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/debug/stats.h"
#include "src/core/lib/debug/stats_data.h"
#include "src/core/lib/surface/channel.h"
@ -34,6 +35,14 @@ absl::StatusOr<OrphanablePtr<Channel>> ChannelCreate(
std::string target, ChannelArgs args,
grpc_channel_stack_type channel_stack_type, Transport* optional_transport) {
global_stats().IncrementClientChannelsCreated();
// For client channels, canonify target string and add channel arg.
// Note: We don't do this for direct channels or lame channels.
if (channel_stack_type == GRPC_CLIENT_CHANNEL) {
target =
CoreConfiguration::Get().resolver_registry().AddDefaultPrefixIfNeeded(
target);
args = args.Set(GRPC_ARG_SERVER_URI, target);
}
// Set default authority if needed.
if (!args.GetString(GRPC_ARG_DEFAULT_AUTHORITY).has_value()) {
auto ssl_override = args.GetString(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG);

@ -1045,10 +1045,12 @@ static bool ValidateCrl(X509* cert, X509* issuer, X509_CRL* crl) {
// 6.3.3b verify issuer and scope
valid = grpc_core::VerifyCrlCertIssuerNamesMatch(crl, cert);
if (!valid) {
gpr_log(GPR_DEBUG, "CRL and cert issuer names mismatched.");
return valid;
}
valid = grpc_core::HasCrlSignBit(issuer);
if (!valid) {
gpr_log(GPR_DEBUG, "CRL issuer not allowed to sign CRLs.");
return valid;
}
// 6.3.3c Not supporting deltas
@ -1058,6 +1060,9 @@ static bool ValidateCrl(X509* cert, X509* issuer, X509_CRL* crl) {
// same.
// 6.3.3g Verify CRL Signature
valid = grpc_core::VerifyCrlSignature(crl, issuer);
if (!valid) {
gpr_log(GPR_DEBUG, "Crl signature check failed.");
}
return valid;
}
@ -1146,6 +1151,7 @@ static int CheckChainRevocation(
static int CustomVerificationFunction(X509_STORE_CTX* ctx, void* arg) {
int ret = X509_verify_cert(ctx);
if (ret <= 0) {
gpr_log(GPR_DEBUG, "Failed to verify cert chain.");
// Verification failed. We shouldn't expect to have a verified chain, so
// there is no need to attempt to extract the root cert from it, check for
// revocation, or check anything else.
@ -1154,10 +1160,10 @@ static int CustomVerificationFunction(X509_STORE_CTX* ctx, void* arg) {
grpc_core::experimental::CrlProvider* provider = GetCrlProvider(ctx);
if (provider != nullptr) {
ret = CheckChainRevocation(ctx, provider);
}
if (ret <= 0) {
// Something has failed return the failure
return ret;
if (ret <= 0) {
gpr_log(GPR_DEBUG, "The chain failed revocation checks.");
return ret;
}
}
return RootCertExtractCallback(ctx, arg);
}

@ -259,12 +259,19 @@ bool VerifyCrlSignature(X509_CRL* crl, X509* issuer) {
if (ikey == nullptr) {
// Can't verify signature because we couldn't get the pubkey, fail the
// check.
gpr_log(GPR_DEBUG, "Could not public key from certificate.");
EVP_PKEY_free(ikey);
return false;
}
bool ret = X509_CRL_verify(crl, ikey) == 1;
int ret = X509_CRL_verify(crl, ikey);
if (ret < 0) {
gpr_log(GPR_DEBUG,
"There was an unexpected problem checking the CRL signature.");
} else if (ret == 0) {
gpr_log(GPR_DEBUG, "CRL failed verification.");
}
EVP_PKEY_free(ikey);
return ret;
return ret == 1;
}
bool VerifyCrlCertIssuerNamesMatch(X509_CRL* crl, X509* cert) {

@ -194,7 +194,7 @@ class CallInvokerTest extends \PHPUnit\Framework\TestCase
$stub = new \Grpc\BaseStub('localhost:50051',
['credentials' => \Grpc\ChannelCredentials::createInsecure(),
'grpc_call_invoker' => $call_invoker]);
$this->assertEquals($call_invoker->getChannel()->getTarget(), 'localhost:50050');
$this->assertEquals($call_invoker->getChannel()->getTarget(), 'dns:///localhost:50050');
$call_invoker->getChannel()->close();
}

@ -94,7 +94,7 @@ class _ChannelServerPair:
channelz_pb2.GetTopChannelsRequest(start_channel_id=0)
)
for channel in resp.channel:
if channel.data.target == self.address:
if channel.data.target == "dns:///" + self.address:
self.channel_ref_id = channel.ref.channel_id
resp = await channelz_stub.GetServers(

@ -1,162 +0,0 @@
%YAML 1.2
--- |
# GRPC GYP build file
# This file has been automatically generated from a template file.
# Please look at the templates directory instead.
# This file can be regenerated from the template by running
# tools/buildgen/generate_projects.sh
# Copyright 2015 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.
<%
def is_absl_lib(target_name):
return target_name.startswith("absl/");
%>
{
'variables': {
# The openssl and zlib dependencies must be passed in as variables
# defined in an included gypi file, usually common.gypi.
'openssl_gyp_target%': 'Please Define openssl_gyp_target variable',
'zlib_gyp_target%': 'Please Define zlib_gyp_target variable',
'grpc_gcov%': 'false',
'grpc_alpine%': 'false',
},
'target_defaults': {
'configurations': {
% for name, args in configs.items():
% if name in ['dbg', 'opt']:
'${{'dbg':'Debug', 'opt': 'Release'}[name]}': {
% for arg, prop in [('CPPFLAGS', 'cflags'), ('DEFINES', 'defines')]:
% if args.get(arg, None) is not None:
'${prop}': [
% for item in args.get(arg).split():
'${item}',
% endfor
],
% endif
% endfor
},
% endif
% endfor
},
% for arg, prop in [('CPPFLAGS', 'cflags'), ('LDFLAGS', 'ldflags')]:
% if defaults['global'].get(arg, None) is not None:
'${prop}': [
% for item in defaults['global'].get(arg).split():
'${item}',
% endfor
],
% endif
% endfor
'cflags_c': [
'-Werror',
'-std=c11',
],
'cflags_cc': [
'-Werror',
'-std=c++14',
],
'include_dirs': [
'.',
'../..',
'include',
],
'defines': [
'GRPC_ARES=0',
],
'dependencies': [
'<(openssl_gyp_target)',
'<(zlib_gyp_target)',
],
'conditions': [
['grpc_gcov=="true"', {
% for arg, prop in [('CPPFLAGS', 'cflags'), ('DEFINES', 'defines'), ('LDFLAGS', 'ldflags')]:
% if configs['gcov'].get(arg, None) is not None:
'${prop}': [
% for item in configs['gcov'].get(arg).split():
'${item}',
% endfor
],
% endif
% endfor
}],
['grpc_alpine=="true"', {
'defines': [
'GPR_MUSL_LIBC_COMPAT'
]
}],
['OS == "win"', {
'defines': [
'_WIN32_WINNT=0x0600',
'WIN32_LEAN_AND_MEAN',
'_HAS_EXCEPTIONS=0',
'UNICODE',
'_UNICODE',
'NOMINMAX',
],
'msvs_settings': {
'VCCLCompilerTool': {
'RuntimeLibrary': 1, # static debug
}
},
"libraries": [
"ws2_32"
]
}],
['OS == "mac"', {
'xcode_settings': {
% if defaults['global'].get('CPPFLAGS', None) is not None:
'OTHER_CFLAGS': [
% for item in defaults['global'].get('CPPFLAGS').split():
'${item}',
% endfor
],
'OTHER_CPLUSPLUSFLAGS': [
% for item in defaults['global'].get('CPPFLAGS').split():
'${item}',
% endfor
'-stdlib=libc++',
'-std=c++14',
'-Wno-error=deprecated-declarations',
],
% endif
},
}]
]
},
'targets': [
% for lib in libs:
% if getattr(lib, 'platforms', None) is None and lib.name != 'cares' and not is_absl_lib(lib.name):
{
'target_name': '${lib.name}',
'type': 'static_library',
'dependencies': [
% for dep in getattr(lib, 'deps', []):
% if dep != 'libssl':
'${dep}',
% endif
% endfor
],
'sources': [
% for source in lib.src:
'${source}',
% endfor
],
},
% endif
% endfor
]
}

@ -1,8 +1,8 @@
# Pinned version of the base image is used to avoid regressions caused
# by rebuilding of this docker image. To see available versions, you can run
# "gcloud container images list-tags gcr.io/oss-fuzz-base/base-builder"
# Image(fd89316ac4c5) is built on Aug 17, 2023
FROM gcr.io/oss-fuzz-base/base-builder@sha256:fd89316ac4c5f3e25802ca95a00062cece14f0602c5512d71ffeedc22734c0b9
# This base image is built on Mar 12, 2024
FROM gcr.io/oss-fuzz-base/base-builder@sha256:c3581153788bc49f3634fec3cd36a5d6dfd26632c4afc157fb6faf8ce3af732e
# -------------------------- WARNING --------------------------------------
# If you are making changes to this file, consider changing

@ -19,26 +19,31 @@
#========================
# Java
RUN apt-get install -y openjdk-8-jdk
RUN apt-get install -y openjdk-21-jdk
#========================
# Android SDK/NDK installation
ENV SDK_ROOT=/opt/android-sdk
ENV ANDROID_SDK_VERSION 11076708
ENV ANDROID_NDK_VERSION 26.2.11394342
ENV SDK_ROOT /opt/android-sdk
RUN mkdir -p $SDK_ROOT
RUN wget -O cmd.zip dl.google.com/android/repository/commandlinetools-linux-7302050_latest.zip && \
unzip cmd.zip && rm cmd.zip && \
yes | ./cmdline-tools/bin/sdkmanager --sdk_root=$SDK_ROOT 'tools' && \
yes | ./cmdline-tools/bin/sdkmanager --sdk_root=$SDK_ROOT 'platform-tools' && \
yes | ./cmdline-tools/bin/sdkmanager --sdk_root=$SDK_ROOT 'build-tools;30.0.3' && \
yes | ./cmdline-tools/bin/sdkmanager --sdk_root=$SDK_ROOT 'platforms;android-29' && \
yes | ./cmdline-tools/bin/sdkmanager --sdk_root=$SDK_ROOT 'ndk-bundle' && \
yes | ./cmdline-tools/bin/sdkmanager --sdk_root=$SDK_ROOT 'ndk;21.4.7075529'
RUN cd $SDK_ROOT && \
wget -O cmd.zip https://dl.google.com/android/repository/commandlinetools-linux-${'${ANDROID_SDK_VERSION}'}_latest.zip && \
unzip -q cmd.zip && \
rm cmd.zip
RUN yes | $SDK_ROOT/cmdline-tools/bin/sdkmanager --sdk_root=$SDK_ROOT --licenses # accept all licenses
# This is not required but desirable to reduce the time to download and the chance of download failure.
RUN mkdir -p ~/.android && touch ~/.android/repositories.cfg
RUN $SDK_ROOT/cmdline-tools/bin/sdkmanager --sdk_root=$SDK_ROOT "ndk;$ANDROID_NDK_VERSION" "platforms;android-33" "build-tools;34.0.0"
# Set environment variables for Bazel rules
ENV ANDROID_HOME=/opt/android-sdk
ENV ANDROID_NDK_HOME=/opt/android-sdk/ndk/21.4.7075529
RUN mkdir -p /var/local/jenkins
ENV ANDROID_HOME $SDK_ROOT
ENV ANDROID_NDK_HOME $SDK_ROOT/ndk/$ANDROID_NDK_VERSION
# Define the default command.
CMD ["bash"]

@ -547,16 +547,6 @@ BasicFuzzer::Result BasicFuzzer::CancelActiveCall() {
return Result::kComplete;
}
BasicFuzzer::Result BasicFuzzer::SendPingOnChannel() {
if (channel() != nullptr) {
pending_pings_++;
grpc_channel_ping(channel(), cq_, Decrement(&pending_pings_), nullptr);
} else {
return Result::kFailed;
}
return Result::kComplete;
}
BasicFuzzer::Result BasicFuzzer::Pause(Duration duration) {
++paused_;
engine()->RunAfterExactly(duration, [this]() { --paused_; });
@ -642,8 +632,7 @@ void BasicFuzzer::ShutdownCalls() {
bool BasicFuzzer::Continue() {
return channel() != nullptr || server() != nullptr ||
pending_channel_watches_ > 0 || pending_pings_ > 0 ||
ActiveCall() != nullptr || paused_;
pending_channel_watches_ > 0 || ActiveCall() != nullptr || paused_;
}
BasicFuzzer::Result BasicFuzzer::ExecuteAction(
@ -699,7 +688,8 @@ BasicFuzzer::Result BasicFuzzer::ExecuteAction(
return ValidateChannelTarget();
// send a ping on a channel
case api_fuzzer::Action::kPing:
return SendPingOnChannel();
// Ping is no longer a part of the API
return BasicFuzzer::Result::kNotSupported;
// enable a tracer
case api_fuzzer::Action::kEnableTracer: {
grpc_tracer_set_enabled(action.enable_tracer().c_str(), 1);

@ -135,8 +135,6 @@ class BasicFuzzer {
Result WatchConnectivity(uint32_t duration_us);
// Verify that the channel target can be reliably queried.
Result ValidateChannelTarget();
// Send a http ping on the channel.
Result SendPingOnChannel();
// Server specific actions
// Create an active server.
@ -183,7 +181,6 @@ class BasicFuzzer {
bool server_shutdown_ = false;
int pending_server_shutdowns_ = 0;
int pending_channel_watches_ = 0;
int pending_pings_ = 0;
int paused_ = 0;
std::vector<std::shared_ptr<Call>> calls_;
RefCountedPtr<ResourceQuota> resource_quota_;

@ -313,6 +313,21 @@ TEST(TcpSocketUtilsTest, SockAddrPortTest) {
EXPECT_EQ(ResolvedAddressToNormalizedString(wild6).value(), "[::]:22");
}
TEST(TcpSocketUtilsTest, MaybeGetWildcardPortFromAddress) {
EventEngine::ResolvedAddress wild4 = ResolvedAddressMakeWild4(20);
EventEngine::ResolvedAddress wild6 = ResolvedAddressMakeWild6(20);
auto v4_port = MaybeGetWildcardPortFromAddress(wild4);
ASSERT_TRUE(v4_port.has_value());
auto v6_port = MaybeGetWildcardPortFromAddress(wild6);
ASSERT_TRUE(v6_port.has_value());
wild4 = MakeAddr4(kIPv4, sizeof(kIPv4));
v4_port = MaybeGetWildcardPortFromAddress(wild4);
ASSERT_FALSE(v4_port.has_value());
wild6 = MakeAddr6(kMapped, sizeof(kMapped));
v6_port = MaybeGetWildcardPortFromAddress(wild6);
ASSERT_FALSE(v6_port.has_value());
}
} // namespace experimental
} // namespace grpc_event_engine

@ -285,8 +285,7 @@ TEST_F(PartyTest, CanSpawnAndRun) {
"TestSpawn",
[i = 10]() mutable -> Poll<int> {
EXPECT_EQ(GetContext<Activity>()->DebugTag(), "TestParty");
gpr_log(GPR_DEBUG, "i=%d", i);
GPR_ASSERT(i > 0);
EXPECT_GT(i, 0);
GetContext<Activity>()->ForceImmediateRepoll();
--i;
if (i == 0) return 42;
@ -786,6 +785,60 @@ TEST_F(PartyTest, ThreadStressTestWithInnerSpawn) {
}
}
TEST_F(PartyTest, NestedWakeup) {
auto party1 = MakeRefCounted<TestParty>();
auto party2 = MakeRefCounted<TestParty>();
auto party3 = MakeRefCounted<TestParty>();
int whats_going_on = 0;
Notification started2;
Notification done2;
Notification started3;
Notification notify_done;
party1->Spawn(
"p1",
[&]() {
EXPECT_EQ(whats_going_on, 0);
whats_going_on = 1;
party2->Spawn(
"p2",
[&]() {
started2.Notify();
started3.WaitForNotification();
EXPECT_EQ(whats_going_on, 3);
whats_going_on = 4;
return Empty{};
},
[&](Empty) {
EXPECT_EQ(whats_going_on, 4);
whats_going_on = 5;
done2.Notify();
});
party3->Spawn(
"p3",
[&]() {
started2.WaitForNotification();
started3.Notify();
done2.WaitForNotification();
EXPECT_EQ(whats_going_on, 5);
whats_going_on = 6;
return Empty{};
},
[&](Empty) {
EXPECT_EQ(whats_going_on, 6);
whats_going_on = 7;
notify_done.Notify();
});
EXPECT_EQ(whats_going_on, 1);
whats_going_on = 2;
return Empty{};
},
[&](Empty) {
EXPECT_EQ(whats_going_on, 2);
whats_going_on = 3;
});
notify_done.WaitForNotification();
}
} // namespace grpc_core
int main(int argc, char** argv) {

@ -71,10 +71,10 @@ grpc_cc_test(
"//test/core/tsi/test_creds/crl_data:evil_ca.pem",
"//test/core/tsi/test_creds/crl_data:intermediate_ca.pem",
"//test/core/tsi/test_creds/crl_data:leaf_signed_by_intermediate.pem",
"//test/core/tsi/test_creds/crl_data/bad_crls:invalid_content.crl",
"//test/core/tsi/test_creds/crl_data/bad_crls:invalid_signature.crl",
"//test/core/tsi/test_creds/crl_data/crls:current.crl",
"//test/core/tsi/test_creds/crl_data/crls:intermediate.crl",
"//test/core/tsi/test_creds/crl_data/crls:invalid_content.crl",
"//test/core/tsi/test_creds/crl_data/crls:invalid_signature.crl",
],
external_deps = ["gtest"],
language = "C++",
@ -136,13 +136,13 @@ grpc_cc_test(
"//test/core/tsi/test_creds/crl_data:revoked.pem",
"//test/core/tsi/test_creds/crl_data:valid.key",
"//test/core/tsi/test_creds/crl_data:valid.pem",
"//test/core/tsi/test_creds/crl_data/bad_crls:evil.crl",
"//test/core/tsi/test_creds/crl_data/bad_crls:invalid_content.crl",
"//test/core/tsi/test_creds/crl_data/bad_crls:invalid_signature.crl",
"//test/core/tsi/test_creds/crl_data/crls:ab06acdd.r0",
"//test/core/tsi/test_creds/crl_data/crls:b9322cac.r0",
"//test/core/tsi/test_creds/crl_data/crls:current.crl",
"//test/core/tsi/test_creds/crl_data/crls:evil.crl",
"//test/core/tsi/test_creds/crl_data/crls:intermediate.crl",
"//test/core/tsi/test_creds/crl_data/crls:invalid_content.crl",
"//test/core/tsi/test_creds/crl_data/crls:invalid_signature.crl",
"//test/core/tsi/test_creds/crl_data/crls_missing_intermediate:ab06acdd.r0",
"//test/core/tsi/test_creds/crl_data/crls_missing_root:b9322cac.r0",
],

@ -69,10 +69,11 @@ const char* kRootCrlPath = "test/core/tsi/test_creds/crl_data/crls/current.crl";
const char* kIntermediateCrlPath =
"test/core/tsi/test_creds/crl_data/crls/intermediate.crl";
const char* kModifiedSignaturePath =
"test/core/tsi/test_creds/crl_data/crls/invalid_signature.crl";
"test/core/tsi/test_creds/crl_data/bad_crls/invalid_signature.crl";
const char* kModifiedContentPath =
"test/core/tsi/test_creds/crl_data/crls/invalid_content.crl";
const char* kEvilCrlPath = "test/core/tsi/test_creds/crl_data/crls/evil.crl";
"test/core/tsi/test_creds/crl_data/bad_crls/invalid_content.crl";
const char* kEvilCrlPath =
"test/core/tsi/test_creds/crl_data/bad_crls/evil.crl";
class CrlSslTransportSecurityTest
: public testing::TestWithParam<tsi_tls_version> {

@ -46,9 +46,9 @@ namespace testing {
const char* kValidCrl = "test/core/tsi/test_creds/crl_data/crls/current.crl";
const char* kCrlIssuer = "test/core/tsi/test_creds/crl_data/ca.pem";
const char* kModifiedSignature =
"test/core/tsi/test_creds/crl_data/crls/invalid_signature.crl";
"test/core/tsi/test_creds/crl_data/bad_crls/invalid_signature.crl";
const char* kModifiedContent =
"test/core/tsi/test_creds/crl_data/crls/invalid_content.crl";
"test/core/tsi/test_creds/crl_data/bad_crls/invalid_content.crl";
const char* kIntermediateCrl =
"test/core/tsi/test_creds/crl_data/crls/intermediate.crl";
const char* kIntermediateCrlIssuer =

@ -57,7 +57,8 @@ Run `ca_with_akid_gen.sh` from the `test/core/tsi/test_creds/crl_data` directory
Create CRLs with modified signatures and content
----------------------------------------------------------------------------
Make two copies of `test/core/tsi/test_creds/crl_data/crls/current.crl` named `test/core/tsi/test_creds/crl_data/crls/invalid_content.crl` and `test/core/tsi/test_creds/crl_data/crls/invalid_signature.crl`.
Make a directory `test/core/tsi/test_creds/crl_data/bad_crls
Make two copies of `test/core/tsi/test_creds/crl_data/crls/current.crl` in the bad_crls directory named `test/core/tsi/test_creds/crl_data/bad_crls/invalid_content.crl` and `test/core/tsi/test_creds/crl_data/bad_crls/invalid_signature.crl`.
In `invalid_content.crl`, change the first letter on the second line.
In `invalid_signature.crl`, change the last letter before the `=` on the second to last line.

@ -0,0 +1,21 @@
# Copyright 2021 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.
licenses(["notice"])
exports_files([
"evil.crl",
"invalid_content.crl",
"invalid_signature.crl",
])

@ -19,7 +19,4 @@ exports_files([
"b9322cac.r0",
"current.crl",
"intermediate.crl",
"invalid_signature.crl",
"invalid_content.crl",
"evil.crl",
])

@ -37,6 +37,7 @@ grpc_cc_test(
"//:gpr",
"//src/core:grpc_xds_client",
"//test/core/util:grpc_test_util",
"//test/core/util:scoped_env_var",
],
)
@ -162,6 +163,18 @@ grpc_cc_library(
],
)
grpc_cc_library(
name = "xds_client_test_peer",
hdrs = ["xds_client_test_peer.h"],
external_deps = [
"absl/functional:function_ref",
],
language = "C++",
deps = [
"//:xds_client",
],
)
grpc_cc_test(
name = "xds_client_test",
srcs = ["xds_client_test.cc"],
@ -171,6 +184,7 @@ grpc_cc_test(
uses_event_engine = True,
uses_polling = False,
deps = [
":xds_client_test_peer",
":xds_transport_fake",
"//:xds_client",
"//src/proto/grpc/testing/xds/v3:discovery_proto",
@ -192,6 +206,7 @@ grpc_proto_fuzzer(
uses_event_engine = False,
uses_polling = False,
deps = [
":xds_client_test_peer",
":xds_transport_fake",
"//src/core:grpc_xds_client",
"//test/core/util:grpc_test_util",

@ -49,6 +49,7 @@
#include "src/core/lib/security/certificate_provider/certificate_provider_factory.h"
#include "src/core/lib/security/credentials/channel_creds_registry.h"
#include "src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h"
#include "test/core/util/scoped_env_var.h"
#include "test/core/util/test_config.h"
namespace grpc_core {
@ -163,8 +164,7 @@ TEST(XdsBootstrapTest, Basic) {
ASSERT_TRUE(bootstrap_or.ok()) << bootstrap_or.status();
auto bootstrap = std::move(*bootstrap_or);
EXPECT_THAT(bootstrap->servers(),
::testing::ElementsAre(EqXdsServer("fake:///lb1", "fake"),
EqXdsServer("fake:///lb2", "fake")));
::testing::ElementsAre(EqXdsServer("fake:///lb1", "fake")));
EXPECT_EQ(bootstrap->authorities().size(), 2);
auto* authority = static_cast<const GrpcXdsBootstrap::GrpcAuthority*>(
bootstrap->LookupAuthority("xds.example.com"));
@ -172,10 +172,8 @@ TEST(XdsBootstrapTest, Basic) {
EXPECT_EQ(authority->client_listener_resource_name_template(),
"xdstp://xds.example.com/envoy.config.listener.v3.Listener/grpc/"
"server/%s");
EXPECT_THAT(
authority->servers(),
::testing::ElementsAre(EqXdsServer("fake:///xds_server", "fake"),
EqXdsServer("fake:///xds_server2", "fake")));
EXPECT_THAT(authority->servers(), ::testing::ElementsAre(EqXdsServer(
"fake:///xds_server", "fake")));
authority = static_cast<const GrpcXdsBootstrap::GrpcAuthority*>(
bootstrap->LookupAuthority("xds.example2.com"));
ASSERT_NE(authority, nullptr);
@ -726,6 +724,92 @@ TEST(XdsBootstrapTest, XdsServerToJsonAndParse) {
EXPECT_EQ(*xds_server, *output_xds_server);
}
TEST(XdsBootstrapTest, NoXdsServersEnvVar) {
ScopedEnvVar fallback_enabled("GRPC_EXPERIMENTAL_XDS_FALLBACK", "1");
const char* json_str =
"{"
" \"xds_servers\": ["
" {"
" \"server_uri\": \"fake:///lb1\","
" \"channel_creds\": ["
" {"
" \"type\": \"fake\","
" \"ignore\": 0"
" }"
" ],"
" \"ignore\": 0"
" },"
" {"
" \"server_uri\": \"fake:///lb2\","
" \"channel_creds\": ["
" {"
" \"type\": \"fake\","
" \"ignore\": 0"
" }"
" ],"
" \"ignore\": 0"
" }"
" ],"
" \"authorities\": {"
" \"xds.example.com\": {"
" \"client_listener_resource_name_template\": "
"\"xdstp://xds.example.com/envoy.config.listener.v3.Listener/grpc/server/"
"%s\","
" \"xds_servers\": ["
" {"
" \"server_uri\": \"fake:///xds_server\","
" \"channel_creds\": ["
" {"
" \"type\": \"fake\""
" }"
" ],"
" \"server_features\": [\"xds_v3\"]"
" },"
" {"
" \"server_uri\": \"fake:///xds_server2\","
" \"channel_creds\": ["
" {"
" \"type\": \"fake\""
" }"
" ],"
" \"server_features\": [\"xds_v3\"]"
" }"
" ]"
" }"
" },"
" \"node\": {"
" \"id\": \"foo\","
" \"cluster\": \"bar\","
" \"locality\": {"
" \"region\": \"milky_way\","
" \"zone\": \"sol_system\","
" \"sub_zone\": \"earth\","
" \"ignore\": {}"
" },"
" \"metadata\": {"
" \"foo\": 1,"
" \"bar\": 2"
" },"
" \"ignore\": \"whee\""
" },"
" \"server_listener_resource_name_template\": \"example/resource\","
" \"ignore\": {}"
"}";
auto bootstrap_or = GrpcXdsBootstrap::Create(json_str);
ASSERT_TRUE(bootstrap_or.ok()) << bootstrap_or.status();
auto bootstrap = std::move(*bootstrap_or);
EXPECT_THAT(bootstrap->servers(),
::testing::ElementsAre(EqXdsServer("fake:///lb1", "fake"),
EqXdsServer("fake:///lb2", "fake")));
auto* authority = static_cast<const GrpcXdsBootstrap::GrpcAuthority*>(
bootstrap->LookupAuthority("xds.example.com"));
ASSERT_NE(authority, nullptr);
EXPECT_THAT(
authority->servers(),
::testing::ElementsAre(EqXdsServer("fake:///xds_server", "fake"),
EqXdsServer("fake:///xds_server2", "fake")));
}
} // namespace
} // namespace testing
} // namespace grpc_core

@ -43,30 +43,11 @@
#include "src/libfuzzer/libfuzzer_macro.h"
#include "src/proto/grpc/testing/xds/v3/discovery.pb.h"
#include "test/core/xds/xds_client_fuzzer.pb.h"
#include "test/core/xds/xds_client_test_peer.h"
#include "test/core/xds/xds_transport_fake.h"
namespace grpc_core {
namespace testing {
class XdsClientTestPeer {
public:
explicit XdsClientTestPeer(XdsClient* xds_client) : xds_client_(xds_client) {}
void TestDumpClientConfig() {
upb::Arena arena;
auto client_config = envoy_service_status_v3_ClientConfig_new(arena.ptr());
std::set<std::string> string_pool;
MutexLock lock(xds_client_->mu());
xds_client_->DumpClientConfig(&string_pool, arena.ptr(), client_config);
}
private:
XdsClient* xds_client_;
};
} // namespace testing
class Fuzzer {
public:
explicit Fuzzer(absl::string_view bootstrap_json) {
@ -84,8 +65,8 @@ class Fuzzer {
transport_factory_ = transport_factory.get();
xds_client_ = MakeRefCounted<XdsClient>(
std::move(*bootstrap), std::move(transport_factory),
grpc_event_engine::experimental::GetDefaultEventEngine(), "foo agent",
"foo version");
grpc_event_engine::experimental::GetDefaultEventEngine(),
/*metrics_reporter=*/nullptr, "foo agent", "foo version");
}
void Act(const xds_client_fuzzer::Action& action) {
@ -135,6 +116,28 @@ class Fuzzer {
case xds_client_fuzzer::Action::kDumpCsdsData:
testing::XdsClientTestPeer(xds_client_.get()).TestDumpClientConfig();
break;
case xds_client_fuzzer::Action::kReportResourceCounts:
testing::XdsClientTestPeer(xds_client_.get())
.TestReportResourceCounts(
[](const testing::XdsClientTestPeer::ResourceCountLabels&
labels,
uint64_t count) {
gpr_log(GPR_INFO,
"xds_authority=\"%s\", resource_type=\"%s\", "
"cache_state=\"%s\" count=%" PRIu64,
std::string(labels.xds_authority).c_str(),
std::string(labels.resource_type).c_str(),
std::string(labels.cache_state).c_str(), count);
});
break;
case xds_client_fuzzer::Action::kReportServerConnections:
testing::XdsClientTestPeer(xds_client_.get())
.TestReportServerConnections(
[](absl::string_view xds_server, bool connected) {
gpr_log(GPR_INFO, "xds_server=\"%s\" connected=%d",
std::string(xds_server).c_str(), connected);
});
break;
case xds_client_fuzzer::Action::kTriggerConnectionFailure:
TriggerConnectionFailure(
action.trigger_connection_failure().authority(),

@ -59,6 +59,10 @@ message StopWatch {
message DumpCsdsData {}
message ReportResourceCounts {}
message ReportServerConnections {}
//
// interactions with fake transport
//
@ -96,12 +100,15 @@ message SendStatusToClient {
Status status = 2;
}
// Next free field: 10
message Action {
oneof action_type {
// interactions with XdsClient API
StartWatch start_watch = 1;
StopWatch stop_watch = 2;
DumpCsdsData dump_csds_data = 3;
ReportResourceCounts report_resource_counts = 8;
ReportServerConnections report_server_connections = 9;
// interactions with fake transport
TriggerConnectionFailure trigger_connection_failure = 4;
ReadMessageFromClient read_message_from_client = 5;

File diff suppressed because it is too large Load Diff

@ -0,0 +1,80 @@
//
// Copyright 2022 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.
//
#ifndef GRPC_TEST_CORE_XDS_XDS_CLIENT_TEST_PEER_H
#define GRPC_TEST_CORE_XDS_XDS_CLIENT_TEST_PEER_H
#include <grpc/support/port_platform.h>
#include <set>
#include "absl/functional/function_ref.h"
#include "absl/strings/str_cat.h"
#include "src/core/ext/xds/xds_client.h"
namespace grpc_core {
namespace testing {
class XdsClientTestPeer {
public:
explicit XdsClientTestPeer(XdsClient* xds_client) : xds_client_(xds_client) {}
void TestDumpClientConfig() {
upb::Arena arena;
auto client_config = envoy_service_status_v3_ClientConfig_new(arena.ptr());
std::set<std::string> string_pool;
MutexLock lock(xds_client_->mu());
xds_client_->DumpClientConfig(&string_pool, arena.ptr(), client_config);
}
struct ResourceCountLabels {
std::string xds_authority;
std::string resource_type;
std::string cache_state;
std::string ToString() const {
return absl::StrCat("xds_authority=\"", xds_authority,
"\" resource_type=\"", resource_type,
"\" cache_state=\"", cache_state, "\"");
}
};
void TestReportResourceCounts(
absl::FunctionRef<void(const ResourceCountLabels&, uint64_t)> func) {
MutexLock lock(xds_client_->mu());
xds_client_->ReportResourceCounts(
[&](const XdsClient::ResourceCountLabels& labels, uint64_t count) {
ResourceCountLabels labels_copy = {std::string(labels.xds_authority),
std::string(labels.resource_type),
std::string(labels.cache_state)};
func(labels_copy, count);
});
}
void TestReportServerConnections(
absl::FunctionRef<void(absl::string_view, bool)> func) {
MutexLock lock(xds_client_->mu());
xds_client_->ReportServerConnections(func);
}
private:
XdsClient* xds_client_;
};
} // namespace testing
} // namespace grpc_core
#endif // GRPC_TEST_CORE_XDS_XDS_CLIENT_TEST_PEER_H

@ -118,7 +118,8 @@ class XdsClusterTest : public ::testing::Test {
}
return MakeRefCounted<XdsClient>(std::move(*bootstrap),
/*transport_factory=*/nullptr,
/*event_engine=*/nullptr, "foo agent",
/*event_engine=*/nullptr,
/*metrics_reporter=*/nullptr, "foo agent",
"foo version");
}

@ -104,7 +104,8 @@ class XdsCommonTypesTest : public ::testing::Test {
}
return MakeRefCounted<XdsClient>(std::move(*bootstrap),
/*transport_factory=*/nullptr,
/*event_engine=*/nullptr, "foo agent",
/*event_engine=*/nullptr,
/*metrics_reporter=*/nullptr, "foo agent",
"foo version");
}

@ -95,7 +95,8 @@ class XdsEndpointTest : public ::testing::Test {
}
return MakeRefCounted<XdsClient>(std::move(*bootstrap),
/*transport_factory=*/nullptr,
/*event_engine=*/nullptr, "foo agent",
/*event_engine=*/nullptr,
/*metrics_reporter=*/nullptr, "foo agent",
"foo version");
}

@ -117,7 +117,8 @@ class XdsHttpFilterTest : public ::testing::Test {
}
return MakeRefCounted<XdsClient>(std::move(*bootstrap),
/*transport_factory=*/nullptr,
/*event_engine=*/nullptr, "foo agent",
/*event_engine=*/nullptr,
/*metrics_reporter=*/nullptr, "foo agent",
"foo version");
}

@ -118,7 +118,8 @@ class XdsListenerTest : public ::testing::Test {
}
return MakeRefCounted<XdsClient>(std::move(*bootstrap),
/*transport_factory=*/nullptr,
/*event_engine=*/nullptr, "foo agent",
/*event_engine=*/nullptr,
/*metrics_reporter=*/nullptr, "foo agent",
"foo version");
}

@ -107,7 +107,8 @@ class XdsRouteConfigTest : public ::testing::Test {
}
return MakeRefCounted<XdsClient>(std::move(*bootstrap),
/*transport_factory=*/nullptr,
/*event_engine=*/nullptr, "foo agent",
/*event_engine=*/nullptr,
/*metrics_reporter=*/nullptr, "foo agent",
"foo version");
}

@ -61,7 +61,8 @@ const char* kRevokedCertPath = "test/core/tsi/test_creds/crl_data/revoked.pem";
const char* kValidKeyPath = "test/core/tsi/test_creds/crl_data/valid.key";
const char* kValidCertPath = "test/core/tsi/test_creds/crl_data/valid.pem";
const char* kRootCrlPath = "test/core/tsi/test_creds/crl_data/crls/current.crl";
const char* kCrlDirectoryPath = "test/core/tsi/test_creds/crl_data/crls/";
const char* kCrlDirectoryPath =
"test/core/tsi/test_creds/crl_data/crl_provider_test_dir/";
constexpr char kMessage[] = "Hello";
// This test must be at the top of the file because the

@ -223,6 +223,7 @@ grpc_cc_test(
"//:gpr",
"//:grpc",
"//:grpc++",
"//test/core/util:fake_stats_plugin",
"//test/core/util:grpc_test_util",
"//test/core/util:scoped_env_var",
],

@ -27,6 +27,7 @@
#include "src/core/client_channel/backup_poller.h"
#include "src/core/lib/config/config_vars.h"
#include "src/proto/grpc/testing/xds/v3/listener.pb.h"
#include "test/core/util/fake_stats_plugin.h"
#include "test/core/util/resolve_localhost_ip46.h"
#include "test/core/util/scoped_env_var.h"
#include "test/cpp/end2end/xds/xds_end2end_test_lib.h"
@ -1071,6 +1072,172 @@ TEST_P(XdsFederationTest, FederationServer) {
WaitForAllBackends(DEBUG_LOCATION);
}
//
// XdsMetricsTest - tests xDS metrics
//
class XdsMetricsTest : public XdsEnd2endTest {
protected:
void SetUp() override {
stats_plugin_ = grpc_core::FakeStatsPluginBuilder()
.UseDisabledByDefaultMetrics(true)
.BuildAndRegister();
InitClient();
}
std::shared_ptr<grpc_core::FakeStatsPlugin> stats_plugin_;
};
// Runs with RDS so that we know all resource types work properly.
INSTANTIATE_TEST_SUITE_P(
XdsTest, XdsMetricsTest,
::testing::Values(XdsTestType().set_enable_rds_testing()),
&XdsTestType::Name);
TEST_P(XdsMetricsTest, MetricDefinitionResourceUpdatesValid) {
const auto* descriptor =
grpc_core::GlobalInstrumentsRegistryTestPeer::FindMetricDescriptorByName(
"grpc.xds_client.resource_updates_valid");
ASSERT_NE(descriptor, nullptr);
EXPECT_EQ(descriptor->value_type,
grpc_core::GlobalInstrumentsRegistry::ValueType::kUInt64);
EXPECT_EQ(descriptor->instrument_type,
grpc_core::GlobalInstrumentsRegistry::InstrumentType::kCounter);
EXPECT_EQ(descriptor->enable_by_default, false);
EXPECT_EQ(descriptor->name, "grpc.xds_client.resource_updates_valid");
EXPECT_EQ(descriptor->unit, "{resource}");
EXPECT_THAT(descriptor->label_keys,
::testing::ElementsAre("grpc.target", "grpc.xds.server",
"grpc.xds.resource_type"));
EXPECT_THAT(descriptor->optional_label_keys, ::testing::ElementsAre());
}
TEST_P(XdsMetricsTest, MetricDefinitionResourceUpdatesInvalid) {
const auto* descriptor =
grpc_core::GlobalInstrumentsRegistryTestPeer::FindMetricDescriptorByName(
"grpc.xds_client.resource_updates_invalid");
ASSERT_NE(descriptor, nullptr);
EXPECT_EQ(descriptor->value_type,
grpc_core::GlobalInstrumentsRegistry::ValueType::kUInt64);
EXPECT_EQ(descriptor->instrument_type,
grpc_core::GlobalInstrumentsRegistry::InstrumentType::kCounter);
EXPECT_EQ(descriptor->enable_by_default, false);
EXPECT_EQ(descriptor->name, "grpc.xds_client.resource_updates_invalid");
EXPECT_EQ(descriptor->unit, "{resource}");
EXPECT_THAT(descriptor->label_keys,
::testing::ElementsAre("grpc.target", "grpc.xds.server",
"grpc.xds.resource_type"));
EXPECT_THAT(descriptor->optional_label_keys, ::testing::ElementsAre());
}
TEST_P(XdsMetricsTest, MetricDefinitionConnected) {
const auto* descriptor =
grpc_core::GlobalInstrumentsRegistryTestPeer::FindMetricDescriptorByName(
"grpc.xds_client.connected");
ASSERT_NE(descriptor, nullptr);
EXPECT_EQ(descriptor->value_type,
grpc_core::GlobalInstrumentsRegistry::ValueType::kInt64);
EXPECT_EQ(
descriptor->instrument_type,
grpc_core::GlobalInstrumentsRegistry::InstrumentType::kCallbackGauge);
EXPECT_EQ(descriptor->enable_by_default, false);
EXPECT_EQ(descriptor->name, "grpc.xds_client.connected");
EXPECT_EQ(descriptor->unit, "{bool}");
EXPECT_THAT(descriptor->label_keys,
::testing::ElementsAre("grpc.target", "grpc.xds.server"));
EXPECT_THAT(descriptor->optional_label_keys, ::testing::ElementsAre());
}
TEST_P(XdsMetricsTest, MetricDefinitionResources) {
const auto* descriptor =
grpc_core::GlobalInstrumentsRegistryTestPeer::FindMetricDescriptorByName(
"grpc.xds_client.resources");
ASSERT_NE(descriptor, nullptr);
EXPECT_EQ(descriptor->value_type,
grpc_core::GlobalInstrumentsRegistry::ValueType::kInt64);
EXPECT_EQ(
descriptor->instrument_type,
grpc_core::GlobalInstrumentsRegistry::InstrumentType::kCallbackGauge);
EXPECT_EQ(descriptor->enable_by_default, false);
EXPECT_EQ(descriptor->name, "grpc.xds_client.resources");
EXPECT_EQ(descriptor->unit, "{resource}");
EXPECT_THAT(
descriptor->label_keys,
::testing::ElementsAre("grpc.target", "grpc.xds.authority",
"grpc.xds.resource_type", "grpc.xds.cache_state"));
EXPECT_THAT(descriptor->optional_label_keys, ::testing::ElementsAre());
}
TEST_P(XdsMetricsTest, MetricValues) {
const auto kMetricResourceUpdatesValid =
grpc_core::GlobalInstrumentsRegistryTestPeer::
FindUInt64CounterHandleByName(
"grpc.xds_client.resource_updates_valid")
.value();
const auto kMetricResourceUpdatesInvalid =
grpc_core::GlobalInstrumentsRegistryTestPeer::
FindUInt64CounterHandleByName(
"grpc.xds_client.resource_updates_invalid")
.value();
const auto kMetricConnected =
grpc_core::GlobalInstrumentsRegistryTestPeer::
FindCallbackInt64GaugeHandleByName("grpc.xds_client.connected")
.value();
const auto kMetricResources =
grpc_core::GlobalInstrumentsRegistryTestPeer::
FindCallbackInt64GaugeHandleByName("grpc.xds_client.resources")
.value();
const std::string kTarget = absl::StrCat("xds:", kServerName);
const std::string kXdsServer = absl::StrCat("localhost:", balancer_->port());
CreateAndStartBackends(1, /*xds_enabled=*/true);
EdsResourceArgs args =
EdsResourceArgs({{"locality0", CreateEndpointsForBackends()}});
balancer_->ads_service()->SetEdsResource(BuildEdsResource(args));
CheckRpcSendOk(DEBUG_LOCATION);
stats_plugin_->TriggerCallbacks();
// Check client metrics.
EXPECT_THAT(stats_plugin_->GetCallbackGaugeValue(kMetricConnected,
{kTarget, kXdsServer}, {}),
::testing::Optional(1));
for (absl::string_view type_url :
{"envoy.config.listener.v3.Listener",
"envoy.config.route.v3.RouteConfiguration",
"envoy.config.cluster.v3.Cluster",
"envoy.config.endpoint.v3.ClusterLoadAssignment"}) {
EXPECT_THAT(
stats_plugin_->GetCounterValue(kMetricResourceUpdatesValid,
{kTarget, kXdsServer, type_url}, {}),
::testing::Optional(1));
EXPECT_THAT(
stats_plugin_->GetCounterValue(kMetricResourceUpdatesInvalid,
{kTarget, kXdsServer, type_url}, {}),
::testing::Optional(0));
EXPECT_THAT(stats_plugin_->GetCallbackGaugeValue(
kMetricResources, {kTarget, "#old", type_url, "acked"}, {}),
::testing::Optional(1));
}
// Check server metrics.
EXPECT_THAT(stats_plugin_->GetCallbackGaugeValue(kMetricConnected,
{"#server", kXdsServer}, {}),
::testing::Optional(1));
for (absl::string_view type_url :
{"envoy.config.listener.v3.Listener",
"envoy.config.route.v3.RouteConfiguration"}) {
EXPECT_THAT(
stats_plugin_->GetCounterValue(kMetricResourceUpdatesValid,
{"#server", kXdsServer, type_url}, {}),
::testing::Optional(1));
EXPECT_THAT(
stats_plugin_->GetCounterValue(kMetricResourceUpdatesInvalid,
{"#server", kXdsServer, type_url}, {}),
::testing::Optional(0));
EXPECT_THAT(
stats_plugin_->GetCallbackGaugeValue(
kMetricResources, {"#server", "#old", type_url, "acked"}, {}),
::testing::Optional(1));
}
}
//
// XdsFederationDisabledTest
//

@ -1,3 +0,0 @@
exports_files([
"android_configure.bzl",
])

@ -1,62 +0,0 @@
"""Repository rule for Android SDK and NDK autoconfiguration.
This rule is a no-op unless the required android environment variables are set.
"""
# Based on https://github.com/tensorflow/tensorflow/tree/34c03ed67692eb76cb3399cebca50ea8bcde064c/third_party/android
# Workaround for https://github.com/bazelbuild/bazel/issues/14260
_ANDROID_NDK_HOME = "ANDROID_NDK_HOME"
_ANDROID_SDK_HOME = "ANDROID_HOME"
def _escape_for_windows(path):
"""Properly escape backslashes for Windows.
Ideally, we would do this conditionally, but there is seemingly no way to
determine whether or not this is being called from Windows.
"""
return path.replace("\\", "\\\\")
def _android_autoconf_impl(repository_ctx):
sdk_home = repository_ctx.os.environ.get(_ANDROID_SDK_HOME)
ndk_home = repository_ctx.os.environ.get(_ANDROID_NDK_HOME)
# version 31.0.0 won't work https://stackoverflow.com/a/68036845
sdk_rule = ""
if sdk_home:
sdk_rule = """
native.android_sdk_repository(
name="androidsdk",
path="{}",
build_tools_version="30.0.3",
)
""".format(_escape_for_windows(sdk_home))
# Note that Bazel does not support NDK 22 yet, and Bazel 3.7.1 only
# supports up to API level 29 for NDK 21
ndk_rule = ""
if ndk_home:
ndk_rule = """
native.android_ndk_repository(
name="androidndk",
path="{}",
)
""".format(_escape_for_windows(ndk_home))
if ndk_rule == "" and sdk_rule == "":
sdk_rule = "pass"
repository_ctx.file("BUILD.bazel", "")
repository_ctx.file("android_configure.bzl", """
def android_workspace():
{}
{}
""".format(sdk_rule, ndk_rule))
android_configure = repository_rule(
implementation = _android_autoconf_impl,
environ = [
_ANDROID_NDK_HOME,
_ANDROID_SDK_HOME,
],
)

@ -29,9 +29,9 @@ config_setting(
# This just helps with the build for now.
config_setting(
name = "android",
values = {
"crosstool_top": "//external:android/crosstool",
},
values = {"crosstool_top": "//external:android/crosstool"},
# TODO: Use constraint_values to detect android after Bazel 7.0 platforms migration is finished
# constraint_values = [ "@platforms//os:android" ],
)
# iOS is not officially supported through C++.

@ -36,7 +36,6 @@ build:opt --compilation_mode=opt
build:opt --copt=-Wframe-larger-than=16384
build:dbg --compilation_mode=dbg
build:dbg --copt=-Werror=return-stack-address
# Dynamic link cause issues like: `dyld: malformed mach-o: load commands size (59272) > 32768`
# https://github.com/bazelbuild/bazel/issues/9190

@ -88,9 +88,9 @@ DOCKERIMAGE_CURRENT_VERSIONS = {
"tools/dockerfile/interoptest/grpc_interop_ruby.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/grpc_interop_ruby@sha256:efd7f41a736dd4b8f73b32f5215b86f6bfe9013c422dfcd77978de0253aaee45",
"tools/dockerfile/interoptest/lb_interop_fake_servers.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/lb_interop_fake_servers@sha256:b89a51dd9147e1293f50ee64dd719fce5929ca7894d3770a3d80dbdecb99fd52",
"tools/dockerfile/test/android_ndk.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/android_ndk@sha256:ab154ecb062af2111d2d3550c4d3da3384201d9893bbd37d49e8160fc34bc137",
"tools/dockerfile/test/bazel.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/bazel@sha256:32bde2dcb2087f2a32afab59e4dfedf7e8c76a52c69881f63a239d311f0e5ecf",
"tools/dockerfile/test/bazel_arm64.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/bazel_arm64@sha256:3b087387c44dee405c1b80d6ff50994e6d8e90a4ef67cc94b4291f1a29c0ef41",
"tools/dockerfile/test/binder_transport_apk.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/binder_transport_apk@sha256:bf60a187cd2ce1abe8b4f32ae6479040a72ca6aa789cd5ab509f60ceb37a41f9",
"tools/dockerfile/test/bazel.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/bazel@sha256:eb327f8e44f2712f557de1d8918c41c3cba1112c4b39b13104c29211ed8f827a",
"tools/dockerfile/test/bazel_arm64.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/bazel_arm64@sha256:6cddc0ecdb42a7db7105b73fc3192edb911702102d1bac671e26d44a17d7aa95",
"tools/dockerfile/test/binder_transport_apk.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/binder_transport_apk@sha256:ff64e263dfa5491ee6fddd7f0d7c1a20ba756636655849a3b923c665d78c8ef2",
"tools/dockerfile/test/csharp_debian11_arm64.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/csharp_debian11_arm64@sha256:4d4bc5f15e03f3d3d8fd889670ecde2c66a2e4d2dd9db80733c05c1d90c8a248",
"tools/dockerfile/test/csharp_debian11_x64.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/csharp_debian11_x64@sha256:b2e5c47d986312ea0850e2f2e696b45d23ee0aabceea161d31e28559e19ec4a5",
"tools/dockerfile/test/cxx_alpine_x64.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/cxx_alpine_x64@sha256:f2019edf9f2afd5042567f11afb1aa78a789fc9acdcce5ee0c14cc11f6830ed7",
@ -112,5 +112,5 @@ DOCKERIMAGE_CURRENT_VERSIONS = {
"tools/dockerfile/test/rbe_ubuntu2004.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/rbe_ubuntu2004@sha256:d3951aeadf43e3bee6adc5b86d26cdaf0b9d1b5baf790d7b2530d1c197adc9f8",
"tools/dockerfile/test/ruby_debian11_arm64.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/ruby_debian11_arm64@sha256:d2e79919b2e2d4cc36a29682ecb5170641df4fb506cfb453978ffdeb8a841bd9",
"tools/dockerfile/test/ruby_debian11_x64.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/ruby_debian11_x64@sha256:f8fc0ec22065278e5bc02ad7f9a68191e46d083035b3a90ed587561dba9c58c5",
"tools/dockerfile/test/sanity.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/sanity@sha256:ca65b29302e8e381aabf9deb1952281f4e9963654e19c3d681148b5aa972c8a2",
"tools/dockerfile/test/sanity.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/sanity@sha256:a83cf1344c166834d76f49e08448f4253b535cdbc47efffb195cfa710f5114d6",
}

@ -17,6 +17,6 @@ This file is generated from the supported_bazel_versions.bzl.template
"""
SUPPORTED_BAZEL_VERSIONS = [
"6.4.0",
"7.0.0",
"6.5.0",
"7.1.0",
]

@ -23,7 +23,6 @@ import subprocess
from subprocess import PIPE
import sys
import sysconfig
import traceback
import setuptools
from setuptools import Extension
@ -152,14 +151,7 @@ class BuildExt(build_ext.build_ext):
self.compiler._compile = new_compile
try:
build_ext.build_ext.build_extensions(self)
except Exception as error:
formatted_exception = traceback.format_exc()
support.diagnose_build_ext_error(self, error, formatted_exception)
raise CommandError(
"Failed `build_ext` step:\n{}".format(formatted_exception)
)
build_ext.build_ext.build_extensions(self)
# There are some situations (like on Windows) where CC, CFLAGS, and LDFLAGS are
@ -179,12 +171,23 @@ if EXTRA_ENV_COMPILE_ARGS is None:
# We need to statically link the C++ Runtime, only the C runtime is
# available dynamically
EXTRA_ENV_COMPILE_ARGS += " /MT"
elif "linux" in sys.platform or "darwin" in sys.platform:
# GCC & Clang by defaults uses C17 so only C++14 needs to be specified.
elif "linux" in sys.platform:
# GCC by defaults uses C17 so only C++14 needs to be specified.
EXTRA_ENV_COMPILE_ARGS += " -std=c++14"
EXTRA_ENV_COMPILE_ARGS += " -fno-wrapv -frtti"
# Reduce the optimization level from O3 (in many cases) to O1 to
# workaround gcc misalignment bug with MOVAPS (internal b/329134877)
EXTRA_ENV_COMPILE_ARGS += " -O1"
elif "darwin" in sys.platform:
# AppleClang by defaults uses C17 so only C++14 needs to be specified.
EXTRA_ENV_COMPILE_ARGS += " -std=c++14"
EXTRA_ENV_COMPILE_ARGS += " -fno-wrapv -frtti"
EXTRA_ENV_COMPILE_ARGS += " -stdlib=libc++ -DHAVE_UNISTD_H"
if EXTRA_ENV_LINK_ARGS is None:
EXTRA_ENV_LINK_ARGS = ""
# This is needed for protobuf/main.cc
if "win32" in sys.platform:
EXTRA_ENV_LINK_ARGS += " Shell32.lib"
# NOTE(rbellevi): Clang on Mac OS will make all static symbols (both
# variables and objects) global weak symbols. When a process loads the
# protobuf wheel's shared object library before loading *this* C extension,

@ -1 +1 @@
us-docker.pkg.dev/grpc-testing/testing-images-public/bazel:cacad91746cd598d8756de89b912be291de1f019@sha256:32bde2dcb2087f2a32afab59e4dfedf7e8c76a52c69881f63a239d311f0e5ecf
us-docker.pkg.dev/grpc-testing/testing-images-public/bazel:71afcbd2698751336bd9890d00eb37ed790b3ac6@sha256:eb327f8e44f2712f557de1d8918c41c3cba1112c4b39b13104c29211ed8f827a

@ -15,8 +15,8 @@
# Pinned version of the base image is used to avoid regressions caused
# by rebuilding of this docker image. To see available versions, you can run
# "gcloud container images list-tags gcr.io/oss-fuzz-base/base-builder"
# Image(fd89316ac4c5) is built on Aug 17, 2023
FROM gcr.io/oss-fuzz-base/base-builder@sha256:fd89316ac4c5f3e25802ca95a00062cece14f0602c5512d71ffeedc22734c0b9
# This base image is built on Mar 12, 2024
FROM gcr.io/oss-fuzz-base/base-builder@sha256:c3581153788bc49f3634fec3cd36a5d6dfd26632c4afc157fb6faf8ce3af732e
# -------------------------- WARNING --------------------------------------
# If you are making changes to this file, consider changing
@ -38,7 +38,7 @@ RUN apt-get update && apt-get -y install \
# Bazel installation
# Must be in sync with tools/bazel
ENV BAZEL_VERSION 6.4.0
ENV BAZEL_VERSION 6.5.0
# The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper.
ENV DISABLE_BAZEL_WRAPPER 1

@ -1 +1 @@
us-docker.pkg.dev/grpc-testing/testing-images-public/bazel_arm64:2638335cbe0cbd8f77c54affdf0e4b36f7741785@sha256:3b087387c44dee405c1b80d6ff50994e6d8e90a4ef67cc94b4291f1a29c0ef41
us-docker.pkg.dev/grpc-testing/testing-images-public/bazel_arm64:415b428a3108de92d1d819cd053181a110a8078b@sha256:6cddc0ecdb42a7db7105b73fc3192edb911702102d1bac671e26d44a17d7aa95

@ -97,7 +97,7 @@ RUN apt-get update && apt-get -y install libc++-dev clang && apt-get clean
# Bazel installation
# Must be in sync with tools/bazel
ENV BAZEL_VERSION 6.4.0
ENV BAZEL_VERSION 6.5.0
# The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper.
ENV DISABLE_BAZEL_WRAPPER 1

@ -1 +1 @@
us-docker.pkg.dev/grpc-testing/testing-images-public/binder_transport_apk:783671f597502a2dc3ebf190d52d55be70836a33@sha256:bf60a187cd2ce1abe8b4f32ae6479040a72ca6aa789cd5ab509f60ceb37a41f9
us-docker.pkg.dev/grpc-testing/testing-images-public/binder_transport_apk:611a0d410d3032bc41175599a5f1495a07759c1f@sha256:ff64e263dfa5491ee6fddd7f0d7c1a20ba756636655849a3b923c665d78c8ef2

@ -15,8 +15,8 @@
# Pinned version of the base image is used to avoid regressions caused
# by rebuilding of this docker image. To see available versions, you can run
# "gcloud container images list-tags gcr.io/oss-fuzz-base/base-builder"
# Image(fd89316ac4c5) is built on Aug 17, 2023
FROM gcr.io/oss-fuzz-base/base-builder@sha256:fd89316ac4c5f3e25802ca95a00062cece14f0602c5512d71ffeedc22734c0b9
# This base image is built on Mar 12, 2024
FROM gcr.io/oss-fuzz-base/base-builder@sha256:c3581153788bc49f3634fec3cd36a5d6dfd26632c4afc157fb6faf8ce3af732e
# -------------------------- WARNING --------------------------------------
# If you are making changes to this file, consider changing
@ -38,7 +38,7 @@ RUN apt-get update && apt-get -y install \
# Bazel installation
# Must be in sync with tools/bazel
ENV BAZEL_VERSION 6.4.0
ENV BAZEL_VERSION 6.5.0
# The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper.
ENV DISABLE_BAZEL_WRAPPER 1
@ -60,19 +60,28 @@ RUN BAZEL_ARCH_SUFFIX="$(uname -m | sed s/aarch64/arm64/)" \
#========================
# Java
RUN apt-get install -y openjdk-8-jdk
RUN apt-get install -y openjdk-21-jdk
#========================
# Android SDK/NDK installation
ENV SDK_ROOT=/opt/android-sdk
ENV ANDROID_SDK_VERSION 11076708
ENV ANDROID_NDK_VERSION 26.2.11394342
ENV SDK_ROOT /opt/android-sdk
RUN mkdir -p $SDK_ROOT
RUN wget -O cmd.zip dl.google.com/android/repository/commandlinetools-linux-7302050_latest.zip && unzip cmd.zip && rm cmd.zip && yes | ./cmdline-tools/bin/sdkmanager --sdk_root=$SDK_ROOT 'tools' && yes | ./cmdline-tools/bin/sdkmanager --sdk_root=$SDK_ROOT 'platform-tools' && yes | ./cmdline-tools/bin/sdkmanager --sdk_root=$SDK_ROOT 'build-tools;30.0.3' && yes | ./cmdline-tools/bin/sdkmanager --sdk_root=$SDK_ROOT 'platforms;android-29' && yes | ./cmdline-tools/bin/sdkmanager --sdk_root=$SDK_ROOT 'ndk-bundle' && yes | ./cmdline-tools/bin/sdkmanager --sdk_root=$SDK_ROOT 'ndk;21.4.7075529'
RUN cd $SDK_ROOT && wget -O cmd.zip https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_SDK_VERSION}_latest.zip && unzip -q cmd.zip && rm cmd.zip
# Set environment variables for Bazel rules
ENV ANDROID_HOME=/opt/android-sdk
ENV ANDROID_NDK_HOME=/opt/android-sdk/ndk/21.4.7075529
RUN yes | $SDK_ROOT/cmdline-tools/bin/sdkmanager --sdk_root=$SDK_ROOT --licenses # accept all licenses
RUN mkdir -p /var/local/jenkins
# This is not required but desirable to reduce the time to download and the chance of download failure.
RUN mkdir -p ~/.android && touch ~/.android/repositories.cfg
RUN $SDK_ROOT/cmdline-tools/bin/sdkmanager --sdk_root=$SDK_ROOT "ndk;$ANDROID_NDK_VERSION" "platforms;android-33" "build-tools;34.0.0"
# Set environment variables for Bazel rules
ENV ANDROID_HOME $SDK_ROOT
ENV ANDROID_NDK_HOME $SDK_ROOT/ndk/$ANDROID_NDK_VERSION
# Define the default command.
CMD ["bash"]

@ -1 +1 @@
us-docker.pkg.dev/grpc-testing/testing-images-public/sanity:2d20232b40465f3487deef87274f4bfd7122b201@sha256:ca65b29302e8e381aabf9deb1952281f4e9963654e19c3d681148b5aa972c8a2
us-docker.pkg.dev/grpc-testing/testing-images-public/sanity:38e0bdb9e26335d2d947263d33efa0f688dcd2fc@sha256:a83cf1344c166834d76f49e08448f4253b535cdbc47efffb195cfa710f5114d6

@ -108,7 +108,7 @@ RUN apt-get update && apt-get install -y jq git && apt-get clean
# Bazel installation
# Must be in sync with tools/bazel
ENV BAZEL_VERSION 6.4.0
ENV BAZEL_VERSION 6.5.0
# The correct bazel version is already preinstalled, no need to use //tools/bazel wrapper.
ENV DISABLE_BAZEL_WRAPPER 1

@ -2115,6 +2115,7 @@ src/core/ext/xds/xds_lb_policy_registry.cc \
src/core/ext/xds/xds_lb_policy_registry.h \
src/core/ext/xds/xds_listener.cc \
src/core/ext/xds/xds_listener.h \
src/core/ext/xds/xds_metrics.h \
src/core/ext/xds/xds_resource_type.h \
src/core/ext/xds/xds_resource_type_impl.h \
src/core/ext/xds/xds_route_config.cc \

@ -1885,6 +1885,7 @@ src/core/ext/xds/xds_lb_policy_registry.cc \
src/core/ext/xds/xds_lb_policy_registry.h \
src/core/ext/xds/xds_listener.cc \
src/core/ext/xds/xds_listener.h \
src/core/ext/xds/xds_metrics.h \
src/core/ext/xds/xds_resource_type.h \
src/core/ext/xds/xds_resource_type_impl.h \
src/core/ext/xds/xds_route_config.cc \

@ -18,19 +18,15 @@ set -ex
echo $ANDROID_HOME
echo $ANDROID_NDK_HOME
# Build all targets using the strict warning option which leverages the
# clang compiler to check if sources can pass a set of warning options.
# CPU are specified because gRPC does not build with 32bit NDK (which has socklen_t
# defined as int due to an accident).
# The python option is for disabling python2 enforcement when packing APK
# Android platforms only works with Bazel >= 7.0
export OVERRIDE_BAZEL_VERSION=7.1.0
python3 tools/run_tests/python_utils/bazel_report_helper.py --report_path bazel_binder_example_app
bazel_binder_example_app/bazel_wrapper \
--bazelrc=tools/remote_build/include/test_locally_with_resultstore_results.bazelrc \
build \
--define=use_strict_warning=true \
--copt=-Wno-unknown-warning-option \
--fat_apk_cpu=x86_64,arm64-v8a \
--extra_toolchains=@rules_python//python:autodetecting_toolchain_nonstrict \
--extra_toolchains=@androidndk//:all \
--android_platforms=//:android_x86_64,//:android_armv7,//:android_arm64 \
//examples/android/binder/java/io/grpc/binder/cpp/exampleclient:app \
//examples/android/binder/java/io/grpc/binder/cpp/exampleserver:app

@ -297,7 +297,7 @@ LANG_RELEASE_MATRIX = {
("v1.59.0", ReleaseInfo(runtimes=["go1.19"])),
("v1.60.1", ReleaseInfo(runtimes=["go1.19"])),
("v1.61.0", ReleaseInfo(runtimes=["go1.19"])),
("v1.62.0", ReleaseInfo(runtimes=["go1.19"])),
("v1.62.1", ReleaseInfo(runtimes=["go1.19"])),
]
),
"java": OrderedDict(

Loading…
Cancel
Save