Merge branch 'master' into tjagtap_src_ext_transport_binder

pull/36504/head
tanvi-jagtap 7 months ago
commit 4669996fd8
  1. 16
      BUILD
  2. 17
      CMakeLists.txt
  3. 1
      Makefile
  4. 1
      Package.swift
  5. 8
      build_autogenerated.yaml
  6. 2
      gRPC-C++.podspec
  7. 2
      gRPC-Core.podspec
  8. 1
      grpc.gemspec
  9. 1
      include/grpc/module.modulemap
  10. 62
      include/grpc/passive_listener.h
  11. 27
      include/grpcpp/passive_listener.h
  12. 1
      include/grpcpp/security/server_credentials.h
  13. 28
      include/grpcpp/server_builder.h
  14. 1
      package.xml
  15. 19
      src/core/BUILD
  16. 5
      src/core/ext/filters/http/message_compress/compression_filter.cc
  17. 13
      src/core/ext/filters/stateful_session/stateful_session_filter.cc
  18. 3
      src/core/ext/gcp/metadata_query.cc
  19. 7
      src/core/ext/transport/binder/server/binder_server.cc
  20. 9
      src/core/ext/transport/chaotic_good/client/chaotic_good_connector.cc
  21. 3
      src/core/ext/transport/chaotic_good/client_transport.cc
  22. 9
      src/core/ext/transport/chaotic_good/frame.cc
  23. 18
      src/core/ext/transport/chaotic_good/server/chaotic_good_server.cc
  24. 4
      src/core/ext/transport/chaotic_good/server/chaotic_good_server.h
  25. 9
      src/core/ext/transport/chaotic_good/server_transport.cc
  26. 241
      src/core/ext/transport/chttp2/server/chttp2_server.cc
  27. 33
      src/core/ext/transport/chttp2/server/chttp2_server.h
  28. 1
      src/core/ext/transport/cronet/BUILD
  29. 23
      src/core/ext/transport/cronet/transport/cronet_api_phony.cc
  30. 13
      src/core/ext/transport/cronet/transport/cronet_transport.cc
  31. 6
      src/core/ext/transport/inproc/inproc_transport.cc
  32. 5
      src/core/ext/transport/inproc/legacy_inproc_transport.cc
  33. 7
      src/core/lib/event_engine/extensions/supports_fd.h
  34. 33
      src/core/lib/event_engine/posix_engine/posix_engine.cc
  35. 2
      src/core/lib/event_engine/posix_engine/posix_engine.h
  36. 13
      src/core/lib/gpr/log.cc
  37. 4
      src/core/lib/slice/percent_encoding.cc
  38. 18
      src/core/lib/slice/slice.cc
  39. 5
      src/core/lib/slice/slice.h
  40. 26
      src/core/lib/slice/slice_buffer.cc
  41. 3
      src/core/lib/slice/slice_internal.h
  42. 4
      src/core/lib/surface/byte_buffer_reader.cc
  43. 69
      src/core/lib/surface/call.cc
  44. 10
      src/core/lib/surface/channel.cc
  45. 4
      src/core/lib/surface/channel_create.cc
  46. 9
      src/core/lib/surface/channel_init.cc
  47. 3
      src/core/lib/surface/channel_init.h
  48. 32
      src/core/lib/surface/completion_queue.cc
  49. 12
      src/core/lib/surface/completion_queue_factory.cc
  50. 13
      src/core/lib/surface/legacy_channel.cc
  51. 3
      src/core/lib/surface/validate_metadata.h
  52. 63
      src/core/server/server.cc
  53. 14
      src/core/server/server.h
  54. 3
      src/core/server/server_config_selector_filter.cc
  55. 60
      src/cpp/server/server_builder.cc
  56. 65
      test/core/event_engine/event_engine_test_utils.h
  57. 19
      test/cpp/microbenchmarks/BUILD
  58. 425
      test/cpp/microbenchmarks/bm_chttp2_transport.cc
  59. 1
      test/cpp/server/BUILD
  60. 55
      test/cpp/server/server_builder_test.cc
  61. 6
      test/cpp/util/BUILD
  62. 44
      test/cpp/util/channelz_sampler.cc
  63. 21
      test/cpp/util/channelz_sampler_test.cc
  64. 13
      test/cpp/util/cli_credentials.cc
  65. 10
      test/cpp/util/metrics_server.cc
  66. 106
      test/cpp/util/proto_reflection_descriptor_database.cc
  67. 5
      test/cpp/util/test_credentials_provider.cc
  68. 4
      tools/distrib/check_namespace_qualification.py
  69. 9
      tools/distrib/check_redundant_namespace_qualifiers.py
  70. 2
      tools/doxygen/Doxyfile.c++
  71. 2
      tools/doxygen/Doxyfile.c++.internal
  72. 1
      tools/doxygen/Doxyfile.core
  73. 1
      tools/doxygen/Doxyfile.core.internal
  74. 2
      tools/internal_ci/linux/grpc_microbenchmark_diff_in_docker.sh
  75. 6
      tools/internal_ci/linux/grpc_xds_k8s_lb.cfg
  76. 193
      tools/internal_ci/linux/grpc_xds_k8s_lb.sh
  77. 6
      tools/internal_ci/linux/grpc_xds_k8s_lb_python.cfg
  78. 196
      tools/internal_ci/linux/grpc_xds_k8s_lb_python.sh
  79. 6
      tools/internal_ci/linux/grpc_xds_url_map.cfg
  80. 150
      tools/internal_ci/linux/grpc_xds_url_map.sh
  81. 6
      tools/internal_ci/linux/grpc_xds_url_map_python.cfg
  82. 160
      tools/internal_ci/linux/grpc_xds_url_map_python.sh
  83. 6
      tools/internal_ci/linux/psm-csm-python.cfg
  84. 190
      tools/internal_ci/linux/psm-csm-python.sh
  85. 6
      tools/internal_ci/linux/psm-csm.cfg
  86. 175
      tools/internal_ci/linux/psm-csm.sh
  87. 34
      tools/internal_ci/linux/psm-interop-build-cpp.sh
  88. 34
      tools/internal_ci/linux/psm-interop-build-python.sh
  89. 32
      tools/internal_ci/linux/psm-interop-install-lib.sh
  90. 24
      tools/internal_ci/linux/psm-interop-test-cpp.sh
  91. 24
      tools/internal_ci/linux/psm-interop-test-python.sh
  92. 6
      tools/internal_ci/linux/psm-security-python.cfg
  93. 185
      tools/internal_ci/linux/psm-security-python.sh
  94. 6
      tools/internal_ci/linux/psm-security.cfg
  95. 169
      tools/internal_ci/linux/psm-security.sh
  96. 9
      tools/interop_matrix/client_matrix.py
  97. 1
      tools/profiling/microbenchmarks/bm_diff/bm_constants.py

16
BUILD

@ -296,7 +296,6 @@ GRPC_PUBLIC_HDRS = [
"include/grpc/grpc_posix.h",
"include/grpc/grpc_security.h",
"include/grpc/grpc_security_constants.h",
"include/grpc/passive_listener.h",
"include/grpc/slice.h",
"include/grpc/slice_buffer.h",
"include/grpc/status.h",
@ -458,7 +457,6 @@ GRPCXX_PUBLIC_HDRS = [
"include/grpcpp/impl/service_type.h",
"include/grpcpp/impl/status.h",
"include/grpcpp/impl/sync.h",
"include/grpcpp/passive_listener.h",
"include/grpcpp/resource_quota.h",
"include/grpcpp/security/audit_logging.h",
"include/grpcpp/security/tls_crl_provider.h",
@ -788,7 +786,6 @@ grpc_cc_library(
"absl/base:log_severity",
"absl/functional:any_invocable",
"absl/log",
"absl/log:globals",
"absl/memory",
"absl/random",
"absl/status",
@ -884,7 +881,7 @@ grpc_cc_library(
grpc_cc_library(
name = "grpc_public_hdrs",
hdrs = GRPC_PUBLIC_HDRS + GRPC_PUBLIC_EVENT_ENGINE_HDRS,
hdrs = GRPC_PUBLIC_HDRS,
external_deps = [
"absl/status:statusor",
"absl/strings",
@ -1503,6 +1500,9 @@ grpc_cc_library(
"//src/core:lib/surface/byte_buffer.cc",
"//src/core:lib/surface/byte_buffer_reader.cc",
],
external_deps = [
"absl/log:check",
],
language = "c++",
deps = [
"exec_ctx",
@ -1760,6 +1760,7 @@ grpc_cc_library(
],
external_deps = [
"absl/base:core_headers",
"absl/log:check",
"absl/status:statusor",
"absl/strings",
"absl/types:optional",
@ -1802,6 +1803,7 @@ grpc_cc_library(
],
external_deps = [
"absl/base:core_headers",
"absl/log:check",
"absl/status",
"absl/status:statusor",
"absl/types:optional",
@ -1848,6 +1850,7 @@ grpc_cc_library(
],
external_deps = [
"absl/base:core_headers",
"absl/log:check",
"absl/status:statusor",
"absl/strings",
"absl/types:optional",
@ -1889,6 +1892,7 @@ grpc_cc_library(
"absl/container:flat_hash_map",
"absl/container:flat_hash_set",
"absl/hash",
"absl/log:check",
"absl/random",
"absl/status",
"absl/status:statusor",
@ -2502,7 +2506,6 @@ grpc_cc_library(
"//src/core:grpc_backend_metric_provider",
"//src/core:grpc_crl_provider",
"//src/core:grpc_service_config",
"//src/core:grpc_transport_chttp2_server",
"//src/core:grpc_transport_inproc",
"//src/core:json",
"//src/core:json_reader",
@ -2561,7 +2564,6 @@ grpc_cc_library(
"grpc_security_base",
"grpc_service_config_impl",
"grpc_trace",
"grpc_transport_chttp2",
"grpc_unsecure",
"grpcpp_backend_metric_recorder",
"grpcpp_call_metric_recorder",
@ -2583,7 +2585,6 @@ grpc_cc_library(
"//src/core:grpc_backend_metric_provider",
"//src/core:grpc_insecure_credentials",
"//src/core:grpc_service_config",
"//src/core:grpc_transport_chttp2_server",
"//src/core:grpc_transport_inproc",
"//src/core:ref_counted",
"//src/core:resource_quota",
@ -4241,6 +4242,7 @@ grpc_cc_library(
],
external_deps = [
"absl/base:core_headers",
"absl/log:check",
"absl/status",
"absl/status:statusor",
"absl/strings",

17
CMakeLists.txt generated

@ -1749,7 +1749,6 @@ target_link_libraries(gpr
absl::flags_marshalling
absl::any_invocable
absl::check
absl::log_globals
absl::log
absl::memory
absl::random_random
@ -2746,7 +2745,6 @@ foreach(_hdr
include/grpc/impl/propagation_bits.h
include/grpc/impl/slice_type.h
include/grpc/load_reporting.h
include/grpc/passive_listener.h
include/grpc/slice.h
include/grpc/slice_buffer.h
include/grpc/status.h
@ -3447,7 +3445,6 @@ foreach(_hdr
include/grpc/impl/propagation_bits.h
include/grpc/impl/slice_type.h
include/grpc/load_reporting.h
include/grpc/passive_listener.h
include/grpc/slice.h
include/grpc/slice_buffer.h
include/grpc/status.h
@ -4316,7 +4313,6 @@ foreach(_hdr
include/grpcpp/impl/service_type.h
include/grpcpp/impl/status.h
include/grpcpp/impl/sync.h
include/grpcpp/passive_listener.h
include/grpcpp/resource_quota.h
include/grpcpp/security/audit_logging.h
include/grpcpp/security/auth_context.h
@ -5057,7 +5053,6 @@ foreach(_hdr
include/grpcpp/impl/service_type.h
include/grpcpp/impl/status.h
include/grpcpp/impl/sync.h
include/grpcpp/passive_listener.h
include/grpcpp/resource_quota.h
include/grpcpp/security/audit_logging.h
include/grpcpp/security/auth_context.h
@ -5508,7 +5503,6 @@ foreach(_hdr
include/grpc/impl/propagation_bits.h
include/grpc/impl/slice_type.h
include/grpc/load_reporting.h
include/grpc/passive_listener.h
include/grpc/slice.h
include/grpc/slice_buffer.h
include/grpc/status.h
@ -26837,7 +26831,6 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/orca_load_report.grpc.pb.cc
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/orca_load_report.pb.h
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/orca_load_report.grpc.pb.h
test/core/event_engine/event_engine_test_utils.cc
test/core/test_util/cmdline.cc
test/core/test_util/fuzzer_util.cc
test/core/test_util/grpc_profiler.cc
@ -36926,7 +36919,7 @@ generate_pkgconfig(
"gpr"
"gRPC platform support library"
"${gRPC_CORE_VERSION}"
"absl_any_invocable absl_base absl_check absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_log absl_log_globals absl_log_severity absl_memory absl_optional absl_random_random absl_status absl_str_format absl_strings absl_synchronization absl_time absl_variant"
"absl_any_invocable absl_base absl_check absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_log absl_log_severity absl_memory absl_optional absl_random_random absl_status absl_str_format absl_strings absl_synchronization absl_time absl_variant"
""
"-lgpr"
""
@ -36937,7 +36930,7 @@ generate_pkgconfig(
"gRPC"
"high performance general RPC framework"
"${gRPC_CORE_VERSION}"
"absl_algorithm_container absl_any_invocable absl_base absl_bind_front absl_check absl_cleanup absl_config absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_log absl_log_globals absl_log_severity absl_memory absl_no_destructor absl_optional absl_random_bit_gen_ref absl_random_distributions absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant gpr"
"absl_algorithm_container absl_any_invocable absl_base absl_bind_front absl_check absl_cleanup absl_config absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_log absl_log_severity absl_memory absl_no_destructor absl_optional absl_random_bit_gen_ref absl_random_distributions absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant gpr"
"libcares openssl re2 zlib"
"-lgrpc"
"-laddress_sorting -lupb_textformat_lib -lupb_json_lib -lupb_message_lib -lupb_mem_lib -lupb_base_lib -lutf8_range_lib"
@ -36948,7 +36941,7 @@ generate_pkgconfig(
"gRPC unsecure"
"high performance general RPC framework without SSL"
"${gRPC_CORE_VERSION}"
"absl_algorithm_container absl_any_invocable absl_base absl_bind_front absl_check absl_cleanup absl_config absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_log absl_log_globals absl_log_severity absl_memory absl_no_destructor absl_optional absl_random_bit_gen_ref absl_random_distributions absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant gpr"
"absl_algorithm_container absl_any_invocable absl_base absl_bind_front absl_check absl_cleanup absl_config absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_log absl_log_severity absl_memory absl_no_destructor absl_optional absl_random_bit_gen_ref absl_random_distributions absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant gpr"
"libcares zlib"
"-lgrpc_unsecure"
"-laddress_sorting -lupb_message_lib -lupb_mem_lib -lupb_base_lib -lutf8_range_lib"
@ -36959,7 +36952,7 @@ generate_pkgconfig(
"gRPC++"
"C++ wrapper for gRPC"
"${gRPC_CPP_VERSION}"
"absl_algorithm_container absl_any_invocable absl_base absl_bind_front absl_check absl_cleanup absl_config absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_log absl_log_globals absl_log_severity absl_memory absl_no_destructor absl_optional absl_random_bit_gen_ref absl_random_distributions absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant gpr grpc"
"absl_algorithm_container absl_any_invocable absl_base absl_bind_front absl_check absl_cleanup absl_config absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_log absl_log_severity absl_memory absl_no_destructor absl_optional absl_random_bit_gen_ref absl_random_distributions absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant gpr grpc"
"libcares openssl re2 zlib"
"-lgrpc++"
"-laddress_sorting -lupb_textformat_lib -lupb_json_lib -lupb_message_lib -lupb_mem_lib -lupb_base_lib -lutf8_range_lib"
@ -36970,7 +36963,7 @@ generate_pkgconfig(
"gRPC++ unsecure"
"C++ wrapper for gRPC without SSL"
"${gRPC_CPP_VERSION}"
"absl_algorithm_container absl_any_invocable absl_base absl_bind_front absl_check absl_cleanup absl_config absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_log absl_log_globals absl_log_severity absl_memory absl_no_destructor absl_optional absl_random_bit_gen_ref absl_random_distributions absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant gpr grpc_unsecure"
"absl_algorithm_container absl_any_invocable absl_base absl_bind_front absl_check absl_cleanup absl_config absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_log absl_log_severity absl_memory absl_no_destructor absl_optional absl_random_bit_gen_ref absl_random_distributions absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant gpr grpc_unsecure"
"libcares zlib"
"-lgrpc++_unsecure"
"-laddress_sorting -lupb_message_lib -lupb_mem_lib -lupb_base_lib -lutf8_range_lib"

1
Makefile generated

@ -1775,7 +1775,6 @@ PUBLIC_HEADERS_C += \
include/grpc/impl/propagation_bits.h \
include/grpc/impl/slice_type.h \
include/grpc/load_reporting.h \
include/grpc/passive_listener.h \
include/grpc/slice.h \
include/grpc/slice_buffer.h \
include/grpc/status.h \

1
Package.swift generated

@ -93,7 +93,6 @@ let package = Package(
"include/grpc/impl/propagation_bits.h",
"include/grpc/impl/slice_type.h",
"include/grpc/load_reporting.h",
"include/grpc/passive_listener.h",
"include/grpc/slice.h",
"include/grpc/slice_buffer.h",
"include/grpc/status.h",

@ -130,7 +130,6 @@ libs:
- absl/flags:marshalling
- absl/functional:any_invocable
- absl/log:check
- absl/log:globals
- absl/log:log
- absl/memory:memory
- absl/random:random
@ -198,7 +197,6 @@ libs:
- include/grpc/impl/propagation_bits.h
- include/grpc/impl/slice_type.h
- include/grpc/load_reporting.h
- include/grpc/passive_listener.h
- include/grpc/slice.h
- include/grpc/slice_buffer.h
- include/grpc/status.h
@ -2183,7 +2181,6 @@ libs:
- include/grpc/impl/propagation_bits.h
- include/grpc/impl/slice_type.h
- include/grpc/load_reporting.h
- include/grpc/passive_listener.h
- include/grpc/slice.h
- include/grpc/slice_buffer.h
- include/grpc/status.h
@ -3788,7 +3785,6 @@ libs:
- include/grpcpp/impl/service_type.h
- include/grpcpp/impl/status.h
- include/grpcpp/impl/sync.h
- include/grpcpp/passive_listener.h
- include/grpcpp/resource_quota.h
- include/grpcpp/security/audit_logging.h
- include/grpcpp/security/auth_context.h
@ -4216,7 +4212,6 @@ libs:
- include/grpcpp/impl/service_type.h
- include/grpcpp/impl/status.h
- include/grpcpp/impl/sync.h
- include/grpcpp/passive_listener.h
- include/grpcpp/resource_quota.h
- include/grpcpp/security/audit_logging.h
- include/grpcpp/security/auth_context.h
@ -4365,7 +4360,6 @@ libs:
- include/grpc/impl/propagation_bits.h
- include/grpc/impl/slice_type.h
- include/grpc/load_reporting.h
- include/grpc/passive_listener.h
- include/grpc/slice.h
- include/grpc/slice_buffer.h
- include/grpc/status.h
@ -17787,7 +17781,6 @@ targets:
build: test
language: c++
headers:
- test/core/event_engine/event_engine_test_utils.h
- test/core/test_util/cmdline.h
- test/core/test_util/evaluate_args_test_util.h
- test/core/test_util/fuzzer_util.h
@ -17803,7 +17796,6 @@ targets:
- src/proto/grpc/testing/echo_messages.proto
- src/proto/grpc/testing/simple_messages.proto
- src/proto/grpc/testing/xds/v3/orca_load_report.proto
- test/core/event_engine/event_engine_test_utils.cc
- test/core/test_util/cmdline.cc
- test/core/test_util/fuzzer_util.cc
- test/core/test_util/grpc_profiler.cc

2
gRPC-C++.podspec generated

@ -176,7 +176,6 @@ Pod::Spec.new do |s|
'include/grpcpp/impl/service_type.h',
'include/grpcpp/impl/status.h',
'include/grpcpp/impl/sync.h',
'include/grpcpp/passive_listener.h',
'include/grpcpp/resource_quota.h',
'include/grpcpp/security/audit_logging.h',
'include/grpcpp/security/auth_context.h',
@ -245,7 +244,6 @@ Pod::Spec.new do |s|
ss.dependency 'abseil/functional/function_ref', abseil_version
ss.dependency 'abseil/hash/hash', abseil_version
ss.dependency 'abseil/log/check', abseil_version
ss.dependency 'abseil/log/globals', abseil_version
ss.dependency 'abseil/log/log', abseil_version
ss.dependency 'abseil/memory/memory', abseil_version
ss.dependency 'abseil/meta/type_traits', abseil_version

2
gRPC-Core.podspec generated

@ -168,7 +168,6 @@ Pod::Spec.new do |s|
'include/grpc/impl/propagation_bits.h',
'include/grpc/impl/slice_type.h',
'include/grpc/load_reporting.h',
'include/grpc/passive_listener.h',
'include/grpc/slice.h',
'include/grpc/slice_buffer.h',
'include/grpc/status.h',
@ -217,7 +216,6 @@ Pod::Spec.new do |s|
ss.dependency 'abseil/functional/function_ref', abseil_version
ss.dependency 'abseil/hash/hash', abseil_version
ss.dependency 'abseil/log/check', abseil_version
ss.dependency 'abseil/log/globals', abseil_version
ss.dependency 'abseil/log/log', abseil_version
ss.dependency 'abseil/memory/memory', abseil_version
ss.dependency 'abseil/meta/type_traits', abseil_version

1
grpc.gemspec generated

@ -99,7 +99,6 @@ Gem::Specification.new do |s|
s.files += %w( include/grpc/impl/propagation_bits.h )
s.files += %w( include/grpc/impl/slice_type.h )
s.files += %w( include/grpc/load_reporting.h )
s.files += %w( include/grpc/passive_listener.h )
s.files += %w( include/grpc/slice.h )
s.files += %w( include/grpc/slice_buffer.h )
s.files += %w( include/grpc/status.h )

@ -38,7 +38,6 @@ header "byte_buffer.h"
header "impl/propagation_bits.h"
header "impl/slice_type.h"
header "load_reporting.h"
header "passive_listener.h"
header "slice.h"
header "slice_buffer.h"
header "status.h"

@ -1,62 +0,0 @@
// Copyright 2024 The gRPC Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef GRPC_PASSIVE_LISTENER_H
#define GRPC_PASSIVE_LISTENER_H
#include <memory>
#include <grpc/event_engine/event_engine.h>
#include <grpc/grpc.h>
// #include <grpc/support/port_platform.h>
namespace grpc_core {
class Server;
namespace experimental {
class PassiveListenerImpl;
/// -- EXPERIMENTAL API --
/// Interface for used for Server Endpoint injection.
class PassiveListener {
public:
virtual ~PassiveListener() = default;
/// -- EXPERIMENTAL API --
///
/// Takes an Endpoint for an established connection, and treats it as if the
/// connection had been accepted by the server.
///
/// The server must be started before endpoints can be accepted.
virtual absl::Status AcceptConnectedEndpoint(
std::unique_ptr<grpc_event_engine::experimental::EventEngine::Endpoint>
endpoint) = 0;
/// -- EXPERIMENTAL API --
///
/// Takes a connected file descriptor, and treats it as if the server had
/// accepted the connection itself.
///
/// Returns a failure status if the server's active EventEngine does not
/// support Endpoint creation from fds.
virtual absl::Status AcceptConnectedFd(int fd) = 0;
};
} // namespace experimental
} // namespace grpc_core
absl::Status grpc_server_add_passive_listener(
grpc_core::Server* server, grpc_server_credentials* credentials,
std::shared_ptr<grpc_core::experimental::PassiveListenerImpl>
passive_listener);
#endif /* GRPC_PASSIVE_LISTENER_H */

@ -1,27 +0,0 @@
// Copyright 2024 The gRPC Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef GRPCPP_PASSIVE_LISTENER_H
#define GRPCPP_PASSIVE_LISTENER_H
#include <grpc/passive_listener.h>
namespace grpc {
namespace experimental {
using grpc_core::experimental::PassiveListener;
} // namespace experimental
} // namespace grpc
#endif // GRPCPP_PASSIVE_LISTENER_H

@ -84,7 +84,6 @@ class ServerCredentials : private grpc::internal::GrpcLibrary {
// Needed for access to AddPortToServer.
friend class Server;
// Needed for access to c_creds_.
friend class ServerBuilder;
friend std::shared_ptr<ServerCredentials> grpc::XdsServerCredentials(
const std::shared_ptr<ServerCredentials>& fallback_credentials);

@ -25,17 +25,13 @@
#include <vector>
#include <grpc/compression.h>
#include <grpc/event_engine/event_engine.h>
#include <grpc/passive_listener.h>
#include <grpc/support/cpu.h>
#include <grpc/support/port_platform.h>
#include <grpc/support/workaround_list.h>
#include <grpcpp/impl/channel_argument_option.h>
#include <grpcpp/impl/server_builder_option.h>
#include <grpcpp/impl/server_builder_plugin.h>
#include <grpcpp/passive_listener.h>
#include <grpcpp/security/authorization_policy_provider.h>
#include <grpcpp/security/server_credentials.h>
#include <grpcpp/server.h>
#include <grpcpp/support/config.h>
#include <grpcpp/support/server_interceptor.h>
@ -295,18 +291,6 @@ class ServerBuilder {
void EnableCallMetricRecording(
experimental::ServerMetricRecorder* server_metric_recorder = nullptr);
// Creates a passive listener for Server Endpoint injection.
///
/// \a PasiveListener lets applications provide pre-established connections
/// to gRPC Servers. The server will behave as if it accepted the connection
/// itself on its own listening addresses.
///
/// This can be called multiple times to create passive listeners with
/// different server credentials.
ServerBuilder& AddPassiveListener(
std::shared_ptr<grpc::ServerCredentials> creds,
std::unique_ptr<grpc::experimental::PassiveListener>& passive_listener);
private:
ServerBuilder* builder_;
};
@ -380,17 +364,6 @@ class ServerBuilder {
private:
friend class grpc::testing::ServerBuilderPluginTest;
struct UnstartedPassiveListener {
std::weak_ptr<grpc_core::experimental::PassiveListenerImpl>
passive_listener;
std::shared_ptr<grpc::ServerCredentials> credentials;
UnstartedPassiveListener(
std::weak_ptr<grpc_core::experimental::PassiveListenerImpl> listener,
std::shared_ptr<grpc::ServerCredentials> creds)
: passive_listener(std::move(listener)),
credentials(std::move(creds)) {}
};
struct SyncServerSettings {
SyncServerSettings()
: num_cqs(1), min_pollers(1), max_pollers(2), cq_timeout_msec(10000) {}
@ -415,7 +388,6 @@ class ServerBuilder {
std::vector<std::unique_ptr<grpc::ServerBuilderOption>> options_;
std::vector<std::unique_ptr<NamedService>> services_;
std::vector<Port> ports_;
std::vector<UnstartedPassiveListener> unstarted_passive_listeners_;
SyncServerSettings sync_server_settings_;

1
package.xml generated

@ -81,7 +81,6 @@
<file baseinstalldir="/" name="include/grpc/impl/propagation_bits.h" role="src" />
<file baseinstalldir="/" name="include/grpc/impl/slice_type.h" role="src" />
<file baseinstalldir="/" name="include/grpc/load_reporting.h" role="src" />
<file baseinstalldir="/" name="include/grpc/passive_listener.h" role="src" />
<file baseinstalldir="/" name="include/grpc/slice.h" role="src" />
<file baseinstalldir="/" name="include/grpc/slice_buffer.h" role="src" />
<file baseinstalldir="/" name="include/grpc/status.h" role="src" />

@ -1559,6 +1559,7 @@ grpc_cc_library(
],
external_deps = [
"absl/hash",
"absl/log:check",
"absl/strings",
],
visibility = ["@grpc:alt_grpc_base_legacy"],
@ -1580,6 +1581,9 @@ grpc_cc_library(
"lib/slice/slice_buffer.h",
"//:include/grpc/slice_buffer.h",
],
external_deps = [
"absl/log:check",
],
deps = [
"slice",
"slice_refcount",
@ -2877,6 +2881,9 @@ grpc_cc_library(
hdrs = [
"lib/slice/percent_encoding.h",
],
external_deps = [
"absl/log:check",
],
deps = [
"bitset",
"slice",
@ -3041,6 +3048,7 @@ grpc_cc_library(
],
external_deps = [
"absl/functional:any_invocable",
"absl/log:check",
"absl/strings",
"absl/types:optional",
],
@ -3644,6 +3652,7 @@ grpc_cc_library(
],
external_deps = [
"absl/base:core_headers",
"absl/log:check",
"absl/status",
"absl/status:statusor",
"absl/types:optional",
@ -4755,6 +4764,7 @@ grpc_cc_library(
"ext/filters/stateful_session/stateful_session_service_config_parser.h",
],
external_deps = [
"absl/log:check",
"absl/status:statusor",
"absl/strings",
"absl/types:optional",
@ -6858,8 +6868,6 @@ grpc_cc_library(
"connection_quota",
"error",
"error_utils",
"event_engine_extensions",
"event_engine_query_extensions",
"grpc_insecure_credentials",
"handshaker_registry",
"iomgr_fwd",
@ -6904,6 +6912,7 @@ grpc_cc_library(
"ext/transport/inproc/legacy_inproc_transport.h",
],
external_deps = [
"absl/log:check",
"absl/status",
"absl/status:statusor",
"absl/strings",
@ -6954,6 +6963,7 @@ grpc_cc_library(
"ext/transport/chaotic_good/frame.h",
],
external_deps = [
"absl/log:check",
"absl/random:bit_gen_ref",
"absl/status",
"absl/status:statusor",
@ -7027,6 +7037,7 @@ grpc_cc_library(
],
external_deps = [
"absl/functional:any_invocable",
"absl/log:check",
"absl/status",
"absl/status:statusor",
"absl/strings",
@ -7186,6 +7197,7 @@ grpc_cc_library(
external_deps = [
"absl/base:core_headers",
"absl/container:flat_hash_map",
"absl/log:check",
"absl/random",
"absl/random:bit_gen_ref",
"absl/status",
@ -7243,6 +7255,7 @@ grpc_cc_library(
"absl/base:core_headers",
"absl/container:flat_hash_map",
"absl/functional:any_invocable",
"absl/log:check",
"absl/random",
"absl/random:bit_gen_ref",
"absl/status",
@ -7574,6 +7587,7 @@ grpc_cc_library(
],
external_deps = [
"absl/container:flat_hash_map",
"absl/log:check",
"absl/random",
"absl/random:bit_gen_ref",
"absl/status",
@ -7638,6 +7652,7 @@ grpc_cc_library(
"ext/transport/chaotic_good/client/chaotic_good_connector.h",
],
external_deps = [
"absl/log:check",
"absl/random",
"absl/random:bit_gen_ref",
"absl/status",

@ -22,6 +22,7 @@
#include <memory>
#include <utility>
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h"
@ -144,7 +145,7 @@ MessageHandle ChannelCompression::CompressMessage(
const size_t after_size = tmp.Length();
const float savings_ratio = 1.0f - static_cast<float>(after_size) /
static_cast<float>(before_size);
GPR_ASSERT(grpc_compression_algorithm_name(algorithm, &algo_name));
CHECK(grpc_compression_algorithm_name(algorithm, &algo_name));
gpr_log(GPR_INFO,
"Compressed[%s] %" PRIuPTR " bytes vs. %" PRIuPTR
" bytes (%.2f%% savings)",
@ -158,7 +159,7 @@ MessageHandle ChannelCompression::CompressMessage(
} else {
if (GRPC_TRACE_FLAG_ENABLED(grpc_compression_trace)) {
const char* algo_name;
GPR_ASSERT(grpc_compression_algorithm_name(algorithm, &algo_name));
CHECK(grpc_compression_algorithm_name(algorithm, &algo_name));
gpr_log(GPR_INFO,
"Algorithm '%s' enabled but decided not to compress. Input size: "
"%" PRIuPTR,

@ -27,6 +27,7 @@
#include <utility>
#include <vector>
#include "absl/log/check.h"
#include "absl/strings/escaping.h"
#include "absl/strings/match.h"
#include "absl/strings/str_cat.h"
@ -143,7 +144,7 @@ absl::string_view GetClusterToUse(
// Get cluster assigned by the XdsConfigSelector.
auto cluster_attribute =
service_config_call_data->GetCallAttribute<XdsClusterAttribute>();
GPR_ASSERT(cluster_attribute != nullptr);
CHECK_NE(cluster_attribute, nullptr);
auto current_cluster = cluster_attribute->cluster();
static constexpr absl::string_view kClusterPrefix = "cluster:";
// If prefix is not "cluster:", then we can't use cluster override.
@ -157,7 +158,7 @@ absl::string_view GetClusterToUse(
// Use cluster from the cookie if it is configured for the route.
auto route_data =
service_config_call_data->GetCallAttribute<XdsRouteStateAttribute>();
GPR_ASSERT(route_data != nullptr);
CHECK_NE(route_data, nullptr);
// Cookie cluster was not configured for route - use the one from the
// attribute
if (!route_data->HasClusterForRoute(cluster_from_cookie)) {
@ -202,7 +203,7 @@ bool IsConfiguredPath(absl::string_view configured_path,
// Check to see if the configured path matches the request path.
const Slice* path_slice =
client_initial_metadata.get_pointer(HttpPathMetadata());
GPR_ASSERT(path_slice != nullptr);
CHECK_NE(path_slice, nullptr);
absl::string_view path = path_slice->as_string_view();
// Matching criteria from
// https://www.rfc-editor.org/rfc/rfc6265#section-5.1.4.
@ -227,13 +228,13 @@ void StatefulSessionFilter::Call::OnClientInitialMetadata(
GetContext<
grpc_call_context_element>()[GRPC_CONTEXT_SERVICE_CONFIG_CALL_DATA]
.value);
GPR_ASSERT(service_config_call_data != nullptr);
CHECK_NE(service_config_call_data, nullptr);
auto* method_params = static_cast<StatefulSessionMethodParsedConfig*>(
service_config_call_data->GetMethodParsedConfig(
filter->service_config_parser_index_));
GPR_ASSERT(method_params != nullptr);
CHECK_NE(method_params, nullptr);
cookie_config_ = method_params->GetConfig(filter->index_);
GPR_ASSERT(cookie_config_ != nullptr);
CHECK_NE(cookie_config_, nullptr);
if (!cookie_config_->name.has_value() ||
!IsConfiguredPath(cookie_config_->path, md)) {
return;

@ -23,6 +23,7 @@
#include <memory>
#include <utility>
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_format.h"
@ -73,7 +74,7 @@ MetadataQuery::MetadataQuery(
GRPC_CLOSURE_INIT(&on_done_, OnDone, this, nullptr);
auto uri = URI::Create("http", std::move(metadata_server_name), attribute_,
{} /* query params */, "" /* fragment */);
GPR_ASSERT(uri.ok()); // params are hardcoded
CHECK(uri.ok()); // params are hardcoded
grpc_http_request request;
memset(&request, 0, sizeof(grpc_http_request));
grpc_http_header header = {const_cast<char*>("Metadata-Flavor"),

@ -160,7 +160,7 @@ class BinderServerListener : public Server::ListenerInterface {
on_destroy_done_ = on_destroy_done;
}
void Orphan() override { Unref(); }
void Orphan() override { delete this; }
~BinderServerListener() override {
ExecCtx::Get()->Flush();
@ -240,8 +240,9 @@ bool AddBinderPort(const std::string& addr, grpc_server* server,
}
std::string conn_id = addr.substr(kBinderUriScheme.size());
Server* core_server = Server::FromC(server);
core_server->AddListener(MakeOrphanable<BinderServerListener>(
core_server, conn_id, std::move(factory), security_policy));
core_server->AddListener(
OrphanablePtr<Server::ListenerInterface>(new BinderServerListener(
core_server, conn_id, std::move(factory), security_policy)));
return true;
}

@ -18,6 +18,7 @@
#include <memory>
#include <utility>
#include "absl/log/check.h"
#include "absl/random/bit_gen_ref.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
@ -78,7 +79,7 @@ ChaoticGoodConnector::ChaoticGoodConnector(
handshake_mgr_(std::make_shared<HandshakeManager>()) {}
ChaoticGoodConnector::~ChaoticGoodConnector() {
GPR_ASSERT(notify_ == nullptr);
CHECK_EQ(notify_, nullptr);
if (connect_activity_ != nullptr) {
connect_activity_.reset();
}
@ -224,7 +225,7 @@ void ChaoticGoodConnector::Connect(const Args& args, Result* result,
MutexLock lock(&mu_);
result_ = result;
if (is_shutdown_) {
GPR_ASSERT(notify_ == nullptr);
CHECK_EQ(notify_, nullptr);
ExecCtx::Run(DEBUG_LOCATION, notify,
GRPC_ERROR_CREATE("connector shutdown"));
return;
@ -235,7 +236,7 @@ void ChaoticGoodConnector::Connect(const Args& args, Result* result,
resolved_addr_ = EventEngine::ResolvedAddress(
reinterpret_cast<const sockaddr*>(args_.address->addr),
args_.address->len);
GPR_ASSERT(resolved_addr_.value().address() != nullptr);
CHECK_NE(resolved_addr_.value().address(), nullptr);
grpc_event_engine::experimental::EventEngine::OnConnectCallback on_connect =
[self = RefAsSubclass<ChaoticGoodConnector>()](
absl::StatusOr<std::unique_ptr<EventEngine::Endpoint>>
@ -299,7 +300,7 @@ void ChaoticGoodConnector::OnHandshakeDone(void* arg, grpc_error_handle error) {
}
}
if (args->endpoint != nullptr) {
GPR_ASSERT(grpc_event_engine::experimental::grpc_is_event_engine_endpoint(
CHECK(grpc_event_engine::experimental::grpc_is_event_engine_endpoint(
args->endpoint));
self->control_endpoint_ = PromiseEndpoint(
grpc_event_engine::experimental::

@ -21,6 +21,7 @@
#include <tuple>
#include <utility>
#include "absl/log/check.h"
#include "absl/random/bit_gen_ref.h"
#include "absl/random/random.h"
#include "absl/status/statusor.h"
@ -279,7 +280,7 @@ auto ChaoticGoodClientTransport::CallOutboundLoop(uint32_t stream_id,
message_length % aligned_bytes == 0
? 0
: aligned_bytes - message_length % aligned_bytes;
GPR_ASSERT((message_length + padding) % aligned_bytes == 0);
CHECK_EQ((message_length + padding) % aligned_bytes, 0u);
frame.message = FragmentMessage(std::move(message), padding,
message_length);
return send_fragment(std::move(frame));

@ -20,6 +20,7 @@
#include <limits>
#include <utility>
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
@ -152,7 +153,7 @@ absl::StatusOr<Arena::PoolPtr<Metadata>> ReadMetadata(
Arena* arena) {
if (!maybe_slices.ok()) return maybe_slices.status();
auto& slices = *maybe_slices;
GPR_ASSERT(arena != nullptr);
CHECK_NE(arena, nullptr);
Arena::PoolPtr<Metadata> metadata = Arena::MakePooled<Metadata>();
parser->BeginFrame(
metadata.get(), std::numeric_limits<uint32_t>::max(),
@ -275,7 +276,7 @@ absl::Status ClientFragmentFrame::Deserialize(HPackParser* parser,
}
BufferPair ClientFragmentFrame::Serialize(HPackCompressor* encoder) const {
GPR_ASSERT(stream_id != 0);
CHECK_NE(stream_id, 0u);
FrameSerializer serializer(FrameType::kFragment, stream_id);
if (headers.get() != nullptr) {
encoder->EncodeRawHeaders(*headers.get(), serializer.AddHeaders());
@ -354,7 +355,7 @@ absl::Status ServerFragmentFrame::Deserialize(HPackParser* parser,
}
BufferPair ServerFragmentFrame::Serialize(HPackCompressor* encoder) const {
GPR_ASSERT(stream_id != 0);
CHECK_NE(stream_id, 0u);
FrameSerializer serializer(FrameType::kFragment, stream_id);
if (headers.get() != nullptr) {
encoder->EncodeRawHeaders(*headers.get(), serializer.AddHeaders());
@ -399,7 +400,7 @@ absl::Status CancelFrame::Deserialize(HPackParser*, const FrameHeader& header,
}
BufferPair CancelFrame::Serialize(HPackCompressor*) const {
GPR_ASSERT(stream_id != 0);
CHECK_NE(stream_id, 0u);
FrameSerializer serializer(FrameType::kCancel, stream_id);
return serializer.Finish();
}

@ -21,6 +21,7 @@
#include <utility>
#include <vector>
#include "absl/log/check.h"
#include "absl/random/bit_gen_ref.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
@ -102,8 +103,8 @@ absl::StatusOr<int> ChaoticGoodServerListener::Bind(
str.ok() ? str->c_str() : str.status().ToString().c_str());
}
EventEngine::Listener::AcceptCallback accept_cb =
[self = RefAsSubclass<ChaoticGoodServerListener>()](
std::unique_ptr<EventEngine::Endpoint> ep, MemoryAllocator) {
[self = Ref()](std::unique_ptr<EventEngine::Endpoint> ep,
MemoryAllocator) {
ExecCtx exec_ctx;
MutexLock lock(&self->mu_);
if (self->shutdown_) return;
@ -116,7 +117,7 @@ absl::StatusOr<int> ChaoticGoodServerListener::Bind(
StatusToString(status).c_str());
}
};
GPR_ASSERT(event_engine_ != nullptr);
CHECK_NE(event_engine_, nullptr);
auto ee_listener = event_engine_->CreateListener(
std::move(accept_cb), std::move(shutdown_cb),
grpc_event_engine::experimental::ChannelArgsEndpointConfig(args_),
@ -135,7 +136,7 @@ absl::StatusOr<int> ChaoticGoodServerListener::Bind(
}
absl::Status ChaoticGoodServerListener::StartListening() {
GPR_ASSERT(ee_listener_ != nullptr);
CHECK(ee_listener_ != nullptr);
auto status = ee_listener_->Start();
if (!status.ok()) {
gpr_log(GPR_ERROR, "Start listening failed: %s", status.ToString().c_str());
@ -148,8 +149,7 @@ absl::Status ChaoticGoodServerListener::StartListening() {
ChaoticGoodServerListener::ActiveConnection::ActiveConnection(
RefCountedPtr<ChaoticGoodServerListener> listener,
std::unique_ptr<EventEngine::Endpoint> endpoint)
: memory_allocator_(listener->memory_allocator_),
listener_(std::move(listener)) {
: memory_allocator_(listener->memory_allocator_), listener_(listener) {
handshaking_state_ = MakeRefCounted<HandshakingState>(Ref());
handshaking_state_->Start(std::move(endpoint));
}
@ -384,7 +384,7 @@ auto ChaoticGoodServerListener::ActiveConnection::HandshakingState::
void ChaoticGoodServerListener::ActiveConnection::HandshakingState::
OnHandshakeDone(void* arg, grpc_error_handle error) {
auto* args = static_cast<HandshakerArgs*>(arg);
GPR_ASSERT(args != nullptr);
CHECK_NE(args, nullptr);
RefCountedPtr<HandshakingState> self(
static_cast<HandshakingState*>(args->user_data));
grpc_slice_buffer_destroy(args->read_buffer);
@ -398,7 +398,7 @@ void ChaoticGoodServerListener::ActiveConnection::HandshakingState::
self->connection_->Done("Server handshake done but has empty endpoint.");
return;
}
GPR_ASSERT(grpc_event_engine::experimental::grpc_is_event_engine_endpoint(
CHECK(grpc_event_engine::experimental::grpc_is_event_engine_endpoint(
args->endpoint));
auto ee_endpoint =
grpc_event_engine::experimental::grpc_take_wrapped_event_engine_endpoint(
@ -503,7 +503,7 @@ int grpc_server_add_chaotic_good_port(grpc_server* server, const char* addr) {
if (port_num == 0) {
port_num = bind_result.value();
} else {
GPR_ASSERT(port_num == bind_result.value());
CHECK(port_num == bind_result.value());
}
core_server->AddListener(std::move(listener));
}

@ -49,7 +49,9 @@
namespace grpc_core {
namespace chaotic_good {
class ChaoticGoodServerListener final : public Server::ListenerInterface {
class ChaoticGoodServerListener final
: public Server::ListenerInterface,
public RefCounted<ChaoticGoodServerListener> {
public:
static absl::AnyInvocable<std::string()> DefaultConnectionIDGenerator() {
return [bitgen = absl::BitGen()]() mutable {

@ -18,6 +18,7 @@
#include <string>
#include <tuple>
#include "absl/log/check.h"
#include "absl/random/bit_gen_ref.h"
#include "absl/random/random.h"
#include "absl/status/status.h"
@ -72,7 +73,7 @@ auto ChaoticGoodServerTransport::TransportWriteLoop(
auto ChaoticGoodServerTransport::PushFragmentIntoCall(
CallInitiator call_initiator, ClientFragmentFrame frame,
uint32_t stream_id) {
GPR_DEBUG_ASSERT(frame.headers == nullptr);
DCHECK(frame.headers == nullptr);
if (grpc_chaotic_good_trace.enabled()) {
gpr_log(GPR_INFO, "CHAOTIC_GOOD: PushFragmentIntoCall: frame=%s",
frame.ToString().c_str());
@ -167,7 +168,7 @@ auto ChaoticGoodServerTransport::SendCallBody(
message_length % aligned_bytes == 0
? 0
: aligned_bytes - message_length % aligned_bytes;
GPR_ASSERT((message_length + padding) % aligned_bytes == 0);
CHECK_EQ((message_length + padding) % aligned_bytes, 0u);
frame.message =
FragmentMessage(std::move(message), padding, message_length);
frame.stream_id = stream_id;
@ -381,8 +382,8 @@ ChaoticGoodServerTransport::ChaoticGoodServerTransport(
}
void ChaoticGoodServerTransport::SetAcceptor(Acceptor* acceptor) {
GPR_ASSERT(acceptor_ == nullptr);
GPR_ASSERT(acceptor != nullptr);
CHECK_EQ(acceptor_, nullptr);
CHECK_NE(acceptor, nullptr);
acceptor_ = acceptor;
got_acceptor_.Set();
}

@ -41,7 +41,6 @@
#include <grpc/grpc.h>
#include <grpc/grpc_posix.h>
#include <grpc/impl/channel_arg_names.h>
#include <grpc/passive_listener.h>
#include <grpc/slice_buffer.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
@ -58,8 +57,6 @@
#include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/event_engine/channel_args_endpoint_config.h"
#include "src/core/lib/event_engine/extensions/supports_fd.h"
#include "src/core/lib/event_engine/query_extensions.h"
#include "src/core/lib/gprpp/debug_location.h"
#include "src/core/lib/gprpp/orphanable.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h"
@ -69,7 +66,6 @@
#include "src/core/lib/gprpp/unique_type_name.h"
#include "src/core/lib/iomgr/closure.h"
#include "src/core/lib/iomgr/endpoint.h"
#include "src/core/lib/iomgr/event_engine_shims/endpoint.h"
#include "src/core/lib/iomgr/iomgr_fwd.h"
#include "src/core/lib/iomgr/pollset_set.h"
#include "src/core/lib/iomgr/resolve_address.h"
@ -96,11 +92,9 @@
#endif // GPR_SUPPORT_CHANNELS_FROM_FD
namespace grpc_core {
namespace {
using grpc_event_engine::experimental::ChannelArgsEndpointConfig;
using grpc_event_engine::experimental::EventEngine;
using grpc_event_engine::experimental::EventEngineSupportsFdExtension;
using grpc_event_engine::experimental::QueryExtension;
using ::grpc_event_engine::experimental::EventEngine;
const char kUnixUriPrefix[] = "unix:";
const char kUnixAbstractUriPrefix[] = "unix-abstract:";
@ -117,23 +111,14 @@ class Chttp2ServerListener : public Server::ListenerInterface {
Server* server, const char* name, const ChannelArgs& args,
Chttp2ServerArgsModifier args_modifier);
static Chttp2ServerListener* CreateForPassiveListener(
Server* server, const ChannelArgs& args,
std::shared_ptr<experimental::PassiveListenerImpl> passive_listener);
// Do not instantiate directly. Use one of the factory methods above.
Chttp2ServerListener(Server* server, const ChannelArgs& args,
Chttp2ServerArgsModifier args_modifier,
grpc_server_config_fetcher* config_fetcher,
std::shared_ptr<experimental::PassiveListenerImpl>
passive_listener = nullptr);
Chttp2ServerArgsModifier args_modifier);
~Chttp2ServerListener() override;
void Start(Server* server,
const std::vector<grpc_pollset*>* pollsets) override;
void AcceptConnectedEndpoint(std::unique_ptr<EventEngine::Endpoint> endpoint);
channelz::ListenSocketNode* channelz_listen_socket_node() const override {
return channelz_listen_socket_.get();
}
@ -143,8 +128,6 @@ class Chttp2ServerListener : public Server::ListenerInterface {
void Orphan() override;
private:
friend class experimental::PassiveListenerImpl;
class ConfigFetcherWatcher
: public grpc_server_config_fetcher::WatcherInterface {
public:
@ -251,8 +234,34 @@ class Chttp2ServerListener : public Server::ListenerInterface {
static void DestroyListener(Server* /*server*/, void* arg,
grpc_closure* destroy_done);
Server* const server_ = nullptr;
grpc_tcp_server* tcp_server_ = nullptr;
// The interface required by RefCountedPtr<> has been manually implemented
// here to take a ref on tcp_server_ instead. Note that, the handshaker
// needs tcp_server_ to exist for the lifetime of the handshake since it's
// needed by acceptor. Sharing refs between the listener and tcp_server_ is
// just an optimization to avoid taking additional refs on the listener,
// since TcpServerShutdownComplete already holds a ref to the listener.
void IncrementRefCount() { grpc_tcp_server_ref(tcp_server_); }
void IncrementRefCount(const DebugLocation& /* location */,
const char* /* reason */) {
IncrementRefCount();
}
GRPC_MUST_USE_RESULT RefCountedPtr<Chttp2ServerListener> Ref() {
IncrementRefCount();
return RefCountedPtr<Chttp2ServerListener>(this);
}
GRPC_MUST_USE_RESULT RefCountedPtr<Chttp2ServerListener> Ref(
const DebugLocation& /* location */, const char* /* reason */) {
return Ref();
}
void Unref() { grpc_tcp_server_unref(tcp_server_); }
void Unref(const DebugLocation& /* location */, const char* /* reason */) {
Unref();
}
Server* const server_;
grpc_tcp_server* tcp_server_;
grpc_resolved_address resolved_address_;
Chttp2ServerArgsModifier const args_modifier_;
ConfigFetcherWatcher* config_fetcher_watcher_ = nullptr;
@ -275,10 +284,6 @@ class Chttp2ServerListener : public Server::ListenerInterface {
RefCountedPtr<channelz::ListenSocketNode> channelz_listen_socket_;
MemoryQuotaRefPtr memory_quota_;
ConnectionQuotaRefPtr connection_quota_;
grpc_server_config_fetcher* config_fetcher_ = nullptr;
// TODO(yashykt): consider using absl::variant<> to minimize memory usage for
// disjoint cases where different fields are used.
std::shared_ptr<experimental::PassiveListenerImpl> passive_listener_;
};
//
@ -375,17 +380,13 @@ Chttp2ServerListener::ActiveConnection::HandshakingState::HandshakingState(
handshake_mgr_(MakeRefCounted<HandshakeManager>()),
deadline_(GetConnectionDeadline(args)),
interested_parties_(grpc_pollset_set_create()) {
if (accepting_pollset != nullptr) {
grpc_pollset_set_add_pollset(interested_parties_, accepting_pollset_);
}
CoreConfiguration::Get().handshaker_registry().AddHandshakers(
HANDSHAKER_SERVER, args, interested_parties_, handshake_mgr_.get());
}
Chttp2ServerListener::ActiveConnection::HandshakingState::~HandshakingState() {
if (accepting_pollset_ != nullptr) {
grpc_pollset_set_del_pollset(interested_parties_, accepting_pollset_);
}
grpc_pollset_set_destroy(interested_parties_);
gpr_free(acceptor_);
}
@ -707,18 +708,19 @@ void Chttp2ServerListener::ActiveConnection::OnDrainGraceTimeExpiry() {
grpc_error_handle Chttp2ServerListener::Create(
Server* server, grpc_resolved_address* addr, const ChannelArgs& args,
Chttp2ServerArgsModifier args_modifier, int* port_num) {
Chttp2ServerListener* listener = nullptr;
// The bulk of this method is inside of a lambda to make cleanup
// easier without using goto.
grpc_error_handle error = [&]() {
grpc_error_handle error;
// Create Chttp2ServerListener.
OrphanablePtr<Chttp2ServerListener> listener =
MakeOrphanable<Chttp2ServerListener>(server, args, args_modifier,
server->config_fetcher());
// The tcp_server will be unreffed when the listener is orphaned, which could
// be at the end of this function if the listener was not added to the
// server's set of listeners.
grpc_error_handle error = grpc_tcp_server_create(
&listener->tcp_server_shutdown_complete_, ChannelArgsEndpointConfig(args),
OnAccept, listener.get(), &listener->tcp_server_);
listener = new Chttp2ServerListener(server, args, args_modifier);
error = grpc_tcp_server_create(
&listener->tcp_server_shutdown_complete_,
grpc_event_engine::experimental::ChannelArgsEndpointConfig(args),
OnAccept, listener, &listener->tcp_server_);
if (!error.ok()) return error;
if (listener->config_fetcher_ != nullptr) {
if (server->config_fetcher() != nullptr) {
listener->resolved_address_ = *addr;
// TODO(yashykt): Consider binding so as to be able to return the port
// number.
@ -735,54 +737,54 @@ grpc_error_handle Chttp2ServerListener::Create(
}
listener->channelz_listen_socket_ =
MakeRefCounted<channelz::ListenSocketNode>(
*string_address, absl::StrCat("chttp2 listener ", *string_address));
*string_address,
absl::StrCat("chttp2 listener ", *string_address));
}
// Register with the server only upon success
server->AddListener(std::move(listener));
server->AddListener(OrphanablePtr<Server::ListenerInterface>(listener));
return absl::OkStatus();
}();
if (!error.ok()) {
if (listener != nullptr) {
if (listener->tcp_server_ != nullptr) {
// listener is deleted when tcp_server_ is shutdown.
grpc_tcp_server_unref(listener->tcp_server_);
} else {
delete listener;
}
}
}
return error;
}
grpc_error_handle Chttp2ServerListener::CreateWithAcceptor(
Server* server, const char* name, const ChannelArgs& args,
Chttp2ServerArgsModifier args_modifier) {
auto listener = MakeOrphanable<Chttp2ServerListener>(
server, args, args_modifier, server->config_fetcher());
Chttp2ServerListener* listener =
new Chttp2ServerListener(server, args, args_modifier);
grpc_error_handle error = grpc_tcp_server_create(
&listener->tcp_server_shutdown_complete_, ChannelArgsEndpointConfig(args),
OnAccept, listener.get(), &listener->tcp_server_);
if (!error.ok()) return error;
&listener->tcp_server_shutdown_complete_,
grpc_event_engine::experimental::ChannelArgsEndpointConfig(args),
OnAccept, listener, &listener->tcp_server_);
if (!error.ok()) {
delete listener;
return error;
}
// TODO(yangg) channelz
TcpServerFdHandler** arg_val = args.GetPointer<TcpServerFdHandler*>(name);
*arg_val = grpc_tcp_server_create_fd_handler(listener->tcp_server_);
server->AddListener(std::move(listener));
server->AddListener(OrphanablePtr<Server::ListenerInterface>(listener));
return absl::OkStatus();
}
Chttp2ServerListener* Chttp2ServerListener::CreateForPassiveListener(
Server* server, const ChannelArgs& args,
std::shared_ptr<experimental::PassiveListenerImpl> passive_listener) {
// TODO(hork): figure out how to handle channelz in this case
auto listener = MakeOrphanable<Chttp2ServerListener>(
server, args, /*args_modifier=*/
[](const ChannelArgs& args, grpc_error_handle*) { return args; }, nullptr,
std::move(passive_listener));
auto listener_ptr = listener.get();
server->AddListener(std::move(listener));
return listener_ptr;
}
Chttp2ServerListener::Chttp2ServerListener(
Server* server, const ChannelArgs& args,
Chttp2ServerArgsModifier args_modifier,
grpc_server_config_fetcher* config_fetcher,
std::shared_ptr<experimental::PassiveListenerImpl> passive_listener)
Chttp2ServerArgsModifier args_modifier)
: server_(server),
args_modifier_(args_modifier),
args_(args),
memory_quota_(args.GetObject<ResourceQuota>()->memory_quota()),
connection_quota_(MakeRefCounted<ConnectionQuota>()),
config_fetcher_(config_fetcher),
passive_listener_(std::move(passive_listener)) {
connection_quota_(MakeRefCounted<ConnectionQuota>()) {
auto max_allowed_incoming_connections =
args.GetInt(GRPC_ARG_MAX_ALLOWED_INCOMING_CONNECTIONS);
if (max_allowed_incoming_connections.has_value()) {
@ -797,9 +799,6 @@ Chttp2ServerListener::~Chttp2ServerListener() {
// Flush queued work before destroying handshaker factory, since that
// may do a synchronous unref.
ExecCtx::Get()->Flush();
if (passive_listener_ != nullptr) {
passive_listener_->ListenerDestroyed();
}
if (on_destroy_done_ != nullptr) {
ExecCtx::Run(DEBUG_LOCATION, on_destroy_done_, absl::OkStatus());
ExecCtx::Get()->Flush();
@ -809,11 +808,10 @@ Chttp2ServerListener::~Chttp2ServerListener() {
// Server callback: start listening on our ports
void Chttp2ServerListener::Start(
Server* /*server*/, const std::vector<grpc_pollset*>* /* pollsets */) {
if (config_fetcher_ != nullptr) {
auto watcher = std::make_unique<ConfigFetcherWatcher>(
RefAsSubclass<Chttp2ServerListener>());
if (server_->config_fetcher() != nullptr) {
auto watcher = std::make_unique<ConfigFetcherWatcher>(Ref());
config_fetcher_watcher_ = watcher.get();
config_fetcher_->StartWatch(
server_->config_fetcher()->StartWatch(
grpc_sockaddr_to_string(&resolved_address_, false).value(),
std::move(watcher));
} else {
@ -827,22 +825,14 @@ void Chttp2ServerListener::Start(
}
void Chttp2ServerListener::StartListening() {
if (tcp_server_ != nullptr) {
grpc_tcp_server_start(tcp_server_, &server_->pollsets());
}
}
void Chttp2ServerListener::SetOnDestroyDone(grpc_closure* on_destroy_done) {
MutexLock lock(&mu_);
on_destroy_done_ = on_destroy_done;
}
void Chttp2ServerListener::AcceptConnectedEndpoint(
std::unique_ptr<EventEngine::Endpoint> endpoint) {
OnAccept(this, grpc_event_engine_endpoint_create(std::move(endpoint)),
/*accepting_pollset=*/nullptr, /*acceptor=*/nullptr);
}
void Chttp2ServerListener::OnAccept(void* arg, grpc_endpoint* tcp,
grpc_pollset* accepting_pollset,
grpc_tcp_server_acceptor* acceptor) {
@ -867,7 +857,7 @@ void Chttp2ServerListener::OnAccept(void* arg, grpc_endpoint* tcp,
endpoint_cleanup(error);
return;
}
if (self->config_fetcher_ != nullptr) {
if (self->server_->config_fetcher() != nullptr) {
if (connection_manager == nullptr) {
grpc_error_handle error = GRPC_ERROR_CREATE(
"No ConnectionManager configured. Closing connection.");
@ -908,7 +898,7 @@ void Chttp2ServerListener::OnAccept(void* arg, grpc_endpoint* tcp,
// heap-use-after-free issues where `Ref()` is invoked when the ref of
// tcp_server_ has already reached 0. (Ref() implementation of
// Chttp2ServerListener is grpc_tcp_server_ref().)
listener_ref = self->RefAsSubclass<Chttp2ServerListener>();
listener_ref = self->Ref();
self->connections_.emplace(connection.get(), std::move(connection));
}
}
@ -923,7 +913,7 @@ void Chttp2ServerListener::TcpServerShutdownComplete(
void* arg, grpc_error_handle /*error*/) {
Chttp2ServerListener* self = static_cast<Chttp2ServerListener*>(arg);
self->channelz_listen_socket_.reset();
self->Unref();
delete self;
}
// Server callback: destroy the tcp listener (so we don't generate further
@ -932,8 +922,7 @@ void Chttp2ServerListener::Orphan() {
// Cancel the watch before shutting down so as to avoid holding a ref to the
// listener in the watcher.
if (config_fetcher_watcher_ != nullptr) {
GPR_ASSERT(config_fetcher_ != nullptr);
config_fetcher_->CancelWatch(config_fetcher_watcher_);
server_->config_fetcher()->CancelWatch(config_fetcher_watcher_);
}
std::map<ActiveConnection*, OrphanablePtr<ActiveConnection>> connections;
grpc_tcp_server* tcp_server;
@ -951,14 +940,12 @@ void Chttp2ServerListener::Orphan() {
}
tcp_server = tcp_server_;
}
if (tcp_server != nullptr) {
grpc_tcp_server_shutdown_listeners(tcp_server);
grpc_tcp_server_unref(tcp_server);
} else {
Unref();
}
}
} // namespace
//
// Chttp2ServerAddPort()
//
@ -1059,50 +1046,6 @@ ChannelArgs ModifyArgsForConnection(const ChannelArgs& args,
}
} // namespace
namespace experimental {
absl::Status PassiveListenerImpl::AcceptConnectedEndpoint(
std::unique_ptr<EventEngine::Endpoint> endpoint) {
GPR_ASSERT(server_ != nullptr);
RefCountedPtr<Chttp2ServerListener> listener;
{
MutexLock lock(&mu_);
if (listener_ != nullptr) {
listener =
listener_->RefIfNonZero().TakeAsSubclass<Chttp2ServerListener>();
}
}
if (listener == nullptr) {
return absl::UnavailableError("passive listener already shut down");
}
ExecCtx exec_ctx;
listener->AcceptConnectedEndpoint(std::move(endpoint));
return absl::OkStatus();
}
absl::Status PassiveListenerImpl::AcceptConnectedFd(int fd) {
GPR_ASSERT(server_ != nullptr);
ExecCtx exec_ctx;
auto& args = server_->channel_args();
auto* supports_fd = QueryExtension<EventEngineSupportsFdExtension>(
/*engine=*/args.GetObjectRef<EventEngine>().get());
if (supports_fd == nullptr) {
return absl::UnimplementedError(
"The server's EventEngine does not support adding endpoints from "
"connected file descriptors.");
}
auto endpoint =
supports_fd->CreateEndpointFromFd(fd, ChannelArgsEndpointConfig(args));
return AcceptConnectedEndpoint(std::move(endpoint));
}
void PassiveListenerImpl::ListenerDestroyed() {
MutexLock lock(&mu_);
listener_ = nullptr;
}
} // namespace experimental
} // namespace grpc_core
int grpc_server_add_http2_port(grpc_server* server, const char* addr,
@ -1200,31 +1143,3 @@ void grpc_server_add_channel_from_fd(grpc_server* /* server */, int /* fd */,
}
#endif // GPR_SUPPORT_CHANNELS_FROM_FD
absl::Status grpc_server_add_passive_listener(
grpc_core::Server* server, grpc_server_credentials* credentials,
std::shared_ptr<grpc_core::experimental::PassiveListenerImpl>
passive_listener) {
grpc_core::ExecCtx exec_ctx;
GRPC_API_TRACE("grpc_server_add_passive_listener(server=%p, credentials=%p)",
2, (server, credentials));
// Create security context.
if (credentials == nullptr) {
return absl::UnavailableError(
"No credentials specified for passive listener");
}
auto sc = credentials->create_security_connector(grpc_core::ChannelArgs());
if (sc == nullptr) {
return absl::UnavailableError(
absl::StrCat("Unable to create secure server with credentials of type ",
credentials->type().name()));
}
auto args = server->channel_args()
.SetObject(credentials->Ref())
.SetObject(std::move(sc));
passive_listener->listener_ =
grpc_core::Chttp2ServerListener::CreateForPassiveListener(
server, args, passive_listener);
passive_listener->server_ = server->Ref();
return absl::OkStatus();
}

@ -21,7 +21,6 @@
#include <functional>
#include <grpc/passive_listener.h>
#include <grpc/support/port_platform.h>
#include "src/core/lib/channel/channel_args.h"
@ -43,38 +42,6 @@ grpc_error_handle Chttp2ServerAddPort(
Server* server, const char* addr, const ChannelArgs& args,
Chttp2ServerArgsModifier connection_args_modifier, int* port_num);
class Chttp2ServerListener;
namespace experimental {
// An implementation of the public C++ passive listener interface.
// The server builder holds a weak_ptr to one of these objects, and the
// application owns the instance.
class PassiveListenerImpl final : public PassiveListener {
public:
absl::Status AcceptConnectedEndpoint(
std::unique_ptr<grpc_event_engine::experimental::EventEngine::Endpoint>
endpoint) override ABSL_LOCKS_EXCLUDED(mu_);
absl::Status AcceptConnectedFd(GRPC_UNUSED int fd) override
ABSL_LOCKS_EXCLUDED(mu_);
void ListenerDestroyed() ABSL_LOCKS_EXCLUDED(mu_);
private:
// note: the grpc_core::Server redundant namespace qualification is
// required for older gcc versions.
friend absl::Status(::grpc_server_add_passive_listener)(
grpc_core::Server* server, grpc_server_credentials* credentials,
std::shared_ptr<grpc_core::experimental::PassiveListenerImpl>
passive_listener);
Mutex mu_;
// Data members will be populated when initialized.
RefCountedPtr<Server> server_;
Chttp2ServerListener* listener_;
};
} // namespace experimental
} // namespace grpc_core
#endif // GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_SERVER_CHTTP2_SERVER_H

@ -40,6 +40,7 @@ grpc_cc_library(
"transport/cronet_transport.h",
],
external_deps = [
"absl/log:check",
"cronet_c_for_grpc",
],
language = "c++",

@ -19,6 +19,7 @@
// This file has empty implementation of all the functions exposed by the cronet
// library, so we can build it in all environments
#include "absl/log/check.h"
#include "third_party/objective_c/Cronet/bidirectional_stream_c.h"
#include <grpc/support/log.h>
@ -31,12 +32,12 @@
bidirectional_stream* bidirectional_stream_create(
stream_engine* /*engine*/, void* /*annotation*/,
bidirectional_stream_callback* /*callback*/) {
GPR_ASSERT(0);
CHECK(0);
return nullptr;
}
int bidirectional_stream_destroy(bidirectional_stream* /*stream*/) {
GPR_ASSERT(0);
CHECK(0);
return 0;
}
@ -45,39 +46,35 @@ int bidirectional_stream_start(
const char* /*method*/,
const bidirectional_stream_header_array* /*headers*/,
bool /*end_of_stream*/) {
GPR_ASSERT(0);
CHECK(0);
return 0;
}
int bidirectional_stream_read(bidirectional_stream* /*stream*/,
char* /*buffer*/, int /*capacity*/) {
GPR_ASSERT(0);
CHECK(0);
return 0;
}
int bidirectional_stream_write(bidirectional_stream* /*stream*/,
const char* /*buffer*/, int /*count*/,
bool /*end_of_stream*/) {
GPR_ASSERT(0);
CHECK(0);
return 0;
}
void bidirectional_stream_cancel(bidirectional_stream* /*stream*/) {
GPR_ASSERT(0);
}
void bidirectional_stream_cancel(bidirectional_stream* /*stream*/) { CHECK(0); }
void bidirectional_stream_disable_auto_flush(bidirectional_stream* /*stream*/,
bool /*disable_auto_flush*/) {
GPR_ASSERT(0);
CHECK(0);
}
void bidirectional_stream_delay_request_headers_until_flush(
bidirectional_stream* /*stream*/, bool /*delay_headers_until_flush*/) {
GPR_ASSERT(0);
CHECK(0);
}
void bidirectional_stream_flush(bidirectional_stream* /*stream*/) {
GPR_ASSERT(0);
}
void bidirectional_stream_flush(bidirectional_stream* /*stream*/) { CHECK(0); }
#endif // GRPC_COMPILE_WITH_CRONET

@ -26,6 +26,7 @@
#include <string>
#include <utility>
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/strings/match.h"
#include "absl/strings/str_cat.h"
@ -412,7 +413,7 @@ static void execute_from_storage(stream_obj* s) {
gpr_mu_lock(&s->mu);
for (struct op_and_state* curr = s->storage.head; curr != nullptr;) {
CRONET_LOG(GPR_DEBUG, "calling op at %p. done = %d", curr, curr->done);
GPR_ASSERT(!curr->done);
CHECK(!curr->done);
enum e_op_result result = execute_stream_op(curr);
CRONET_LOG(GPR_DEBUG, "execute_stream_op[%p] returns %s", curr,
op_result_string(result));
@ -592,7 +593,7 @@ static void on_response_headers_received(
s->state.state_callback_received[OP_FAILED])) {
// Do an extra read to trigger on_succeeded() callback in case connection
// is closed
GPR_ASSERT(s->state.rs.length_field_received == false);
CHECK(s->state.rs.length_field_received == false);
read_grpc_header(s);
}
gpr_mu_unlock(&s->mu);
@ -794,7 +795,7 @@ class CronetMetadataEncoder {
value = grpc_slice_to_c_string(value_slice.c_slice());
}
CRONET_LOG(GPR_DEBUG, "header %s = %s", key, value);
GPR_ASSERT(count_ < capacity_);
CHECK_LT(count_, capacity_);
headers_[count_].key = key;
headers_[count_].value = value;
++count_;
@ -1057,8 +1058,8 @@ static enum e_op_result execute_stream_op(struct op_and_state* oas) {
CRONET_LOG(GPR_DEBUG, "running: %p OP_SEND_INITIAL_METADATA", oas);
// Start new cronet stream. It is destroyed in on_succeeded, on_canceled,
// on_failed
GPR_ASSERT(s->cbs == nullptr);
GPR_ASSERT(!stream_state->state_op_done[OP_SEND_INITIAL_METADATA]);
CHECK_EQ(s->cbs, nullptr);
CHECK(!stream_state->state_op_done[OP_SEND_INITIAL_METADATA]);
s->cbs =
bidirectional_stream_create(t->engine, s->curr_gs, &cronet_callbacks);
CRONET_LOG(GPR_DEBUG, "%p = bidirectional_stream_create()", s->cbs);
@ -1229,7 +1230,7 @@ static enum e_op_result execute_stream_op(struct op_and_state* oas) {
if (stream_state->rs.length_field > 0) {
stream_state->rs.read_buffer = static_cast<char*>(
gpr_malloc(static_cast<size_t>(stream_state->rs.length_field)));
GPR_ASSERT(stream_state->rs.read_buffer);
CHECK(stream_state->rs.read_buffer);
stream_state->rs.remaining_bytes = stream_state->rs.length_field;
stream_state->rs.received_bytes = 0;
CRONET_LOG(GPR_DEBUG, "bidirectional_stream_read(%p)", s->cbs);

@ -16,6 +16,8 @@
#include <atomic>
#include "absl/log/check.h"
#include <grpc/grpc.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
@ -152,8 +154,8 @@ class InprocClientTransport final : public ClientTransport {
bool UsePromiseBasedTransport() {
if (!IsPromiseBasedInprocTransportEnabled()) return false;
GPR_ASSERT(IsPromiseBasedClientCallEnabled());
GPR_ASSERT(IsPromiseBasedServerCallEnabled());
CHECK(IsPromiseBasedClientCallEnabled());
CHECK(IsPromiseBasedServerCallEnabled());
return true;
}

@ -27,6 +27,7 @@
#include <string>
#include <utility>
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_cat.h"
@ -1266,7 +1267,7 @@ grpc_channel* grpc_legacy_inproc_channel_create(grpc_server* server,
auto new_channel = grpc_core::ChannelCreate(
"inproc", client_args, GRPC_CLIENT_DIRECT_CHANNEL, client_transport);
if (!new_channel.ok()) {
GPR_ASSERT(!channel);
CHECK(!channel);
gpr_log(GPR_ERROR, "Failed to create client channel: %s",
grpc_core::StatusToString(error).c_str());
intptr_t integer;
@ -1284,7 +1285,7 @@ grpc_channel* grpc_legacy_inproc_channel_create(grpc_server* server,
channel = new_channel->release()->c_ptr();
}
} else {
GPR_ASSERT(!channel);
CHECK(!channel);
gpr_log(GPR_ERROR, "Failed to create server channel: %s",
grpc_core::StatusToString(error).c_str());
intptr_t integer;

@ -112,13 +112,6 @@ class EventEngineSupportsFdExtension {
int fd, const EndpointConfig& config,
MemoryAllocator memory_allocator) = 0;
/// Creates an EventEngine::Endpoint from an fd which is already assumed to be
/// connected to a remote peer. See \a CreatePosixEndpointFromFd for details.
/// This has the same behavior, but the \a memory_allocator is taken from the
/// EndpointConfig's resource quota.
virtual std::unique_ptr<EventEngine::Endpoint> CreateEndpointFromFd(
int fd, const EndpointConfig& config) = 0;
/// Called when the posix listener has accepted a new client connection.
/// \a listener_fd - The listening socket fd that accepted the new client
/// connection.

@ -25,6 +25,7 @@
#include "absl/cleanup/cleanup.h"
#include "absl/functional/any_invocable.h"
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/strings/match.h"
#include "absl/strings/str_cat.h"
@ -142,7 +143,7 @@ void AsyncConnect::OnWritable(absl::Status status)
absl::StatusOr<std::unique_ptr<EventEngine::Endpoint>> ep;
mu_.Lock();
GPR_ASSERT(fd_ != nullptr);
CHECK_NE(fd_, nullptr);
fd = std::exchange(fd_, nullptr);
bool connect_cancelled = connect_cancelled_;
if (fd->IsHandleShutdown() && status.ok()) {
@ -334,7 +335,7 @@ PosixEnginePollerManager::PosixEnginePollerManager(
poller_state_(PollerState::kExternal),
executor_(nullptr),
trigger_shutdown_called_(false) {
GPR_DEBUG_ASSERT(poller_ != nullptr);
DCHECK_NE(poller_, nullptr);
}
void PosixEnginePollerManager::Run(
@ -351,7 +352,7 @@ void PosixEnginePollerManager::Run(absl::AnyInvocable<void()> cb) {
}
void PosixEnginePollerManager::TriggerShutdown() {
GPR_DEBUG_ASSERT(trigger_shutdown_called_ == false);
DCHECK(trigger_shutdown_called_ == false);
trigger_shutdown_called_ = true;
// If the poller is external, dont try to shut it down. Otherwise
// set poller state to PollerState::kShuttingDown.
@ -467,7 +468,7 @@ PosixEventEngine::~PosixEventEngine() {
this, HandleToString(handle).c_str());
}
}
GPR_ASSERT(GPR_LIKELY(known_handles_.empty()));
CHECK(GPR_LIKELY(known_handles_.empty()));
}
timer_manager_->Shutdown();
#if GRPC_PLATFORM_SUPPORTS_POSIX_POLLING
@ -592,7 +593,7 @@ bool PosixEventEngine::CancelConnect(EventEngine::ConnectionHandle handle) {
auto it = shard->pending_connections.find(connection_handle);
if (it != shard->pending_connections.end()) {
ac = it->second;
GPR_ASSERT(ac != nullptr);
CHECK_NE(ac, nullptr);
// Trying to acquire ac->mu here would could cause a deadlock because
// the OnWritable method tries to acquire the two mutexes used
// here in the reverse order. But we dont need to acquire ac->mu before
@ -639,7 +640,7 @@ EventEngine::ConnectionHandle PosixEventEngine::Connect(
const EndpointConfig& args, MemoryAllocator memory_allocator,
Duration timeout) {
#if GRPC_PLATFORM_SUPPORTS_POSIX_POLLING
GPR_ASSERT(poller_manager_ != nullptr);
CHECK_NE(poller_manager_, nullptr);
PosixTcpOptions options = TcpOptionsFromEndpointConfig(args);
absl::StatusOr<PosixSocketWrapper::PosixSocketCreateResult> socket =
PosixSocketWrapper::CreateAndPrepareTcpClientSocket(options, addr);
@ -661,9 +662,9 @@ PosixEventEngine::CreatePosixEndpointFromFd(int fd,
const EndpointConfig& config,
MemoryAllocator memory_allocator) {
#if GRPC_PLATFORM_SUPPORTS_POSIX_POLLING
GPR_ASSERT(fd > 0);
DCHECK_GT(fd, 0);
PosixEventPoller* poller = poller_manager_->Poller();
GPR_DEBUG_ASSERT(poller != nullptr);
DCHECK_NE(poller, nullptr);
EventHandle* handle =
poller->CreateHandle(fd, "tcp-client", poller->CanTrackErrors());
return CreatePosixEndpoint(handle, nullptr, shared_from_this(),
@ -676,22 +677,6 @@ PosixEventEngine::CreatePosixEndpointFromFd(int fd,
#endif // GRPC_PLATFORM_SUPPORTS_POSIX_POLLING
}
std::unique_ptr<EventEngine::Endpoint> PosixEventEngine::CreateEndpointFromFd(
int fd, const EndpointConfig& config) {
auto options = TcpOptionsFromEndpointConfig(config);
MemoryAllocator allocator;
if (options.memory_allocator_factory != nullptr) {
return CreatePosixEndpointFromFd(
fd, config,
options.memory_allocator_factory->CreateMemoryAllocator(
absl::StrCat("allocator:", fd)));
}
return CreatePosixEndpointFromFd(
fd, config,
options.resource_quota->memory_quota()->CreateMemoryAllocator(
absl::StrCat("allocator:", fd)));
}
absl::StatusOr<std::unique_ptr<EventEngine::Listener>>
PosixEventEngine::CreateListener(
Listener::AcceptCallback on_accept,

@ -172,8 +172,6 @@ class PosixEventEngine final : public PosixEventEngineWithFdSupport,
std::unique_ptr<EventEngine::Endpoint> CreatePosixEndpointFromFd(
int fd, const EndpointConfig& config,
MemoryAllocator memory_allocator) override;
std::unique_ptr<EventEngine::Endpoint> CreateEndpointFromFd(
int fd, const EndpointConfig& config) override;
absl::StatusOr<std::unique_ptr<Listener>> CreateListener(
Listener::AcceptCallback on_accept,

@ -23,7 +23,6 @@
#include <stdio.h>
#include <string.h>
#include "absl/log/globals.h"
#include "absl/strings/match.h"
#include "absl/strings/str_cat.h"
@ -39,7 +38,6 @@
#define GPR_DEFAULT_LOG_VERBOSITY_STRING "ERROR"
#endif // !GPR_DEFAULT_LOG_VERBOSITY_STRING
static constexpr int g_absl_vlog_level_for_gpr_verbosity_debug = 2;
static constexpr gpr_atm GPR_LOG_SEVERITY_UNSET = GPR_LOG_SEVERITY_ERROR + 10;
static constexpr gpr_atm GPR_LOG_SEVERITY_NONE = GPR_LOG_SEVERITY_ERROR + 11;
@ -85,9 +83,8 @@ void gpr_default_log(gpr_log_func_args* args) {
}
switch (args->severity) {
case GPR_LOG_SEVERITY_DEBUG:
VLOG(g_absl_vlog_level_for_gpr_verbosity_debug)
.AtLocation(args->file, args->line)
<< args->message;
// Log DEBUG messages as VLOG(2).
VLOG(2).AtLocation(args->file, args->line) << args->message;
return;
case GPR_LOG_SEVERITY_INFO:
LOG(INFO).AtLocation(args->file, args->line) << args->message;
@ -148,12 +145,6 @@ void gpr_log_verbosity_init() {
parse_log_severity(verbosity, min_severity_to_print);
}
gpr_atm_no_barrier_store(&g_min_severity_to_print, min_severity_to_print);
if (grpc_core::ConfigVars::Get().AbslLogging() &&
min_severity_to_print == GPR_LOG_SEVERITY_DEBUG) {
// Matches full file paths that include a `*grpc*` folder, including
// grpcpp.
absl::SetVLogLevel("*grpc*/*", g_absl_vlog_level_for_gpr_verbosity_debug);
}
}
// init stacktrace_minloglevel when it hasn't been set
if ((gpr_atm_no_barrier_load(&g_min_severity_to_print_stacktrace)) ==

@ -23,6 +23,8 @@
#include <cstdint>
#include <utility>
#include "absl/log/check.h"
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
@ -100,7 +102,7 @@ Slice PercentEncodeSlice(Slice slice, PercentEncodingType type) {
*q++ = hex[c & 15];
}
}
GPR_ASSERT(q == out.end());
CHECK(q == out.end());
return Slice(std::move(out));
}

@ -22,6 +22,8 @@
#include <new>
#include "absl/log/check.h"
#include <grpc/slice.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
@ -244,11 +246,11 @@ static grpc_slice sub_no_ref(const grpc_slice& source, size_t begin,
size_t end) {
grpc_slice subset;
GPR_ASSERT(end >= begin);
CHECK(end >= begin);
if (source.refcount != nullptr) {
// Enforce preconditions
GPR_ASSERT(source.data.refcounted.length >= end);
CHECK(source.data.refcounted.length >= end);
// Build the result
subset.refcount = source.refcount;
@ -257,7 +259,7 @@ static grpc_slice sub_no_ref(const grpc_slice& source, size_t begin,
subset.data.refcounted.length = end - begin;
} else {
// Enforce preconditions
GPR_ASSERT(source.data.inlined.length >= end);
CHECK(source.data.inlined.length >= end);
subset.refcount = nullptr;
subset.data.inlined.length = static_cast<uint8_t>(end - begin);
memcpy(subset.data.inlined.bytes, source.data.inlined.bytes + begin,
@ -296,7 +298,7 @@ grpc_slice grpc_slice_split_tail_maybe_ref_impl(grpc_slice* source,
if (source->refcount == nullptr) {
// inlined data, copy it out
GPR_ASSERT(source->data.inlined.length >= split);
CHECK(source->data.inlined.length >= split);
tail.refcount = nullptr;
tail.data.inlined.length =
static_cast<uint8_t>(source->data.inlined.length - split);
@ -311,7 +313,7 @@ grpc_slice grpc_slice_split_tail_maybe_ref_impl(grpc_slice* source,
source->data.refcounted.length = split;
} else {
size_t tail_length = source->data.refcounted.length - split;
GPR_ASSERT(source->data.refcounted.length >= split);
CHECK(source->data.refcounted.length >= split);
if (allow_inline && tail_length < sizeof(tail.data.inlined.bytes) &&
ref_whom != GRPC_SLICE_REF_TAIL) {
// Copy out the bytes - it'll be cheaper than refcounting
@ -371,7 +373,7 @@ grpc_slice grpc_slice_split_head_impl(grpc_slice* source, size_t split) {
grpc_slice head;
if (source->refcount == nullptr) {
GPR_ASSERT(source->data.inlined.length >= split);
CHECK(source->data.inlined.length >= split);
head.refcount = nullptr;
head.data.inlined.length = static_cast<uint8_t>(split);
@ -381,7 +383,7 @@ grpc_slice grpc_slice_split_head_impl(grpc_slice* source, size_t split) {
memmove(source->data.inlined.bytes, source->data.inlined.bytes + split,
source->data.inlined.length);
} else if (allow_inline && split < sizeof(head.data.inlined.bytes)) {
GPR_ASSERT(source->data.refcounted.length >= split);
CHECK(source->data.refcounted.length >= split);
head.refcount = nullptr;
head.data.inlined.length = static_cast<uint8_t>(split);
@ -389,7 +391,7 @@ grpc_slice grpc_slice_split_head_impl(grpc_slice* source, size_t split) {
source->data.refcounted.bytes += split;
source->data.refcounted.length -= split;
} else {
GPR_ASSERT(source->data.refcounted.length >= split);
CHECK(source->data.refcounted.length >= split);
// Build the result
head.refcount = source->refcount;

@ -21,6 +21,7 @@
#include <string>
#include <utility>
#include "absl/log/check.h"
#include "absl/strings/string_view.h"
#include <grpc/event_engine/internal/slice_cast.h>
@ -243,7 +244,7 @@ class StaticSlice : public slice_detail::BaseSlice,
StaticSlice() = default;
explicit StaticSlice(const grpc_slice& slice)
: slice_detail::BaseSlice(slice) {
GPR_DEBUG_ASSERT(slice.refcount == grpc_slice_refcount::NoopRefcount());
DCHECK(slice.refcount == grpc_slice_refcount::NoopRefcount());
}
StaticSlice(const StaticSlice& other)
@ -267,7 +268,7 @@ class GPR_MSVC_EMPTY_BASE_CLASS_WORKAROUND MutableSlice
MutableSlice() = default;
explicit MutableSlice(const grpc_slice& slice)
: slice_detail::BaseSlice(slice) {
GPR_DEBUG_ASSERT(slice.refcount == nullptr || slice.refcount->IsUnique());
DCHECK(slice.refcount == nullptr || slice.refcount->IsUnique());
}
~MutableSlice() { CSliceUnref(c_slice()); }

@ -22,6 +22,8 @@
#include <utility>
#include "absl/log/check.h"
#include <grpc/slice.h>
#include <grpc/slice_buffer.h>
#include <grpc/support/alloc.h>
@ -80,7 +82,7 @@ Slice SliceBuffer::JoinIntoSlice() const {
GRPC_SLICE_LENGTH(slice_buffer_.slices[i]));
ofs += GRPC_SLICE_LENGTH(slice_buffer_.slices[i]);
}
GPR_ASSERT(ofs == slice_buffer_.length);
CHECK(ofs == slice_buffer_.length);
return Slice(slice);
}
@ -330,7 +332,7 @@ static void slice_buffer_move_first_maybe_ref(grpc_slice_buffer* src, size_t n,
return;
}
GPR_ASSERT(src->length >= n);
CHECK(src->length >= n);
if (src->length == n) {
grpc_slice_buffer_move_into(src, dst);
return;
@ -358,7 +360,7 @@ static void slice_buffer_move_first_maybe_ref(grpc_slice_buffer* src, size_t n,
src, grpc_slice_split_tail_maybe_ref_no_inline(
&slice, n, GRPC_SLICE_REF_BOTH));
}
GPR_ASSERT(GRPC_SLICE_LENGTH(slice) == n);
CHECK(GRPC_SLICE_LENGTH(slice) == n);
grpc_slice_buffer_add(dst, slice);
break;
} else { // n < slice_len
@ -371,14 +373,14 @@ static void slice_buffer_move_first_maybe_ref(grpc_slice_buffer* src, size_t n,
src, grpc_slice_split_tail_maybe_ref_no_inline(
&slice, n, GRPC_SLICE_REF_TAIL));
}
GPR_ASSERT(GRPC_SLICE_LENGTH(slice) == n);
CHECK(GRPC_SLICE_LENGTH(slice) == n);
grpc_slice_buffer_add_indexed(dst, slice);
break;
}
}
GPR_ASSERT(dst->length == output_len);
GPR_ASSERT(src->length == new_input_len);
GPR_ASSERT(src->count > 0);
CHECK(dst->length == output_len);
CHECK(src->length == new_input_len);
CHECK_GT(src->count, 0u);
}
void grpc_slice_buffer_move_first_no_inline(grpc_slice_buffer* src, size_t n,
@ -399,7 +401,7 @@ void grpc_slice_buffer_move_first_no_ref(grpc_slice_buffer* src, size_t n,
void grpc_slice_buffer_move_first_into_buffer(grpc_slice_buffer* src, size_t n,
void* dst) {
char* dstp = static_cast<char*>(dst);
GPR_ASSERT(src->length >= n);
CHECK(src->length >= n);
while (n > 0) {
grpc_slice slice = grpc_slice_buffer_take_first(src);
@ -425,7 +427,7 @@ void grpc_slice_buffer_move_first_into_buffer(grpc_slice_buffer* src, size_t n,
void grpc_slice_buffer_copy_first_into_buffer(grpc_slice_buffer* src, size_t n,
void* dst) {
uint8_t* dstp = static_cast<uint8_t*>(dst);
GPR_ASSERT(src->length >= n);
CHECK(src->length >= n);
for (size_t i = 0; i < src->count; i++) {
grpc_slice slice = src->slices[i];
@ -442,7 +444,7 @@ void grpc_slice_buffer_copy_first_into_buffer(grpc_slice_buffer* src, size_t n,
template <bool allow_inline>
void grpc_slice_buffer_trim_end_impl(grpc_slice_buffer* sb, size_t n,
grpc_slice_buffer* garbage) {
GPR_ASSERT(n <= sb->length);
CHECK(n <= sb->length);
sb->length -= n;
for (;;) {
size_t idx = sb->count - 1;
@ -493,7 +495,7 @@ void grpc_slice_buffer_trim_end(grpc_slice_buffer* sb, size_t n,
grpc_slice grpc_slice_buffer_take_first(grpc_slice_buffer* sb) {
grpc_slice slice;
GPR_ASSERT(sb->count > 0);
CHECK_GT(sb->count, 0u);
slice = sb->slices[0];
sb->slices++;
sb->count--;
@ -503,7 +505,7 @@ grpc_slice grpc_slice_buffer_take_first(grpc_slice_buffer* sb) {
}
void grpc_slice_buffer_remove_first(grpc_slice_buffer* sb) {
GPR_DEBUG_ASSERT(sb->count > 0);
DCHECK_GT(sb->count, 0u);
sb->length -= GRPC_SLICE_LENGTH(sb->slices[0]);
grpc_core::CSliceUnref(sb->slices[0]);
sb->slices++;

@ -25,6 +25,7 @@
#include <string>
#include "absl/hash/hash.h"
#include "absl/log/check.h"
#include "absl/strings/string_view.h"
#include <grpc/slice.h>
@ -36,7 +37,7 @@
// Returns a pointer to the first slice in the slice buffer without giving
// ownership to or a reference count on that slice.
inline grpc_slice* grpc_slice_buffer_peek_first(grpc_slice_buffer* sb) {
GPR_DEBUG_ASSERT(sb->count > 0);
DCHECK_GT(sb->count, 0u);
return &sb->slices[0];
}

@ -19,6 +19,8 @@
#include <stdint.h>
#include <string.h>
#include "absl/log/check.h"
#include <grpc/byte_buffer.h>
#include <grpc/byte_buffer_reader.h>
#include <grpc/grpc.h>
@ -93,7 +95,7 @@ grpc_slice grpc_byte_buffer_reader_readall(grpc_byte_buffer_reader* reader) {
memcpy(&(outbuf[bytes_read]), GRPC_SLICE_START_PTR(in_slice), slice_length);
bytes_read += slice_length;
grpc_core::CSliceUnref(in_slice);
GPR_ASSERT(bytes_read <= input_size);
CHECK(bytes_read <= input_size);
}
return out_slice;

@ -33,6 +33,7 @@
#include <vector>
#include "absl/base/thread_annotations.h"
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h"
@ -143,8 +144,8 @@ absl::Status Call::InitParent(Call* parent, uint32_t propagation_mask) {
child_ = arena()->New<ChildCall>(parent);
parent->InternalRef("child");
GPR_ASSERT(is_client_);
GPR_ASSERT(!parent->is_client_);
CHECK(is_client_);
CHECK(!parent->is_client_);
if (propagation_mask & GRPC_PROPAGATE_DEADLINE) {
send_deadline_ = std::min(send_deadline_, parent->send_deadline_);
@ -321,7 +322,7 @@ void Call::ProcessIncomingInitialMetadata(grpc_metadata_batch& md) {
HandleCompressionAlgorithmDisabled(compression_algorithm);
}
// GRPC_COMPRESS_NONE is always set.
GPR_DEBUG_ASSERT(encodings_accepted_by_peer_.IsSet(GRPC_COMPRESS_NONE));
DCHECK(encodings_accepted_by_peer_.IsSet(GRPC_COMPRESS_NONE));
if (GPR_UNLIKELY(!encodings_accepted_by_peer_.IsSet(compression_algorithm))) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_compression_trace)) {
HandleCompressionAlgorithmNotAccepted(compression_algorithm);
@ -460,7 +461,7 @@ class FilterStackCall final : public Call {
bool is_trailers_only() const override {
bool result = is_trailers_only_;
GPR_DEBUG_ASSERT(!result || recv_initial_metadata_.TransportSize() == 0);
DCHECK(!result || recv_initial_metadata_.TransportSize() == 0);
return result;
}
@ -554,7 +555,7 @@ class FilterStackCall final : public Call {
PendingOpString(r & ~mask).c_str(),
completion_data_.notify_tag.tag);
}
GPR_ASSERT((r & mask) != 0);
CHECK_NE((r & mask), 0);
return r == mask;
}
@ -704,8 +705,8 @@ grpc_error_handle FilterStackCall::Create(grpc_call_create_args* args,
Arena* arena = channel->CreateArena();
call = new (arena->Alloc(call_alloc_size)) FilterStackCall(arena, *args);
GPR_DEBUG_ASSERT(FromC(call->c_ptr()) == call);
GPR_DEBUG_ASSERT(FromCallStack(call->call_stack()) == call);
DCHECK(FromC(call->c_ptr()) == call);
DCHECK(FromCallStack(call->call_stack()) == call);
*out_call = call->c_ptr();
grpc_slice path = grpc_empty_slice();
ScopedContext ctx(call);
@ -778,9 +779,9 @@ grpc_error_handle FilterStackCall::Create(grpc_call_create_args* args,
call->CancelWithError(error);
}
if (args->cq != nullptr) {
GPR_ASSERT(args->pollset_set_alternative == nullptr &&
"Only one of 'cq' and 'pollset_set_alternative' should be "
"non-nullptr.");
CHECK(args->pollset_set_alternative == nullptr)
<< "Only one of 'cq' and 'pollset_set_alternative' should be "
"non-nullptr.";
GRPC_CQ_INTERNAL_REF(args->cq, "bind");
call->pollent_ =
grpc_polling_entity_create_from_pollset(grpc_cq_pollset(args->cq));
@ -817,7 +818,7 @@ grpc_error_handle FilterStackCall::Create(grpc_call_create_args* args,
}
void FilterStackCall::SetCompletionQueue(grpc_completion_queue* cq) {
GPR_ASSERT(cq);
CHECK(cq);
if (grpc_polling_entity_pollset_set(&pollent_) != nullptr) {
Crash("A pollset_set is already registered for this call.");
@ -867,7 +868,7 @@ void FilterStackCall::ExternalUnref() {
MaybeUnpublishFromParent();
GPR_ASSERT(!destroy_called_);
CHECK(!destroy_called_);
destroy_called_ = true;
bool cancel = gpr_atm_acq_load(&received_final_op_atm_) == 0;
if (cancel) {
@ -1358,7 +1359,7 @@ void FilterStackCall::BatchControl::ReceivingInitialMetadataReady(
while (true) {
gpr_atm rsr_bctlp = gpr_atm_acq_load(&call->recv_state_);
// Should only receive initial metadata once
GPR_ASSERT(rsr_bctlp != 1);
CHECK_NE(rsr_bctlp, 1);
if (rsr_bctlp == 0) {
// We haven't seen initial metadata and messages before, thus initial
// metadata is received first.
@ -1412,7 +1413,7 @@ namespace {
void EndOpImmediately(grpc_completion_queue* cq, void* notify_tag,
bool is_notify_tag_closure) {
if (!is_notify_tag_closure) {
GPR_ASSERT(grpc_cq_begin_op(cq, notify_tag));
CHECK(grpc_cq_begin_op(cq, notify_tag));
grpc_cq_end_op(
cq, notify_tag, absl::OkStatus(),
[](void*, grpc_cq_completion* completion) { gpr_free(completion); },
@ -1783,7 +1784,7 @@ grpc_call_error FilterStackCall::StartBatch(const grpc_op* ops, size_t nops,
InternalRef("completion");
if (!is_notify_tag_closure) {
GPR_ASSERT(grpc_cq_begin_op(cq_, notify_tag));
CHECK(grpc_cq_begin_op(cq_, notify_tag));
}
bctl->set_pending_ops(pending_ops);
@ -2064,7 +2065,7 @@ class PromiseBasedCall : public BasicPromiseBasedCall {
class Completion {
public:
Completion() : index_(kNullIndex) {}
~Completion() { GPR_ASSERT(index_ == kNullIndex); }
~Completion() { CHECK(index_ == kNullIndex); }
explicit Completion(uint8_t index) : index_(index) {}
Completion(const Completion& other) = delete;
Completion& operator=(const Completion& other) = delete;
@ -2072,7 +2073,7 @@ class PromiseBasedCall : public BasicPromiseBasedCall {
other.index_ = kNullIndex;
}
Completion& operator=(Completion&& other) noexcept {
GPR_ASSERT(index_ == kNullIndex);
CHECK(index_ == kNullIndex);
index_ = other.index_;
other.index_ = kNullIndex;
return *this;
@ -2257,13 +2258,13 @@ class PromiseBasedCall : public BasicPromiseBasedCall {
if (reason == PendingOp::kReceiveMessage) is_recv_message = true;
auto prev =
state.fetch_or(PendingOpBit(reason), std::memory_order_relaxed);
GPR_ASSERT((prev & PendingOpBit(reason)) == 0);
CHECK_EQ((prev & PendingOpBit(reason)), 0u);
}
CompletionState RemovePendingBit(PendingOp reason) {
const uint32_t mask = ~PendingOpBit(reason);
auto prev = state.fetch_and(mask, std::memory_order_acq_rel);
GPR_ASSERT((prev & PendingOpBit(reason)) != 0);
CHECK_NE((prev & PendingOpBit(reason)), 0u);
switch (prev & mask) {
case kOpFailed:
return kFailure;
@ -2324,7 +2325,7 @@ grpc_error_handle MakePromiseBasedCall(grpc_call_create_args* args,
auto* arena = channel->CreateArena();
PromiseBasedCall* call = arena->New<T>(arena, args);
*out_call = call->c_ptr();
GPR_DEBUG_ASSERT(Call::FromC(*out_call) == call);
DCHECK(Call::FromC(*out_call) == call);
return absl::OkStatus();
}
@ -2371,7 +2372,7 @@ PromiseBasedCall::Completion PromiseBasedCall::AddOpToCompletion(
gpr_log(GPR_INFO, "%s[call] AddOpToCompletion %s %s", DebugTag().c_str(),
CompletionString(completion).c_str(), PendingOpString(reason));
}
GPR_ASSERT(completion.has_value());
CHECK(completion.has_value());
completion_info_[completion.index()].pending.AddPendingBit(reason);
return Completion(completion.index());
}
@ -2398,7 +2399,7 @@ void PromiseBasedCall::FinishOpOnCompletion(Completion* completion,
PendingOpString(reason));
}
const uint8_t i = completion->TakeIndex();
GPR_ASSERT(i < GPR_ARRAY_SIZE(completion_info_));
CHECK(i < GPR_ARRAY_SIZE(completion_info_));
CompletionInfo::Pending& pending = completion_info_[i].pending;
bool success;
switch (pending.RemovePendingBit(reason)) {
@ -2579,9 +2580,9 @@ class ClientPromiseBasedCall final : public PromiseBasedCall {
: grpc_polling_entity{})) {
global_stats().IncrementClientCallsCreated();
if (args->cq != nullptr) {
GPR_ASSERT(args->pollset_set_alternative == nullptr &&
"Only one of 'cq' and 'pollset_set_alternative' should be "
"non-nullptr.");
CHECK(args->pollset_set_alternative == nullptr)
<< "Only one of 'cq' and 'pollset_set_alternative' should be "
"non-nullptr.";
}
ScopedContext context(this);
args->channel->channel_stack()->stats_plugin_group->AddClientCallTracers(
@ -2741,11 +2742,11 @@ class ClientPromiseBasedCall final : public PromiseBasedCall {
Latch<ServerMetadataHandle> cancel_error_;
Latch<bool> was_cancelled_latch_;
};
GPR_ASSERT(call_args.server_initial_metadata ==
CHECK(call_args.server_initial_metadata ==
&server_initial_metadata_.sender);
GPR_ASSERT(call_args.client_to_server_messages ==
CHECK(call_args.client_to_server_messages ==
&client_to_server_messages_.receiver);
GPR_ASSERT(call_args.server_to_client_messages ==
CHECK(call_args.server_to_client_messages ==
&server_to_client_messages_.sender);
call_args.client_initial_metadata_outstanding.Complete(true);
return MakeRefCounted<WrappingCallSpine>(
@ -3951,12 +3952,12 @@ void ServerCallSpine::CommitBatch(const grpc_op* ops, size_t nops,
metadata->Set(GrpcMessageMetadata(),
Slice(grpc_slice_copy(*details)));
}
GPR_ASSERT(metadata != nullptr);
CHECK(metadata != nullptr);
return [this, metadata = std::move(metadata)]() mutable {
GPR_ASSERT(metadata != nullptr);
CHECK(metadata != nullptr);
return [this,
metadata = std::move(metadata)]() mutable -> Poll<Success> {
GPR_ASSERT(metadata != nullptr);
CHECK(metadata != nullptr);
PushServerTrailingMetadata(std::move(metadata));
return Success{};
};
@ -3964,7 +3965,7 @@ void ServerCallSpine::CommitBatch(const grpc_op* ops, size_t nops,
});
auto recv_message =
MaybeOp(ops, got_ops[GRPC_OP_RECV_MESSAGE], [this](const grpc_op& op) {
GPR_ASSERT(recv_message_ == nullptr);
CHECK_EQ(recv_message_, nullptr);
recv_message_ = op.data.recv_message.recv_message;
return [this]() mutable {
return Map(client_to_server_messages_.receiver.Next(),
@ -4087,7 +4088,7 @@ grpc_call* grpc_call_from_top_element(grpc_call_element* surface_element) {
grpc_call_error grpc_call_cancel(grpc_call* call, void* reserved) {
GRPC_API_TRACE("grpc_call_cancel(call=%p, reserved=%p)", 2, (call, reserved));
GPR_ASSERT(reserved == nullptr);
CHECK_EQ(reserved, nullptr);
if (call == nullptr) {
return GRPC_CALL_ERROR;
}
@ -4105,7 +4106,7 @@ grpc_call_error grpc_call_cancel_with_status(grpc_call* c,
"grpc_call_cancel_with_status("
"c=%p, status=%d, description=%s, reserved=%p)",
4, (c, (int)status, description, reserved));
GPR_ASSERT(reserved == nullptr);
CHECK_EQ(reserved, nullptr);
if (c == nullptr) {
return GRPC_CALL_ERROR;
}

@ -16,6 +16,8 @@
#include "src/core/lib/surface/channel.h"
#include "absl/log/check.h"
#include <grpc/compression.h>
#include <grpc/grpc.h>
#include <grpc/impl/channel_arg_names.h>
@ -98,7 +100,7 @@ grpc_call* grpc_channel_create_call(grpc_channel* channel,
grpc_completion_queue* completion_queue,
grpc_slice method, const grpc_slice* host,
gpr_timespec deadline, void* reserved) {
GPR_ASSERT(!reserved);
CHECK(!reserved);
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
grpc_core::ExecCtx exec_ctx;
return grpc_core::Channel::FromC(channel)->CreateCall(
@ -116,7 +118,7 @@ void* grpc_channel_register_call(grpc_channel* channel, const char* method,
GRPC_API_TRACE(
"grpc_channel_register_call(channel=%p, method=%s, host=%s, reserved=%p)",
4, (channel, method, host, reserved));
GPR_ASSERT(!reserved);
CHECK(!reserved);
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
grpc_core::ExecCtx exec_ctx;
return grpc_core::Channel::FromC(channel)->RegisterCall(method, host);
@ -139,7 +141,7 @@ grpc_call* grpc_channel_create_registered_call(
(channel, parent_call, (unsigned)propagation_mask, completion_queue,
registered_call_handle, deadline.tv_sec, deadline.tv_nsec,
(int)deadline.clock_type, reserved));
GPR_ASSERT(!reserved);
CHECK(!reserved);
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
grpc_core::ExecCtx exec_ctx;
return grpc_core::Channel::FromC(channel)->CreateCall(
@ -213,6 +215,6 @@ void grpc_channel_ping(grpc_channel* channel, grpc_completion_queue* cq,
grpc_core::ExecCtx exec_ctx;
GRPC_API_TRACE("grpc_channel_ping(channel=%p, cq=%p, tag=%p, reserved=%p)", 4,
(channel, cq, tag, reserved));
GPR_ASSERT(reserved == nullptr);
CHECK_EQ(reserved, nullptr);
grpc_core::Channel::FromC(channel)->Ping(cq, tag);
}

@ -14,6 +14,8 @@
// limitations under the License.
//
#include "absl/log/check.h"
#include <grpc/grpc.h>
#include <grpc/impl/channel_arg_names.h>
#include <grpc/support/log.h>
@ -103,6 +105,6 @@ grpc_channel* grpc_lame_client_channel_create(const char* target,
auto channel =
grpc_core::ChannelCreate(target == nullptr ? "" : target, std::move(args),
GRPC_CLIENT_LAME_CHANNEL, nullptr);
GPR_ASSERT(channel.ok());
CHECK(channel.ok());
return channel->release()->c_ptr();
}

@ -26,6 +26,7 @@
#include <string>
#include <type_traits>
#include "absl/log/check.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_join.h"
#include "absl/strings/string_view.h"
@ -137,9 +138,9 @@ ChannelInit::StackConfig ChannelInit::BuildStackConfig(
}
filter_to_registration[registration->filter_] = registration.get();
if (registration->terminal_) {
GPR_ASSERT(registration->after_.empty());
GPR_ASSERT(registration->before_.empty());
GPR_ASSERT(!registration->before_all_);
CHECK(registration->after_.empty());
CHECK(registration->before_.empty());
CHECK(!registration->before_all_);
terminal_filters.emplace_back(
registration->filter_, nullptr, std::move(registration->predicates_),
registration->skip_v3_, registration->registration_source_);
@ -149,7 +150,7 @@ ChannelInit::StackConfig ChannelInit::BuildStackConfig(
}
for (const auto& registration : registrations) {
if (registration->terminal_) continue;
GPR_ASSERT(filter_to_registration.count(registration->filter_) > 0);
CHECK_GT(filter_to_registration.count(registration->filter_), 0u);
for (F after : registration->after_) {
if (filter_to_registration.count(after) == 0) {
gpr_log(

@ -27,6 +27,7 @@
#include <vector>
#include "absl/functional/any_invocable.h"
#include "absl/log/check.h"
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
@ -217,7 +218,7 @@ class ChannelInit {
PostProcessorSlot slot,
PostProcessor post_processor) {
auto& slot_value = post_processors_[type][static_cast<int>(slot)];
GPR_ASSERT(slot_value == nullptr);
CHECK(slot_value == nullptr);
slot_value = std::move(post_processor);
}

@ -27,6 +27,7 @@
#include <utility>
#include <vector>
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/strings/str_format.h"
#include "absl/strings/str_join.h"
@ -178,7 +179,7 @@ grpc_error_handle non_polling_poller_kick(
void non_polling_poller_shutdown(grpc_pollset* pollset, grpc_closure* closure) {
non_polling_poller* p = reinterpret_cast<non_polling_poller*>(pollset);
GPR_ASSERT(closure != nullptr);
CHECK_NE(closure, nullptr);
p->shutdown = closure;
if (p->root == nullptr) {
grpc_core::ExecCtx::Run(DEBUG_LOCATION, closure, absl::OkStatus());
@ -256,7 +257,7 @@ class CqEventQueue {
struct cq_next_data {
~cq_next_data() {
GPR_ASSERT(queue.num_items() == 0);
CHECK_EQ(queue.num_items(), 0);
#ifndef NDEBUG
if (pending_events.load(std::memory_order_acquire) != 0) {
gpr_log(GPR_ERROR, "Destroying CQ without draining it fully.");
@ -286,8 +287,7 @@ struct cq_pluck_data {
}
~cq_pluck_data() {
GPR_ASSERT(completed_head.next ==
reinterpret_cast<uintptr_t>(&completed_head));
CHECK(completed_head.next == reinterpret_cast<uintptr_t>(&completed_head));
#ifndef NDEBUG
if (pending_events.load(std::memory_order_acquire) != 0) {
gpr_log(GPR_ERROR, "Destroying CQ without draining it fully.");
@ -655,7 +655,7 @@ static void cq_check_tag(grpc_completion_queue* cq, void* tag, bool lock_cq) {
gpr_mu_unlock(cq->mu);
}
GPR_ASSERT(found);
CHECK(found);
}
#else
static void cq_check_tag(grpc_completion_queue* /*cq*/, void* /*tag*/,
@ -905,7 +905,7 @@ class ExecCtxNext : public grpc_core::ExecCtx {
static_cast<cq_is_finished_arg*>(check_ready_to_finish_arg_);
grpc_completion_queue* cq = a->cq;
cq_next_data* cqd = static_cast<cq_next_data*> DATA_FROM_CQ(cq);
GPR_ASSERT(a->stolen_completion == nullptr);
CHECK_EQ(a->stolen_completion, nullptr);
intptr_t current_last_seen_things_queued_ever =
cqd->things_queued_ever.load(std::memory_order_relaxed);
@ -962,7 +962,7 @@ static grpc_event cq_next(grpc_completion_queue* cq, gpr_timespec deadline,
5,
(cq, deadline.tv_sec, deadline.tv_nsec, (int)deadline.clock_type,
reserved));
GPR_ASSERT(!reserved);
CHECK(!reserved);
dump_pending_tags(cq);
@ -1068,7 +1068,7 @@ static grpc_event cq_next(grpc_completion_queue* cq, gpr_timespec deadline,
GRPC_SURFACE_TRACE_RETURNED_EVENT(cq, &ret);
GRPC_CQ_INTERNAL_UNREF(cq, "next");
GPR_ASSERT(is_finished_arg.stolen_completion == nullptr);
CHECK_EQ(is_finished_arg.stolen_completion, nullptr);
return ret;
}
@ -1082,8 +1082,8 @@ static grpc_event cq_next(grpc_completion_queue* cq, gpr_timespec deadline,
static void cq_finish_shutdown_next(grpc_completion_queue* cq) {
cq_next_data* cqd = static_cast<cq_next_data*> DATA_FROM_CQ(cq);
GPR_ASSERT(cqd->shutdown_called);
GPR_ASSERT(cqd->pending_events.load(std::memory_order_relaxed) == 0);
CHECK(cqd->shutdown_called);
CHECK_EQ(cqd->pending_events.load(std::memory_order_relaxed), 0);
cq->poller_vtable->shutdown(POLLSET_FROM_CQ(cq), &cq->pollset_shutdown_done);
}
@ -1156,7 +1156,7 @@ class ExecCtxPluck : public grpc_core::ExecCtx {
grpc_completion_queue* cq = a->cq;
cq_pluck_data* cqd = static_cast<cq_pluck_data*> DATA_FROM_CQ(cq);
GPR_ASSERT(a->stolen_completion == nullptr);
CHECK_EQ(a->stolen_completion, nullptr);
gpr_atm current_last_seen_things_queued_ever =
cqd->things_queued_ever.load(std::memory_order_relaxed);
if (current_last_seen_things_queued_ever !=
@ -1207,7 +1207,7 @@ static grpc_event cq_pluck(grpc_completion_queue* cq, void* tag,
(cq, tag, deadline.tv_sec, deadline.tv_nsec, (int)deadline.clock_type,
reserved));
}
GPR_ASSERT(!reserved);
CHECK(!reserved);
dump_pending_tags(cq);
@ -1298,7 +1298,7 @@ done:
GRPC_SURFACE_TRACE_RETURNED_EVENT(cq, &ret);
GRPC_CQ_INTERNAL_UNREF(cq, "pluck");
GPR_ASSERT(is_finished_arg.stolen_completion == nullptr);
CHECK_EQ(is_finished_arg.stolen_completion, nullptr);
return ret;
}
@ -1311,8 +1311,8 @@ grpc_event grpc_completion_queue_pluck(grpc_completion_queue* cq, void* tag,
static void cq_finish_shutdown_pluck(grpc_completion_queue* cq) {
cq_pluck_data* cqd = static_cast<cq_pluck_data*> DATA_FROM_CQ(cq);
GPR_ASSERT(cqd->shutdown_called);
GPR_ASSERT(!cqd->shutdown.load(std::memory_order_relaxed));
CHECK(cqd->shutdown_called);
CHECK(!cqd->shutdown.load(std::memory_order_relaxed));
cqd->shutdown.store(true, std::memory_order_relaxed);
cq->poller_vtable->shutdown(POLLSET_FROM_CQ(cq), &cq->pollset_shutdown_done);
@ -1348,7 +1348,7 @@ static void cq_finish_shutdown_callback(grpc_completion_queue* cq) {
cq_callback_data* cqd = static_cast<cq_callback_data*> DATA_FROM_CQ(cq);
auto* callback = cqd->shutdown_callback;
GPR_ASSERT(cqd->shutdown_called);
CHECK(cqd->shutdown_called);
cq->poller_vtable->shutdown(POLLSET_FROM_CQ(cq), &cq->pollset_shutdown_done);
if (grpc_iomgr_is_any_background_poller_thread()) {

@ -18,6 +18,8 @@
#include "src/core/lib/surface/completion_queue_factory.h"
#include "absl/log/check.h"
#include <grpc/grpc.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
@ -47,7 +49,7 @@ static const grpc_completion_queue_factory g_default_cq_factory = {
const grpc_completion_queue_factory* grpc_completion_queue_factory_lookup(
const grpc_completion_queue_attributes* attributes) {
GPR_ASSERT(attributes->version >= 1 &&
CHECK(attributes->version >= 1 &&
attributes->version <= GRPC_CQ_CURRENT_VERSION);
// The default factory can handle version 1 of the attributes structure. We
@ -61,7 +63,7 @@ const grpc_completion_queue_factory* grpc_completion_queue_factory_lookup(
grpc_completion_queue* grpc_completion_queue_create_for_next(void* reserved) {
grpc_core::ExecCtx exec_ctx;
GPR_ASSERT(!reserved);
CHECK(!reserved);
grpc_completion_queue_attributes attr = {1, GRPC_CQ_NEXT,
GRPC_CQ_DEFAULT_POLLING, nullptr};
return g_default_cq_factory.vtable->create(&g_default_cq_factory, &attr);
@ -69,7 +71,7 @@ grpc_completion_queue* grpc_completion_queue_create_for_next(void* reserved) {
grpc_completion_queue* grpc_completion_queue_create_for_pluck(void* reserved) {
grpc_core::ExecCtx exec_ctx;
GPR_ASSERT(!reserved);
CHECK(!reserved);
grpc_completion_queue_attributes attr = {1, GRPC_CQ_PLUCK,
GRPC_CQ_DEFAULT_POLLING, nullptr};
return g_default_cq_factory.vtable->create(&g_default_cq_factory, &attr);
@ -78,7 +80,7 @@ grpc_completion_queue* grpc_completion_queue_create_for_pluck(void* reserved) {
grpc_completion_queue* grpc_completion_queue_create_for_callback(
grpc_completion_queue_functor* shutdown_callback, void* reserved) {
grpc_core::ExecCtx exec_ctx;
GPR_ASSERT(!reserved);
CHECK(!reserved);
grpc_completion_queue_attributes attr = {
2, GRPC_CQ_CALLBACK, GRPC_CQ_DEFAULT_POLLING, shutdown_callback};
return g_default_cq_factory.vtable->create(&g_default_cq_factory, &attr);
@ -88,6 +90,6 @@ grpc_completion_queue* grpc_completion_queue_create(
const grpc_completion_queue_factory* factory,
const grpc_completion_queue_attributes* attr, void* reserved) {
grpc_core::ExecCtx exec_ctx;
GPR_ASSERT(!reserved);
CHECK(!reserved);
return factory->vtable->create(factory, attr);
}

@ -19,6 +19,7 @@
#include "src/core/lib/surface/legacy_channel.h"
#include "absl/base/thread_annotations.h"
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/types/optional.h"
@ -166,8 +167,8 @@ grpc_call* LegacyChannel::CreateCall(
grpc_completion_queue* cq, grpc_pollset_set* pollset_set_alternative,
Slice path, absl::optional<Slice> authority, Timestamp deadline,
bool registered_method) {
GPR_ASSERT(is_client_);
GPR_ASSERT(!(cq != nullptr && pollset_set_alternative != nullptr));
CHECK(is_client_);
CHECK(!(cq != nullptr && pollset_set_alternative != nullptr));
grpc_call_create_args args;
args.channel = Ref();
args.server = nullptr;
@ -213,7 +214,7 @@ class LegacyChannel::StateWatcher final : public DualRefCounted<StateWatcher> {
cq_(cq),
tag_(tag),
state_(last_observed_state) {
GPR_ASSERT(grpc_cq_begin_op(cq, tag));
CHECK(grpc_cq_begin_op(cq, tag));
GRPC_CLOSURE_INIT(&on_complete_, WatchComplete, this, nullptr);
ClientChannelFilter* client_channel = channel_->GetClientChannelFilter();
if (client_channel == nullptr) {
@ -343,14 +344,14 @@ void LegacyChannel::AddConnectivityWatcher(
grpc_connectivity_state initial_state,
OrphanablePtr<AsyncConnectivityStateWatcherInterface> watcher) {
auto* client_channel = GetClientChannelFilter();
GPR_ASSERT(client_channel != nullptr);
CHECK_NE(client_channel, nullptr);
client_channel->AddConnectivityWatcher(initial_state, std::move(watcher));
}
void LegacyChannel::RemoveConnectivityWatcher(
AsyncConnectivityStateWatcherInterface* watcher) {
auto* client_channel = GetClientChannelFilter();
GPR_ASSERT(client_channel != nullptr);
CHECK_NE(client_channel, nullptr);
client_channel->RemoveConnectivityWatcher(watcher);
}
@ -394,7 +395,7 @@ void LegacyChannel::Ping(grpc_completion_queue* cq, void* tag) {
grpc_transport_op* op = grpc_make_transport_op(nullptr);
op->send_ping.on_ack = &pr->closure;
op->bind_pollset = grpc_cq_pollset(cq);
GPR_ASSERT(grpc_cq_begin_op(cq, tag));
CHECK(grpc_cq_begin_op(cq, tag));
grpc_channel_element* top_elem =
grpc_channel_stack_element(channel_stack_.get(), 0);
top_elem->filter->start_transport_op(top_elem, op);

@ -23,6 +23,7 @@
#include <cstring>
#include "absl/log/check.h"
#include "absl/strings/string_view.h"
#include <grpc/slice.h>
@ -58,7 +59,7 @@ inline int grpc_key_is_binary_header(const uint8_t* buf, size_t length) {
return 0 == memcmp(buf + length - 4, "-bin", 4);
}
inline int grpc_is_refcounted_slice_binary_header(const grpc_slice& slice) {
GPR_DEBUG_ASSERT(slice.refcount != nullptr);
DCHECK_NE(slice.refcount, nullptr);
return grpc_key_is_binary_header(slice.data.refcounted.bytes,
slice.data.refcounted.length);
}

@ -32,6 +32,7 @@
#include "absl/cleanup/cleanup.h"
#include "absl/container/flat_hash_map.h"
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/types/optional.h"
@ -237,7 +238,7 @@ struct Server::RequestedCall {
Timestamp deadline = GetContext<Call>()->deadline();
switch (type) {
case RequestedCall::Type::BATCH_CALL:
GPR_ASSERT(!payload.has_value());
CHECK(!payload.has_value());
data.batch.details->host =
CSliceRef(md.get_pointer(HttpAuthorityMetadata())->c_slice());
data.batch.details->method =
@ -294,9 +295,9 @@ class Server::RealRequestMatcherFilterStack : public RequestMatcherInterface {
~RealRequestMatcherFilterStack() override {
for (LockedMultiProducerSingleConsumerQueue& queue : requests_per_cq_) {
GPR_ASSERT(queue.Pop() == nullptr);
CHECK_EQ(queue.Pop(), nullptr);
}
GPR_ASSERT(pending_.empty());
CHECK(pending_.empty());
}
void ZombifyPending() override {
@ -426,7 +427,7 @@ class Server::RealRequestMatcherPromises : public RequestMatcherInterface {
~RealRequestMatcherPromises() override {
for (LockedMultiProducerSingleConsumerQueue& queue : requests_per_cq_) {
GPR_ASSERT(queue.Pop() == nullptr);
CHECK_EQ(queue.Pop(), nullptr);
}
}
@ -563,7 +564,7 @@ class Server::RealRequestMatcherPromises : public RequestMatcherInterface {
if (!result.compare_exchange_strong(expected, new_value,
std::memory_order_acq_rel,
std::memory_order_acquire)) {
GPR_ASSERT(new_value->value().TakeCall() == requested_call);
CHECK(new_value->value().TakeCall() == requested_call);
delete new_value;
return false;
}
@ -600,7 +601,7 @@ class Server::AllocatingRequestMatcherBase : public RequestMatcherInterface {
break;
}
}
GPR_ASSERT(idx < server->cqs_.size());
CHECK(idx < server->cqs_.size());
cq_idx_ = idx;
}
@ -646,9 +647,9 @@ class Server::AllocatingRequestMatcherBatch
absl::MakeCleanup([this] { server()->ShutdownUnrefOnRequest(); });
if (still_running) {
BatchCallAllocation call_info = allocator_();
GPR_ASSERT(server()->ValidateServerRequest(
cq(), static_cast<void*>(call_info.tag), nullptr,
nullptr) == GRPC_CALL_OK);
CHECK(server()->ValidateServerRequest(cq(),
static_cast<void*>(call_info.tag),
nullptr, nullptr) == GRPC_CALL_OK);
RequestedCall* rc = new RequestedCall(
static_cast<void*>(call_info.tag), call_info.cq, call_info.call,
call_info.initial_metadata, call_info.details);
@ -662,9 +663,9 @@ class Server::AllocatingRequestMatcherBatch
ArenaPromise<absl::StatusOr<MatchResult>> MatchRequest(
size_t /*start_request_queue_index*/) override {
BatchCallAllocation call_info = allocator_();
GPR_ASSERT(server()->ValidateServerRequest(
cq(), static_cast<void*>(call_info.tag), nullptr, nullptr) ==
GRPC_CALL_OK);
CHECK(server()->ValidateServerRequest(cq(),
static_cast<void*>(call_info.tag),
nullptr, nullptr) == GRPC_CALL_OK);
RequestedCall* rc = new RequestedCall(
static_cast<void*>(call_info.tag), call_info.cq, call_info.call,
call_info.initial_metadata, call_info.details);
@ -692,7 +693,7 @@ class Server::AllocatingRequestMatcherRegistered
absl::MakeCleanup([this] { server()->ShutdownUnrefOnRequest(); });
if (server()->ShutdownRefOnRequest()) {
RegisteredCallAllocation call_info = allocator_();
GPR_ASSERT(server()->ValidateServerRequest(
CHECK(server()->ValidateServerRequest(
cq(), call_info.tag, call_info.optional_payload,
registered_method_) == GRPC_CALL_OK);
RequestedCall* rc =
@ -709,8 +710,8 @@ class Server::AllocatingRequestMatcherRegistered
ArenaPromise<absl::StatusOr<MatchResult>> MatchRequest(
size_t /*start_request_queue_index*/) override {
RegisteredCallAllocation call_info = allocator_();
GPR_ASSERT(server()->ValidateServerRequest(
cq(), call_info.tag, call_info.optional_payload,
CHECK(server()->ValidateServerRequest(cq(), call_info.tag,
call_info.optional_payload,
registered_method_) == GRPC_CALL_OK);
RequestedCall* rc = new RequestedCall(
call_info.tag, call_info.cq, call_info.call, call_info.initial_metadata,
@ -736,7 +737,7 @@ class ChannelBroadcaster {
// Copies over the channels from the locked server.
void FillChannelsLocked(std::vector<RefCountedPtr<Channel>> channels) {
GPR_DEBUG_ASSERT(channels_.empty());
DCHECK(channels_.empty());
channels_ = std::move(channels);
}
@ -955,7 +956,7 @@ void Server::SetRegisteredMethodAllocator(
void Server::SetBatchMethodAllocator(
grpc_completion_queue* cq, std::function<BatchCallAllocation()> allocator) {
GPR_DEBUG_ASSERT(unregistered_request_matcher_ == nullptr);
DCHECK(unregistered_request_matcher_ == nullptr);
unregistered_request_matcher_ =
std::make_unique<AllocatingRequestMatcherBatch>(this, cq,
std::move(allocator));
@ -1007,7 +1008,7 @@ void Server::FailCall(size_t cq_idx, RequestedCall* rc,
grpc_error_handle error) {
*rc->call = nullptr;
rc->initial_metadata->count = 0;
GPR_ASSERT(!error.ok());
CHECK(!error.ok());
grpc_cq_end_op(cqs_[cq_idx], rc->tag, error, DoneRequestEvent, rc,
&rc->completion);
}
@ -1101,7 +1102,7 @@ void Server::ShutdownAndNotify(grpc_completion_queue* cq, void* tag) {
starting_cv_.Wait(&mu_global_);
}
// Stay locked, and gather up some stuff to do.
GPR_ASSERT(grpc_cq_begin_op(cq, tag));
CHECK(grpc_cq_begin_op(cq, tag));
if (shutdown_published_) {
grpc_cq_end_op(cq, tag, absl::OkStatus(), DonePublishedShutdown, nullptr,
new grpc_cq_completion);
@ -1162,8 +1163,8 @@ void Server::SendGoaways() {
void Server::Orphan() {
{
MutexLock lock(&mu_global_);
GPR_ASSERT(ShutdownCalled() || listeners_.empty());
GPR_ASSERT(listeners_destroyed_ == listeners_.size());
CHECK(ShutdownCalled() || listeners_.empty());
CHECK(listeners_destroyed_ == listeners_.size());
}
Unref();
}
@ -1341,7 +1342,7 @@ void Server::ChannelData::InitTransport(RefCountedPtr<Server> server,
++accept_stream_types;
transport->server_transport()->SetAcceptor(this);
}
GPR_ASSERT(accept_stream_types == 1);
CHECK_EQ(accept_stream_types, 1);
op->start_connectivity_watch = MakeOrphanable<ConnectivityWatcher>(this);
if (server_->ShutdownCalled()) {
op->disconnect_with_error = GRPC_ERROR_CREATE("Server shutdown");
@ -1403,8 +1404,8 @@ void Server::ChannelData::AcceptStream(void* arg, Transport* /*transport*/,
grpc_error_handle error = grpc_call_create(&args, &call);
grpc_call_stack* call_stack = grpc_call_get_call_stack(call);
if (call_stack == nullptr) { // Promise based calls do not have a call stack
GPR_ASSERT(error.ok());
GPR_ASSERT(IsPromiseBasedServerCallEnabled());
CHECK(error.ok());
CHECK(IsPromiseBasedServerCallEnabled());
return;
} else {
grpc_call_element* elem = grpc_call_stack_element(call_stack, 0);
@ -1598,7 +1599,7 @@ void Server::ChannelData::FinishDestroy(void* arg,
void Server::ChannelData::Destroy() {
if (!list_position_.has_value()) return;
GPR_ASSERT(server_ != nullptr);
CHECK(server_ != nullptr);
server_->channels_.erase(*list_position_);
list_position_.reset();
server_->Ref().release();
@ -1620,8 +1621,8 @@ void Server::ChannelData::Destroy() {
grpc_error_handle Server::ChannelData::InitChannelElement(
grpc_channel_element* elem, grpc_channel_element_args* args) {
GPR_ASSERT(args->is_first);
GPR_ASSERT(!args->is_last);
CHECK(args->is_first);
CHECK(!args->is_last);
new (elem->channel_data) ChannelData();
return absl::OkStatus();
}
@ -1648,7 +1649,7 @@ Server::CallData::CallData(grpc_call_element* elem,
}
Server::CallData::~CallData() {
GPR_ASSERT(state_.load(std::memory_order_relaxed) != CallState::PENDING);
CHECK(state_.load(std::memory_order_relaxed) != CallState::PENDING);
grpc_metadata_array_destroy(&initial_metadata_);
grpc_byte_buffer_destroy(payload_);
}
@ -1699,8 +1700,8 @@ void Server::CallData::Publish(size_t cq_idx, RequestedCall* rc) {
std::swap(*rc->initial_metadata, initial_metadata_);
switch (rc->type) {
case RequestedCall::Type::BATCH_CALL:
GPR_ASSERT(host_.has_value());
GPR_ASSERT(path_.has_value());
CHECK(host_.has_value());
CHECK(path_.has_value());
rc->data.batch.details->host = CSliceRef(host_->c_slice());
rc->data.batch.details->method = CSliceRef(path_->c_slice());
rc->data.batch.details->deadline =
@ -1914,7 +1915,7 @@ void grpc_server_register_completion_queue(grpc_server* server,
GRPC_API_TRACE(
"grpc_server_register_completion_queue(server=%p, cq=%p, reserved=%p)", 3,
(server, cq, reserved));
GPR_ASSERT(!reserved);
CHECK(!reserved);
auto cq_type = grpc_get_cq_completion_type(cq);
if (cq_type != GRPC_CQ_NEXT && cq_type != GRPC_CQ_CALLBACK) {
gpr_log(GPR_INFO,

@ -39,7 +39,6 @@
#include "absl/types/optional.h"
#include <grpc/grpc.h>
#include <grpc/passive_listener.h>
#include <grpc/slice.h>
#include <grpc/support/port_platform.h>
#include <grpc/support/time.h>
@ -75,9 +74,6 @@
"grpc.server.max_pending_requests_hard_limit"
namespace grpc_core {
namespace experimental {
class PassiveListenerImpl;
} // namespace experimental
extern TraceFlag grpc_server_channel_trace;
@ -116,7 +112,7 @@ class Server : public ServerInterface,
/// Interface for listeners.
/// Implementations must override the Orphan() method, which should stop
/// listening and initiate destruction of the listener.
class ListenerInterface : public InternallyRefCounted<ListenerInterface> {
class ListenerInterface : public Orphanable {
public:
~ListenerInterface() override = default;
@ -216,14 +212,6 @@ class Server : public ServerInterface,
void SendGoaways() ABSL_LOCKS_EXCLUDED(mu_global_, mu_call_);
private:
// note: the grpc_core::Server redundant namespace qualification is
// required for older gcc versions.
// TODO(yashykt): eliminate this friend statement as part of your upcoming
// server listener refactoring.
friend absl::Status(::grpc_server_add_passive_listener)(
grpc_core::Server* server, grpc_server_credentials* credentials,
std::shared_ptr<grpc_core::experimental::PassiveListenerImpl>
passive_listener);
struct RequestedCall;
class RequestMatcherInterface;

@ -19,6 +19,7 @@
#include <utility>
#include "absl/base/thread_annotations.h"
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/types/optional.h"
@ -119,7 +120,7 @@ ServerConfigSelectorFilter::ServerConfigSelectorFilter(
RefCountedPtr<ServerConfigSelectorProvider> server_config_selector_provider)
: server_config_selector_provider_(
std::move(server_config_selector_provider)) {
GPR_ASSERT(server_config_selector_provider_ != nullptr);
CHECK(server_config_selector_provider_ != nullptr);
auto server_config_selector_watcher =
std::make_unique<ServerConfigSelectorWatcher>(Ref());
auto config_selector = server_config_selector_provider_->Watch(

@ -31,7 +31,6 @@
#include <grpc/impl/channel_arg_names.h>
#include <grpc/impl/compression_types.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
#include <grpc/support/sync.h>
#include <grpc/support/workaround_list.h>
#include <grpcpp/completion_queue.h>
@ -48,38 +47,11 @@
#include <grpcpp/support/channel_arguments.h>
#include <grpcpp/support/server_interceptor.h>
#include "src/core/ext/transport/chttp2/server/chttp2_server.h"
#include "src/core/lib/gpr/string.h"
#include "src/core/lib/gpr/useful.h"
#include "src/core/server/server.h"
#include "src/cpp/server/external_connection_acceptor_impl.h"
namespace grpc {
namespace {
// A PIMPL wrapper class that owns the only ref to the passive listener
// implementation. This is returned to the application.
class PassiveListenerOwner final
: public grpc_core::experimental::PassiveListener {
public:
explicit PassiveListenerOwner(std::shared_ptr<PassiveListener> listener)
: listener_(std::move(listener)) {}
absl::Status AcceptConnectedEndpoint(
std::unique_ptr<grpc_event_engine::experimental::EventEngine::Endpoint>
endpoint) override {
return listener_->AcceptConnectedEndpoint(std::move(endpoint));
}
absl::Status AcceptConnectedFd(int fd) override {
return listener_->AcceptConnectedFd(fd);
}
private:
std::shared_ptr<PassiveListener> listener_;
};
} // namespace
static std::vector<std::unique_ptr<ServerBuilderPlugin> (*)()>*
g_plugin_factory_list;
@ -253,18 +225,6 @@ ServerBuilder& ServerBuilder::SetResourceQuota(
return *this;
}
ServerBuilder& ServerBuilder::experimental_type::AddPassiveListener(
std::shared_ptr<grpc::ServerCredentials> creds,
std::unique_ptr<experimental::PassiveListener>& passive_listener) {
auto core_passive_listener =
std::make_shared<grpc_core::experimental::PassiveListenerImpl>();
builder_->unstarted_passive_listeners_.emplace_back(core_passive_listener,
std::move(creds));
passive_listener =
std::make_unique<PassiveListenerOwner>(std::move(core_passive_listener));
return *builder_;
}
ServerBuilder& ServerBuilder::AddListeningPort(
const std::string& addr_uri, std::shared_ptr<ServerCredentials> creds,
int* selected_port) {
@ -438,26 +398,6 @@ std::unique_ptr<grpc::Server> ServerBuilder::BuildAndStart() {
cq->RegisterServer(server.get());
}
for (auto& unstarted_listener : unstarted_passive_listeners_) {
has_frequently_polled_cqs = true;
auto passive_listener = unstarted_listener.passive_listener.lock();
auto* core_server = grpc_core::Server::FromC(server->c_server());
if (passive_listener != nullptr) {
auto* creds = unstarted_listener.credentials->c_creds();
if (creds == nullptr) {
gpr_log(GPR_ERROR, "Credentials missing for PassiveListener");
return nullptr;
}
auto success = grpc_server_add_passive_listener(
core_server, creds, std::move(passive_listener));
if (!success.ok()) {
gpr_log(GPR_ERROR, "Failed to create a passive listener: %s",
success.ToString().c_str());
return nullptr;
}
}
}
if (!has_frequently_polled_cqs) {
gpr_log(GPR_ERROR,
"At least one of the completion queues must be frequently polled");

@ -19,7 +19,6 @@
#include <map>
#include <memory>
#include <string>
#include <thread>
#include <tuple>
#include <utility>
#include <vector>
@ -160,70 +159,6 @@ class NotifyOnDelete {
grpc_core::Notification* signal_;
};
// An endpoint implementation that supports Read and Write via std::threads.
// Passing a grpc_core::Notification will allow owners to know when all
// in-flight callbacks have been run, and all endpoint state has been destroyed.
class ThreadedNoopEndpoint : public EventEngine::Endpoint {
public:
explicit ThreadedNoopEndpoint(grpc_core::Notification* destroyed)
: state_(std::make_shared<EndpointState>(destroyed)) {}
~ThreadedNoopEndpoint() override {
std::thread deleter([state = state_]() {
CleanupThread(state->read);
CleanupThread(state->write);
});
deleter.detach();
}
bool Read(absl::AnyInvocable<void(absl::Status)> on_read, SliceBuffer* buffer,
const ReadArgs* /* args */) override {
buffer->Clear();
CleanupThread(state_->read);
state_->read = new std::thread([cb = std::move(on_read)]() mutable {
cb(absl::UnknownError("test"));
});
return false;
}
bool Write(absl::AnyInvocable<void(absl::Status)> on_writable,
SliceBuffer* data, const WriteArgs* /* args */) override {
data->Clear();
CleanupThread(state_->write);
state_->write = new std::thread([cb = std::move(on_writable)]() mutable {
cb(absl::UnknownError("test"));
});
return false;
}
const EventEngine::ResolvedAddress& GetPeerAddress() const override {
return peer_;
}
const EventEngine::ResolvedAddress& GetLocalAddress() const override {
return local_;
}
private:
struct EndpointState {
explicit EndpointState(grpc_core::Notification* deleter)
: delete_notifier_(deleter) {}
std::thread* read = nullptr;
std::thread* write = nullptr;
NotifyOnDelete delete_notifier_;
};
static void CleanupThread(std::thread* thd) {
if (thd != nullptr) {
thd->join();
delete thd;
}
}
std::shared_ptr<EndpointState> state_;
EventEngine::ResolvedAddress peer_;
EventEngine::ResolvedAddress local_;
};
} // namespace experimental
} // namespace grpc_event_engine

@ -381,25 +381,6 @@ grpc_cc_test(
],
)
grpc_cc_test(
name = "bm_chttp2_transport",
srcs = ["bm_chttp2_transport.cc"],
args = grpc_benchmark_args(),
external_deps = [
"absl/log:check",
],
tags = [
"no_mac",
"no_windows",
"nomsan",
],
deps = [
":helpers",
"//src/core:closure",
"//src/core:slice",
],
)
grpc_cc_test(
name = "bm_opencensus_plugin",
srcs = ["bm_opencensus_plugin.cc"],

@ -1,425 +0,0 @@
//
//
// 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.
//
//
// Microbenchmarks around CHTTP2 transport operations
#include <string.h>
#include <memory>
#include <queue>
#include <sstream>
#include <benchmark/benchmark.h>
#include "absl/log/check.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include <grpcpp/support/channel_arguments.h>
#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
#include "src/core/ext/transport/chttp2/transport/internal.h"
#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/iomgr/closure.h"
#include "src/core/lib/resource_quota/api.h"
#include "src/core/lib/slice/slice_internal.h"
#include "test/core/test_util/test_config.h"
#include "test/cpp/microbenchmarks/helpers.h"
#include "test/cpp/util/test_config.h"
////////////////////////////////////////////////////////////////////////////////
// Helper classes
//
class PhonyEndpoint : public grpc_endpoint {
public:
PhonyEndpoint() {
static const grpc_endpoint_vtable my_vtable = {read,
write,
add_to_pollset,
add_to_pollset_set,
delete_from_pollset_set,
shutdown,
destroy,
get_peer,
get_local_address,
get_fd,
can_track_err};
grpc_endpoint::vtable = &my_vtable;
}
void PushInput(grpc_slice slice) {
if (read_cb_ == nullptr) {
CHECK(!have_slice_);
buffered_slice_ = slice;
have_slice_ = true;
return;
}
grpc_slice_buffer_add(slices_, slice);
grpc_core::ExecCtx::Run(DEBUG_LOCATION, read_cb_, absl::OkStatus());
read_cb_ = nullptr;
}
private:
grpc_closure* read_cb_ = nullptr;
grpc_slice_buffer* slices_ = nullptr;
bool have_slice_ = false;
grpc_slice buffered_slice_;
void QueueRead(grpc_slice_buffer* slices, grpc_closure* cb) {
CHECK_EQ(read_cb_, nullptr);
if (have_slice_) {
have_slice_ = false;
grpc_slice_buffer_add(slices, buffered_slice_);
grpc_core::ExecCtx::Run(DEBUG_LOCATION, cb, absl::OkStatus());
return;
}
read_cb_ = cb;
slices_ = slices;
}
static void read(grpc_endpoint* ep, grpc_slice_buffer* slices,
grpc_closure* cb, bool /*urgent*/,
int /*min_progress_size*/) {
static_cast<PhonyEndpoint*>(ep)->QueueRead(slices, cb);
}
static void write(grpc_endpoint* /*ep*/, grpc_slice_buffer* /*slices*/,
grpc_closure* cb, void* /*arg*/, int /*max_frame_size*/) {
grpc_core::ExecCtx::Run(DEBUG_LOCATION, cb, absl::OkStatus());
}
static void add_to_pollset(grpc_endpoint* /*ep*/, grpc_pollset* /*pollset*/) {
}
static void add_to_pollset_set(grpc_endpoint* /*ep*/,
grpc_pollset_set* /*pollset*/) {}
static void delete_from_pollset_set(grpc_endpoint* /*ep*/,
grpc_pollset_set* /*pollset*/) {}
static void shutdown(grpc_endpoint* ep, grpc_error_handle why) {
grpc_core::ExecCtx::Run(DEBUG_LOCATION,
static_cast<PhonyEndpoint*>(ep)->read_cb_, why);
}
static void destroy(grpc_endpoint* ep) {
delete static_cast<PhonyEndpoint*>(ep);
}
static absl::string_view get_peer(grpc_endpoint* /*ep*/) { return "test"; }
static absl::string_view get_local_address(grpc_endpoint* /*ep*/) {
return "test";
}
static int get_fd(grpc_endpoint* /*ep*/) { return 0; }
static bool can_track_err(grpc_endpoint* /*ep*/) { return false; }
};
class Fixture {
public:
Fixture(const grpc::ChannelArguments& args, bool client) {
grpc_channel_args c_args = args.c_channel_args();
ep_ = new PhonyEndpoint;
auto final_args = grpc_core::CoreConfiguration::Get()
.channel_args_preconditioning()
.PreconditionChannelArgs(&c_args);
t_ = grpc_create_chttp2_transport(final_args, ep_, client);
grpc_chttp2_transport_start_reading(t_, nullptr, nullptr, nullptr);
FlushExecCtx();
}
void FlushExecCtx() { grpc_core::ExecCtx::Get()->Flush(); }
~Fixture() { t_->Orphan(); }
grpc_chttp2_transport* chttp2_transport() {
return reinterpret_cast<grpc_chttp2_transport*>(t_);
}
grpc_core::Transport* transport() { return t_; }
void PushInput(grpc_slice slice) { ep_->PushInput(slice); }
private:
PhonyEndpoint* ep_;
grpc_core::Transport* t_;
};
class TestClosure : public grpc_closure {
public:
virtual ~TestClosure() {}
};
template <class F>
std::unique_ptr<TestClosure> MakeTestClosure(F f) {
struct C : public TestClosure {
explicit C(const F& f) : f_(f) {
GRPC_CLOSURE_INIT(this, Execute, this, nullptr);
}
F f_;
static void Execute(void* arg, grpc_error_handle error) {
static_cast<C*>(arg)->f_(error);
}
};
return std::unique_ptr<TestClosure>(new C(f));
}
template <class F>
grpc_closure* MakeOnceClosure(F f) {
struct C : public grpc_closure {
explicit C(const F& f) : f_(f) {}
F f_;
static void Execute(void* arg, grpc_error_handle error) {
static_cast<C*>(arg)->f_(error);
delete static_cast<C*>(arg);
}
};
auto* c = new C{f};
return GRPC_CLOSURE_INIT(c, C::Execute, c, nullptr);
}
class Stream {
public:
explicit Stream(Fixture* f) : f_(f) {
stream_size_ = f->transport()->filter_stack_transport()->SizeOfStream();
stream_ = gpr_malloc(stream_size_);
arena_ = grpc_core::Arena::Create(4096, &memory_allocator_);
}
~Stream() {
gpr_event_wait(&done_, gpr_inf_future(GPR_CLOCK_REALTIME));
gpr_free(stream_);
arena_->Destroy();
}
void Init(benchmark::State& state) {
GRPC_STREAM_REF_INIT(&refcount_, 1, &Stream::FinishDestroy, this,
"test_stream");
gpr_event_init(&done_);
memset(stream_, 0, stream_size_);
if ((state.iterations() & 0xffff) == 0) {
arena_->Destroy();
arena_ = grpc_core::Arena::Create(4096, &memory_allocator_);
}
f_->transport()->filter_stack_transport()->InitStream(
static_cast<grpc_stream*>(stream_), &refcount_, nullptr, arena_);
}
void DestroyThen(grpc_closure* closure) {
destroy_closure_ = closure;
#ifndef NDEBUG
grpc_stream_unref(&refcount_, "DestroyThen");
#else
grpc_stream_unref(&refcount_);
#endif
}
void Op(grpc_transport_stream_op_batch* op) {
f_->transport()->filter_stack_transport()->PerformStreamOp(
static_cast<grpc_stream*>(stream_), op);
}
grpc_chttp2_stream* chttp2_stream() {
return static_cast<grpc_chttp2_stream*>(stream_);
}
private:
static void FinishDestroy(void* arg, grpc_error_handle /*error*/) {
auto stream = static_cast<Stream*>(arg);
stream->f_->transport()->filter_stack_transport()->DestroyStream(
static_cast<grpc_stream*>(stream->stream_), stream->destroy_closure_);
gpr_event_set(&stream->done_, reinterpret_cast<void*>(1));
}
Fixture* f_;
grpc_stream_refcount refcount_;
grpc_core::MemoryAllocator memory_allocator_ =
grpc_core::MemoryAllocator(grpc_core::ResourceQuota::Default()
->memory_quota()
->CreateMemoryAllocator("test"));
grpc_core::Arena* arena_;
size_t stream_size_;
void* stream_;
grpc_closure* destroy_closure_ = nullptr;
gpr_event done_;
};
////////////////////////////////////////////////////////////////////////////////
// Benchmarks
//
std::vector<std::unique_ptr<gpr_event>> done_events;
static void BM_StreamCreateDestroy(benchmark::State& state) {
grpc_core::ExecCtx exec_ctx;
Fixture f(grpc::ChannelArguments(), true);
auto* s = new Stream(&f);
grpc_transport_stream_op_batch op;
grpc_transport_stream_op_batch_payload op_payload(nullptr);
op = {};
op.cancel_stream = true;
op.payload = &op_payload;
op_payload.cancel_stream.cancel_error = absl::CancelledError();
std::unique_ptr<TestClosure> next =
MakeTestClosure([&, s](grpc_error_handle /*error*/) {
if (!state.KeepRunning()) {
delete s;
return;
}
s->Init(state);
s->Op(&op);
s->DestroyThen(next.get());
});
grpc_core::Closure::Run(DEBUG_LOCATION, next.get(), absl::OkStatus());
f.FlushExecCtx();
}
BENCHMARK(BM_StreamCreateDestroy);
class RepresentativeClientInitialMetadata {
public:
static void Prepare(grpc_metadata_batch* b) {
b->Set(grpc_core::HttpSchemeMetadata(),
grpc_core::HttpSchemeMetadata::kHttp);
b->Set(grpc_core::HttpMethodMetadata(),
grpc_core::HttpMethodMetadata::kPost);
b->Set(grpc_core::HttpPathMetadata(),
grpc_core::Slice(grpc_core::StaticSlice::FromStaticString(
"/foo/bar/bm_chttp2_transport")));
b->Set(grpc_core::HttpAuthorityMetadata(),
grpc_core::Slice(grpc_core::StaticSlice::FromStaticString(
"foo.test.google.fr:1234")));
b->Set(
grpc_core::GrpcAcceptEncodingMetadata(),
grpc_core::CompressionAlgorithmSet(
{GRPC_COMPRESS_NONE, GRPC_COMPRESS_DEFLATE, GRPC_COMPRESS_GZIP}));
b->Set(grpc_core::TeMetadata(), grpc_core::TeMetadata::kTrailers);
b->Set(grpc_core::ContentTypeMetadata(),
grpc_core::ContentTypeMetadata::kApplicationGrpc);
b->Set(grpc_core::UserAgentMetadata(),
grpc_core::Slice(grpc_core::StaticSlice::FromStaticString(
"grpc-c/3.0.0-dev (linux; chttp2; green)")));
}
};
template <class Metadata>
static void BM_StreamCreateSendInitialMetadataDestroy(benchmark::State& state) {
grpc_core::ExecCtx exec_ctx;
Fixture f(grpc::ChannelArguments(), true);
auto* s = new Stream(&f);
grpc_transport_stream_op_batch op;
grpc_transport_stream_op_batch_payload op_payload(nullptr);
std::unique_ptr<TestClosure> start;
std::unique_ptr<TestClosure> done;
auto reset_op = [&]() {
op = {};
op.payload = &op_payload;
};
grpc_core::MemoryAllocator memory_allocator =
grpc_core::MemoryAllocator(grpc_core::ResourceQuota::Default()
->memory_quota()
->CreateMemoryAllocator("test"));
auto arena = grpc_core::MakeScopedArena(1024, &memory_allocator);
grpc_metadata_batch b;
Metadata::Prepare(&b);
f.FlushExecCtx();
gpr_event bm_done;
gpr_event_init(&bm_done);
start = MakeTestClosure([&, s](grpc_error_handle /*error*/) {
if (!state.KeepRunning()) {
delete s;
gpr_event_set(&bm_done, (void*)1);
return;
}
s->Init(state);
reset_op();
op.on_complete = done.get();
op.send_initial_metadata = true;
op.payload->send_initial_metadata.send_initial_metadata = &b;
s->Op(&op);
});
done = MakeTestClosure([&](grpc_error_handle /*error*/) {
reset_op();
op.cancel_stream = true;
op.payload->cancel_stream.cancel_error = absl::CancelledError();
s->Op(&op);
s->DestroyThen(start.get());
});
grpc_core::ExecCtx::Run(DEBUG_LOCATION, start.get(), absl::OkStatus());
f.FlushExecCtx();
gpr_event_wait(&bm_done, gpr_inf_future(GPR_CLOCK_REALTIME));
}
BENCHMARK_TEMPLATE(BM_StreamCreateSendInitialMetadataDestroy,
RepresentativeClientInitialMetadata);
static void BM_TransportEmptyOp(benchmark::State& state) {
grpc_core::ExecCtx exec_ctx;
Fixture f(grpc::ChannelArguments(), true);
auto* s = new Stream(&f);
s->Init(state);
grpc_transport_stream_op_batch op;
grpc_transport_stream_op_batch_payload op_payload(nullptr);
auto reset_op = [&]() {
op = {};
op.payload = &op_payload;
};
std::unique_ptr<TestClosure> c =
MakeTestClosure([&](grpc_error_handle /*error*/) {
if (!state.KeepRunning()) return;
reset_op();
op.on_complete = c.get();
s->Op(&op);
});
grpc_core::ExecCtx::Run(DEBUG_LOCATION, c.get(), absl::OkStatus());
f.FlushExecCtx();
reset_op();
op.cancel_stream = true;
op_payload.cancel_stream.cancel_error = absl::CancelledError();
gpr_event* stream_cancel_done = new gpr_event;
gpr_event_init(stream_cancel_done);
std::unique_ptr<TestClosure> stream_cancel_closure =
MakeTestClosure([&](grpc_error_handle error) {
CHECK_OK(error);
gpr_event_set(stream_cancel_done, reinterpret_cast<void*>(1));
});
op.on_complete = stream_cancel_closure.get();
s->Op(&op);
f.FlushExecCtx();
gpr_event_wait(stream_cancel_done, gpr_inf_future(GPR_CLOCK_REALTIME));
done_events.emplace_back(stream_cancel_done);
s->DestroyThen(
MakeOnceClosure([s](grpc_error_handle /*error*/) { delete s; }));
f.FlushExecCtx();
}
BENCHMARK(BM_TransportEmptyOp);
// Some distros have RunSpecifiedBenchmarks under the benchmark namespace,
// and others do not. This allows us to support both modes.
namespace benchmark {
void RunTheBenchmarksNamespaced() { RunSpecifiedBenchmarks(); }
} // namespace benchmark
int main(int argc, char** argv) {
grpc::testing::TestEnvironment env(&argc, argv);
LibraryInitializer libInit;
::benchmark::Initialize(&argc, argv);
grpc::testing::InitTest(&argc, &argv, false);
benchmark::RunTheBenchmarksNamespaced();
return 0;
}

@ -28,7 +28,6 @@ grpc_cc_test(
deps = [
"//:grpc++_unsecure",
"//src/proto/grpc/testing:echo_proto",
"//test/core/event_engine:event_engine_test_utils",
"//test/core/test_util:grpc_test_util_base",
"//test/core/test_util:grpc_test_util_unsecure",
],

@ -16,19 +16,14 @@
//
//
#include <sys/socket.h>
#include <gtest/gtest.h>
#include <grpc/event_engine/slice_buffer.h>
#include <grpc/grpc.h>
#include <grpcpp/server.h>
#include <grpcpp/server_builder.h>
#include <grpcpp/support/config.h>
#include "src/core/lib/gprpp/notification.h"
#include "src/proto/grpc/testing/echo.grpc.pb.h"
#include "test/core/event_engine/event_engine_test_utils.h"
#include "test/core/test_util/port.h"
#include "test/core/test_util/test_config.h"
@ -88,56 +83,6 @@ TEST_F(ServerBuilderTest, CreateServerRepeatedPortWithDisallowedReusePort) {
nullptr);
}
TEST_F(ServerBuilderTest, AddPassiveListener) {
std::unique_ptr<experimental::PassiveListener> passive_listener;
auto server =
ServerBuilder()
.experimental()
.AddPassiveListener(InsecureServerCredentials(), passive_listener)
.BuildAndStart();
server->Shutdown();
}
TEST_F(ServerBuilderTest, PassiveListenerAcceptConnectedFd) {
std::unique_ptr<experimental::PassiveListener> passive_listener;
ServerBuilder builder;
auto cq = builder.AddCompletionQueue();
// TODO(hork): why is the service necessary? Queue isn't drained otherwise.
auto server =
builder.RegisterService(&g_service)
.experimental()
.AddPassiveListener(InsecureServerCredentials(), passive_listener)
.BuildAndStart();
ASSERT_NE(server.get(), nullptr);
#ifdef GPR_SUPPORT_CHANNELS_FROM_FD
int fd = socket(AF_INET, SOCK_STREAM, 0);
auto accept_status = passive_listener->AcceptConnectedFd(fd);
ASSERT_TRUE(accept_status.ok()) << accept_status;
#else
int fd = -1;
auto accept_status = passive_listener->AcceptConnectedFd(fd);
ASSERT_FALSE(accept_status.ok()) << accept_status;
#endif
server->Shutdown();
}
TEST_F(ServerBuilderTest, PassiveListenerAcceptConnectedEndpoint) {
std::unique_ptr<experimental::PassiveListener> passive_listener;
auto server =
ServerBuilder()
.experimental()
.AddPassiveListener(InsecureServerCredentials(), passive_listener)
.BuildAndStart();
grpc_core::Notification endpoint_destroyed;
auto success = passive_listener->AcceptConnectedEndpoint(
std::make_unique<grpc_event_engine::experimental::ThreadedNoopEndpoint>(
&endpoint_destroyed));
ASSERT_TRUE(success.ok())
<< "AcceptConnectedEndpoint failure: " << success.ToString();
endpoint_destroyed.WaitForNotification();
server->Shutdown();
}
} // namespace
} // namespace grpc

@ -45,6 +45,7 @@ grpc_cc_library(
hdrs = [
"proto_reflection_descriptor_database.h",
],
external_deps = ["absl/log:log"],
deps = [
"//:grpc++",
"//:grpc++_config_proto",
@ -78,6 +79,7 @@ grpc_cc_library(
external_deps = [
"absl/flags:flag",
"absl/log:check",
"absl/log:log",
"protobuf",
],
deps = [
@ -141,6 +143,7 @@ grpc_cc_library(
external_deps = [
"absl/flags:flag",
"absl/log:check",
"absl/log:log",
"protobuf",
"protobuf_clib",
],
@ -175,6 +178,7 @@ grpc_cc_library(
hdrs = [
"metrics_server.h",
],
external_deps = ["absl/log:log"],
deps = [
"//:grpc++",
"//src/proto/grpc/testing:metrics_proto",
@ -338,6 +342,7 @@ grpc_cc_binary(
external_deps = [
"absl/flags:flag",
"absl/log:check",
"absl/log:log",
"absl/strings",
],
language = "c++",
@ -364,6 +369,7 @@ grpc_cc_test(
],
external_deps = [
"absl/log:check",
"absl/log:log",
"gtest",
],
flaky = True,

@ -28,6 +28,7 @@
#include "absl/flags/flag.h"
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/strings/str_format.h"
#include "absl/strings/str_join.h"
#include "google/protobuf/text_format.h"
@ -133,8 +134,8 @@ class ChannelzSampler final {
Status status = channelz_stub_->GetChannel(
&get_channel_context, get_channel_request, &get_channel_response);
if (!status.ok()) {
gpr_log(GPR_ERROR, "GetChannelRPC failed: %s",
get_channel_context.debug_error_string().c_str());
LOG(ERROR) << "GetChannelRPC failed: "
<< get_channel_context.debug_error_string();
CHECK(0);
}
return get_channel_response.channel();
@ -152,8 +153,8 @@ class ChannelzSampler final {
get_subchannel_request,
&get_subchannel_response);
if (!status.ok()) {
gpr_log(GPR_ERROR, "GetSubchannelRPC failed: %s",
get_subchannel_context.debug_error_string().c_str());
LOG(ERROR) << "GetSubchannelRPC failed: "
<< get_subchannel_context.debug_error_string();
CHECK(0);
}
return get_subchannel_response.subchannel();
@ -170,8 +171,8 @@ class ChannelzSampler final {
Status status = channelz_stub_->GetSocket(
&get_socket_context, get_socket_request, &get_socket_response);
if (!status.ok()) {
gpr_log(GPR_ERROR, "GetSocketRPC failed: %s",
get_socket_context.debug_error_string().c_str());
LOG(ERROR) << "GetSocketRPC failed: "
<< get_socket_context.debug_error_string();
CHECK(0);
}
return get_socket_response.socket();
@ -297,10 +298,9 @@ class ChannelzSampler final {
grpc::testing::GetCredentialsProvider()->GetChannelCredentials(
custom_credentials_type, &channel_args);
if (!channel_creds) {
gpr_log(GPR_ERROR,
"Wrong user credential type: %s. Allowed credential types: "
"INSECURE_CREDENTIALS, ssl, alts, google_default_credentials.",
custom_credentials_type.c_str());
LOG(ERROR) << "Wrong user credential type: " << custom_credentials_type
<< ". Allowed credential types: INSECURE_CREDENTIALS, ssl, "
"alts, google_default_credentials.";
CHECK(0);
}
std::shared_ptr<grpc::Channel> channel =
@ -324,15 +324,14 @@ class ChannelzSampler final {
&get_servers_context, get_servers_request, &get_servers_response);
if (!status.ok()) {
if (status.error_code() == StatusCode::UNIMPLEMENTED) {
gpr_log(GPR_ERROR,
"Error status UNIMPLEMENTED. Please check and make sure "
"channelz has been registered on the server being queried.");
LOG(ERROR) << "Error status UNIMPLEMENTED. Please check and make "
"sure channelz has been registered on the server being "
"queried.";
} else {
gpr_log(GPR_ERROR,
"GetServers RPC with GetServersRequest.server_start_id=%d, "
"failed: %s",
static_cast<int>(server_start_id),
get_servers_context.debug_error_string().c_str());
LOG(ERROR) << "GetServers RPC with "
"GetServersRequest.server_start_id="
<< server_start_id << ", failed: "
<< get_servers_context.debug_error_string();
}
CHECK(0);
}
@ -384,11 +383,10 @@ class ChannelzSampler final {
&get_top_channels_context, get_top_channels_request,
&get_top_channels_response);
if (!status.ok()) {
gpr_log(GPR_ERROR,
"GetTopChannels RPC with "
"GetTopChannelsRequest.channel_start_id=%d failed: %s",
static_cast<int>(channel_start_id),
get_top_channels_context.debug_error_string().c_str());
LOG(ERROR) << "GetTopChannels RPC with "
"GetTopChannelsRequest.channel_start_id="
<< channel_start_id << " failed: "
<< get_top_channels_context.debug_error_string();
CHECK(0);
}
for (const auto& _topchannel : get_top_channels_response.channel()) {

@ -25,6 +25,7 @@
#include <thread>
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/strings/str_cat.h"
#include "gtest/gtest.h"
@ -85,7 +86,7 @@ void RunClient(const std::string& client_id, gpr_event* done_ev) {
std::unique_ptr<grpc::testing::TestService::Stub> stub =
grpc::testing::TestService::NewStub(
grpc::CreateChannel(server_address, channel_creds));
gpr_log(GPR_INFO, "Client %s is echoing!", client_id.c_str());
LOG(INFO) << "Client " << client_id << " is echoing!";
while (true) {
if (gpr_event_wait(done_ev, grpc_timeout_seconds_to_deadline(1)) !=
nullptr) {
@ -96,7 +97,7 @@ void RunClient(const std::string& client_id, gpr_event* done_ev) {
ClientContext context;
Status status = stub->EmptyCall(&context, request, &response);
if (!status.ok()) {
gpr_log(GPR_ERROR, "Client echo failed.");
LOG(ERROR) << "Client echo failed.";
CHECK(0);
}
}
@ -125,7 +126,7 @@ TEST(ChannelzSamplerTest, SimpleTest) {
builder.AddListeningPort(server_address, server_creds);
builder.RegisterService(&service);
std::unique_ptr<Server> server(builder.BuildAndStart());
gpr_log(GPR_INFO, "Server listening on %s", server_address.c_str());
LOG(INFO) << "Server listening on " << server_address;
const int kWaitForServerSeconds = 10;
ASSERT_TRUE(WaitForConnection(kWaitForServerSeconds));
// client threads
@ -144,19 +145,17 @@ TEST(ChannelzSamplerTest, SimpleTest) {
int status = test_driver->Join();
if (WIFEXITED(status)) {
if (WEXITSTATUS(status)) {
gpr_log(GPR_ERROR,
"Channelz sampler test test-runner exited with code %d",
WEXITSTATUS(status));
LOG(ERROR) << "Channelz sampler test test-runner exited with code "
<< WEXITSTATUS(status);
CHECK(0); // log the line number of the assertion failure
}
} else if (WIFSIGNALED(status)) {
gpr_log(GPR_ERROR, "Channelz sampler test test-runner ended from signal %d",
WTERMSIG(status));
LOG(ERROR) << "Channelz sampler test test-runner ended from signal "
<< WTERMSIG(status);
CHECK(0);
} else {
gpr_log(GPR_ERROR,
"Channelz sampler test test-runner ended with unknown status %d",
status);
LOG(ERROR) << "Channelz sampler test test-runner ended with unknown status "
<< status;
CHECK(0);
}
delete test_driver;

@ -19,6 +19,7 @@
#include "test/cpp/util/cli_credentials.h"
#include "absl/flags/flag.h"
#include "absl/log/log.h"
#include <grpc/slice.h>
#include <grpc/support/log.h>
@ -97,9 +98,9 @@ CliCredentials::GetChannelCredentials() const {
auto cert = grpc_core::LoadFile(absl::GetFlag(FLAGS_ssl_client_cert),
/*add_null_terminator=*/false);
if (!cert.ok()) {
gpr_log(GPR_ERROR, "error loading file %s: %s",
absl::GetFlag(FLAGS_ssl_client_cert).c_str(),
cert.status().ToString().c_str());
LOG(ERROR) << "error loading file "
<< absl::GetFlag(FLAGS_ssl_client_cert) << ": "
<< cert.status();
} else {
ssl_creds_options.pem_cert_chain = std::string(cert->as_string_view());
}
@ -108,9 +109,9 @@ CliCredentials::GetChannelCredentials() const {
auto key = grpc_core::LoadFile(absl::GetFlag(FLAGS_ssl_client_key),
/*add_null_terminator=*/false);
if (!key.ok()) {
gpr_log(GPR_ERROR, "error loading file %s: %s",
absl::GetFlag(FLAGS_ssl_client_key).c_str(),
key.status().ToString().c_str());
LOG(ERROR) << "error loading file "
<< absl::GetFlag(FLAGS_ssl_client_key) << ": "
<< key.status();
} else {
ssl_creds_options.pem_private_key = std::string(key->as_string_view());
}

@ -18,6 +18,8 @@
#include "test/cpp/util/metrics_server.h"
#include "absl/log/log.h"
#include <grpc/support/log.h>
#include <grpcpp/server.h>
#include <grpcpp/server_builder.h>
@ -54,7 +56,7 @@ long QpsGauge::Get() {
grpc::Status MetricsServiceImpl::GetAllGauges(
ServerContext* /*context*/, const EmptyMessage* /*request*/,
ServerWriter<GaugeResponse>* writer) {
gpr_log(GPR_DEBUG, "GetAllGauges called");
VLOG(2) << "GetAllGauges called";
std::lock_guard<std::mutex> lock(mu_);
for (auto it = qps_gauges_.begin(); it != qps_gauges_.end(); it++) {
@ -99,7 +101,7 @@ std::shared_ptr<QpsGauge> MetricsServiceImpl::CreateQpsGauge(
// Starts the metrics server and returns the grpc::Server instance. Call Wait()
// on the returned server instance.
std::unique_ptr<grpc::Server> MetricsServiceImpl::StartServer(int port) {
gpr_log(GPR_INFO, "Building metrics server..");
LOG(INFO) << "Building metrics server..";
const std::string address = "0.0.0.0:" + std::to_string(port);
@ -108,8 +110,8 @@ std::unique_ptr<grpc::Server> MetricsServiceImpl::StartServer(int port) {
builder.RegisterService(this);
std::unique_ptr<grpc::Server> server(builder.BuildAndStart());
gpr_log(GPR_INFO, "Metrics server %s started. Ready to receive requests..",
address.c_str());
LOG(INFO) << "Metrics server " << address
<< " started. Ready to receive requests..";
return server;
}

@ -20,7 +20,7 @@
#include <vector>
#include <grpc/support/log.h>
#include "absl/log/log.h"
#include "src/core/lib/gprpp/crash.h"
@ -86,23 +86,19 @@ bool ProtoReflectionDescriptorDatabase::FindFileByName(
ServerReflectionResponse::MessageResponseCase::kErrorResponse) {
const ErrorResponse& error = response.error_response();
if (error.error_code() == StatusCode::NOT_FOUND) {
gpr_log(GPR_INFO, "NOT_FOUND from server for FindFileByName(%s)",
filename.c_str());
LOG(INFO) << "NOT_FOUND from server for FindFileByName(" << filename
<< ")";
} else {
gpr_log(GPR_INFO,
"Error on FindFileByName(%s)\n\tError code: %d\n"
"\tError Message: %s",
filename.c_str(), error.error_code(),
error.error_message().c_str());
LOG(INFO) << "Error on FindFileByName(" << filename
<< ")\n\tError code: " << error.error_code()
<< "\n\tError Message: " << error.error_message();
}
} else {
gpr_log(
GPR_INFO,
"Error on FindFileByName(%s) response type\n"
"\tExpecting: %d\n\tReceived: %d",
filename.c_str(),
ServerReflectionResponse::MessageResponseCase::kFileDescriptorResponse,
response.message_response_case());
LOG(INFO) << "Error on FindFileByName(" << filename
<< ") response type\n\tExpecting: "
<< ServerReflectionResponse::MessageResponseCase::
kFileDescriptorResponse
<< "\n\tReceived: " << response.message_response_case();
}
return cached_db_.FindFileByName(filename, output);
@ -134,24 +130,19 @@ bool ProtoReflectionDescriptorDatabase::FindFileContainingSymbol(
const ErrorResponse& error = response.error_response();
if (error.error_code() == StatusCode::NOT_FOUND) {
missing_symbols_.insert(symbol_name);
gpr_log(GPR_INFO,
"NOT_FOUND from server for FindFileContainingSymbol(%s)",
symbol_name.c_str());
LOG(INFO) << "NOT_FOUND from server for FindFileContainingSymbol("
<< symbol_name << ")";
} else {
gpr_log(GPR_INFO,
"Error on FindFileContainingSymbol(%s)\n"
"\tError code: %d\n\tError Message: %s",
symbol_name.c_str(), error.error_code(),
error.error_message().c_str());
LOG(INFO) << "Error on FindFileContainingSymbol(" << symbol_name
<< ")\n\tError code: " << error.error_code()
<< "\n\tError Message: " << error.error_message();
}
} else {
gpr_log(
GPR_INFO,
"Error on FindFileContainingSymbol(%s) response type\n"
"\tExpecting: %d\n\tReceived: %d",
symbol_name.c_str(),
ServerReflectionResponse::MessageResponseCase::kFileDescriptorResponse,
response.message_response_case());
LOG(INFO) << "Error on FindFileContainingSymbol(" << symbol_name
<< ") response type\n\tExpecting: "
<< ServerReflectionResponse::MessageResponseCase::
kFileDescriptorResponse
<< "\n\tReceived: " << response.message_response_case();
}
return cached_db_.FindFileContainingSymbol(symbol_name, output);
}
@ -167,7 +158,7 @@ bool ProtoReflectionDescriptorDatabase::FindFileContainingExtension(
if (missing_extensions_.find(containing_type) != missing_extensions_.end() &&
missing_extensions_[containing_type].find(field_number) !=
missing_extensions_[containing_type].end()) {
gpr_log(GPR_INFO, "nested map.");
LOG(INFO) << "nested map.";
return false;
}
@ -194,24 +185,20 @@ bool ProtoReflectionDescriptorDatabase::FindFileContainingExtension(
missing_extensions_[containing_type] = {};
}
missing_extensions_[containing_type].insert(field_number);
gpr_log(GPR_INFO,
"NOT_FOUND from server for FindFileContainingExtension(%s, %d)",
containing_type.c_str(), field_number);
LOG(INFO) << "NOT_FOUND from server for FindFileContainingExtension("
<< containing_type << ", " << field_number << ")";
} else {
gpr_log(GPR_INFO,
"Error on FindFileContainingExtension(%s, %d)\n"
"\tError code: %d\n\tError Message: %s",
containing_type.c_str(), field_number, error.error_code(),
error.error_message().c_str());
LOG(INFO) << "Error on FindFileContainingExtension(" << containing_type
<< ", " << field_number
<< ")\n\tError code: " << error.error_code()
<< "\n\tError Message: " << error.error_message();
}
} else {
gpr_log(
GPR_INFO,
"Error on FindFileContainingExtension(%s, %d) response type\n"
"\tExpecting: %d\n\tReceived: %d",
containing_type.c_str(), field_number,
ServerReflectionResponse::MessageResponseCase::kFileDescriptorResponse,
response.message_response_case());
LOG(INFO) << "Error on FindFileContainingExtension(" << containing_type
<< ", " << field_number << ") response type\n\tExpecting: "
<< ServerReflectionResponse::MessageResponseCase::
kFileDescriptorResponse
<< "\n\tReceived: " << response.message_response_case();
}
return cached_db_.FindFileContainingExtension(containing_type, field_number,
@ -245,14 +232,12 @@ bool ProtoReflectionDescriptorDatabase::FindAllExtensionNumbers(
ServerReflectionResponse::MessageResponseCase::kErrorResponse) {
const ErrorResponse& error = response.error_response();
if (error.error_code() == StatusCode::NOT_FOUND) {
gpr_log(GPR_INFO, "NOT_FOUND from server for FindAllExtensionNumbers(%s)",
extendee_type.c_str());
LOG(INFO) << "NOT_FOUND from server for FindAllExtensionNumbers("
<< extendee_type << ")";
} else {
gpr_log(GPR_INFO,
"Error on FindAllExtensionNumbersExtension(%s)\n"
"\tError code: %d\n\tError Message: %s",
extendee_type.c_str(), error.error_code(),
error.error_message().c_str());
LOG(INFO) << "Error on FindAllExtensionNumbersExtension(" << extendee_type
<< ")\n\tError code: " << error.error_code()
<< "\n\tError Message: " << error.error_message();
}
}
return false;
@ -278,16 +263,13 @@ bool ProtoReflectionDescriptorDatabase::GetServices(
} else if (response.message_response_case() ==
ServerReflectionResponse::MessageResponseCase::kErrorResponse) {
const ErrorResponse& error = response.error_response();
gpr_log(GPR_INFO,
"Error on GetServices()\n\tError code: %d\n"
"\tError Message: %s",
error.error_code(), error.error_message().c_str());
LOG(INFO) << "Error on GetServices()\n\tError code: " << error.error_code()
<< "\n\tError Message: " << error.error_message();
} else {
gpr_log(
GPR_INFO,
"Error on GetServices() response type\n\tExpecting: %d\n\tReceived: %d",
ServerReflectionResponse::MessageResponseCase::kListServicesResponse,
response.message_response_case());
LOG(INFO)
<< "Error on GetServices() response type\n\tExpecting: "
<< ServerReflectionResponse::MessageResponseCase::kListServicesResponse
<< "\n\tReceived: " << response.message_response_case();
}
return false;
}

@ -27,6 +27,7 @@
#include "absl/flags/flag.h"
#include "absl/log/check.h"
#include "absl/log/log.h"
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
@ -104,7 +105,7 @@ class DefaultCredentialsProvider : public CredentialsProvider {
auto it(std::find(added_secure_type_names_.begin(),
added_secure_type_names_.end(), type));
if (it == added_secure_type_names_.end()) {
gpr_log(GPR_ERROR, "Unsupported credentials type %s.", type.c_str());
LOG(ERROR) << "Unsupported credentials type " << type;
return nullptr;
}
return added_secure_type_providers_[it - added_secure_type_names_.begin()]
@ -137,7 +138,7 @@ class DefaultCredentialsProvider : public CredentialsProvider {
auto it(std::find(added_secure_type_names_.begin(),
added_secure_type_names_.end(), type));
if (it == added_secure_type_names_.end()) {
gpr_log(GPR_ERROR, "Unsupported credentials type %s.", type.c_str());
LOG(ERROR) << "Unsupported credentials type " << type;
return nullptr;
}
return added_secure_type_providers_[it - added_secure_type_names_.begin()]

@ -77,10 +77,6 @@ IGNORED_FILES = [
"src/core/lib/gprpp/global_config_env.h",
"src/core/lib/profiling/timers.h",
"src/core/lib/gprpp/crash.h",
# The grpc_core::Server redundant namespace qualification is required for
# older gcc versions.
"src/core/ext/transport/chttp2/server/chttp2_server.h",
"src/core/server/server.h",
]
# find our home

@ -21,13 +21,6 @@ import os
import re
import sys
IGNORED_FILES = [
# note: the grpc_core::Server redundant namespace qualification is required
# for older gcc versions.
"src/core/ext/transport/chttp2/server/chttp2_server.h",
"src/core/server/server.h",
]
def find_closing_mustache(contents, initial_depth):
"""Find the closing mustache for a given number of open mustaches."""
@ -173,8 +166,6 @@ for config in _CONFIGURATION:
for file in files:
if file.endswith(".cc") or file.endswith(".h"):
path = os.path.join(root, file)
if path in IGNORED_FILES:
continue
try:
with open(path) as f:
contents = f.read()

@ -928,7 +928,6 @@ include/grpc/impl/grpc_types.h \
include/grpc/impl/propagation_bits.h \
include/grpc/impl/slice_type.h \
include/grpc/load_reporting.h \
include/grpc/passive_listener.h \
include/grpc/slice.h \
include/grpc/slice_buffer.h \
include/grpc/status.h \
@ -1041,7 +1040,6 @@ include/grpcpp/impl/server_initializer.h \
include/grpcpp/impl/service_type.h \
include/grpcpp/impl/status.h \
include/grpcpp/impl/sync.h \
include/grpcpp/passive_listener.h \
include/grpcpp/resource_quota.h \
include/grpcpp/security/audit_logging.h \
include/grpcpp/security/auth_context.h \

@ -928,7 +928,6 @@ include/grpc/impl/grpc_types.h \
include/grpc/impl/propagation_bits.h \
include/grpc/impl/slice_type.h \
include/grpc/load_reporting.h \
include/grpc/passive_listener.h \
include/grpc/slice.h \
include/grpc/slice_buffer.h \
include/grpc/status.h \
@ -1041,7 +1040,6 @@ include/grpcpp/impl/server_initializer.h \
include/grpcpp/impl/service_type.h \
include/grpcpp/impl/status.h \
include/grpcpp/impl/sync.h \
include/grpcpp/passive_listener.h \
include/grpcpp/resource_quota.h \
include/grpcpp/security/audit_logging.h \
include/grpcpp/security/auth_context.h \

@ -861,7 +861,6 @@ include/grpc/impl/grpc_types.h \
include/grpc/impl/propagation_bits.h \
include/grpc/impl/slice_type.h \
include/grpc/load_reporting.h \
include/grpc/passive_listener.h \
include/grpc/slice.h \
include/grpc/slice_buffer.h \
include/grpc/status.h \

@ -861,7 +861,6 @@ include/grpc/impl/grpc_types.h \
include/grpc/impl/propagation_bits.h \
include/grpc/impl/slice_type.h \
include/grpc/load_reporting.h \
include/grpc/passive_listener.h \
include/grpc/slice.h \
include/grpc/slice_buffer.h \
include/grpc/status.h \

@ -23,7 +23,7 @@ cd $(dirname $0)/../../..
time python3 -m pip install --user -r tools/internal_ci/helper_scripts/requirements.linux_perf.txt
# List of benchmarks that provide good signal for analyzing performance changes in pull requests
BENCHMARKS_TO_RUN="bm_fullstack_unary_ping_pong bm_fullstack_streaming_ping_pong bm_fullstack_streaming_pump bm_closure bm_cq bm_chttp2_hpack bm_chttp2_transport"
BENCHMARKS_TO_RUN="bm_fullstack_unary_ping_pong bm_fullstack_streaming_ping_pong bm_fullstack_streaming_pump bm_closure bm_cq bm_chttp2_hpack"
tools/run_tests/start_port_server.py

@ -15,7 +15,7 @@
# Config file for the internal CI (in protobuf text format)
# Location of the continuous shell script in repository.
build_file: "grpc/tools/internal_ci/linux/grpc_xds_k8s_lb.sh"
build_file: "grpc/tools/internal_ci/linux/psm-interop-test-cpp.sh"
timeout_mins: 240
action {
define_artifacts {
@ -24,3 +24,7 @@ action {
strip_prefix: "artifacts"
}
}
env_vars {
key: "PSM_TEST_SUITE"
value: "lb"
}

@ -1,193 +0,0 @@
#!/usr/bin/env bash
# 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.
set -eo pipefail
# Constants
readonly GITHUB_REPOSITORY_NAME="grpc"
readonly TEST_DRIVER_INSTALL_SCRIPT_URL="https://raw.githubusercontent.com/${TEST_DRIVER_REPO_OWNER:-grpc}/psm-interop/${TEST_DRIVER_BRANCH:-main}/.kokoro/psm_interop_kokoro_lib.sh"
## xDS test client Docker images
readonly DOCKER_REGISTRY="us-docker.pkg.dev"
readonly SERVER_IMAGE_NAME="us-docker.pkg.dev/grpc-testing/psm-interop/cpp-server"
readonly CLIENT_IMAGE_NAME="us-docker.pkg.dev/grpc-testing/psm-interop/cpp-client"
readonly FORCE_IMAGE_BUILD="${FORCE_IMAGE_BUILD:-0}"
readonly BUILD_APP_PATH="interop-testing/build/install/grpc-interop-testing"
#######################################
# Builds test app Docker images and pushes them to GCR
# Globals:
# BUILD_APP_PATH
# SERVER_IMAGE_NAME: Test server Docker image name
# CLIENT_IMAGE_NAME: Test client Docker image name
# GIT_COMMIT: SHA-1 of git commit being built
# Arguments:
# None
# Outputs:
# Writes the output of `gcloud builds submit` to stdout, stderr
#######################################
build_test_app_docker_images() {
echo "Building C++ xDS interop test app Docker images"
docker build -f "${SRC_DIR}/tools/dockerfile/interoptest/grpc_interop_cxx_xds/Dockerfile.xds_client" -t "${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" "${SRC_DIR}"
docker build -f "${SRC_DIR}/tools/dockerfile/interoptest/grpc_interop_cxx_xds/Dockerfile.xds_server" -t "${SERVER_IMAGE_NAME}:${GIT_COMMIT}" "${SRC_DIR}"
gcloud -q auth configure-docker "${DOCKER_REGISTRY}"
docker push "${CLIENT_IMAGE_NAME}:${GIT_COMMIT}"
docker push "${SERVER_IMAGE_NAME}:${GIT_COMMIT}"
if is_version_branch "${TESTING_VERSION}"; then
tag_and_push_docker_image "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}" "${TESTING_VERSION}"
tag_and_push_docker_image "${SERVER_IMAGE_NAME}" "${GIT_COMMIT}" "${TESTING_VERSION}"
fi
}
#######################################
# Builds test app and its docker images unless they already exist
# Globals:
# SERVER_IMAGE_NAME: Test server Docker image name
# CLIENT_IMAGE_NAME: Test client Docker image name
# GIT_COMMIT: SHA-1 of git commit being built
# FORCE_IMAGE_BUILD
# Arguments:
# None
# Outputs:
# Writes the output to stdout, stderr
#######################################
build_docker_images_if_needed() {
# Check if images already exist
server_tags="$(gcloud_gcr_list_image_tags "${SERVER_IMAGE_NAME}" "${GIT_COMMIT}")"
printf "Server image: %s:%s\n" "${SERVER_IMAGE_NAME}" "${GIT_COMMIT}"
echo "${server_tags:-Server image not found}"
client_tags="$(gcloud_gcr_list_image_tags "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}")"
printf "Client image: %s:%s\n" "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}"
echo "${client_tags:-Client image not found}"
# Build if any of the images are missing, or FORCE_IMAGE_BUILD=1
if [[ "${FORCE_IMAGE_BUILD}" == "1" || -z "${server_tags}" || -z "${client_tags}" ]]; then
build_test_app_docker_images
else
echo "Skipping C++ test app build"
fi
}
#######################################
# Executes the test case
# Globals:
# TEST_DRIVER_FLAGFILE: Relative path to test driver flagfile
# KUBE_CONTEXT: The name of kubectl context with GKE cluster access
# SECONDARY_KUBE_CONTEXT: The name of kubectl context with secondary GKE cluster access, if any
# TEST_XML_OUTPUT_DIR: Output directory for the test xUnit XML report
# SERVER_IMAGE_NAME: Test server Docker image name
# CLIENT_IMAGE_NAME: Test client Docker image name
# GIT_COMMIT: SHA-1 of git commit being built
# TESTING_VERSION: version branch under test: used by the framework to determine the supported PSM
# features.
# Arguments:
# Test case name
# Outputs:
# Writes the output of test execution to stdout, stderr
# Test xUnit report to ${TEST_XML_OUTPUT_DIR}/${test_name}/sponge_log.xml
#######################################
run_test() {
# Test driver usage:
# https://github.com/grpc/psm-interop#basic-usage
local test_name="${1:?Usage: run_test test_name}"
local out_dir="${TEST_XML_OUTPUT_DIR}/${test_name}"
mkdir -pv "${out_dir}"
set -x
python3 -m "tests.${test_name}" \
--flagfile="${TEST_DRIVER_FLAGFILE}" \
--kube_context="${KUBE_CONTEXT}" \
--secondary_kube_context="${SECONDARY_KUBE_CONTEXT}" \
--server_image="${SERVER_IMAGE_NAME}:${GIT_COMMIT}" \
--client_image="${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" \
--testing_version="${TESTING_VERSION}" \
--force_cleanup \
--collect_app_logs \
--log_dir="${out_dir}" \
--xml_output_file="${out_dir}/sponge_log.xml" \
${@:2} \
|& tee "${out_dir}/sponge_log.log"
}
run_alpha_test() {
local test_name=$1
run_test ${test_name} \
--compute_api_version="v1alpha"
}
#######################################
# Main function: provision software necessary to execute tests, and run them
# Globals:
# KOKORO_ARTIFACTS_DIR
# GITHUB_REPOSITORY_NAME
# SRC_DIR: Populated with absolute path to the source repo
# TEST_DRIVER_REPO_DIR: Populated with the path to the repo containing
# the test driver
# TEST_DRIVER_FULL_DIR: Populated with the path to the test driver source code
# TEST_DRIVER_FLAGFILE: Populated with relative path to test driver flagfile
# TEST_XML_OUTPUT_DIR: Populated with the path to test xUnit XML report
# GIT_ORIGIN_URL: Populated with the origin URL of git repo used for the build
# GIT_COMMIT: Populated with the SHA-1 of git commit being built
# GIT_COMMIT_SHORT: Populated with the short SHA-1 of git commit being built
# KUBE_CONTEXT: Populated with name of kubectl context with GKE cluster access
# SECONDARY_KUBE_CONTEXT: Populated with name of kubectl context with secondary GKE cluster access, if any
# Arguments:
# None
# Outputs:
# Writes the output of test execution to stdout, stderr
#######################################
main() {
local script_dir
script_dir="$(dirname "$0")"
# Source the test captured from the master branch.
echo "Sourcing test driver install captured from: ${TEST_DRIVER_INSTALL_SCRIPT_URL}"
source /dev/stdin <<< "$(curl -s "${TEST_DRIVER_INSTALL_SCRIPT_URL}")"
activate_gke_cluster GKE_CLUSTER_PSM_LB
activate_secondary_gke_cluster GKE_CLUSTER_PSM_LB
set -x
if [[ -n "${KOKORO_ARTIFACTS_DIR}" ]]; then
kokoro_setup_test_driver "${GITHUB_REPOSITORY_NAME}"
else
local_setup_test_driver "${script_dir}"
fi
build_docker_images_if_needed
# Run tests
cd "${TEST_DRIVER_FULL_DIR}"
local failed_tests=0
run_alpha_test subsetting_test || (( ++failed_tests ))
test_suites=(
"app_net_test"
"affinity_test"
"api_listener_test"
"change_backend_service_test"
"custom_lb_test"
"failover_test"
"outlier_detection_test"
"remove_neg_test"
"round_robin_test"
)
if [[ "${TESTING_VERSION}" =~ "master" ]]; then
test_suites+=('bootstrap_generator_test')
fi
for test in "${test_suites[@]}"; do
run_test $test || (( ++failed_tests ))
done
echo "Failed test suites: ${failed_tests}"
}
main "$@"

@ -15,7 +15,7 @@
# Config file for the internal CI (in protobuf text format)
# Location of the continuous shell script in repository.
build_file: "grpc/tools/internal_ci/linux/grpc_xds_k8s_lb_python.sh"
build_file: "grpc/tools/internal_ci/linux/psm-interop-test-python.sh"
timeout_mins: 180
action {
define_artifacts {
@ -24,3 +24,7 @@ action {
strip_prefix: "artifacts"
}
}
env_vars {
key: "PSM_TEST_SUITE"
value: "lb"
}

@ -1,196 +0,0 @@
#!/usr/bin/env bash
# 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.
set -eo pipefail
# Constants
readonly GITHUB_REPOSITORY_NAME="grpc"
readonly TEST_DRIVER_INSTALL_SCRIPT_URL="https://raw.githubusercontent.com/${TEST_DRIVER_REPO_OWNER:-grpc}/psm-interop/${TEST_DRIVER_BRANCH:-main}/.kokoro/psm_interop_kokoro_lib.sh"
## xDS test client Docker images
readonly DOCKER_REGISTRY="us-docker.pkg.dev"
readonly SERVER_IMAGE_NAME="us-docker.pkg.dev/grpc-testing/psm-interop/python-server"
readonly CLIENT_IMAGE_NAME="us-docker.pkg.dev/grpc-testing/psm-interop/python-client"
readonly FORCE_IMAGE_BUILD="${FORCE_IMAGE_BUILD:-0}"
readonly BUILD_APP_PATH="interop-testing/build/install/grpc-interop-testing"
readonly LANGUAGE_NAME="Python"
#######################################
# Builds test app Docker images and pushes them to GCR
# Globals:
# BUILD_APP_PATH
# CLIENT_IMAGE_NAME: Test client Docker image name
# GIT_COMMIT: SHA-1 of git commit being built
# Arguments:
# None
# Outputs:
# Writes the output of `gcloud builds submit` to stdout, stderr
#######################################
build_test_app_docker_images() {
echo "Building ${LANGUAGE_NAME} xDS interop test app Docker images"
pushd "${SRC_DIR}"
docker build \
-f src/python/grpcio_tests/tests_py3_only/interop/Dockerfile.client \
-t "${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" \
.
docker build \
-f src/python/grpcio_tests/tests_py3_only/interop/Dockerfile.server \
-t "${SERVER_IMAGE_NAME}:${GIT_COMMIT}" \
.
popd
gcloud -q auth configure-docker "${DOCKER_REGISTRY}"
docker push "${CLIENT_IMAGE_NAME}:${GIT_COMMIT}"
docker push "${SERVER_IMAGE_NAME}:${GIT_COMMIT}"
if is_version_branch "${TESTING_VERSION}"; then
tag_and_push_docker_image "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}" "${TESTING_VERSION}"
tag_and_push_docker_image "${SERVER_IMAGE_NAME}" "${GIT_COMMIT}" "${TESTING_VERSION}"
fi
}
#######################################
# Builds test app and its docker images unless they already exist
# Globals:
# SERVER_IMAGE_NAME: Test server Docker image name
# CLIENT_IMAGE_NAME: Test client Docker image name
# GIT_COMMIT: SHA-1 of git commit being built
# FORCE_IMAGE_BUILD
# Arguments:
# None
# Outputs:
# Writes the output to stdout, stderr
#######################################
build_docker_images_if_needed() {
# Check if images already exist
server_tags="$(gcloud_gcr_list_image_tags "${SERVER_IMAGE_NAME}" "${GIT_COMMIT}")"
printf "Server image: %s:%s\n" "${SERVER_IMAGE_NAME}" "${GIT_COMMIT}"
echo "${server_tags:-Server image not found}"
client_tags="$(gcloud_gcr_list_image_tags "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}")"
printf "Client image: %s:%s\n" "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}"
echo "${client_tags:-Client image not found}"
# Build if any of the images are missing, or FORCE_IMAGE_BUILD=1
if [[ "${FORCE_IMAGE_BUILD}" == "1" || -z "${server_tags}" || -z "${client_tags}" ]]; then
build_test_app_docker_images
else
echo "Skipping ${LANGUAGE_NAME} test app build"
fi
}
#######################################
# Executes the test case
# Globals:
# TEST_DRIVER_FLAGFILE: Relative path to test driver flagfile
# KUBE_CONTEXT: The name of kubectl context with GKE cluster access
# SECONDARY_KUBE_CONTEXT: The name of kubectl context with secondary GKE cluster access, if any
# TEST_XML_OUTPUT_DIR: Output directory for the test xUnit XML report
# CLIENT_IMAGE_NAME: Test client Docker image name
# GIT_COMMIT: SHA-1 of git commit being built
# TESTING_VERSION: version branch under test: used by the framework to determine the supported PSM
# features.
# Arguments:
# Test case name
# Outputs:
# Writes the output of test execution to stdout, stderr
# Test xUnit report to ${TEST_XML_OUTPUT_DIR}/${test_name}/sponge_log.xml
#######################################
run_test() {
# Test driver usage:
# https://github.com/grpc/psm-interop#basic-usage
local test_name="${1:?Usage: run_test test_name}"
local out_dir="${TEST_XML_OUTPUT_DIR}/${test_name}"
mkdir -pv "${out_dir}"
set -x
python3 -m "tests.${test_name}" \
--flagfile="${TEST_DRIVER_FLAGFILE}" \
--kube_context="${KUBE_CONTEXT}" \
--secondary_kube_context="${SECONDARY_KUBE_CONTEXT}" \
--client_image="${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" \
--server_image="${SERVER_IMAGE_NAME}:${GIT_COMMIT}" \
--testing_version="${TESTING_VERSION}" \
--force_cleanup \
--collect_app_logs \
--log_dir="${out_dir}" \
--xml_output_file="${out_dir}/sponge_log.xml" \
|& tee "${out_dir}/sponge_log.log"
}
#######################################
# Main function: provision software necessary to execute tests, and run them
# Globals:
# KOKORO_ARTIFACTS_DIR
# GITHUB_REPOSITORY_NAME
# SRC_DIR: Populated with absolute path to the source repo
# TEST_DRIVER_REPO_DIR: Populated with the path to the repo containing
# the test driver
# TEST_DRIVER_FULL_DIR: Populated with the path to the test driver source code
# TEST_DRIVER_FLAGFILE: Populated with relative path to test driver flagfile
# TEST_XML_OUTPUT_DIR: Populated with the path to test xUnit XML report
# GIT_ORIGIN_URL: Populated with the origin URL of git repo used for the build
# GIT_COMMIT: Populated with the SHA-1 of git commit being built
# GIT_COMMIT_SHORT: Populated with the short SHA-1 of git commit being built
# KUBE_CONTEXT: Populated with name of kubectl context with GKE cluster access
# SECONDARY_KUBE_CONTEXT: Populated with name of kubectl context with secondary GKE cluster access, if any
# Arguments:
# None
# Outputs:
# Writes the output of test execution to stdout, stderr
#######################################
main() {
local script_dir
script_dir="$(dirname "$0")"
# Source the test driver from the master branch.
echo "Sourcing test driver install script from: ${TEST_DRIVER_INSTALL_SCRIPT_URL}"
source /dev/stdin <<< "$(curl -s "${TEST_DRIVER_INSTALL_SCRIPT_URL}")"
activate_gke_cluster GKE_CLUSTER_PSM_LB
activate_secondary_gke_cluster GKE_CLUSTER_PSM_LB
set -x
if [[ -n "${KOKORO_ARTIFACTS_DIR}" ]]; then
kokoro_setup_test_driver "${GITHUB_REPOSITORY_NAME}"
else
local_setup_test_driver "${script_dir}"
fi
build_docker_images_if_needed
# Run tests
cd "${TEST_DRIVER_FULL_DIR}"
local failed_tests=0
test_suites=(
"app_net_test"
"api_listener_test"
"change_backend_service_test"
"failover_test"
"outlier_detection_test"
"remove_neg_test"
"round_robin_test"
)
if [[ "${TESTING_VERSION}" =~ "master" ]]; then
test_suites+=('bootstrap_generator_test')
fi
for test in "${test_suites[@]}"; do
run_test $test || (( ++failed_tests ))
done
echo "Failed test suites: ${failed_tests}"
}
main "$@"

@ -15,7 +15,7 @@
# Config file for the internal CI (in protobuf text format)
# Location of the continuous shell script in repository.
build_file: "grpc/tools/internal_ci/linux/grpc_xds_url_map.sh"
build_file: "grpc/tools/internal_ci/linux/psm-interop-test-cpp.sh"
timeout_mins: 90
action {
define_artifacts {
@ -24,3 +24,7 @@ action {
strip_prefix: "artifacts"
}
}
env_vars {
key: "PSM_TEST_SUITE"
value: "url_map"
}

@ -1,150 +0,0 @@
#!/usr/bin/env bash
# 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.
set -eo pipefail
# Constants
readonly GITHUB_REPOSITORY_NAME="grpc"
readonly TEST_DRIVER_INSTALL_SCRIPT_URL="https://raw.githubusercontent.com/${TEST_DRIVER_REPO_OWNER:-grpc}/psm-interop/${TEST_DRIVER_BRANCH:-main}/.kokoro/psm_interop_kokoro_lib.sh"
## xDS test client Docker images
readonly DOCKER_REGISTRY="us-docker.pkg.dev"
readonly CLIENT_IMAGE_NAME="us-docker.pkg.dev/grpc-testing/psm-interop/cpp-client"
readonly FORCE_IMAGE_BUILD="${FORCE_IMAGE_BUILD:-0}"
readonly BUILD_APP_PATH="interop-testing/build/install/grpc-interop-testing"
#######################################
# Builds test app Docker images and pushes them to GCR
# Globals:
# BUILD_APP_PATH
# CLIENT_IMAGE_NAME: Test client Docker image name
# GIT_COMMIT: SHA-1 of git commit being built
# Arguments:
# None
# Outputs:
# Writes the output of `gcloud builds submit` to stdout, stderr
#######################################
build_test_app_docker_images() {
echo "Building C++ xDS interop test app Docker images"
docker build -f "${SRC_DIR}/tools/dockerfile/interoptest/grpc_interop_cxx_xds/Dockerfile.xds_client" -t "${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" "${SRC_DIR}"
gcloud -q auth configure-docker "${DOCKER_REGISTRY}"
docker push "${CLIENT_IMAGE_NAME}:${GIT_COMMIT}"
if is_version_branch "${TESTING_VERSION}"; then
tag_and_push_docker_image "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}" "${TESTING_VERSION}"
fi
}
#######################################
# Builds test app and its docker images unless they already exist
# Globals:
# CLIENT_IMAGE_NAME: Test client Docker image name
# GIT_COMMIT: SHA-1 of git commit being built
# FORCE_IMAGE_BUILD
# Arguments:
# None
# Outputs:
# Writes the output to stdout, stderr
#######################################
build_docker_images_if_needed() {
# Check if images already exist
client_tags="$(gcloud_gcr_list_image_tags "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}")"
printf "Client image: %s:%s\n" "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}"
echo "${client_tags:-Client image not found}"
# Build if any of the images are missing, or FORCE_IMAGE_BUILD=1
if [[ "${FORCE_IMAGE_BUILD}" == "1" || -z "${client_tags}" ]]; then
build_test_app_docker_images
else
echo "Skipping C++ test app build"
fi
}
#######################################
# Executes the test case
# Globals:
# TEST_DRIVER_FLAGFILE: Relative path to test driver flagfile
# KUBE_CONTEXT: The name of kubectl context with GKE cluster access
# TEST_XML_OUTPUT_DIR: Output directory for the test xUnit XML report
# CLIENT_IMAGE_NAME: Test client Docker image name
# GIT_COMMIT: SHA-1 of git commit being built
# TESTING_VERSION: version branch under test: used by the framework to determine the supported PSM
# features.
# Arguments:
# Test case name
# Outputs:
# Writes the output of test execution to stdout, stderr
# Test xUnit report to ${TEST_XML_OUTPUT_DIR}/${test_name}/sponge_log.xml
#######################################
run_test() {
# Test driver usage:
# https://github.com/grpc/psm-interop#basic-usage
local test_name="${1:?Usage: run_test test_name}"
local out_dir="${TEST_XML_OUTPUT_DIR}/${test_name}"
mkdir -pv "${out_dir}"
set -x
python3 -m "tests.${test_name}" \
--flagfile="${TEST_DRIVER_FLAGFILE}" \
--flagfile="config/url-map.cfg" \
--kube_context="${KUBE_CONTEXT}" \
--client_image="${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" \
--testing_version="${TESTING_VERSION}" \
--collect_app_logs \
--log_dir="${out_dir}" \
--xml_output_file="${out_dir}/sponge_log.xml" \
|& tee "${out_dir}/sponge_log.log"
}
#######################################
# Main function: provision software necessary to execute tests, and run them
# Globals:
# KOKORO_ARTIFACTS_DIR
# GITHUB_REPOSITORY_NAME
# SRC_DIR: Populated with absolute path to the source repo
# TEST_DRIVER_REPO_DIR: Populated with the path to the repo containing
# the test driver
# TEST_DRIVER_FULL_DIR: Populated with the path to the test driver source code
# TEST_DRIVER_FLAGFILE: Populated with relative path to test driver flagfile
# TEST_XML_OUTPUT_DIR: Populated with the path to test xUnit XML report
# GIT_ORIGIN_URL: Populated with the origin URL of git repo used for the build
# GIT_COMMIT: Populated with the SHA-1 of git commit being built
# GIT_COMMIT_SHORT: Populated with the short SHA-1 of git commit being built
# KUBE_CONTEXT: Populated with name of kubectl context with GKE cluster access
# Arguments:
# None
# Outputs:
# Writes the output of test execution to stdout, stderr
#######################################
main() {
local script_dir
script_dir="$(dirname "$0")"
# Source the test driver from the master branch.
echo "Sourcing test driver install script from: ${TEST_DRIVER_INSTALL_SCRIPT_URL}"
source /dev/stdin <<< "$(curl -s "${TEST_DRIVER_INSTALL_SCRIPT_URL}")"
activate_gke_cluster GKE_CLUSTER_PSM_BASIC
set -x
if [[ -n "${KOKORO_ARTIFACTS_DIR}" ]]; then
kokoro_setup_test_driver "${GITHUB_REPOSITORY_NAME}"
else
local_setup_test_driver "${script_dir}"
fi
build_docker_images_if_needed
# Run tests
cd "${TEST_DRIVER_FULL_DIR}"
run_test url_map || echo "Failed url_map test"
}
main "$@"

@ -15,7 +15,7 @@
# Config file for the internal CI (in protobuf text format)
# Location of the continuous shell script in repository.
build_file: "grpc/tools/internal_ci/linux/grpc_xds_url_map_python.sh"
build_file: "grpc/tools/internal_ci/linux/psm-interop-test-python.sh"
timeout_mins: 90
action {
define_artifacts {
@ -24,3 +24,7 @@ action {
strip_prefix: "artifacts"
}
}
env_vars {
key: "PSM_TEST_SUITE"
value: "url_map"
}

@ -1,160 +0,0 @@
#!/usr/bin/env bash
# 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.
set -eo pipefail
# Constants
readonly GITHUB_REPOSITORY_NAME="grpc"
readonly TEST_DRIVER_INSTALL_SCRIPT_URL="https://raw.githubusercontent.com/${TEST_DRIVER_REPO_OWNER:-grpc}/psm-interop/${TEST_DRIVER_BRANCH:-main}/.kokoro/psm_interop_kokoro_lib.sh"
## xDS test client Docker images
readonly DOCKER_REGISTRY="us-docker.pkg.dev"
readonly CLIENT_IMAGE_NAME="us-docker.pkg.dev/grpc-testing/psm-interop/python-client"
readonly FORCE_IMAGE_BUILD="${FORCE_IMAGE_BUILD:-0}"
readonly BUILD_APP_PATH="interop-testing/build/install/grpc-interop-testing"
readonly LANGUAGE_NAME="Python"
#######################################
# Builds test app Docker images and pushes them to GCR
# Globals:
# BUILD_APP_PATH
# CLIENT_IMAGE_NAME: Test client Docker image name
# GIT_COMMIT: SHA-1 of git commit being built
# Arguments:
# None
# Outputs:
# Writes the output of `gcloud builds submit` to stdout, stderr
#######################################
build_test_app_docker_images() {
echo "Building ${LANGUAGE_NAME} xDS interop test app Docker images"
pushd "${SRC_DIR}"
docker build \
-f src/python/grpcio_tests/tests_py3_only/interop/Dockerfile.client \
-t "${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" \
.
popd
gcloud -q auth configure-docker "${DOCKER_REGISTRY}"
docker push "${CLIENT_IMAGE_NAME}:${GIT_COMMIT}"
if is_version_branch "${TESTING_VERSION}"; then
tag_and_push_docker_image "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}" "${TESTING_VERSION}"
fi
}
#######################################
# Builds test app and its docker images unless they already exist
# Globals:
# CLIENT_IMAGE_NAME: Test client Docker image name
# GIT_COMMIT: SHA-1 of git commit being built
# FORCE_IMAGE_BUILD
# Arguments:
# None
# Outputs:
# Writes the output to stdout, stderr
#######################################
build_docker_images_if_needed() {
# Check if images already exist
client_tags="$(gcloud_gcr_list_image_tags "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}")"
printf "Client image: %s:%s\n" "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}"
echo "${client_tags:-Client image not found}"
# Build if any of the images are missing, or FORCE_IMAGE_BUILD=1
if [[ "${FORCE_IMAGE_BUILD}" == "1" || -z "${client_tags}" ]]; then
build_test_app_docker_images
else
echo "Skipping ${LANGUAGE_NAME} test app build"
fi
}
#######################################
# Executes the test case
# Globals:
# TEST_DRIVER_FLAGFILE: Relative path to test driver flagfile
# KUBE_CONTEXT: The name of kubectl context with GKE cluster access
# TEST_XML_OUTPUT_DIR: Output directory for the test xUnit XML report
# CLIENT_IMAGE_NAME: Test client Docker image name
# GIT_COMMIT: SHA-1 of git commit being built
# TESTING_VERSION: version branch under test: used by the framework to determine the supported PSM
# features.
# Arguments:
# Test case name
# Outputs:
# Writes the output of test execution to stdout, stderr
# Test xUnit report to ${TEST_XML_OUTPUT_DIR}/${test_name}/sponge_log.xml
#######################################
run_test() {
# Test driver usage:
# https://github.com/grpc/psm-interop#basic-usage
local test_name="${1:?Usage: run_test test_name}"
local out_dir="${TEST_XML_OUTPUT_DIR}/${test_name}"
mkdir -pv "${out_dir}"
set -x
python3 -m "tests.${test_name}" \
--flagfile="${TEST_DRIVER_FLAGFILE}" \
--flagfile="config/url-map.cfg" \
--kube_context="${KUBE_CONTEXT}" \
--client_image="${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" \
--testing_version="${TESTING_VERSION}" \
--collect_app_logs \
--log_dir="${out_dir}" \
--xml_output_file="${out_dir}/sponge_log.xml" \
|& tee "${out_dir}/sponge_log.log"
}
#######################################
# Main function: provision software necessary to execute tests, and run them
# Globals:
# KOKORO_ARTIFACTS_DIR
# GITHUB_REPOSITORY_NAME
# SRC_DIR: Populated with absolute path to the source repo
# TEST_DRIVER_REPO_DIR: Populated with the path to the repo containing
# the test driver
# TEST_DRIVER_FULL_DIR: Populated with the path to the test driver source code
# TEST_DRIVER_FLAGFILE: Populated with relative path to test driver flagfile
# TEST_XML_OUTPUT_DIR: Populated with the path to test xUnit XML report
# GIT_ORIGIN_URL: Populated with the origin URL of git repo used for the build
# GIT_COMMIT: Populated with the SHA-1 of git commit being built
# GIT_COMMIT_SHORT: Populated with the short SHA-1 of git commit being built
# KUBE_CONTEXT: Populated with name of kubectl context with GKE cluster access
# Arguments:
# None
# Outputs:
# Writes the output of test execution to stdout, stderr
#######################################
main() {
local script_dir
script_dir="$(dirname "$0")"
# Source the test driver from the master branch.
echo "Sourcing test driver install script from: ${TEST_DRIVER_INSTALL_SCRIPT_URL}"
source /dev/stdin <<< "$(curl -s "${TEST_DRIVER_INSTALL_SCRIPT_URL}")"
activate_gke_cluster GKE_CLUSTER_PSM_BASIC
set -x
if [[ -n "${KOKORO_ARTIFACTS_DIR}" ]]; then
kokoro_setup_test_driver "${GITHUB_REPOSITORY_NAME}"
else
local_setup_test_driver "${script_dir}"
fi
build_docker_images_if_needed
# Run tests
cd "${TEST_DRIVER_FULL_DIR}"
run_test url_map || echo "Failed url_map test"
}
main "$@"

@ -15,7 +15,7 @@
# Config file for the internal CI (in protobuf text format)
# Location of the continuous shell script in repository.
build_file: "grpc/tools/internal_ci/linux/psm-csm-python.sh"
build_file: "grpc/tools/internal_ci/linux/psm-interop-test-python.sh"
timeout_mins: 240
action {
define_artifacts {
@ -24,3 +24,7 @@ action {
strip_prefix: "artifacts"
}
}
env_vars {
key: "PSM_TEST_SUITE"
value: "csm"
}

@ -1,190 +0,0 @@
#!/usr/bin/env bash
# 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.
set -eo pipefail
# Constants
readonly GITHUB_REPOSITORY_NAME="grpc"
readonly TEST_DRIVER_INSTALL_SCRIPT_URL="https://raw.githubusercontent.com/${TEST_DRIVER_REPO_OWNER:-grpc}/psm-interop/${TEST_DRIVER_BRANCH:-main}/.kokoro/psm_interop_kokoro_lib.sh"
## xDS test server/client Docker images
readonly DOCKER_REGISTRY="us-docker.pkg.dev"
readonly SERVER_IMAGE_NAME="us-docker.pkg.dev/grpc-testing/psm-interop/python-server"
readonly CLIENT_IMAGE_NAME="us-docker.pkg.dev/grpc-testing/psm-interop/python-client"
readonly FORCE_IMAGE_BUILD="${FORCE_IMAGE_BUILD:-0}"
readonly BUILD_APP_PATH="interop-testing/build/install/grpc-interop-testing"
#######################################
# Builds test app Docker images and pushes them to GCR
# Globals:
# BUILD_APP_PATH
# SERVER_IMAGE_NAME: Test server Docker image name
# CLIENT_IMAGE_NAME: Test client Docker image name
# GIT_COMMIT: SHA-1 of git commit being built
# TESTING_VERSION: version branch under test, f.e. v1.42.x, master
# Arguments:
# None
# Outputs:
# Writes the output of `gcloud builds submit` to stdout, stderr
#######################################
build_test_app_docker_images() {
echo "Building Python xDS interop test app Docker images"
pushd "${SRC_DIR}"
docker build \
-f src/python/grpcio_tests/tests_py3_only/interop/Dockerfile.client \
-t "${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" \
.
docker build \
-f src/python/grpcio_tests/tests_py3_only/interop/Dockerfile.server \
-t "${SERVER_IMAGE_NAME}:${GIT_COMMIT}" \
.
popd
gcloud -q auth configure-docker "${DOCKER_REGISTRY}"
docker push "${CLIENT_IMAGE_NAME}:${GIT_COMMIT}"
docker push "${SERVER_IMAGE_NAME}:${GIT_COMMIT}"
if is_version_branch "${TESTING_VERSION}"; then
tag_and_push_docker_image "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}" "${TESTING_VERSION}"
tag_and_push_docker_image "${SERVER_IMAGE_NAME}" "${GIT_COMMIT}" "${TESTING_VERSION}"
fi
}
#######################################
# Builds test app and its docker images unless they already exist
# Globals:
# SERVER_IMAGE_NAME: Test server Docker image name
# CLIENT_IMAGE_NAME: Test client Docker image name
# GIT_COMMIT: SHA-1 of git commit being built
# FORCE_IMAGE_BUILD
# Arguments:
# None
# Outputs:
# Writes the output to stdout, stderr
#######################################
build_docker_images_if_needed() {
# Check if images already exist
server_tags="$(gcloud_gcr_list_image_tags "${SERVER_IMAGE_NAME}" "${GIT_COMMIT}")"
printf "Server image: %s:%s\n" "${SERVER_IMAGE_NAME}" "${GIT_COMMIT}"
echo "${server_tags:-Server image not found}"
client_tags="$(gcloud_gcr_list_image_tags "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}")"
printf "Client image: %s:%s\n" "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}"
echo "${client_tags:-Client image not found}"
# Build if any of the images are missing, or FORCE_IMAGE_BUILD=1
if [[ "${FORCE_IMAGE_BUILD}" == "1" || -z "${server_tags}" || -z "${client_tags}" ]]; then
build_test_app_docker_images
else
echo "Skipping Python test app build"
fi
}
#######################################
# Executes the test case
# Globals:
# TEST_DRIVER_FLAGFILE: Relative path to test driver flagfile
# KUBE_CONTEXT: The name of kubectl context with GKE cluster access
# TEST_XML_OUTPUT_DIR: Output directory for the test xUnit XML report
# SERVER_IMAGE_NAME: Test server Docker image name
# CLIENT_IMAGE_NAME: Test client Docker image name
# GIT_COMMIT: SHA-1 of git commit being built
# TESTING_VERSION: version branch under test: used by the framework to determine the supported PSM
# features.
# Arguments:
# Test case name
# Outputs:
# Writes the output of test execution to stdout, stderr
# Test xUnit report to ${TEST_XML_OUTPUT_DIR}/${test_name}/sponge_log.xml
#######################################
run_test() {
# Test driver usage:
# https://github.com/grpc/psm-interop#basic-usage
local test_name="${1:?Usage: run_test test_name}"
local out_dir="${TEST_XML_OUTPUT_DIR}/${test_name}"
mkdir -pv "${out_dir}"
set -x
python3 -m "tests.${test_name}" \
--flagfile="${TEST_DRIVER_FLAGFILE}" \
--flagfile="config/common-csm.cfg" \
--kube_context="${KUBE_CONTEXT}" \
--server_image="${SERVER_IMAGE_NAME}:${GIT_COMMIT}" \
--client_image="${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" \
--testing_version="${TESTING_VERSION}" \
--nocheck_local_certs \
--force_cleanup \
--collect_app_logs \
--log_dir="${out_dir}" \
--xml_output_file="${out_dir}/sponge_log.xml" \
|& tee "${out_dir}/sponge_log.log"
set +x
}
#######################################
# Main function: provision software necessary to execute tests, and run them
# Globals:
# KOKORO_ARTIFACTS_DIR
# GITHUB_REPOSITORY_NAME
# SRC_DIR: Populated with absolute path to the source repo
# TEST_DRIVER_REPO_DIR: Populated with the path to the repo containing
# the test driver
# TEST_DRIVER_FULL_DIR: Populated with the path to the test driver source code
# TEST_DRIVER_FLAGFILE: Populated with relative path to test driver flagfile
# TEST_XML_OUTPUT_DIR: Populated with the path to test xUnit XML report
# GIT_ORIGIN_URL: Populated with the origin URL of git repo used for the build
# GIT_COMMIT: Populated with the SHA-1 of git commit being built
# GIT_COMMIT_SHORT: Populated with the short SHA-1 of git commit being built
# KUBE_CONTEXT: Populated with name of kubectl context with GKE cluster access
# Arguments:
# None
# Outputs:
# Writes the output of test execution to stdout, stderr
#######################################
main() {
local script_dir
script_dir="$(dirname "$0")"
# Source the test driver from the master branch.
echo "Sourcing test driver install script from: ${TEST_DRIVER_INSTALL_SCRIPT_URL}"
source /dev/stdin <<< "$(curl -s "${TEST_DRIVER_INSTALL_SCRIPT_URL}")"
activate_gke_cluster GKE_CLUSTER_PSM_CSM
if [[ -n "${KOKORO_ARTIFACTS_DIR}" ]]; then
kokoro_setup_test_driver "${GITHUB_REPOSITORY_NAME}"
else
local_setup_test_driver "${script_dir}"
fi
build_docker_images_if_needed
# Run tests
cd "${TEST_DRIVER_FULL_DIR}"
local failed_tests=0
test_suites=(
"gamma.gamma_baseline_test"
"gamma.affinity_session_drain_test"
"gamma.affinity_test"
"app_net_ssa_test"
)
for test in "${test_suites[@]}"; do
run_test $test || (( ++failed_tests ))
done
echo "Failed test suites: ${failed_tests}"
}
main "$@"

@ -15,7 +15,7 @@
# Config file for the internal CI (in protobuf text format)
# Location of the continuous shell script in repository.
build_file: "grpc/tools/internal_ci/linux/psm-csm.sh"
build_file: "grpc/tools/internal_ci/linux/psm-interop-test-cpp.sh"
timeout_mins: 120
action {
define_artifacts {
@ -24,3 +24,7 @@ action {
strip_prefix: "artifacts"
}
}
env_vars {
key: "PSM_TEST_SUITE"
value: "csm"
}

@ -1,175 +0,0 @@
#!/usr/bin/env bash
# Copyright 2023 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -eo pipefail
# Constants
readonly GITHUB_REPOSITORY_NAME="grpc"
readonly TEST_DRIVER_INSTALL_SCRIPT_URL="https://raw.githubusercontent.com/${TEST_DRIVER_REPO_OWNER:-grpc}/psm-interop/${TEST_DRIVER_BRANCH:-main}/.kokoro/psm_interop_kokoro_lib.sh"
## xDS test server/client Docker images
readonly DOCKER_REGISTRY="us-docker.pkg.dev"
readonly SERVER_IMAGE_NAME="us-docker.pkg.dev/grpc-testing/psm-interop/cpp-server"
readonly CLIENT_IMAGE_NAME="us-docker.pkg.dev/grpc-testing/psm-interop/cpp-client"
readonly FORCE_IMAGE_BUILD="${FORCE_IMAGE_BUILD:-0}"
readonly BUILD_APP_PATH="interop-testing/build/install/grpc-interop-testing"
#######################################
# Builds test app Docker images and pushes them to GCR
# Globals:
# BUILD_APP_PATH
# SERVER_IMAGE_NAME: Test server Docker image name
# CLIENT_IMAGE_NAME: Test client Docker image name
# GIT_COMMIT: SHA-1 of git commit being built
# TESTING_VERSION: version branch under test, f.e. v1.42.x, master
# Arguments:
# None
# Outputs:
# Writes the output of `gcloud builds submit` to stdout, stderr
#######################################
build_test_app_docker_images() {
echo "Building C++ xDS interop test app Docker images"
docker build -f "${SRC_DIR}/tools/dockerfile/interoptest/grpc_interop_cxx_xds/Dockerfile.xds_client" -t "${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" "${SRC_DIR}"
docker build -f "${SRC_DIR}/tools/dockerfile/interoptest/grpc_interop_cxx_xds/Dockerfile.xds_server" -t "${SERVER_IMAGE_NAME}:${GIT_COMMIT}" "${SRC_DIR}"
gcloud -q auth configure-docker "${DOCKER_REGISTRY}"
docker push "${CLIENT_IMAGE_NAME}:${GIT_COMMIT}"
docker push "${SERVER_IMAGE_NAME}:${GIT_COMMIT}"
if is_version_branch "${TESTING_VERSION}"; then
tag_and_push_docker_image "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}" "${TESTING_VERSION}"
tag_and_push_docker_image "${SERVER_IMAGE_NAME}" "${GIT_COMMIT}" "${TESTING_VERSION}"
fi
}
#######################################
# Builds test app and its docker images unless they already exist
# Globals:
# SERVER_IMAGE_NAME: Test server Docker image name
# CLIENT_IMAGE_NAME: Test client Docker image name
# GIT_COMMIT: SHA-1 of git commit being built
# FORCE_IMAGE_BUILD
# Arguments:
# None
# Outputs:
# Writes the output to stdout, stderr
#######################################
build_docker_images_if_needed() {
# Check if images already exist
server_tags="$(gcloud_gcr_list_image_tags "${SERVER_IMAGE_NAME}" "${GIT_COMMIT}")"
printf "Server image: %s:%s\n" "${SERVER_IMAGE_NAME}" "${GIT_COMMIT}"
echo "${server_tags:-Server image not found}"
client_tags="$(gcloud_gcr_list_image_tags "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}")"
printf "Client image: %s:%s\n" "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}"
echo "${client_tags:-Client image not found}"
# Build if any of the images are missing, or FORCE_IMAGE_BUILD=1
if [[ "${FORCE_IMAGE_BUILD}" == "1" || -z "${server_tags}" || -z "${client_tags}" ]]; then
build_test_app_docker_images
else
echo "Skipping C++ test app build"
fi
}
#######################################
# Executes the test case
# Globals:
# TEST_DRIVER_FLAGFILE: Relative path to test driver flagfile
# KUBE_CONTEXT: The name of kubectl context with GKE cluster access
# TEST_XML_OUTPUT_DIR: Output directory for the test xUnit XML report
# SERVER_IMAGE_NAME: Test server Docker image name
# CLIENT_IMAGE_NAME: Test client Docker image name
# GIT_COMMIT: SHA-1 of git commit being built
# TESTING_VERSION: version branch under test: used by the framework to determine the supported PSM
# features.
# Arguments:
# Test case name
# Outputs:
# Writes the output of test execution to stdout, stderr
# Test xUnit report to ${TEST_XML_OUTPUT_DIR}/${test_name}/sponge_log.xml
#######################################
run_test() {
# Test driver usage:
# https://github.com/grpc/psm-interop#basic-usage
local test_name="${1:?Usage: run_test test_name}"
local out_dir="${TEST_XML_OUTPUT_DIR}/${test_name}"
mkdir -pv "${out_dir}"
set -x
python3 -m "tests.${test_name}" \
--flagfile="${TEST_DRIVER_FLAGFILE}" \
--flagfile="config/common-csm.cfg" \
--kube_context="${KUBE_CONTEXT}" \
--server_image="${SERVER_IMAGE_NAME}:${GIT_COMMIT}" \
--client_image="${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" \
--testing_version="${TESTING_VERSION}" \
--force_cleanup \
--collect_app_logs \
--log_dir="${out_dir}" \
--xml_output_file="${out_dir}/sponge_log.xml" \
|& tee "${out_dir}/sponge_log.log"
}
#######################################
# Main function: provision software necessary to execute tests, and run them
# Globals:
# KOKORO_ARTIFACTS_DIR
# GITHUB_REPOSITORY_NAME
# SRC_DIR: Populated with absolute path to the source repo
# TEST_DRIVER_REPO_DIR: Populated with the path to the repo containing
# the test driver
# TEST_DRIVER_FULL_DIR: Populated with the path to the test driver source code
# TEST_DRIVER_FLAGFILE: Populated with relative path to test driver flagfile
# TEST_XML_OUTPUT_DIR: Populated with the path to test xUnit XML report
# GIT_ORIGIN_URL: Populated with the origin URL of git repo used for the build
# GIT_COMMIT: Populated with the SHA-1 of git commit being built
# GIT_COMMIT_SHORT: Populated with the short SHA-1 of git commit being built
# KUBE_CONTEXT: Populated with name of kubectl context with GKE cluster access
# Arguments:
# None
# Outputs:
# Writes the output of test execution to stdout, stderr
#######################################
main() {
local script_dir
script_dir="$(dirname "$0")"
# Source the test driver from the master branch.
echo "Sourcing test driver install script from: ${TEST_DRIVER_INSTALL_SCRIPT_URL}"
source /dev/stdin <<< "$(curl -s "${TEST_DRIVER_INSTALL_SCRIPT_URL}")"
activate_gke_cluster GKE_CLUSTER_PSM_CSM
set -x
if [[ -n "${KOKORO_ARTIFACTS_DIR}" ]]; then
kokoro_setup_test_driver "${GITHUB_REPOSITORY_NAME}"
else
local_setup_test_driver "${script_dir}"
fi
build_docker_images_if_needed
# Run tests
cd "${TEST_DRIVER_FULL_DIR}"
local failed_tests=0
test_suites=(
"gamma.gamma_baseline_test"
"gamma.affinity_test"
"gamma.affinity_session_drain_test"
"gamma.csm_observability_test"
"app_net_ssa_test"
)
for test in "${test_suites[@]}"; do
run_test $test || (( ++failed_tests ))
done
echo "Failed test suites: ${failed_tests}"
}
main "$@"

@ -0,0 +1,34 @@
#!/usr/bin/env bash
# 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.
set -eo pipefail
#######################################
# Builds test app Docker images and pushes them to GCR.
# Called from psm_interop_kokoro_lib.sh.
#
# Globals:
# SRC_DIR: Absolute path to the source repo on Kokoro VM
# SERVER_IMAGE_NAME: Test server Docker image name
# CLIENT_IMAGE_NAME: Test client Docker image name
# GIT_COMMIT: SHA-1 of git commit being built
# DOCKER_REGISTRY: Docker registry to push to
# Outputs:
# Writes the output of docker image build stdout, stderr
#######################################
psm::lang::build_docker_images() {
local client_dockerfile="tools/dockerfile/interoptest/grpc_interop_cxx_xds/Dockerfile.xds_client"
local server_dockerfile="tools/dockerfile/interoptest/grpc_interop_cxx_xds/Dockerfile.xds_server"
psm::build::docker_images_generic "${client_dockerfile}" "${server_dockerfile}"
}

@ -0,0 +1,34 @@
#!/usr/bin/env bash
# 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.
set -eo pipefail
#######################################
# Builds test app Docker images and pushes them to GCR.
# Called from psm_interop_kokoro_lib.sh.
#
# Globals:
# SRC_DIR: Absolute path to the source repo on Kokoro VM
# SERVER_IMAGE_NAME: Test server Docker image name
# CLIENT_IMAGE_NAME: Test client Docker image name
# GIT_COMMIT: SHA-1 of git commit being built
# DOCKER_REGISTRY: Docker registry to push to
# Outputs:
# Writes the output of docker image build stdout, stderr
#######################################
psm::lang::build_docker_images() {
local client_dockerfile="src/python/grpcio_tests/tests_py3_only/interop/Dockerfile.client"
local server_dockerfile="src/python/grpcio_tests/tests_py3_only/interop/Dockerfile.server"
psm::build::docker_images_generic "${client_dockerfile}" "${server_dockerfile}"
}

@ -0,0 +1,32 @@
#!/usr/bin/env bash
# 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.
set -eo pipefail
# Used locally.
readonly TEST_DRIVER_INSTALL_SCRIPT_URL="https://raw.githubusercontent.com/${TEST_DRIVER_REPO_OWNER:-grpc}/psm-interop/${TEST_DRIVER_BRANCH:-main}/.kokoro/psm_interop_kokoro_lib.sh"
psm::lang::source_install_lib() {
echo "Sourcing test driver install script from: ${TEST_DRIVER_INSTALL_SCRIPT_URL}"
local install_lib
# Download to a tmp file.
install_lib="$(mktemp -d)/psm_interop_kokoro_lib.sh"
curl -s --retry-connrefused --retry 5 -o "${install_lib}" "${TEST_DRIVER_INSTALL_SCRIPT_URL}"
# Checksum.
if command -v sha256sum &> /dev/null; then
echo "Install script checksum:"
sha256sum "${install_lib}"
fi
source "${install_lib}"
}

@ -0,0 +1,24 @@
#!/usr/bin/env bash
# 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.
set -eo pipefail
# Input parameters to psm:: methods of the install script.
readonly GRPC_LANGUAGE="cpp"
readonly BUILD_SCRIPT_DIR="$(dirname "$0")"
source "${BUILD_SCRIPT_DIR}/psm-interop-install-lib.sh"
psm::lang::source_install_lib
source "${BUILD_SCRIPT_DIR}/psm-interop-build-${GRPC_LANGUAGE}.sh"
psm::run "${PSM_TEST_SUITE}"

@ -0,0 +1,24 @@
#!/usr/bin/env bash
# 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.
set -eo pipefail
# Input parameters to psm:: methods of the install script.
readonly GRPC_LANGUAGE="python"
readonly BUILD_SCRIPT_DIR="$(dirname "$0")"
source "${BUILD_SCRIPT_DIR}/psm-interop-install-lib.sh"
psm::lang::source_install_lib
source "${BUILD_SCRIPT_DIR}/psm-interop-build-${GRPC_LANGUAGE}.sh"
psm::run "${PSM_TEST_SUITE}"

@ -15,7 +15,7 @@
# Config file for the internal CI (in protobuf text format)
# Location of the continuous shell script in repository.
build_file: "grpc/tools/internal_ci/linux/psm-security-python.sh"
build_file: "grpc/tools/internal_ci/linux/psm-interop-test-python.sh"
timeout_mins: 240
action {
define_artifacts {
@ -24,3 +24,7 @@ action {
strip_prefix: "artifacts"
}
}
env_vars {
key: "PSM_TEST_SUITE"
value: "security"
}

@ -1,185 +0,0 @@
#!/usr/bin/env bash
# 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.
set -eo pipefail
# Constants
readonly GITHUB_REPOSITORY_NAME="grpc"
readonly TEST_DRIVER_INSTALL_SCRIPT_URL="https://raw.githubusercontent.com/${TEST_DRIVER_REPO_OWNER:-grpc}/psm-interop/${TEST_DRIVER_BRANCH:-main}/.kokoro/psm_interop_kokoro_lib.sh"
## xDS test server/client Docker images
readonly DOCKER_REGISTRY="us-docker.pkg.dev"
readonly SERVER_IMAGE_NAME="us-docker.pkg.dev/grpc-testing/psm-interop/python-server"
readonly CLIENT_IMAGE_NAME="us-docker.pkg.dev/grpc-testing/psm-interop/python-client"
readonly FORCE_IMAGE_BUILD="${FORCE_IMAGE_BUILD:-0}"
readonly BUILD_APP_PATH="interop-testing/build/install/grpc-interop-testing"
readonly LANGUAGE_NAME="Python"
#######################################
# Builds test app Docker images and pushes them to GCR
# Globals:
# BUILD_APP_PATH
# SERVER_IMAGE_NAME: Test server Docker image name
# CLIENT_IMAGE_NAME: Test client Docker image name
# GIT_COMMIT: SHA-1 of git commit being built
# TESTING_VERSION: version branch under test, f.e. v1.42.x, master
# Arguments:
# None
# Outputs:
# Writes the output of `gcloud builds submit` to stdout, stderr
#######################################
build_test_app_docker_images() {
echo "Building ${LANGUAGE_NAME} xDS interop test app Docker images"
pushd "${SRC_DIR}"
docker build \
-f src/python/grpcio_tests/tests_py3_only/interop/Dockerfile.client \
-t "${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" \
.
docker build \
-f src/python/grpcio_tests/tests_py3_only/interop/Dockerfile.server \
-t "${SERVER_IMAGE_NAME}:${GIT_COMMIT}" \
.
popd
gcloud -q auth configure-docker "${DOCKER_REGISTRY}"
docker push "${CLIENT_IMAGE_NAME}:${GIT_COMMIT}"
docker push "${SERVER_IMAGE_NAME}:${GIT_COMMIT}"
if is_version_branch "${TESTING_VERSION}"; then
tag_and_push_docker_image "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}" "${TESTING_VERSION}"
tag_and_push_docker_image "${SERVER_IMAGE_NAME}" "${GIT_COMMIT}" "${TESTING_VERSION}"
fi
}
#######################################
# Builds test app and its docker images unless they already exist
# Globals:
# SERVER_IMAGE_NAME: Test server Docker image name
# CLIENT_IMAGE_NAME: Test client Docker image name
# GIT_COMMIT: SHA-1 of git commit being built
# FORCE_IMAGE_BUILD
# Arguments:
# None
# Outputs:
# Writes the output to stdout, stderr
#######################################
build_docker_images_if_needed() {
# Check if images already exist
server_tags="$(gcloud_gcr_list_image_tags "${SERVER_IMAGE_NAME}" "${GIT_COMMIT}")"
printf "Server image: %s:%s\n" "${SERVER_IMAGE_NAME}" "${GIT_COMMIT}"
echo "${server_tags:-Server image not found}"
client_tags="$(gcloud_gcr_list_image_tags "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}")"
printf "Client image: %s:%s\n" "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}"
echo "${client_tags:-Client image not found}"
# Build if any of the images are missing, or FORCE_IMAGE_BUILD=1
if [[ "${FORCE_IMAGE_BUILD}" == "1" || -z "${server_tags}" || -z "${client_tags}" ]]; then
build_test_app_docker_images
else
echo "Skipping ${LANGUAGE_NAME} test app build"
fi
}
#######################################
# Executes the test case
# Globals:
# TEST_DRIVER_FLAGFILE: Relative path to test driver flagfile
# KUBE_CONTEXT: The name of kubectl context with GKE cluster access
# TEST_XML_OUTPUT_DIR: Output directory for the test xUnit XML report
# SERVER_IMAGE_NAME: Test server Docker image name
# CLIENT_IMAGE_NAME: Test client Docker image name
# GIT_COMMIT: SHA-1 of git commit being built
# TESTING_VERSION: version branch under test: used by the framework to determine the supported PSM
# features.
# Arguments:
# Test case name
# Outputs:
# Writes the output of test execution to stdout, stderr
# Test xUnit report to ${TEST_XML_OUTPUT_DIR}/${test_name}/sponge_log.xml
#######################################
run_test() {
# Test driver usage:
# https://github.com/grpc/psm-interop#basic-usage
local test_name="${1:?Usage: run_test test_name}"
local out_dir="${TEST_XML_OUTPUT_DIR}/${test_name}"
mkdir -pv "${out_dir}"
set -x
python3 -m "tests.${test_name}" \
--flagfile="${TEST_DRIVER_FLAGFILE}" \
--kube_context="${KUBE_CONTEXT}" \
--server_image="${SERVER_IMAGE_NAME}:${GIT_COMMIT}" \
--client_image="${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" \
--testing_version="${TESTING_VERSION}" \
--nocheck_local_certs \
--force_cleanup \
--collect_app_logs \
--log_dir="${out_dir}" \
--xml_output_file="${out_dir}/sponge_log.xml" \
|& tee "${out_dir}/sponge_log.log"
set +x
}
#######################################
# Main function: provision software necessary to execute tests, and run them
# Globals:
# KOKORO_ARTIFACTS_DIR
# GITHUB_REPOSITORY_NAME
# SRC_DIR: Populated with absolute path to the source repo
# TEST_DRIVER_REPO_DIR: Populated with the path to the repo containing
# the test driver
# TEST_DRIVER_FULL_DIR: Populated with the path to the test driver source code
# TEST_DRIVER_FLAGFILE: Populated with relative path to test driver flagfile
# TEST_XML_OUTPUT_DIR: Populated with the path to test xUnit XML report
# GIT_ORIGIN_URL: Populated with the origin URL of git repo used for the build
# GIT_COMMIT: Populated with the SHA-1 of git commit being built
# GIT_COMMIT_SHORT: Populated with the short SHA-1 of git commit being built
# KUBE_CONTEXT: Populated with name of kubectl context with GKE cluster access
# Arguments:
# None
# Outputs:
# Writes the output of test execution to stdout, stderr
#######################################
main() {
local script_dir
script_dir="$(dirname "$0")"
# Source the test driver from the master branch.
echo "Sourcing test driver install script from: ${TEST_DRIVER_INSTALL_SCRIPT_URL}"
source /dev/stdin <<< "$(curl -s "${TEST_DRIVER_INSTALL_SCRIPT_URL}")"
activate_gke_cluster GKE_CLUSTER_PSM_SECURITY
set -x
if [[ -n "${KOKORO_ARTIFACTS_DIR}" ]]; then
kokoro_setup_test_driver "${GITHUB_REPOSITORY_NAME}"
else
local_setup_test_driver "${script_dir}"
fi
build_docker_images_if_needed
# Run tests
cd "${TEST_DRIVER_FULL_DIR}"
local failed_tests=0
test_suites=("baseline_test" "security_test" "authz_test")
for test in "${test_suites[@]}"; do
run_test $test || (( ++failed_tests ))
done
echo "Failed test suites: ${failed_tests}"
}
main "$@"

@ -15,7 +15,7 @@
# Config file for the internal CI (in protobuf text format)
# Location of the continuous shell script in repository.
build_file: "grpc/tools/internal_ci/linux/psm-security.sh"
build_file: "grpc/tools/internal_ci/linux/psm-interop-test-cpp.sh"
timeout_mins: 240
action {
define_artifacts {
@ -24,3 +24,7 @@ action {
strip_prefix: "artifacts"
}
}
env_vars {
key: "PSM_TEST_SUITE"
value: "security"
}

@ -1,169 +0,0 @@
#!/usr/bin/env bash
# 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.
set -eo pipefail
# Constants
readonly GITHUB_REPOSITORY_NAME="grpc"
readonly TEST_DRIVER_INSTALL_SCRIPT_URL="https://raw.githubusercontent.com/${TEST_DRIVER_REPO_OWNER:-grpc}/psm-interop/${TEST_DRIVER_BRANCH:-main}/.kokoro/psm_interop_kokoro_lib.sh"
## xDS test server/client Docker images
readonly DOCKER_REGISTRY="us-docker.pkg.dev"
readonly SERVER_IMAGE_NAME="us-docker.pkg.dev/grpc-testing/psm-interop/cpp-server"
readonly CLIENT_IMAGE_NAME="us-docker.pkg.dev/grpc-testing/psm-interop/cpp-client"
readonly FORCE_IMAGE_BUILD="${FORCE_IMAGE_BUILD:-0}"
readonly BUILD_APP_PATH="interop-testing/build/install/grpc-interop-testing"
#######################################
# Builds test app Docker images and pushes them to GCR
# Globals:
# BUILD_APP_PATH
# SERVER_IMAGE_NAME: Test server Docker image name
# CLIENT_IMAGE_NAME: Test client Docker image name
# GIT_COMMIT: SHA-1 of git commit being built
# TESTING_VERSION: version branch under test, f.e. v1.42.x, master
# Arguments:
# None
# Outputs:
# Writes the output of `gcloud builds submit` to stdout, stderr
#######################################
build_test_app_docker_images() {
echo "Building C++ xDS interop test app Docker images"
docker build -f "${SRC_DIR}/tools/dockerfile/interoptest/grpc_interop_cxx_xds/Dockerfile.xds_client" -t "${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" "${SRC_DIR}"
docker build -f "${SRC_DIR}/tools/dockerfile/interoptest/grpc_interop_cxx_xds/Dockerfile.xds_server" -t "${SERVER_IMAGE_NAME}:${GIT_COMMIT}" "${SRC_DIR}"
gcloud -q auth configure-docker "${DOCKER_REGISTRY}"
docker push "${CLIENT_IMAGE_NAME}:${GIT_COMMIT}"
docker push "${SERVER_IMAGE_NAME}:${GIT_COMMIT}"
if is_version_branch "${TESTING_VERSION}"; then
tag_and_push_docker_image "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}" "${TESTING_VERSION}"
tag_and_push_docker_image "${SERVER_IMAGE_NAME}" "${GIT_COMMIT}" "${TESTING_VERSION}"
fi
}
#######################################
# Builds test app and its docker images unless they already exist
# Globals:
# SERVER_IMAGE_NAME: Test server Docker image name
# CLIENT_IMAGE_NAME: Test client Docker image name
# GIT_COMMIT: SHA-1 of git commit being built
# FORCE_IMAGE_BUILD
# Arguments:
# None
# Outputs:
# Writes the output to stdout, stderr
#######################################
build_docker_images_if_needed() {
# Check if images already exist
server_tags="$(gcloud_gcr_list_image_tags "${SERVER_IMAGE_NAME}" "${GIT_COMMIT}")"
printf "Server image: %s:%s\n" "${SERVER_IMAGE_NAME}" "${GIT_COMMIT}"
echo "${server_tags:-Server image not found}"
client_tags="$(gcloud_gcr_list_image_tags "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}")"
printf "Client image: %s:%s\n" "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}"
echo "${client_tags:-Client image not found}"
# Build if any of the images are missing, or FORCE_IMAGE_BUILD=1
if [[ "${FORCE_IMAGE_BUILD}" == "1" || -z "${server_tags}" || -z "${client_tags}" ]]; then
build_test_app_docker_images
else
echo "Skipping C++ test app build"
fi
}
#######################################
# Executes the test case
# Globals:
# TEST_DRIVER_FLAGFILE: Relative path to test driver flagfile
# KUBE_CONTEXT: The name of kubectl context with GKE cluster access
# TEST_XML_OUTPUT_DIR: Output directory for the test xUnit XML report
# SERVER_IMAGE_NAME: Test server Docker image name
# CLIENT_IMAGE_NAME: Test client Docker image name
# GIT_COMMIT: SHA-1 of git commit being built
# TESTING_VERSION: version branch under test: used by the framework to determine the supported PSM
# features.
# Arguments:
# Test case name
# Outputs:
# Writes the output of test execution to stdout, stderr
# Test xUnit report to ${TEST_XML_OUTPUT_DIR}/${test_name}/sponge_log.xml
#######################################
run_test() {
# Test driver usage:
# https://github.com/grpc/psm-interop#basic-usage
local test_name="${1:?Usage: run_test test_name}"
local out_dir="${TEST_XML_OUTPUT_DIR}/${test_name}"
mkdir -pv "${out_dir}"
set -x
python3 -m "tests.${test_name}" \
--flagfile="${TEST_DRIVER_FLAGFILE}" \
--kube_context="${KUBE_CONTEXT}" \
--server_image="${SERVER_IMAGE_NAME}:${GIT_COMMIT}" \
--client_image="${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" \
--testing_version="${TESTING_VERSION}" \
--nocheck_local_certs \
--force_cleanup \
--collect_app_logs \
--log_dir="${out_dir}" \
--xml_output_file="${out_dir}/sponge_log.xml" \
|& tee "${out_dir}/sponge_log.log"
}
#######################################
# Main function: provision software necessary to execute tests, and run them
# Globals:
# KOKORO_ARTIFACTS_DIR
# GITHUB_REPOSITORY_NAME
# SRC_DIR: Populated with absolute path to the source repo
# TEST_DRIVER_REPO_DIR: Populated with the path to the repo containing
# the test driver
# TEST_DRIVER_FULL_DIR: Populated with the path to the test driver source code
# TEST_DRIVER_FLAGFILE: Populated with relative path to test driver flagfile
# TEST_XML_OUTPUT_DIR: Populated with the path to test xUnit XML report
# GIT_ORIGIN_URL: Populated with the origin URL of git repo used for the build
# GIT_COMMIT: Populated with the SHA-1 of git commit being built
# GIT_COMMIT_SHORT: Populated with the short SHA-1 of git commit being built
# KUBE_CONTEXT: Populated with name of kubectl context with GKE cluster access
# Arguments:
# None
# Outputs:
# Writes the output of test execution to stdout, stderr
#######################################
main() {
local script_dir
script_dir="$(dirname "$0")"
# Source the test driver from the master branch.
echo "Sourcing test driver install script from: ${TEST_DRIVER_INSTALL_SCRIPT_URL}"
source /dev/stdin <<< "$(curl -s "${TEST_DRIVER_INSTALL_SCRIPT_URL}")"
activate_gke_cluster GKE_CLUSTER_PSM_SECURITY
set -x
if [[ -n "${KOKORO_ARTIFACTS_DIR}" ]]; then
kokoro_setup_test_driver "${GITHUB_REPOSITORY_NAME}"
else
local_setup_test_driver "${script_dir}"
fi
build_docker_images_if_needed
# Run tests
cd "${TEST_DRIVER_FULL_DIR}"
local failed_tests=0
test_suites=("baseline_test" "security_test" "authz_test")
for test in "${test_suites[@]}"; do
run_test $test || (( ++failed_tests ))
done
echo "Failed test suites: ${failed_tests}"
}
main "$@"

@ -132,6 +132,7 @@ LANG_RELEASE_MATRIX = {
("v1.60.0", ReleaseInfo()),
("v1.61.0", ReleaseInfo()),
("v1.62.0", ReleaseInfo()),
("v1.63.0", ReleaseInfo()),
]
),
"go": OrderedDict(
@ -781,6 +782,12 @@ LANG_RELEASE_MATRIX = {
runtimes=["python"], testcases_file="python__master"
),
),
(
"v1.63.0",
ReleaseInfo(
runtimes=["python"], testcases_file="python__master"
),
),
]
),
"node": OrderedDict(
@ -877,6 +884,7 @@ LANG_RELEASE_MATRIX = {
("v1.60.0", ReleaseInfo()),
("v1.61.0", ReleaseInfo()),
("v1.62.0", ReleaseInfo()),
("v1.63.0", ReleaseInfo()),
]
),
"php": OrderedDict(
@ -937,6 +945,7 @@ LANG_RELEASE_MATRIX = {
("v1.60.0", ReleaseInfo()),
("v1.61.0", ReleaseInfo()),
("v1.62.0", ReleaseInfo()),
("v1.63.0", ReleaseInfo()),
]
),
"csharp": OrderedDict(

@ -22,7 +22,6 @@ _AVAILABLE_BENCHMARK_TESTS = [
"bm_closure",
"bm_cq",
"bm_chttp2_hpack",
"bm_chttp2_transport",
]
_INTERESTING = (

Loading…
Cancel
Save