Merge branch 'master' into server-credentials

pull/23600/head
Karthik Ravi Shankar 5 years ago
commit be7bab5cb8
  1. 2
      .github/ISSUE_TEMPLATE/bug_report.md
  2. 2
      .github/ISSUE_TEMPLATE/cleanup_request.md
  3. 2
      .github/ISSUE_TEMPLATE/feature_request.md
  4. 2
      .github/ISSUE_TEMPLATE/question.md
  5. 2
      .github/pull_request_template.md
  6. 4
      BUILD
  7. 4
      BUILD.gn
  8. 26
      CMakeLists.txt
  9. 39
      Makefile
  10. 9
      bazel/python_rules.bzl
  11. 2
      bazel/test/python_test_repo/BUILD
  12. 3
      bazel/test/python_test_repo/WORKSPACE
  13. 165
      bazel/test/python_test_repo/namespaced/upper/example/BUILD
  14. 35
      bazel/test/python_test_repo/namespaced/upper/example/import_no_strip_test.py
  15. 35
      bazel/test/python_test_repo/namespaced/upper/example/import_strip_test.py
  16. 27
      bazel/test/python_test_repo/namespaced/upper/example/namespaced_dependency.proto
  17. 38
      bazel/test/python_test_repo/namespaced/upper/example/namespaced_example.proto
  18. 35
      bazel/test/python_test_repo/namespaced/upper/example/no_import_no_strip_test.py
  19. 35
      bazel/test/python_test_repo/namespaced/upper/example/no_import_strip_test.py
  20. 7
      build_autogenerated.yaml
  21. 1
      build_handwritten.yaml
  22. 10
      config.m4
  23. 10
      config.w32
  24. 4
      doc/xds-test-descriptions.md
  25. 4
      gRPC-C++.podspec
  26. 2
      gRPC-Core.podspec
  27. 67
      grpc.gemspec
  28. 2
      grpc.gyp
  29. 2
      include/grpc/impl/codegen/port_platform.h
  30. 67
      include/grpcpp/create_channel.h
  31. 78
      include/grpcpp/create_channel_impl.h
  32. 13
      include/grpcpp/impl/codegen/client_context_impl.h
  33. 356
      include/grpcpp/security/credentials.h
  34. 356
      include/grpcpp/security/credentials_impl.h
  35. 5
      include/grpcpp/security/cronet_credentials.h
  36. 33
      include/grpcpp/security/server_credentials.h
  37. 4
      include/grpcpp/security/tls_credentials_options.h
  38. 5
      include/grpcpp/support/channel_arguments_impl.h
  39. 18
      package.xml
  40. 7
      src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc
  41. 9
      src/core/ext/filters/client_channel/lb_policy/xds/xds_routing.cc
  42. 310
      src/core/ext/transport/chttp2/transport/chttp2_transport.cc
  43. 27
      src/core/lib/channel/channelz.cc
  44. 4
      src/core/lib/channel/channelz_registry.cc
  45. 2
      src/core/lib/iomgr/ev_posix.cc
  46. 10
      src/core/lib/iomgr/iomgr.cc
  47. 10
      src/core/lib/iomgr/iomgr.h
  48. 282
      src/core/lib/surface/completion_queue.cc
  49. 8
      src/core/lib/surface/completion_queue.h
  50. 2
      src/core/lib/surface/init.cc
  51. 12
      src/core/tsi/ssl_transport_security.cc
  52. 2
      src/cpp/client/client_context.cc
  53. 14
      src/cpp/client/create_channel.cc
  54. 4
      src/cpp/client/credentials_cc.cc
  55. 5
      src/cpp/client/cronet_credentials.cc
  56. 4
      src/cpp/client/insecure_credentials.cc
  57. 5
      src/cpp/client/secure_credentials.cc
  58. 8
      src/cpp/client/secure_credentials.h
  59. 4
      src/cpp/common/tls_credentials_options.cc
  60. 4
      src/cpp/common/tls_credentials_options_util.cc
  61. 4
      src/cpp/common/tls_credentials_options_util.h
  62. 2
      src/cpp/server/secure_server_credentials.cc
  63. 2
      src/php/ext/grpc/channel.c
  64. 1
      src/php/ext/grpc/php_grpc.c
  65. 43
      src/proto/grpc/testing/xds/v3/BUILD
  66. 17
      src/proto/grpc/testing/xds/v3/discovery.proto
  67. 89
      src/proto/grpc/testing/xds/v3/status.proto
  68. 8
      src/python/grpcio/grpc_core_dependencies.py
  69. 9
      src/ruby/end2end/call_credentials_returning_bad_metadata_doesnt_kill_background_thread_driver.rb
  70. 21
      src/ruby/end2end/call_credentials_timeout_driver.rb
  71. 13
      src/ruby/end2end/channel_closing_driver.rb
  72. 35
      src/ruby/end2end/end2end_common.rb
  73. 41
      src/ruby/end2end/graceful_sig_handling_driver.rb
  74. 37
      src/ruby/end2end/graceful_sig_stop_driver.rb
  75. 38
      src/ruby/end2end/sig_handling_driver.rb
  76. 10
      src/ruby/end2end/sig_int_during_channel_watch_client.rb
  77. 9
      src/ruby/end2end/sig_int_during_channel_watch_driver.rb
  78. 11
      test/core/security/fetch_oauth2.cc
  79. 2
      test/core/transport/byte_stream_test.cc
  80. 2
      test/core/transport/connectivity_state_test.cc
  81. 2
      test/core/transport/static_metadata_test.cc
  82. 4
      test/core/transport/status_conversion_test.cc
  83. 5
      test/core/transport/status_metadata_test.cc
  84. 5
      test/core/tsi/ssl_transport_security_test.cc
  85. 29
      test/cpp/client/credentials_test.cc
  86. 62
      test/cpp/end2end/client_callback_end2end_test.cc
  87. 86
      test/cpp/end2end/end2end_test.cc
  88. 5
      test/cpp/end2end/interceptors_util.cc
  89. 33
      test/cpp/end2end/message_allocator_end2end_test.cc
  90. 9
      test/cpp/interop/xds_interop_client.cc
  91. 62
      test/cpp/microbenchmarks/bm_cq.cc
  92. 2
      tools/doxygen/Doxyfile.c++
  93. 2
      tools/doxygen/Doxyfile.c++.internal
  94. 13
      tools/internal_ci/linux/grpc_xds_bazel_test_in_docker.sh
  95. 315
      tools/run_tests/run_xds_tests.py

@ -2,7 +2,7 @@
name: Report a bug
about: Create a report to help us improve
labels: kind/bug, priority/P2
assignees: donnadionne
assignees: markdroth
---

@ -2,7 +2,7 @@
name: Request a cleanup
about: Suggest a cleanup in our repository
labels: kind/internal cleanup, priority/P2
assignees: donnadionne
assignees: markdroth
---

@ -2,7 +2,7 @@
name: Request a feature
about: Suggest an idea for this project
labels: kind/enhancement, priority/P2
assignees: donnadionne
assignees: markdroth
---

@ -2,7 +2,7 @@
name: Ask a question
about: Ask a question
labels: kind/question, priority/P3
assignees: donnadionne
assignees: markdroth
---

@ -8,4 +8,4 @@ If you know who should review your pull request, please remove the mentioning be
-->
@donnadionne
@markdroth

@ -225,7 +225,6 @@ GRPCXX_PUBLIC_HDRS = [
"include/grpcpp/completion_queue.h",
"include/grpcpp/completion_queue_impl.h",
"include/grpcpp/create_channel.h",
"include/grpcpp/create_channel_impl.h",
"include/grpcpp/create_channel_posix.h",
"include/grpcpp/ext/health_check_service_server_builder_option.h",
"include/grpcpp/generic/async_generic_service.h",
@ -251,7 +250,6 @@ GRPCXX_PUBLIC_HDRS = [
"include/grpcpp/security/auth_context.h",
"include/grpcpp/security/auth_metadata_processor.h",
"include/grpcpp/security/credentials.h",
"include/grpcpp/security/credentials_impl.h",
"include/grpcpp/security/server_credentials.h",
"include/grpcpp/security/tls_credentials_options.h",
"include/grpcpp/server.h",
@ -552,9 +550,11 @@ grpc_cc_library(
"src/core/lib/profiling/timers.h",
],
external_deps = [
"absl/base",
"absl/memory",
"absl/strings",
"absl/strings:str_format",
"absl/synchronization",
"absl/time:time",
],
language = "c++",

@ -170,9 +170,11 @@ config("grpc_config") {
]
deps = [
":absl/time:time",
":absl/synchronization:synchronization",
":absl/strings:strings",
":absl/strings:str_format",
":absl/memory:memory",
":absl/base:base",
]
public_configs = [
@ -1093,7 +1095,6 @@ config("grpc_config") {
"include/grpcpp/completion_queue.h",
"include/grpcpp/completion_queue_impl.h",
"include/grpcpp/create_channel.h",
"include/grpcpp/create_channel_impl.h",
"include/grpcpp/create_channel_posix.h",
"include/grpcpp/ext/health_check_service_server_builder_option.h",
"include/grpcpp/generic/async_generic_service.h",
@ -1177,7 +1178,6 @@ config("grpc_config") {
"include/grpcpp/security/auth_context.h",
"include/grpcpp/security/auth_metadata_processor.h",
"include/grpcpp/security/credentials.h",
"include/grpcpp/security/credentials_impl.h",
"include/grpcpp/security/server_credentials.h",
"include/grpcpp/security/tls_credentials_options.h",
"include/grpcpp/server.h",

@ -120,9 +120,11 @@ set(gRPC_ABSL_USED_TARGETS
absl_errno_saver
absl_fixed_array
absl_function_ref
absl_graphcycles_internal
absl_inlined_vector
absl_inlined_vector_internal
absl_int128
absl_kernel_timeout_internal
absl_log_severity
absl_malloc_internal
absl_memory
@ -137,6 +139,7 @@ set(gRPC_ABSL_USED_TARGETS
absl_strings
absl_strings_internal
absl_symbolize
absl_synchronization
absl_throw_delegate
absl_time
absl_time_zone
@ -478,9 +481,6 @@ protobuf_generate_grpc_cpp(
protobuf_generate_grpc_cpp(
src/proto/grpc/testing/xds/v3/route.proto
)
protobuf_generate_grpc_cpp(
src/proto/grpc/testing/xds/v3/status.proto
)
protobuf_generate_grpc_cpp(
test/core/tsi/alts/fake_handshaker/handshaker.proto
)
@ -1316,9 +1316,11 @@ target_include_directories(gpr
target_link_libraries(gpr
${_gRPC_ALLTARGETS_LIBRARIES}
absl::time
absl::synchronization
absl::strings
absl::str_format
absl::memory
absl::base
)
if(_gRPC_PLATFORM_ANDROID)
target_link_libraries(gpr
@ -2735,7 +2737,6 @@ foreach(_hdr
include/grpcpp/completion_queue.h
include/grpcpp/completion_queue_impl.h
include/grpcpp/create_channel.h
include/grpcpp/create_channel_impl.h
include/grpcpp/create_channel_posix.h
include/grpcpp/ext/health_check_service_server_builder_option.h
include/grpcpp/generic/async_generic_service.h
@ -2819,7 +2820,6 @@ foreach(_hdr
include/grpcpp/security/auth_context.h
include/grpcpp/security/auth_metadata_processor.h
include/grpcpp/security/credentials.h
include/grpcpp/security/credentials_impl.h
include/grpcpp/security/server_credentials.h
include/grpcpp/security/tls_credentials_options.h
include/grpcpp/server.h
@ -3428,7 +3428,6 @@ foreach(_hdr
include/grpcpp/completion_queue.h
include/grpcpp/completion_queue_impl.h
include/grpcpp/create_channel.h
include/grpcpp/create_channel_impl.h
include/grpcpp/create_channel_posix.h
include/grpcpp/ext/health_check_service_server_builder_option.h
include/grpcpp/generic/async_generic_service.h
@ -3512,7 +3511,6 @@ foreach(_hdr
include/grpcpp/security/auth_context.h
include/grpcpp/security/auth_metadata_processor.h
include/grpcpp/security/credentials.h
include/grpcpp/security/credentials_impl.h
include/grpcpp/security/server_credentials.h
include/grpcpp/security/tls_credentials_options.h
include/grpcpp/server.h
@ -14914,10 +14912,6 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/route.grpc.pb.cc
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/route.pb.h
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/route.grpc.pb.h
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/status.pb.cc
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/status.grpc.pb.cc
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/status.pb.h
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/status.grpc.pb.h
test/cpp/end2end/test_service_impl.cc
test/cpp/end2end/xds_end2end_test.cc
third_party/googletest/googletest/src/gtest-all.cc
@ -15655,7 +15649,7 @@ generate_pkgconfig(
"gRPC platform support library"
"${gRPC_CORE_VERSION}"
""
"-lgpr -labsl_str_format_internal -labsl_time -labsl_time_zone -labsl_civil_time -labsl_strings -labsl_strings_internal -labsl_throw_delegate -labsl_int128 -labsl_base -labsl_spinlock_wait -labsl_raw_logging_internal -labsl_log_severity -labsl_dynamic_annotations"
"-lgpr -labsl_str_format_internal -labsl_synchronization -labsl_graphcycles_internal -labsl_symbolize -labsl_demangle_internal -labsl_stacktrace -labsl_debugging_internal -labsl_malloc_internal -labsl_time -labsl_time_zone -labsl_civil_time -labsl_strings -labsl_strings_internal -labsl_throw_delegate -labsl_int128 -labsl_base -labsl_spinlock_wait -labsl_raw_logging_internal -labsl_log_severity -labsl_dynamic_annotations"
""
"gpr.pc")
@ -15665,7 +15659,7 @@ generate_pkgconfig(
"high performance general RPC framework"
"${gRPC_CORE_VERSION}"
"gpr openssl"
"-lgrpc -laddress_sorting -lre2 -lupb -lcares -lz -labsl_status -labsl_cord -labsl_symbolize -labsl_demangle_internal -labsl_malloc_internal -labsl_stacktrace -labsl_debugging_internal -labsl_bad_optional_access -labsl_str_format_internal -labsl_time -labsl_time_zone -labsl_civil_time -labsl_strings -labsl_strings_internal -labsl_throw_delegate -labsl_int128 -labsl_base -labsl_spinlock_wait -labsl_raw_logging_internal -labsl_log_severity -labsl_dynamic_annotations"
"-lgrpc -laddress_sorting -lre2 -lupb -lcares -lz -labsl_status -labsl_cord -labsl_bad_optional_access -labsl_str_format_internal -labsl_synchronization -labsl_graphcycles_internal -labsl_symbolize -labsl_demangle_internal -labsl_stacktrace -labsl_debugging_internal -labsl_malloc_internal -labsl_time -labsl_time_zone -labsl_civil_time -labsl_strings -labsl_strings_internal -labsl_throw_delegate -labsl_int128 -labsl_base -labsl_spinlock_wait -labsl_raw_logging_internal -labsl_log_severity -labsl_dynamic_annotations"
""
"grpc.pc")
@ -15675,7 +15669,7 @@ generate_pkgconfig(
"high performance general RPC framework without SSL"
"${gRPC_CORE_VERSION}"
"gpr"
"-lgrpc_unsecure -labsl_status -labsl_cord -labsl_symbolize -labsl_demangle_internal -labsl_malloc_internal -labsl_stacktrace -labsl_debugging_internal -labsl_bad_optional_access -labsl_str_format_internal -labsl_time -labsl_time_zone -labsl_civil_time -labsl_strings -labsl_strings_internal -labsl_throw_delegate -labsl_int128 -labsl_base -labsl_spinlock_wait -labsl_raw_logging_internal -labsl_log_severity -labsl_dynamic_annotations"
"-lgrpc_unsecure -labsl_status -labsl_cord -labsl_bad_optional_access -labsl_str_format_internal -labsl_synchronization -labsl_graphcycles_internal -labsl_symbolize -labsl_demangle_internal -labsl_stacktrace -labsl_debugging_internal -labsl_malloc_internal -labsl_time -labsl_time_zone -labsl_civil_time -labsl_strings -labsl_strings_internal -labsl_throw_delegate -labsl_int128 -labsl_base -labsl_spinlock_wait -labsl_raw_logging_internal -labsl_log_severity -labsl_dynamic_annotations"
""
"grpc_unsecure.pc")
@ -15685,7 +15679,7 @@ generate_pkgconfig(
"C++ wrapper for gRPC"
"${gRPC_CPP_VERSION}"
"grpc"
"-lgrpc++ -labsl_status -labsl_cord -labsl_symbolize -labsl_demangle_internal -labsl_malloc_internal -labsl_stacktrace -labsl_debugging_internal -labsl_bad_optional_access -labsl_str_format_internal -labsl_time -labsl_time_zone -labsl_civil_time -labsl_strings -labsl_strings_internal -labsl_throw_delegate -labsl_int128 -labsl_base -labsl_spinlock_wait -labsl_raw_logging_internal -labsl_log_severity -labsl_dynamic_annotations"
"-lgrpc++ -labsl_status -labsl_cord -labsl_bad_optional_access -labsl_str_format_internal -labsl_synchronization -labsl_graphcycles_internal -labsl_symbolize -labsl_demangle_internal -labsl_stacktrace -labsl_debugging_internal -labsl_malloc_internal -labsl_time -labsl_time_zone -labsl_civil_time -labsl_strings -labsl_strings_internal -labsl_throw_delegate -labsl_int128 -labsl_base -labsl_spinlock_wait -labsl_raw_logging_internal -labsl_log_severity -labsl_dynamic_annotations"
""
"grpc++.pc")
@ -15695,6 +15689,6 @@ generate_pkgconfig(
"C++ wrapper for gRPC without SSL"
"${gRPC_CPP_VERSION}"
"grpc_unsecure"
"-lgrpc++_unsecure -labsl_status -labsl_cord -labsl_symbolize -labsl_demangle_internal -labsl_malloc_internal -labsl_stacktrace -labsl_debugging_internal -labsl_bad_optional_access -labsl_str_format_internal -labsl_time -labsl_time_zone -labsl_civil_time -labsl_strings -labsl_strings_internal -labsl_throw_delegate -labsl_int128 -labsl_base -labsl_spinlock_wait -labsl_raw_logging_internal -labsl_log_severity -labsl_dynamic_annotations"
"-lgrpc++_unsecure -labsl_status -labsl_cord -labsl_bad_optional_access -labsl_str_format_internal -labsl_synchronization -labsl_graphcycles_internal -labsl_symbolize -labsl_demangle_internal -labsl_stacktrace -labsl_debugging_internal -labsl_malloc_internal -labsl_time -labsl_time_zone -labsl_civil_time -labsl_strings -labsl_strings_internal -labsl_throw_delegate -labsl_int128 -labsl_base -labsl_spinlock_wait -labsl_raw_logging_internal -labsl_log_severity -labsl_dynamic_annotations"
""
"grpc++_unsecure.pc")

@ -2977,12 +2977,12 @@ $(GENDIR)/src/proto/grpc/testing/xds/v3/discovery.pb.cc: protoc_dep_error
$(GENDIR)/src/proto/grpc/testing/xds/v3/discovery.grpc.pb.cc: protoc_dep_error
else
$(GENDIR)/src/proto/grpc/testing/xds/v3/discovery.pb.cc: src/proto/grpc/testing/xds/v3/discovery.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) $(GENDIR)/src/proto/grpc/testing/xds/v3/base.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/status.pb.cc
$(GENDIR)/src/proto/grpc/testing/xds/v3/discovery.pb.cc: src/proto/grpc/testing/xds/v3/discovery.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) $(GENDIR)/src/proto/grpc/testing/xds/v3/base.pb.cc
$(E) "[PROTOC] Generating protobuf CC file from $<"
$(Q) mkdir -p `dirname $@`
$(Q) $(PROTOC) -Ithird_party/protobuf/src -I. --cpp_out=$(GENDIR) $<
$(GENDIR)/src/proto/grpc/testing/xds/v3/discovery.grpc.pb.cc: src/proto/grpc/testing/xds/v3/discovery.proto $(GENDIR)/src/proto/grpc/testing/xds/v3/discovery.pb.cc $(PROTOBUF_DEP) $(PROTOC_PLUGINS) $(GENDIR)/src/proto/grpc/testing/xds/v3/base.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/base.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/status.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/status.grpc.pb.cc
$(GENDIR)/src/proto/grpc/testing/xds/v3/discovery.grpc.pb.cc: src/proto/grpc/testing/xds/v3/discovery.proto $(GENDIR)/src/proto/grpc/testing/xds/v3/discovery.pb.cc $(PROTOBUF_DEP) $(PROTOC_PLUGINS) $(GENDIR)/src/proto/grpc/testing/xds/v3/base.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/base.grpc.pb.cc
$(E) "[GRPC] Generating gRPC's protobuf service CC file from $<"
$(Q) mkdir -p `dirname $@`
$(Q) $(PROTOC) -Ithird_party/protobuf/src -I. --grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(PROTOC_PLUGINS_DIR)/grpc_cpp_plugin$(EXECUTABLE_SUFFIX) $<
@ -3132,22 +3132,6 @@ $(GENDIR)/src/proto/grpc/testing/xds/v3/route.grpc.pb.cc: src/proto/grpc/testing
$(Q) $(PROTOC) -Ithird_party/protobuf/src -I. --grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(PROTOC_PLUGINS_DIR)/grpc_cpp_plugin$(EXECUTABLE_SUFFIX) $<
endif
ifeq ($(NO_PROTOC),true)
$(GENDIR)/src/proto/grpc/testing/xds/v3/status.pb.cc: protoc_dep_error
$(GENDIR)/src/proto/grpc/testing/xds/v3/status.grpc.pb.cc: protoc_dep_error
else
$(GENDIR)/src/proto/grpc/testing/xds/v3/status.pb.cc: src/proto/grpc/testing/xds/v3/status.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS)
$(E) "[PROTOC] Generating protobuf CC file from $<"
$(Q) mkdir -p `dirname $@`
$(Q) $(PROTOC) -Ithird_party/protobuf/src -I. --cpp_out=$(GENDIR) $<
$(GENDIR)/src/proto/grpc/testing/xds/v3/status.grpc.pb.cc: src/proto/grpc/testing/xds/v3/status.proto $(GENDIR)/src/proto/grpc/testing/xds/v3/status.pb.cc $(PROTOBUF_DEP) $(PROTOC_PLUGINS)
$(E) "[GRPC] Generating gRPC's protobuf service CC file from $<"
$(Q) mkdir -p `dirname $@`
$(Q) $(PROTOC) -Ithird_party/protobuf/src -I. --grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(PROTOC_PLUGINS_DIR)/grpc_cpp_plugin$(EXECUTABLE_SUFFIX) $<
endif
ifeq ($(NO_PROTOC),true)
$(GENDIR)/test/core/tsi/alts/fake_handshaker/handshaker.pb.cc: protoc_dep_error
$(GENDIR)/test/core/tsi/alts/fake_handshaker/handshaker.grpc.pb.cc: protoc_dep_error
@ -4885,7 +4869,6 @@ PUBLIC_HEADERS_CXX += \
include/grpcpp/completion_queue.h \
include/grpcpp/completion_queue_impl.h \
include/grpcpp/create_channel.h \
include/grpcpp/create_channel_impl.h \
include/grpcpp/create_channel_posix.h \
include/grpcpp/ext/health_check_service_server_builder_option.h \
include/grpcpp/generic/async_generic_service.h \
@ -4969,7 +4952,6 @@ PUBLIC_HEADERS_CXX += \
include/grpcpp/security/auth_context.h \
include/grpcpp/security/auth_metadata_processor.h \
include/grpcpp/security/credentials.h \
include/grpcpp/security/credentials_impl.h \
include/grpcpp/security/server_credentials.h \
include/grpcpp/security/tls_credentials_options.h \
include/grpcpp/server.h \
@ -5576,7 +5558,6 @@ PUBLIC_HEADERS_CXX += \
include/grpcpp/completion_queue.h \
include/grpcpp/completion_queue_impl.h \
include/grpcpp/create_channel.h \
include/grpcpp/create_channel_impl.h \
include/grpcpp/create_channel_posix.h \
include/grpcpp/ext/health_check_service_server_builder_option.h \
include/grpcpp/generic/async_generic_service.h \
@ -5660,7 +5641,6 @@ PUBLIC_HEADERS_CXX += \
include/grpcpp/security/auth_context.h \
include/grpcpp/security/auth_metadata_processor.h \
include/grpcpp/security/credentials.h \
include/grpcpp/security/credentials_impl.h \
include/grpcpp/security/server_credentials.h \
include/grpcpp/security/tls_credentials_options.h \
include/grpcpp/server.h \
@ -6529,6 +6509,14 @@ LIBGRPC_ABSEIL_SRC = \
third_party/abseil-cpp/absl/strings/str_split.cc \
third_party/abseil-cpp/absl/strings/string_view.cc \
third_party/abseil-cpp/absl/strings/substitute.cc \
third_party/abseil-cpp/absl/synchronization/barrier.cc \
third_party/abseil-cpp/absl/synchronization/blocking_counter.cc \
third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.cc \
third_party/abseil-cpp/absl/synchronization/internal/graphcycles.cc \
third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.cc \
third_party/abseil-cpp/absl/synchronization/internal/waiter.cc \
third_party/abseil-cpp/absl/synchronization/mutex.cc \
third_party/abseil-cpp/absl/synchronization/notification.cc \
third_party/abseil-cpp/absl/time/civil_time.cc \
third_party/abseil-cpp/absl/time/clock.cc \
third_party/abseil-cpp/absl/time/duration.cc \
@ -19123,7 +19111,6 @@ XDS_END2END_TEST_SRC = \
$(GENDIR)/src/proto/grpc/testing/xds/v3/range.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/range.grpc.pb.cc \
$(GENDIR)/src/proto/grpc/testing/xds/v3/regex.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/regex.grpc.pb.cc \
$(GENDIR)/src/proto/grpc/testing/xds/v3/route.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/route.grpc.pb.cc \
$(GENDIR)/src/proto/grpc/testing/xds/v3/status.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/status.grpc.pb.cc \
test/cpp/end2end/test_service_impl.cc \
test/cpp/end2end/xds_end2end_test.cc \
@ -19204,8 +19191,6 @@ $(OBJDIR)/$(CONFIG)/src/proto/grpc/testing/xds/v3/regex.o: $(LIBDIR)/$(CONFIG)/
$(OBJDIR)/$(CONFIG)/src/proto/grpc/testing/xds/v3/route.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libaddress_sorting.a $(LIBDIR)/$(CONFIG)/libupb.a
$(OBJDIR)/$(CONFIG)/src/proto/grpc/testing/xds/v3/status.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libaddress_sorting.a $(LIBDIR)/$(CONFIG)/libupb.a
$(OBJDIR)/$(CONFIG)/test/cpp/end2end/test_service_impl.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libaddress_sorting.a $(LIBDIR)/$(CONFIG)/libupb.a
$(OBJDIR)/$(CONFIG)/test/cpp/end2end/xds_end2end_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libaddress_sorting.a $(LIBDIR)/$(CONFIG)/libupb.a
@ -19217,8 +19202,8 @@ ifneq ($(NO_DEPS),true)
-include $(XDS_END2END_TEST_OBJS:.o=.dep)
endif
endif
$(OBJDIR)/$(CONFIG)/test/cpp/end2end/test_service_impl.o: $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/simple_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/simple_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/ads_for_test.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/ads_for_test.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/cds_for_test.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/cds_for_test.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/eds_for_test.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/eds_for_test.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/lds_rds_for_test.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/lds_rds_for_test.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/lrs_for_test.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/lrs_for_test.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/address.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/address.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/ads.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/ads.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/base.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/base.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/cluster.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/cluster.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/config_source.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/config_source.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/discovery.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/discovery.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/endpoint.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/endpoint.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/http_connection_manager.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/http_connection_manager.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/listener.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/listener.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/load_report.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/load_report.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/lrs.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/lrs.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/percent.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/percent.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/range.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/range.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/regex.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/regex.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/route.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/route.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/status.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/status.grpc.pb.cc
$(OBJDIR)/$(CONFIG)/test/cpp/end2end/xds_end2end_test.o: $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/simple_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/simple_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/ads_for_test.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/ads_for_test.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/cds_for_test.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/cds_for_test.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/eds_for_test.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/eds_for_test.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/lds_rds_for_test.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/lds_rds_for_test.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/lrs_for_test.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/lrs_for_test.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/address.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/address.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/ads.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/ads.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/base.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/base.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/cluster.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/cluster.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/config_source.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/config_source.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/discovery.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/discovery.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/endpoint.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/endpoint.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/http_connection_manager.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/http_connection_manager.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/listener.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/listener.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/load_report.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/load_report.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/lrs.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/lrs.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/percent.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/percent.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/range.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/range.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/regex.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/regex.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/route.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/route.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/status.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/status.grpc.pb.cc
$(OBJDIR)/$(CONFIG)/test/cpp/end2end/test_service_impl.o: $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/simple_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/simple_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/ads_for_test.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/ads_for_test.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/cds_for_test.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/cds_for_test.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/eds_for_test.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/eds_for_test.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/lds_rds_for_test.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/lds_rds_for_test.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/lrs_for_test.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/lrs_for_test.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/address.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/address.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/ads.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/ads.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/base.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/base.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/cluster.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/cluster.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/config_source.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/config_source.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/discovery.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/discovery.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/endpoint.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/endpoint.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/http_connection_manager.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/http_connection_manager.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/listener.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/listener.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/load_report.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/load_report.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/lrs.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/lrs.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/percent.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/percent.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/range.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/range.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/regex.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/regex.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/route.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/route.grpc.pb.cc
$(OBJDIR)/$(CONFIG)/test/cpp/end2end/xds_end2end_test.o: $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/simple_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/simple_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/ads_for_test.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/ads_for_test.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/cds_for_test.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/cds_for_test.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/eds_for_test.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/eds_for_test.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/lds_rds_for_test.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/lds_rds_for_test.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/lrs_for_test.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/lrs_for_test.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/address.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/address.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/ads.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/ads.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/base.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/base.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/cluster.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/cluster.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/config_source.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/config_source.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/discovery.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/discovery.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/endpoint.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/endpoint.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/http_connection_manager.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/http_connection_manager.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/listener.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/listener.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/load_report.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/load_report.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/lrs.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/lrs.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/percent.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/percent.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/range.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/range.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/regex.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/regex.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/route.pb.cc $(GENDIR)/src/proto/grpc/testing/xds/v3/route.grpc.pb.cc
XDS_INTEROP_CLIENT_SRC = \

@ -53,7 +53,7 @@ def _generate_py_impl(context):
imports = []
if out_dir.import_path:
imports.append("__main__/%s" % out_dir.import_path)
imports.append("%s/%s/%s" % (context.workspace_name, context.label.package, out_dir.import_path))
return [
DefaultInfo(files = depset(direct = out_files)),
@ -164,15 +164,12 @@ def _generate_pb2_grpc_src_impl(context):
mnemonic = "ProtocInvocation",
)
imports = []
if out_dir.import_path:
imports.append("__main__/%s" % out_dir.import_path)
return [
DefaultInfo(files = depset(direct = out_files)),
PyInfo(
transitive_sources = depset(),
imports = depset(direct = imports),
# Imports are already configured by the generated py impl
imports = depset(),
),
]

@ -69,6 +69,8 @@ py2and3_test(
# Test compatibility of py_proto_library and py_grpc_library rules with
# proto_library targets as deps when the latter use import_prefix and/or
# strip_import_prefix arguments
#
# See namespaced/upper/example for more encompassing tests.
proto_library(
name = "helloworld_moved_proto",
srcs = ["helloworld.proto"],

@ -3,6 +3,9 @@ local_repository(
path = "../../..",
)
# Ensure rules don't rely on __main__ naming convention.
workspace(name = "python_test_repo")
load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")
grpc_deps()

@ -0,0 +1,165 @@
# gRPC Bazel BUILD file.
#
# Copyright 2020 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.
load("@rules_proto//proto:defs.bzl", "proto_library")
load(
"@com_github_grpc_grpc//bazel:python_rules.bzl",
"py2and3_test",
"py_grpc_library",
"py_proto_library",
)
_IMPORT_PREFIX = "foo/bar"
_STRIP_PREFIX = "/%s" % package_name()
proto_library(
name = "import_no_strip_proto",
srcs = ["namespaced_example.proto"],
import_prefix = _IMPORT_PREFIX,
strip_import_prefix = None,
)
proto_library(
name = "import_strip_proto",
srcs = ["namespaced_example.proto"],
import_prefix = _IMPORT_PREFIX,
strip_import_prefix = _STRIP_PREFIX,
)
proto_library(
name = "no_import_no_strip_proto",
srcs = ["namespaced_example.proto"],
import_prefix = None,
strip_import_prefix = None,
)
proto_library(
name = "no_import_strip_proto",
srcs = ["namespaced_example.proto"],
import_prefix = None,
strip_import_prefix = _STRIP_PREFIX,
)
py_proto_library(
name = "import_no_strip_py_pb2",
deps = ["import_no_strip_proto"],
)
py_grpc_library(
name = "import_no_strip_py_pb2_grpc",
srcs = ["import_no_strip_proto"],
deps = ["import_no_strip_py_pb2"],
)
py_proto_library(
name = "import_strip_py_pb2",
deps = ["import_strip_proto"],
)
py_grpc_library(
name = "import_strip_py_pb2_grpc",
srcs = ["import_strip_proto"],
deps = ["import_strip_py_pb2"],
)
py_proto_library(
name = "no_import_no_strip_py_pb2",
deps = ["no_import_no_strip_proto"],
)
py_grpc_library(
name = "no_import_no_strip_py_pb2_grpc",
srcs = ["no_import_no_strip_proto"],
deps = ["no_import_no_strip_py_pb2"],
)
py_proto_library(
name = "no_import_strip_py_pb2",
deps = ["no_import_strip_proto"],
)
py_grpc_library(
name = "no_import_strip_py_pb2_grpc",
srcs = ["no_import_strip_proto"],
deps = ["no_import_strip_py_pb2"],
)
#################
# Namespace Tests
#################
# Most examples with protos have all proto packages rooted at the workspace root. i.e. google/api has
# a directory structure:
# - WORKSPACE
# - /google
# - /api
# - files.proto
#
# But if you can't anchor the protos at the root, you have to use strip and import prefixes. This results
# in the following directory layout for python, which needs to properly be added to the imports.
#
# No Import or Strip (Can't compile if there are any proto dependencies)
# bazel-out/darwin-fastbuild/bin/namespaced/upper/example/namespaced_example_pb2.py
#
# No import Prefix (Can't compile if there are any proto dependencies)
# bazel-out/darwin-fastbuild/bin/namespaced/upper/example/_virtual_imports/namespaced_example_proto/namespaced_example_pb2.py
#
# No strip prefix (Can't compile if there are any proto dependencies)
# bazel-out/darwin-fastbuild/bin/namespaced/upper/example/_virtual_imports/namespaced_example_proto/upper/example/namespaced/upper/example/namespaced_example_pb2.py
#
# Both Import and Strip
# bazel-out/darwin-fastbuild/bin/namespaced/upper/example/_virtual_imports/namespaced_example_proto/upper/example/namespaced_example_pb2.py
py2and3_test(
"import_no_strip_test",
srcs = ["import_no_strip_test.py"],
main = "import_no_strip_test.py",
deps = [
":import_no_strip_py_pb2",
":import_no_strip_py_pb2_grpc",
],
)
py2and3_test(
"import_strip_test",
srcs = ["import_strip_test.py"],
main = "import_strip_test.py",
deps = [
":import_strip_py_pb2",
":import_strip_py_pb2_grpc",
],
)
py2and3_test(
"no_import_no_strip_test",
srcs = ["no_import_no_strip_test.py"],
main = "no_import_no_strip_test.py",
deps = [
":no_import_no_strip_py_pb2",
":no_import_no_strip_py_pb2_grpc",
],
)
py2and3_test(
"no_import_strip_test",
srcs = ["no_import_strip_test.py"],
main = "no_import_strip_test.py",
deps = [
":no_import_strip_py_pb2",
":no_import_strip_py_pb2_grpc",
],
)

@ -0,0 +1,35 @@
# Copyright 2020 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.
import logging
import unittest
class ImportTest(unittest.TestCase):
def test_import(self):
from foo.bar.namespaced.upper.example.namespaced_example_pb2 import NamespacedExample
namespaced_example = NamespacedExample()
namespaced_example.value = "hello"
# Dummy assert, important part is namespaced example was imported.
self.assertEqual(namespaced_example.value, "hello")
def test_grpc(self):
from foo.bar.namespaced.upper.example.namespaced_example_pb2_grpc import NamespacedServiceStub
# No error from import
self.assertEqual(1, 1)
if __name__ == '__main__':
logging.basicConfig()
unittest.main()

@ -0,0 +1,35 @@
# Copyright 2020 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.
import logging
import unittest
class ImportTest(unittest.TestCase):
def test_import(self):
from foo.bar.namespaced_example_pb2 import NamespacedExample
namespaced_example = NamespacedExample()
namespaced_example.value = "hello"
# Dummy assert, important part is namespaced example was imported.
self.assertEqual(namespaced_example.value, "hello")
def test_grpc(self):
from foo.bar.namespaced_example_pb2_grpc import NamespacedServiceStub
# No error from import
self.assertEqual(1, 1)
if __name__ == '__main__':
logging.basicConfig()
unittest.main()

@ -0,0 +1,27 @@
// Copyright 2020 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.
syntax = "proto3";
option java_multiple_files = true;
option java_package = "io.grpc.examples.namespaced";
option java_outer_classname = "NamespacedDependencyProtos";
option objc_class_prefix = "NEP";
package upper.example;
message NamespacedDependency {
int32 value = 1;
}

@ -0,0 +1,38 @@
// Copyright 2020 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.
syntax = "proto3";
option java_multiple_files = true;
option java_package = "io.grpc.examples.namespaced";
option java_outer_classname = "NamespacedExampleProtos";
option objc_class_prefix = "NEP";
package upper.example;
// TODO: dependencies are still broken
// Need to do something like this: https://packaging.python.org/guides/packaging-namespace-packages/
// import "upper/example/namespaced_dependency.proto";
message NamespacedExample {
string value = 1;
// TODO: dependencies are still broken
// NamespacedDependency dependency = 2;
}
service NamespacedService {
rpc SayHello (NamespacedExample) returns (NamespacedExample) {}
}

@ -0,0 +1,35 @@
# Copyright 2020 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.
import logging
import unittest
class ImportTest(unittest.TestCase):
def test_import(self):
from namespaced.upper.example.namespaced_example_pb2 import NamespacedExample
namespaced_example = NamespacedExample()
namespaced_example.value = "hello"
# Dummy assert, important part is namespaced example was imported.
self.assertEqual(namespaced_example.value, "hello")
def test_grpc(self):
from namespaced.upper.example.namespaced_example_pb2_grpc import NamespacedServiceStub
# No error from import
self.assertEqual(1, 1)
if __name__ == '__main__':
logging.basicConfig()
unittest.main()

@ -0,0 +1,35 @@
# Copyright 2020 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.
import logging
import unittest
class ImportTest(unittest.TestCase):
def test_import(self):
from namespaced_example_pb2 import NamespacedExample
namespaced_example = NamespacedExample()
namespaced_example.value = "hello"
# Dummy assert, important part is namespaced example was imported.
self.assertEqual(namespaced_example.value, "hello")
def test_grpc(self):
from namespaced_example_pb2_grpc import NamespacedServiceStub
# No error from import
self.assertEqual(1, 1)
if __name__ == '__main__':
logging.basicConfig()
unittest.main()

@ -349,9 +349,11 @@ libs:
- src/core/lib/profiling/stap_timers.cc
deps:
- absl/time:time
- absl/synchronization:synchronization
- absl/strings:strings
- absl/strings:str_format
- absl/memory:memory
- absl/base:base
secure: false
- name: grpc
build: all
@ -2068,7 +2070,6 @@ libs:
- include/grpcpp/completion_queue.h
- include/grpcpp/completion_queue_impl.h
- include/grpcpp/create_channel.h
- include/grpcpp/create_channel_impl.h
- include/grpcpp/create_channel_posix.h
- include/grpcpp/ext/health_check_service_server_builder_option.h
- include/grpcpp/generic/async_generic_service.h
@ -2152,7 +2153,6 @@ libs:
- include/grpcpp/security/auth_context.h
- include/grpcpp/security/auth_metadata_processor.h
- include/grpcpp/security/credentials.h
- include/grpcpp/security/credentials_impl.h
- include/grpcpp/security/server_credentials.h
- include/grpcpp/security/tls_credentials_options.h
- include/grpcpp/server.h
@ -2453,7 +2453,6 @@ libs:
- include/grpcpp/completion_queue.h
- include/grpcpp/completion_queue_impl.h
- include/grpcpp/create_channel.h
- include/grpcpp/create_channel_impl.h
- include/grpcpp/create_channel_posix.h
- include/grpcpp/ext/health_check_service_server_builder_option.h
- include/grpcpp/generic/async_generic_service.h
@ -2537,7 +2536,6 @@ libs:
- include/grpcpp/security/auth_context.h
- include/grpcpp/security/auth_metadata_processor.h
- include/grpcpp/security/credentials.h
- include/grpcpp/security/credentials_impl.h
- include/grpcpp/security/server_credentials.h
- include/grpcpp/security/tls_credentials_options.h
- include/grpcpp/server.h
@ -7596,7 +7594,6 @@ targets:
- src/proto/grpc/testing/xds/v3/range.proto
- src/proto/grpc/testing/xds/v3/regex.proto
- src/proto/grpc/testing/xds/v3/route.proto
- src/proto/grpc/testing/xds/v3/status.proto
- test/cpp/end2end/test_service_impl.cc
- test/cpp/end2end/xds_end2end_test.cc
deps:

@ -264,4 +264,5 @@ ruby_gem:
- address_sorting
- ares
- boringssl
- re2
- z

@ -549,6 +549,14 @@ if test "$PHP_GRPC" != "no"; then
third_party/abseil-cpp/absl/strings/str_split.cc \
third_party/abseil-cpp/absl/strings/string_view.cc \
third_party/abseil-cpp/absl/strings/substitute.cc \
third_party/abseil-cpp/absl/synchronization/barrier.cc \
third_party/abseil-cpp/absl/synchronization/blocking_counter.cc \
third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.cc \
third_party/abseil-cpp/absl/synchronization/internal/graphcycles.cc \
third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.cc \
third_party/abseil-cpp/absl/synchronization/internal/waiter.cc \
third_party/abseil-cpp/absl/synchronization/mutex.cc \
third_party/abseil-cpp/absl/synchronization/notification.cc \
third_party/abseil-cpp/absl/time/civil_time.cc \
third_party/abseil-cpp/absl/time/clock.cc \
third_party/abseil-cpp/absl/time/duration.cc \
@ -989,6 +997,8 @@ if test "$PHP_GRPC" != "no"; then
PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/strings)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/strings/internal)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/strings/internal/str_format)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/synchronization)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/synchronization/internal)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/time)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/time/internal/cctz/src)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/types)

@ -517,6 +517,14 @@ if (PHP_GRPC != "no") {
"third_party\\abseil-cpp\\absl\\strings\\str_split.cc " +
"third_party\\abseil-cpp\\absl\\strings\\string_view.cc " +
"third_party\\abseil-cpp\\absl\\strings\\substitute.cc " +
"third_party\\abseil-cpp\\absl\\synchronization\\barrier.cc " +
"third_party\\abseil-cpp\\absl\\synchronization\\blocking_counter.cc " +
"third_party\\abseil-cpp\\absl\\synchronization\\internal\\create_thread_identity.cc " +
"third_party\\abseil-cpp\\absl\\synchronization\\internal\\graphcycles.cc " +
"third_party\\abseil-cpp\\absl\\synchronization\\internal\\per_thread_sem.cc " +
"third_party\\abseil-cpp\\absl\\synchronization\\internal\\waiter.cc " +
"third_party\\abseil-cpp\\absl\\synchronization\\mutex.cc " +
"third_party\\abseil-cpp\\absl\\synchronization\\notification.cc " +
"third_party\\abseil-cpp\\absl\\time\\civil_time.cc " +
"third_party\\abseil-cpp\\absl\\time\\clock.cc " +
"third_party\\abseil-cpp\\absl\\time\\duration.cc " +
@ -1037,6 +1045,8 @@ if (PHP_GRPC != "no") {
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\strings");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\strings\\internal");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\strings\\internal\\str_format");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\synchronization");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\synchronization\\internal");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\time");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\time\\internal");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\time\\internal\\cctz");

@ -27,7 +27,9 @@ Clients should accept these arguments:
* --fail_on_failed_rpcs=BOOL
* If true, the client should exit with a non-zero return code if any RPCs
fail. Default is false.
fail after at least one RPC has succeeded, indicating a valid xDS config
was received. This accounts for any startup-related delays in receiving
an initial config from the load balancer. Default is false.
* --num_channels=CHANNELS
* The number of channels to create to the server.
* --qps=QPS

@ -84,7 +84,6 @@ Pod::Spec.new do |s|
'include/grpcpp/completion_queue.h',
'include/grpcpp/completion_queue_impl.h',
'include/grpcpp/create_channel.h',
'include/grpcpp/create_channel_impl.h',
'include/grpcpp/create_channel_posix.h',
'include/grpcpp/ext/health_check_service_server_builder_option.h',
'include/grpcpp/generic/async_generic_service.h',
@ -164,7 +163,6 @@ Pod::Spec.new do |s|
'include/grpcpp/security/auth_context.h',
'include/grpcpp/security/auth_metadata_processor.h',
'include/grpcpp/security/credentials.h',
'include/grpcpp/security/credentials_impl.h',
'include/grpcpp/security/server_credentials.h',
'include/grpcpp/security/tls_credentials_options.h',
'include/grpcpp/server.h',
@ -207,11 +205,13 @@ Pod::Spec.new do |s|
ss.dependency "#{s.name}/Interface", version
ss.dependency 'gRPC-Core', version
abseil_version = '1.20200225.0'
ss.dependency 'abseil/base/base', abseil_version
ss.dependency 'abseil/container/inlined_vector', abseil_version
ss.dependency 'abseil/memory/memory', abseil_version
ss.dependency 'abseil/status/status', abseil_version
ss.dependency 'abseil/strings/str_format', abseil_version
ss.dependency 'abseil/strings/strings', abseil_version
ss.dependency 'abseil/synchronization/synchronization', abseil_version
ss.dependency 'abseil/time/time', abseil_version
ss.dependency 'abseil/types/optional', abseil_version

@ -174,11 +174,13 @@ Pod::Spec.new do |s|
ss.dependency "#{s.name}/Interface", version
ss.dependency 'BoringSSL-GRPC', '0.0.11'
abseil_version = '1.20200225.0'
ss.dependency 'abseil/base/base', abseil_version
ss.dependency 'abseil/container/inlined_vector', abseil_version
ss.dependency 'abseil/memory/memory', abseil_version
ss.dependency 'abseil/status/status', abseil_version
ss.dependency 'abseil/strings/str_format', abseil_version
ss.dependency 'abseil/strings/strings', abseil_version
ss.dependency 'abseil/synchronization/synchronization', abseil_version
ss.dependency 'abseil/time/time', abseil_version
ss.dependency 'abseil/types/optional', abseil_version
ss.compiler_flags = '-DBORINGSSL_PREFIX=GRPC -Wno-unreachable-code -Wno-shorten-64-to-32'

@ -1104,6 +1104,24 @@ Gem::Specification.new do |s|
s.files += %w( third_party/abseil-cpp/absl/strings/strip.h )
s.files += %w( third_party/abseil-cpp/absl/strings/substitute.cc )
s.files += %w( third_party/abseil-cpp/absl/strings/substitute.h )
s.files += %w( third_party/abseil-cpp/absl/synchronization/barrier.cc )
s.files += %w( third_party/abseil-cpp/absl/synchronization/barrier.h )
s.files += %w( third_party/abseil-cpp/absl/synchronization/blocking_counter.cc )
s.files += %w( third_party/abseil-cpp/absl/synchronization/blocking_counter.h )
s.files += %w( third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.cc )
s.files += %w( third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.h )
s.files += %w( third_party/abseil-cpp/absl/synchronization/internal/graphcycles.cc )
s.files += %w( third_party/abseil-cpp/absl/synchronization/internal/graphcycles.h )
s.files += %w( third_party/abseil-cpp/absl/synchronization/internal/kernel_timeout.h )
s.files += %w( third_party/abseil-cpp/absl/synchronization/internal/mutex_nonprod.inc )
s.files += %w( third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.cc )
s.files += %w( third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.h )
s.files += %w( third_party/abseil-cpp/absl/synchronization/internal/waiter.cc )
s.files += %w( third_party/abseil-cpp/absl/synchronization/internal/waiter.h )
s.files += %w( third_party/abseil-cpp/absl/synchronization/mutex.cc )
s.files += %w( third_party/abseil-cpp/absl/synchronization/mutex.h )
s.files += %w( third_party/abseil-cpp/absl/synchronization/notification.cc )
s.files += %w( third_party/abseil-cpp/absl/synchronization/notification.h )
s.files += %w( third_party/abseil-cpp/absl/time/civil_time.cc )
s.files += %w( third_party/abseil-cpp/absl/time/civil_time.h )
s.files += %w( third_party/abseil-cpp/absl/time/clock.cc )
@ -1690,6 +1708,55 @@ Gem::Specification.new do |s|
s.files += %w( third_party/cares/config_freebsd/ares_config.h )
s.files += %w( third_party/cares/config_linux/ares_config.h )
s.files += %w( third_party/cares/config_openbsd/ares_config.h )
s.files += %w( third_party/re2/re2/bitmap256.h )
s.files += %w( third_party/re2/re2/bitstate.cc )
s.files += %w( third_party/re2/re2/compile.cc )
s.files += %w( third_party/re2/re2/dfa.cc )
s.files += %w( third_party/re2/re2/filtered_re2.cc )
s.files += %w( third_party/re2/re2/filtered_re2.h )
s.files += %w( third_party/re2/re2/mimics_pcre.cc )
s.files += %w( third_party/re2/re2/nfa.cc )
s.files += %w( third_party/re2/re2/onepass.cc )
s.files += %w( third_party/re2/re2/parse.cc )
s.files += %w( third_party/re2/re2/perl_groups.cc )
s.files += %w( third_party/re2/re2/pod_array.h )
s.files += %w( third_party/re2/re2/prefilter.cc )
s.files += %w( third_party/re2/re2/prefilter.h )
s.files += %w( third_party/re2/re2/prefilter_tree.cc )
s.files += %w( third_party/re2/re2/prefilter_tree.h )
s.files += %w( third_party/re2/re2/prog.cc )
s.files += %w( third_party/re2/re2/prog.h )
s.files += %w( third_party/re2/re2/re2.cc )
s.files += %w( third_party/re2/re2/re2.h )
s.files += %w( third_party/re2/re2/regexp.cc )
s.files += %w( third_party/re2/re2/regexp.h )
s.files += %w( third_party/re2/re2/set.cc )
s.files += %w( third_party/re2/re2/set.h )
s.files += %w( third_party/re2/re2/simplify.cc )
s.files += %w( third_party/re2/re2/sparse_array.h )
s.files += %w( third_party/re2/re2/sparse_set.h )
s.files += %w( third_party/re2/re2/stringpiece.cc )
s.files += %w( third_party/re2/re2/stringpiece.h )
s.files += %w( third_party/re2/re2/tostring.cc )
s.files += %w( third_party/re2/re2/unicode_casefold.cc )
s.files += %w( third_party/re2/re2/unicode_casefold.h )
s.files += %w( third_party/re2/re2/unicode_groups.cc )
s.files += %w( third_party/re2/re2/unicode_groups.h )
s.files += %w( third_party/re2/re2/walker-inl.h )
s.files += %w( third_party/re2/util/benchmark.h )
s.files += %w( third_party/re2/util/flags.h )
s.files += %w( third_party/re2/util/logging.h )
s.files += %w( third_party/re2/util/malloc_counter.h )
s.files += %w( third_party/re2/util/mix.h )
s.files += %w( third_party/re2/util/mutex.h )
s.files += %w( third_party/re2/util/pcre.cc )
s.files += %w( third_party/re2/util/pcre.h )
s.files += %w( third_party/re2/util/rune.cc )
s.files += %w( third_party/re2/util/strutil.cc )
s.files += %w( third_party/re2/util/strutil.h )
s.files += %w( third_party/re2/util/test.h )
s.files += %w( third_party/re2/util/utf.h )
s.files += %w( third_party/re2/util/util.h )
s.files += %w( third_party/upb/upb/decode.c )
s.files += %w( third_party/upb/upb/decode.h )
s.files += %w( third_party/upb/upb/encode.c )

@ -375,9 +375,11 @@
'type': 'static_library',
'dependencies': [
'absl/time:time',
'absl/synchronization:synchronization',
'absl/strings:strings',
'absl/strings:str_format',
'absl/memory:memory',
'absl/base:base',
],
'sources': [
'src/core/lib/gpr/alloc.cc',

@ -31,7 +31,7 @@
* Defines GPR_ABSEIL_SYNC to use synchronization features from Abseil
*/
#ifndef GPR_ABSEIL_SYNC
/* #define GPR_ABSEIL_SYNC 1 */
#define GPR_ABSEIL_SYNC 1
#endif
/* Get windows.h included everywhere (we need it) */

@ -1,6 +1,6 @@
/*
*
* Copyright 2019 gRPC authors.
* 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.
@ -19,36 +19,59 @@
#ifndef GRPCPP_CREATE_CHANNEL_H
#define GRPCPP_CREATE_CHANNEL_H
#include <grpcpp/create_channel_impl.h>
#include <memory>
#include <grpcpp/channel.h>
#include <grpcpp/impl/codegen/client_interceptor.h>
#include <grpcpp/security/credentials.h>
#include <grpcpp/support/channel_arguments.h>
#include <grpcpp/support/config.h>
namespace grpc {
/// Create a new \a Channel pointing to \a target.
///
/// \param target The URI of the endpoint to connect to.
/// \param creds Credentials to use for the created channel. If it does not
/// hold an object or is invalid, a lame channel (one on which all operations
/// fail) is returned.
std::shared_ptr<Channel> CreateChannel(
const grpc::string& target,
const std::shared_ptr<ChannelCredentials>& creds);
static inline std::shared_ptr<::grpc::Channel> CreateChannel(
const std::string& target,
const std::shared_ptr<ChannelCredentials>& creds) {
return ::grpc_impl::CreateChannelImpl(target, creds);
}
static inline std::shared_ptr<::grpc::Channel> CreateCustomChannel(
const std::string& target, const std::shared_ptr<ChannelCredentials>& creds,
const ChannelArguments& args) {
return ::grpc_impl::CreateCustomChannelImpl(target, creds, args);
}
/// Create a new \em custom \a Channel pointing to \a target.
///
/// \warning For advanced use and testing ONLY. Override default channel
/// arguments only if necessary.
///
/// \param target The URI of the endpoint to connect to.
/// \param creds Credentials to use for the created channel. If it does not
/// hold an object or is invalid, a lame channel (one on which all operations
/// fail) is returned.
/// \param args Options for channel creation.
std::shared_ptr<Channel> CreateCustomChannel(
const grpc::string& target,
const std::shared_ptr<ChannelCredentials>& creds,
const ChannelArguments& args);
namespace experimental {
static inline std::shared_ptr<::grpc::Channel>
CreateCustomChannelWithInterceptors(
const std::string& target, const std::shared_ptr<ChannelCredentials>& creds,
/// Create a new \em custom \a Channel pointing to \a target with \a
/// interceptors being invoked per call.
///
/// \warning For advanced use and testing ONLY. Override default channel
/// arguments only if necessary.
///
/// \param target The URI of the endpoint to connect to.
/// \param creds Credentials to use for the created channel. If it does not
/// hold an object or is invalid, a lame channel (one on which all operations
/// fail) is returned.
/// \param args Options for channel creation.
std::shared_ptr<Channel> CreateCustomChannelWithInterceptors(
const grpc::string& target,
const std::shared_ptr<ChannelCredentials>& creds,
const ChannelArguments& args,
std::vector<
std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>
interceptor_creators) {
return ::grpc_impl::experimental::CreateCustomChannelWithInterceptors(
target, creds, args, std::move(interceptor_creators));
}
interceptor_creators);
} // namespace experimental
} // namespace grpc

@ -1,78 +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.
*
*/
#ifndef GRPCPP_CREATE_CHANNEL_IMPL_H
#define GRPCPP_CREATE_CHANNEL_IMPL_H
#include <memory>
#include <grpcpp/channel.h>
#include <grpcpp/impl/codegen/client_interceptor.h>
#include <grpcpp/security/credentials.h>
#include <grpcpp/support/channel_arguments.h>
#include <grpcpp/support/config.h>
namespace grpc_impl {
/// Create a new \a Channel pointing to \a target.
///
/// \param target The URI of the endpoint to connect to.
/// \param creds Credentials to use for the created channel. If it does not
/// hold an object or is invalid, a lame channel (one on which all operations
/// fail) is returned.
std::shared_ptr<::grpc::Channel> CreateChannelImpl(
const std::string& target,
const std::shared_ptr<::grpc::ChannelCredentials>& creds);
/// Create a new \em custom \a Channel pointing to \a target.
///
/// \warning For advanced use and testing ONLY. Override default channel
/// arguments only if necessary.
///
/// \param target The URI of the endpoint to connect to.
/// \param creds Credentials to use for the created channel. If it does not
/// hold an object or is invalid, a lame channel (one on which all operations
/// fail) is returned.
/// \param args Options for channel creation.
std::shared_ptr<::grpc::Channel> CreateCustomChannelImpl(
const std::string& target,
const std::shared_ptr<::grpc::ChannelCredentials>& creds,
const ::grpc::ChannelArguments& args);
namespace experimental {
/// Create a new \em custom \a Channel pointing to \a target with \a
/// interceptors being invoked per call.
///
/// \warning For advanced use and testing ONLY. Override default channel
/// arguments only if necessary.
///
/// \param target The URI of the endpoint to connect to.
/// \param creds Credentials to use for the created channel. If it does not
/// hold an object or is invalid, a lame channel (one on which all operations
/// fail) is returned.
/// \param args Options for channel creation.
std::shared_ptr<::grpc::Channel> CreateCustomChannelWithInterceptors(
const std::string& target,
const std::shared_ptr<grpc::ChannelCredentials>& creds,
const ::grpc::ChannelArguments& args,
std::vector<
std::unique_ptr<grpc::experimental::ClientInterceptorFactoryInterface>>
interceptor_creators);
} // namespace experimental
} // namespace grpc_impl
#endif // GRPCPP_CREATE_CHANNEL_IMPL_H

@ -58,6 +58,7 @@ struct grpc_call;
namespace grpc {
class CallCredentials;
class ChannelInterface;
namespace internal {
@ -88,7 +89,6 @@ class ClientCallbackUnaryImpl;
class ClientContextAccessor;
} // namespace internal
class CallCredentials;
class Channel;
class CompletionQueue;
class ServerContext;
@ -318,16 +318,15 @@ class ClientContext {
///
/// It is legal to call this only before initial metadata is sent.
///
/// \see https://grpc.io/docs/guides/auth
void set_credentials(
const std::shared_ptr<grpc_impl::CallCredentials>& creds);
/// \see https://grpc.io/docs/guides/auth.html
void set_credentials(const std::shared_ptr<grpc::CallCredentials>& creds);
/// EXPERIMENTAL debugging API
///
/// Returns the credentials for the client call. This should be used only in
/// tests and for diagnostic purposes, and should not be used by application
/// logic.
std::shared_ptr<grpc_impl::CallCredentials> credentials() { return creds_; }
std::shared_ptr<grpc::CallCredentials> credentials() { return creds_; }
/// Return the compression algorithm the client call will request be used.
/// Note that the gRPC runtime may decide to ignore this request, for example,
@ -494,8 +493,8 @@ class ClientContext {
grpc_call* call_;
bool call_canceled_;
gpr_timespec deadline_;
std::string authority_;
std::shared_ptr<grpc_impl::CallCredentials> creds_;
grpc::string authority_;
std::shared_ptr<grpc::CallCredentials> creds_;
mutable std::shared_ptr<const grpc::AuthContext> auth_context_;
struct census_context* census_context_;
std::multimap<std::string, std::string> send_initial_metadata_;

@ -19,123 +19,301 @@
#ifndef GRPCPP_SECURITY_CREDENTIALS_H
#define GRPCPP_SECURITY_CREDENTIALS_H
#include <grpcpp/security/credentials_impl.h>
#include <map>
#include <memory>
#include <vector>
#include <grpc/grpc_security_constants.h>
#include <grpcpp/channel.h>
#include <grpcpp/impl/codegen/client_interceptor.h>
#include <grpcpp/impl/codegen/grpc_library.h>
#include <grpcpp/security/auth_context.h>
#include <grpcpp/security/tls_credentials_options.h>
#include <grpcpp/support/channel_arguments.h>
#include <grpcpp/support/status.h>
#include <grpcpp/support/string_ref.h>
struct grpc_call;
namespace grpc {
class CallCredentials;
class SecureCallCredentials;
class SecureChannelCredentials;
class ChannelCredentials;
typedef ::grpc_impl::ChannelCredentials ChannelCredentials;
typedef ::grpc_impl::CallCredentials CallCredentials;
typedef ::grpc_impl::SslCredentialsOptions SslCredentialsOptions;
typedef ::grpc_impl::SecureCallCredentials SecureCallCredentials;
typedef ::grpc_impl::SecureChannelCredentials SecureChannelCredentials;
typedef ::grpc_impl::MetadataCredentialsPlugin MetadataCredentialsPlugin;
std::shared_ptr<Channel> CreateCustomChannel(
const grpc::string& target,
const std::shared_ptr<grpc::ChannelCredentials>& creds,
const grpc::ChannelArguments& args);
static inline std::shared_ptr<grpc_impl::ChannelCredentials>
GoogleDefaultCredentials() {
return ::grpc_impl::GoogleDefaultCredentials();
namespace experimental {
std::shared_ptr<grpc::Channel> CreateCustomChannelWithInterceptors(
const grpc::string& target,
const std::shared_ptr<grpc::ChannelCredentials>& creds,
const grpc::ChannelArguments& args,
std::vector<
std::unique_ptr<grpc::experimental::ClientInterceptorFactoryInterface>>
interceptor_creators);
}
static inline std::shared_ptr<ChannelCredentials> SslCredentials(
const SslCredentialsOptions& options) {
return ::grpc_impl::SslCredentials(options);
}
/// A channel credentials object encapsulates all the state needed by a client
/// to authenticate with a server for a given channel.
/// It can make various assertions, e.g., about the client’s identity, role
/// for all the calls on that channel.
///
/// \see https://grpc.io/docs/guides/auth.html
class ChannelCredentials : private grpc::GrpcLibraryCodegen {
public:
ChannelCredentials();
~ChannelCredentials();
static inline std::shared_ptr<grpc_impl::CallCredentials>
GoogleComputeEngineCredentials() {
return ::grpc_impl::GoogleComputeEngineCredentials();
}
protected:
friend std::shared_ptr<ChannelCredentials> CompositeChannelCredentials(
const std::shared_ptr<ChannelCredentials>& channel_creds,
const std::shared_ptr<CallCredentials>& call_creds);
/// Constant for maximum auth token lifetime.
constexpr long kMaxAuthTokenLifetimeSecs =
::grpc_impl::kMaxAuthTokenLifetimeSecs;
virtual SecureChannelCredentials* AsSecureCredentials() = 0;
static inline std::shared_ptr<grpc_impl::CallCredentials>
ServiceAccountJWTAccessCredentials(
const std::string& json_key,
long token_lifetime_seconds = grpc::kMaxAuthTokenLifetimeSecs) {
return ::grpc_impl::ServiceAccountJWTAccessCredentials(
json_key, token_lifetime_seconds);
}
private:
friend std::shared_ptr<grpc::Channel> CreateCustomChannel(
const grpc::string& target,
const std::shared_ptr<grpc::ChannelCredentials>& creds,
const grpc::ChannelArguments& args);
static inline std::shared_ptr<grpc_impl::CallCredentials>
GoogleRefreshTokenCredentials(const std::string& json_refresh_token) {
return ::grpc_impl::GoogleRefreshTokenCredentials(json_refresh_token);
}
friend std::shared_ptr<grpc::Channel>
grpc::experimental::CreateCustomChannelWithInterceptors(
const grpc::string& target,
const std::shared_ptr<grpc::ChannelCredentials>& creds,
const grpc::ChannelArguments& args,
std::vector<std::unique_ptr<
grpc::experimental::ClientInterceptorFactoryInterface>>
interceptor_creators);
static inline std::shared_ptr<grpc_impl::CallCredentials>
AccessTokenCredentials(const std::string& access_token) {
return ::grpc_impl::AccessTokenCredentials(access_token);
}
virtual std::shared_ptr<Channel> CreateChannelImpl(
const grpc::string& target, const ChannelArguments& args) = 0;
static inline std::shared_ptr<grpc_impl::CallCredentials> GoogleIAMCredentials(
const std::string& authorization_token,
const std::string& authority_selector) {
return ::grpc_impl::GoogleIAMCredentials(authorization_token,
authority_selector);
}
// This function should have been a pure virtual function, but it is
// implemented as a virtual function so that it does not break API.
virtual std::shared_ptr<Channel> CreateChannelWithInterceptors(
const grpc::string& /*target*/, const ChannelArguments& /*args*/,
std::vector<std::unique_ptr<
grpc::experimental::ClientInterceptorFactoryInterface>>
/*interceptor_creators*/) {
return nullptr;
}
};
/// A call credentials object encapsulates the state needed by a client to
/// authenticate with a server for a given call on a channel.
///
/// \see https://grpc.io/docs/guides/auth.html
class CallCredentials : private grpc::GrpcLibraryCodegen {
public:
CallCredentials();
~CallCredentials();
/// Apply this instance's credentials to \a call.
virtual bool ApplyToCall(grpc_call* call) = 0;
virtual grpc::string DebugString() {
return "CallCredentials did not provide a debug string";
}
protected:
friend std::shared_ptr<ChannelCredentials> CompositeChannelCredentials(
const std::shared_ptr<ChannelCredentials>& channel_creds,
const std::shared_ptr<CallCredentials>& call_creds);
friend std::shared_ptr<CallCredentials> CompositeCallCredentials(
const std::shared_ptr<CallCredentials>& creds1,
const std::shared_ptr<CallCredentials>& creds2);
virtual SecureCallCredentials* AsSecureCredentials() = 0;
};
/// Options used to build SslCredentials.
struct SslCredentialsOptions {
/// The buffer containing the PEM encoding of the server root certificates. If
/// this parameter is empty, the default roots will be used. The default
/// roots can be overridden using the \a GRPC_DEFAULT_SSL_ROOTS_FILE_PATH
/// environment variable pointing to a file on the file system containing the
/// roots.
grpc::string pem_root_certs;
/// The buffer containing the PEM encoding of the client's private key. This
/// parameter can be empty if the client does not have a private key.
grpc::string pem_private_key;
/// The buffer containing the PEM encoding of the client's certificate chain.
/// This parameter can be empty if the client does not have a certificate
/// chain.
grpc::string pem_cert_chain;
};
// Factories for building different types of Credentials The functions may
// return empty shared_ptr when credentials cannot be created. If a
// Credentials pointer is returned, it can still be invalid when used to create
// a channel. A lame channel will be created then and all rpcs will fail on it.
/// Builds credentials with reasonable defaults.
///
/// \warning Only use these credentials when connecting to a Google endpoint.
/// Using these credentials to connect to any other service may result in this
/// service being able to impersonate your client for requests to Google
/// services.
std::shared_ptr<ChannelCredentials> GoogleDefaultCredentials();
/// Builds SSL Credentials given SSL specific options
std::shared_ptr<ChannelCredentials> SslCredentials(
const SslCredentialsOptions& options);
/// Builds credentials for use when running in GCE
///
/// \warning Only use these credentials when connecting to a Google endpoint.
/// Using these credentials to connect to any other service may result in this
/// service being able to impersonate your client for requests to Google
/// services.
std::shared_ptr<CallCredentials> GoogleComputeEngineCredentials();
static inline std::shared_ptr<ChannelCredentials> CompositeChannelCredentials(
constexpr long kMaxAuthTokenLifetimeSecs = 3600;
/// Builds Service Account JWT Access credentials.
/// json_key is the JSON key string containing the client's private key.
/// token_lifetime_seconds is the lifetime in seconds of each Json Web Token
/// (JWT) created with this credentials. It should not exceed
/// \a kMaxAuthTokenLifetimeSecs or will be cropped to this value.
std::shared_ptr<CallCredentials> ServiceAccountJWTAccessCredentials(
const grpc::string& json_key,
long token_lifetime_seconds = kMaxAuthTokenLifetimeSecs);
/// Builds refresh token credentials.
/// json_refresh_token is the JSON string containing the refresh token along
/// with a client_id and client_secret.
///
/// \warning Only use these credentials when connecting to a Google endpoint.
/// Using these credentials to connect to any other service may result in this
/// service being able to impersonate your client for requests to Google
/// services.
std::shared_ptr<CallCredentials> GoogleRefreshTokenCredentials(
const grpc::string& json_refresh_token);
/// Builds access token credentials.
/// access_token is an oauth2 access token that was fetched using an out of band
/// mechanism.
///
/// \warning Only use these credentials when connecting to a Google endpoint.
/// Using these credentials to connect to any other service may result in this
/// service being able to impersonate your client for requests to Google
/// services.
std::shared_ptr<CallCredentials> AccessTokenCredentials(
const grpc::string& access_token);
/// Builds IAM credentials.
///
/// \warning Only use these credentials when connecting to a Google endpoint.
/// Using these credentials to connect to any other service may result in this
/// service being able to impersonate your client for requests to Google
/// services.
std::shared_ptr<CallCredentials> GoogleIAMCredentials(
const grpc::string& authorization_token,
const grpc::string& authority_selector);
/// Combines a channel credentials and a call credentials into a composite
/// channel credentials.
std::shared_ptr<ChannelCredentials> CompositeChannelCredentials(
const std::shared_ptr<ChannelCredentials>& channel_creds,
const std::shared_ptr<CallCredentials>& call_creds) {
return ::grpc_impl::CompositeChannelCredentials(channel_creds, call_creds);
}
const std::shared_ptr<CallCredentials>& call_creds);
static inline std::shared_ptr<grpc_impl::CallCredentials>
CompositeCallCredentials(const std::shared_ptr<CallCredentials>& creds1,
const std::shared_ptr<CallCredentials>& creds2) {
return ::grpc_impl::CompositeCallCredentials(creds1, creds2);
}
/// Combines two call credentials objects into a composite call credentials.
std::shared_ptr<CallCredentials> CompositeCallCredentials(
const std::shared_ptr<CallCredentials>& creds1,
const std::shared_ptr<CallCredentials>& creds2);
static inline std::shared_ptr<grpc_impl::ChannelCredentials>
InsecureChannelCredentials() {
return ::grpc_impl::InsecureChannelCredentials();
}
/// Credentials for an unencrypted, unauthenticated channel
std::shared_ptr<ChannelCredentials> InsecureChannelCredentials();
typedef ::grpc_impl::MetadataCredentialsPlugin MetadataCredentialsPlugin;
/// User defined metadata credentials.
class MetadataCredentialsPlugin {
public:
virtual ~MetadataCredentialsPlugin() {}
static inline std::shared_ptr<grpc_impl::CallCredentials>
MetadataCredentialsFromPlugin(
std::unique_ptr<MetadataCredentialsPlugin> plugin) {
return ::grpc_impl::MetadataCredentialsFromPlugin(std::move(plugin));
}
/// If this method returns true, the Process function will be scheduled in
/// a different thread from the one processing the call.
virtual bool IsBlocking() const { return true; }
/// Type of credentials this plugin is implementing.
virtual const char* GetType() const { return ""; }
/// Gets the auth metatada produced by this plugin.
/// The fully qualified method name is:
/// service_url + "/" + method_name.
/// The channel_auth_context contains (among other things), the identity of
/// the server.
virtual grpc::Status GetMetadata(
grpc::string_ref service_url, grpc::string_ref method_name,
const grpc::AuthContext& channel_auth_context,
std::multimap<grpc::string, grpc::string>* metadata) = 0;
virtual grpc::string DebugString() {
return "MetadataCredentialsPlugin did not provide a debug string";
}
};
std::shared_ptr<CallCredentials> MetadataCredentialsFromPlugin(
std::unique_ptr<MetadataCredentialsPlugin> plugin);
namespace experimental {
typedef ::grpc_impl::experimental::StsCredentialsOptions StsCredentialsOptions;
/// Options for creating STS Oauth Token Exchange credentials following the IETF
/// draft https://tools.ietf.org/html/draft-ietf-oauth-token-exchange-16.
/// Optional fields may be set to empty string. It is the responsibility of the
/// caller to ensure that the subject and actor tokens are refreshed on disk at
/// the specified paths.
struct StsCredentialsOptions {
grpc::string token_exchange_service_uri; // Required.
grpc::string resource; // Optional.
grpc::string audience; // Optional.
grpc::string scope; // Optional.
grpc::string requested_token_type; // Optional.
grpc::string subject_token_path; // Required.
grpc::string subject_token_type; // Required.
grpc::string actor_token_path; // Optional.
grpc::string actor_token_type; // Optional.
};
static inline grpc::Status StsCredentialsOptionsFromJson(
const std::string& json_string, StsCredentialsOptions* options) {
return ::grpc_impl::experimental::StsCredentialsOptionsFromJson(json_string,
options);
}
grpc::Status StsCredentialsOptionsFromJson(const std::string& json_string,
StsCredentialsOptions* options);
static inline grpc::Status StsCredentialsOptionsFromEnv(
StsCredentialsOptions* options) {
return grpc_impl::experimental::StsCredentialsOptionsFromEnv(options);
}
/// Creates STS credentials options from the $STS_CREDENTIALS environment
/// variable. This environment variable points to the path of a JSON file
/// comforming to the schema described above.
grpc::Status StsCredentialsOptionsFromEnv(StsCredentialsOptions* options);
static inline std::shared_ptr<grpc_impl::CallCredentials> StsCredentials(
const StsCredentialsOptions& options) {
return grpc_impl::experimental::StsCredentials(options);
}
std::shared_ptr<CallCredentials> StsCredentials(
const StsCredentialsOptions& options);
typedef ::grpc_impl::experimental::AltsCredentialsOptions
AltsCredentialsOptions;
std::shared_ptr<CallCredentials> MetadataCredentialsFromPlugin(
std::unique_ptr<MetadataCredentialsPlugin> plugin,
grpc_security_level min_security_level);
static inline std::shared_ptr<grpc_impl::ChannelCredentials> AltsCredentials(
const AltsCredentialsOptions& options) {
return ::grpc_impl::experimental::AltsCredentials(options);
}
/// Options used to build AltsCredentials.
struct AltsCredentialsOptions {
/// service accounts of target endpoint that will be acceptable
/// by the client. If service accounts are provided and none of them matches
/// that of the server, authentication will fail.
std::vector<grpc::string> target_service_accounts;
};
static inline std::shared_ptr<grpc_impl::ChannelCredentials> LocalCredentials(
grpc_local_connect_type type) {
return ::grpc_impl::experimental::LocalCredentials(type);
}
/// Builds ALTS Credentials given ALTS specific options
std::shared_ptr<ChannelCredentials> AltsCredentials(
const AltsCredentialsOptions& options);
static inline std::shared_ptr<grpc_impl::ChannelCredentials> TlsCredentials(
const ::grpc_impl::experimental::TlsCredentialsOptions& options) {
return ::grpc_impl::experimental::TlsCredentials(options);
}
/// Builds Local Credentials.
std::shared_ptr<ChannelCredentials> LocalCredentials(
grpc_local_connect_type type);
/// Builds TLS Credentials given TLS options.
std::shared_ptr<ChannelCredentials> TlsCredentials(
const TlsCredentialsOptions& options);
} // namespace experimental
} // namespace grpc

@ -1,356 +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.
*
*/
#ifndef GRPCPP_SECURITY_CREDENTIALS_IMPL_H
#define GRPCPP_SECURITY_CREDENTIALS_IMPL_H
#include <map>
#include <memory>
#include <vector>
#include <grpc/grpc_security_constants.h>
#include <grpcpp/channel_impl.h>
#include <grpcpp/impl/codegen/client_interceptor.h>
#include <grpcpp/impl/codegen/grpc_library.h>
#include <grpcpp/security/auth_context.h>
#include <grpcpp/security/tls_credentials_options.h>
#include <grpcpp/support/channel_arguments_impl.h>
#include <grpcpp/support/status.h>
#include <grpcpp/support/string_ref.h>
struct grpc_call;
namespace grpc_impl {
class ChannelCredentials;
class CallCredentials;
class SecureCallCredentials;
class SecureChannelCredentials;
std::shared_ptr<Channel> CreateCustomChannelImpl(
const std::string& target, const std::shared_ptr<ChannelCredentials>& creds,
const ChannelArguments& args);
namespace experimental {
std::shared_ptr<Channel> CreateCustomChannelWithInterceptors(
const std::string& target, const std::shared_ptr<ChannelCredentials>& creds,
const ChannelArguments& args,
std::vector<
std::unique_ptr<grpc::experimental::ClientInterceptorFactoryInterface>>
interceptor_creators);
}
/// A channel credentials object encapsulates all the state needed by a client
/// to authenticate with a server for a given channel.
/// It can make various assertions, e.g., about the client’s identity, role
/// for all the calls on that channel.
///
/// \see https://grpc.io/docs/guides/auth
class ChannelCredentials : private grpc::GrpcLibraryCodegen {
public:
ChannelCredentials();
~ChannelCredentials();
protected:
friend std::shared_ptr<ChannelCredentials> CompositeChannelCredentials(
const std::shared_ptr<ChannelCredentials>& channel_creds,
const std::shared_ptr<CallCredentials>& call_creds);
virtual SecureChannelCredentials* AsSecureCredentials() = 0;
private:
friend std::shared_ptr<Channel> CreateCustomChannelImpl(
const std::string& target,
const std::shared_ptr<ChannelCredentials>& creds,
const ChannelArguments& args);
friend std::shared_ptr<Channel>
grpc_impl::experimental::CreateCustomChannelWithInterceptors(
const std::string& target,
const std::shared_ptr<ChannelCredentials>& creds,
const ChannelArguments& args,
std::vector<std::unique_ptr<
grpc::experimental::ClientInterceptorFactoryInterface>>
interceptor_creators);
virtual std::shared_ptr<Channel> CreateChannelImpl(
const std::string& target, const ChannelArguments& args) = 0;
// This function should have been a pure virtual function, but it is
// implemented as a virtual function so that it does not break API.
virtual std::shared_ptr<Channel> CreateChannelWithInterceptors(
const std::string& /*target*/, const ChannelArguments& /*args*/,
std::vector<std::unique_ptr<
grpc::experimental::ClientInterceptorFactoryInterface>>
/*interceptor_creators*/) {
return nullptr;
}
};
/// A call credentials object encapsulates the state needed by a client to
/// authenticate with a server for a given call on a channel.
///
/// \see https://grpc.io/docs/guides/auth
class CallCredentials : private grpc::GrpcLibraryCodegen {
public:
CallCredentials();
~CallCredentials();
/// Apply this instance's credentials to \a call.
virtual bool ApplyToCall(grpc_call* call) = 0;
virtual std::string DebugString() {
return "CallCredentials did not provide a debug string";
}
protected:
friend std::shared_ptr<ChannelCredentials> CompositeChannelCredentials(
const std::shared_ptr<ChannelCredentials>& channel_creds,
const std::shared_ptr<CallCredentials>& call_creds);
friend std::shared_ptr<CallCredentials> CompositeCallCredentials(
const std::shared_ptr<CallCredentials>& creds1,
const std::shared_ptr<CallCredentials>& creds2);
virtual SecureCallCredentials* AsSecureCredentials() = 0;
};
/// Options used to build SslCredentials.
struct SslCredentialsOptions {
/// The buffer containing the PEM encoding of the server root certificates. If
/// this parameter is empty, the default roots will be used. The default
/// roots can be overridden using the \a GRPC_DEFAULT_SSL_ROOTS_FILE_PATH
/// environment variable pointing to a file on the file system containing the
/// roots.
std::string pem_root_certs;
/// The buffer containing the PEM encoding of the client's private key. This
/// parameter can be empty if the client does not have a private key.
std::string pem_private_key;
/// The buffer containing the PEM encoding of the client's certificate chain.
/// This parameter can be empty if the client does not have a certificate
/// chain.
std::string pem_cert_chain;
};
// Factories for building different types of Credentials The functions may
// return empty shared_ptr when credentials cannot be created. If a
// Credentials pointer is returned, it can still be invalid when used to create
// a channel. A lame channel will be created then and all rpcs will fail on it.
/// Builds credentials with reasonable defaults.
///
/// \warning Only use these credentials when connecting to a Google endpoint.
/// Using these credentials to connect to any other service may result in this
/// service being able to impersonate your client for requests to Google
/// services.
std::shared_ptr<ChannelCredentials> GoogleDefaultCredentials();
/// Builds SSL Credentials given SSL specific options
std::shared_ptr<ChannelCredentials> SslCredentials(
const SslCredentialsOptions& options);
/// Builds credentials for use when running in GCE
///
/// \warning Only use these credentials when connecting to a Google endpoint.
/// Using these credentials to connect to any other service may result in this
/// service being able to impersonate your client for requests to Google
/// services.
std::shared_ptr<CallCredentials> GoogleComputeEngineCredentials();
constexpr long kMaxAuthTokenLifetimeSecs = 3600;
/// Builds Service Account JWT Access credentials.
/// json_key is the JSON key string containing the client's private key.
/// token_lifetime_seconds is the lifetime in seconds of each Json Web Token
/// (JWT) created with this credentials. It should not exceed
/// \a kMaxAuthTokenLifetimeSecs or will be cropped to this value.
std::shared_ptr<CallCredentials> ServiceAccountJWTAccessCredentials(
const std::string& json_key,
long token_lifetime_seconds = grpc_impl::kMaxAuthTokenLifetimeSecs);
/// Builds refresh token credentials.
/// json_refresh_token is the JSON string containing the refresh token along
/// with a client_id and client_secret.
///
/// \warning Only use these credentials when connecting to a Google endpoint.
/// Using these credentials to connect to any other service may result in this
/// service being able to impersonate your client for requests to Google
/// services.
std::shared_ptr<CallCredentials> GoogleRefreshTokenCredentials(
const std::string& json_refresh_token);
/// Builds access token credentials.
/// access_token is an oauth2 access token that was fetched using an out of band
/// mechanism.
///
/// \warning Only use these credentials when connecting to a Google endpoint.
/// Using these credentials to connect to any other service may result in this
/// service being able to impersonate your client for requests to Google
/// services.
std::shared_ptr<CallCredentials> AccessTokenCredentials(
const std::string& access_token);
/// Builds IAM credentials.
///
/// \warning Only use these credentials when connecting to a Google endpoint.
/// Using these credentials to connect to any other service may result in this
/// service being able to impersonate your client for requests to Google
/// services.
std::shared_ptr<CallCredentials> GoogleIAMCredentials(
const std::string& authorization_token,
const std::string& authority_selector);
/// Combines a channel credentials and a call credentials into a composite
/// channel credentials.
std::shared_ptr<ChannelCredentials> CompositeChannelCredentials(
const std::shared_ptr<ChannelCredentials>& channel_creds,
const std::shared_ptr<CallCredentials>& call_creds);
/// Combines two call credentials objects into a composite call credentials.
std::shared_ptr<CallCredentials> CompositeCallCredentials(
const std::shared_ptr<CallCredentials>& creds1,
const std::shared_ptr<CallCredentials>& creds2);
/// Credentials for an unencrypted, unauthenticated channel
std::shared_ptr<ChannelCredentials> InsecureChannelCredentials();
/// User defined metadata credentials.
class MetadataCredentialsPlugin {
public:
virtual ~MetadataCredentialsPlugin() {}
/// If this method returns true, the Process function will be scheduled in
/// a different thread from the one processing the call.
virtual bool IsBlocking() const { return true; }
/// Type of credentials this plugin is implementing.
virtual const char* GetType() const { return ""; }
/// Gets the auth metatada produced by this plugin.
/// The fully qualified method name is:
/// service_url + "/" + method_name.
/// The channel_auth_context contains (among other things), the identity of
/// the server.
virtual grpc::Status GetMetadata(
grpc::string_ref service_url, grpc::string_ref method_name,
const grpc::AuthContext& channel_auth_context,
std::multimap<std::string, std::string>* metadata) = 0;
virtual std::string DebugString() {
return "MetadataCredentialsPlugin did not provide a debug string";
}
};
std::shared_ptr<CallCredentials> MetadataCredentialsFromPlugin(
std::unique_ptr<MetadataCredentialsPlugin> plugin);
namespace experimental {
/// Options for creating STS Oauth Token Exchange credentials following the IETF
/// draft https://tools.ietf.org/html/draft-ietf-oauth-token-exchange-16.
/// Optional fields may be set to empty string. It is the responsibility of the
/// caller to ensure that the subject and actor tokens are refreshed on disk at
/// the specified paths.
struct StsCredentialsOptions {
std::string token_exchange_service_uri; // Required.
std::string resource; // Optional.
std::string audience; // Optional.
std::string scope; // Optional.
std::string requested_token_type; // Optional.
std::string subject_token_path; // Required.
std::string subject_token_type; // Required.
std::string actor_token_path; // Optional.
std::string actor_token_type; // Optional.
};
/// Creates STS Options from a JSON string. The JSON schema is as follows:
/// {
/// "title": "STS Credentials Config",
/// "type": "object",
/// "required": ["token_exchange_service_uri", "subject_token_path",
/// "subject_token_type"],
/// "properties": {
/// "token_exchange_service_uri": {
/// "type": "string"
/// },
/// "resource": {
/// "type": "string"
/// },
/// "audience": {
/// "type": "string"
/// },
/// "scope": {
/// "type": "string"
/// },
/// "requested_token_type": {
/// "type": "string"
/// },
/// "subject_token_path": {
/// "type": "string"
/// },
/// "subject_token_type": {
/// "type": "string"
/// },
/// "actor_token_path" : {
/// "type": "string"
/// },
/// "actor_token_type": {
/// "type": "string"
/// }
/// }
/// }
grpc::Status StsCredentialsOptionsFromJson(const std::string& json_string,
StsCredentialsOptions* options);
/// Creates STS credentials options from the $STS_CREDENTIALS environment
/// variable. This environment variable points to the path of a JSON file
/// comforming to the schema described above.
grpc::Status StsCredentialsOptionsFromEnv(StsCredentialsOptions* options);
std::shared_ptr<CallCredentials> StsCredentials(
const StsCredentialsOptions& options);
std::shared_ptr<CallCredentials> MetadataCredentialsFromPlugin(
std::unique_ptr<MetadataCredentialsPlugin> plugin,
grpc_security_level min_security_level);
/// Options used to build AltsCredentials.
struct AltsCredentialsOptions {
/// service accounts of target endpoint that will be acceptable
/// by the client. If service accounts are provided and none of them matches
/// that of the server, authentication will fail.
std::vector<std::string> target_service_accounts;
};
/// Builds ALTS Credentials given ALTS specific options
std::shared_ptr<ChannelCredentials> AltsCredentials(
const AltsCredentialsOptions& options);
/// Builds Local Credentials.
std::shared_ptr<ChannelCredentials> LocalCredentials(
grpc_local_connect_type type);
/// Builds TLS Credentials given TLS options.
std::shared_ptr<ChannelCredentials> TlsCredentials(
const TlsCredentialsOptions& options);
} // namespace experimental
} // namespace grpc_impl
#endif // GRPCPP_SECURITY_CREDENTIALS_IMPL_H

@ -23,10 +23,7 @@
namespace grpc {
static inline std::shared_ptr<grpc_impl::ChannelCredentials>
CronetChannelCredentials(void* engine) {
return ::grpc_impl::CronetChannelCredentials(engine);
}
std::shared_ptr<ChannelCredentials> CronetChannelCredentials(void* engine);
} // namespace grpc

@ -34,7 +34,32 @@ namespace grpc_impl {
class Server;
} // namespace grpc_impl
namespace grpc {
struct SslServerCredentialsOptions;
/// Options to create ServerCredentials with SSL
struct SslServerCredentialsOptions {
/// \warning Deprecated
SslServerCredentialsOptions()
: force_client_auth(false),
client_certificate_request(GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE) {}
SslServerCredentialsOptions(
grpc_ssl_client_certificate_request_type request_type)
: force_client_auth(false), client_certificate_request(request_type) {}
struct PemKeyCertPair {
std::string private_key;
std::string cert_chain;
};
std::string pem_root_certs;
std::vector<PemKeyCertPair> pem_key_cert_pairs;
/// \warning Deprecated
bool force_client_auth;
/// If both \a force_client_auth and \a client_certificate_request
/// fields are set, \a force_client_auth takes effect, i.e.
/// \a REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY
/// will be enforced.
grpc_ssl_client_certificate_request_type client_certificate_request;
};
/// Wrapper around \a grpc_server_credentials, a way to authenticate a server.
class ServerCredentials {
@ -61,7 +86,6 @@ class ServerCredentials {
std::shared_ptr<ServerCredentials> SslServerCredentials(
const grpc::SslServerCredentialsOptions& options);
/// Builds insecure server credentials.
std::shared_ptr<ServerCredentials> InsecureServerCredentials();
namespace experimental {
@ -76,12 +100,15 @@ std::shared_ptr<ServerCredentials> AltsServerCredentials(
const AltsServerCredentialsOptions& options);
/// Builds Local ServerCredentials.
std::shared_ptr<ServerCredentials> AltsServerCredentials(
const AltsServerCredentialsOptions& options);
std::shared_ptr<ServerCredentials> LocalServerCredentials(
grpc_local_connect_type type);
/// Builds TLS ServerCredentials given TLS options.
std::shared_ptr<ServerCredentials> TlsServerCredentials(
const ::grpc_impl::experimental::TlsCredentialsOptions& options);
const experimental::TlsCredentialsOptions& options);
} // namespace experimental
} // namespace grpc

@ -36,7 +36,7 @@ typedef struct grpc_tls_server_authorization_check_config
grpc_tls_server_authorization_check_config;
typedef struct grpc_tls_credentials_options grpc_tls_credentials_options;
namespace grpc_impl {
namespace grpc {
namespace experimental {
/** TLS key materials config, wrapper for grpc_tls_key_materials_config. It is
@ -340,6 +340,6 @@ class TlsCredentialsOptions {
};
} // namespace experimental
} // namespace grpc_impl
} // namespace grpc
#endif // GRPCPP_SECURITY_TLS_CREDENTIALS_OPTIONS_H

@ -28,6 +28,7 @@
#include <grpcpp/support/config.h>
namespace grpc {
class SecureChannelCredentials;
namespace testing {
class ChannelArgumentsTest;
} // namespace testing
@ -35,8 +36,6 @@ class ChannelArgumentsTest;
namespace grpc_impl {
class SecureChannelCredentials;
/// Options for channel creation. The user can use generic setters to pass
/// key value pairs down to C channel creation code. For gRPC related options,
/// concrete setters are provided.
@ -126,7 +125,7 @@ class ChannelArguments {
}
private:
friend class grpc_impl::SecureChannelCredentials;
friend class grpc::SecureChannelCredentials;
friend class grpc::testing::ChannelArgumentsTest;
/// Default pointer argument operations.

@ -1106,6 +1106,24 @@
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/strings/strip.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/strings/substitute.cc" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/strings/substitute.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/synchronization/barrier.cc" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/synchronization/barrier.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/synchronization/blocking_counter.cc" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/synchronization/blocking_counter.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.cc" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/synchronization/internal/graphcycles.cc" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/synchronization/internal/graphcycles.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/synchronization/internal/kernel_timeout.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/synchronization/internal/mutex_nonprod.inc" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.cc" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/synchronization/internal/waiter.cc" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/synchronization/internal/waiter.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/synchronization/mutex.cc" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/synchronization/mutex.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/synchronization/notification.cc" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/synchronization/notification.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/time/civil_time.cc" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/time/civil_time.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/time/clock.cc" role="src" />

@ -171,7 +171,7 @@ class WeightedTargetLb : public LoadBalancingPolicy {
// The owning LB policy.
RefCountedPtr<WeightedTargetLb> weighted_target_policy_;
const std::string& name_;
const std::string name_;
uint32_t weight_;
@ -290,9 +290,8 @@ void WeightedTargetLb::UpdateLocked(UpdateArgs args) {
const std::string& name = p.first;
auto it = targets_.find(name);
if (it == targets_.end()) {
it = targets_.emplace(std::make_pair(name, nullptr)).first;
it->second = MakeOrphanable<WeightedChild>(
Ref(DEBUG_LOCATION, "WeightedChild"), it->first);
targets_.emplace(name, MakeOrphanable<WeightedChild>(
Ref(DEBUG_LOCATION, "WeightedChild"), name));
}
}
// Update all children.

@ -187,7 +187,7 @@ class XdsRoutingLb : public LoadBalancingPolicy {
RefCountedPtr<XdsRoutingLb> xds_routing_policy_;
// Points to the corresponding key in XdsRoutingLb::actions_.
const std::string& name_;
const std::string name_;
OrphanablePtr<LoadBalancingPolicy> child_policy_;
@ -407,9 +407,10 @@ void XdsRoutingLb::UpdateLocked(UpdateArgs args) {
const RefCountedPtr<LoadBalancingPolicy::Config>& config = p.second;
auto it = actions_.find(name);
if (it == actions_.end()) {
it = actions_.emplace(std::make_pair(name, nullptr)).first;
it->second = MakeOrphanable<XdsRoutingChild>(
Ref(DEBUG_LOCATION, "XdsRoutingChild"), it->first);
it = actions_
.emplace(name, MakeOrphanable<XdsRoutingChild>(
Ref(DEBUG_LOCATION, "XdsRoutingChild"), name))
.first;
}
it->second->UpdateLocked(config, args.addresses, args.args);
}

@ -1,20 +1,18 @@
/*
*
* Copyright 2018 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.
*
*/
//
// Copyright 2018 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.
//
#include <grpc/support/port_platform.h>
@ -104,7 +102,7 @@ grpc_core::TraceFlag grpc_keepalive_trace(false, "http_keepalive");
grpc_core::DebugOnlyTraceFlag grpc_trace_chttp2_refcount(false,
"chttp2_refcount");
/* forward declarations of various callbacks that we'll build closures around */
// forward declarations of various callbacks that we'll build closures around
static void write_action_begin_locked(void* t, grpc_error* error);
static void write_action(void* t, grpc_error* error);
static void write_action_end(void* t, grpc_error* error);
@ -116,14 +114,14 @@ static void continue_read_action_locked(grpc_chttp2_transport* t);
static void complete_fetch(void* gs, grpc_error* error);
static void complete_fetch_locked(void* gs, grpc_error* error);
/** Set a transport level setting, and push it to our peer */
// Set a transport level setting, and push it to our peer
static void queue_setting_update(grpc_chttp2_transport* t,
grpc_chttp2_setting_id id, uint32_t value);
static void close_from_api(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
grpc_error* error);
/** Start new streams that have been created if we can */
// Start new streams that have been created if we can
static void maybe_start_some_streams(grpc_chttp2_transport* t);
static void connectivity_state_set(grpc_chttp2_transport* t,
@ -156,7 +154,7 @@ static void send_ping_locked(grpc_chttp2_transport* t,
grpc_closure* on_complete);
static void retry_initiate_ping_locked(void* tp, grpc_error* error);
/** keepalive-relevant functions */
// keepalive-relevant functions
static void init_keepalive_ping(void* arg, grpc_error* error);
static void init_keepalive_ping_locked(void* arg, grpc_error* error);
static void start_keepalive_ping(void* arg, grpc_error* error);
@ -172,9 +170,9 @@ static void reset_byte_stream(void* arg, grpc_error* error);
// GRPC_EXPERIMENTAL_DISABLE_FLOW_CONTROL
bool g_flow_control_enabled = true;
/*******************************************************************************
* CONSTRUCTION/DESTRUCTION/REFCOUNTING
*/
//
// CONSTRUCTION/DESTRUCTION/REFCOUNTING
//
grpc_chttp2_transport::~grpc_chttp2_transport() {
size_t i;
@ -233,7 +231,7 @@ grpc_chttp2_transport::~grpc_chttp2_transport() {
static const grpc_transport_vtable* get_vtable(void);
/* Returns whether bdp is enabled */
// Returns whether bdp is enabled
static bool read_channel_args(grpc_chttp2_transport* t,
const grpc_channel_args* channel_args,
bool is_client) {
@ -431,8 +429,8 @@ static void init_keepalive_pings_if_enabled(grpc_chttp2_transport* t) {
grpc_core::ExecCtx::Get()->Now() + t->keepalive_time,
&t->init_keepalive_ping_locked);
} else {
/* Use GRPC_CHTTP2_KEEPALIVE_STATE_DISABLED to indicate there are no
inflight keeaplive timers */
// Use GRPC_CHTTP2_KEEPALIVE_STATE_DISABLED to indicate there are no
// inflight keeaplive timers
t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_DISABLED;
}
}
@ -453,11 +451,11 @@ grpc_chttp2_transport::grpc_chttp2_transport(
GPR_ASSERT(strlen(GRPC_CHTTP2_CLIENT_CONNECT_STRING) ==
GRPC_CHTTP2_CLIENT_CONNECT_STRLEN);
base.vtable = get_vtable();
/* 8 is a random stab in the dark as to a good initial size: it's small enough
that it shouldn't waste memory for infrequently used connections, yet
large enough that the exponential growth should happen nicely when it's
needed.
TODO(ctiller): tune this */
// 8 is a random stab in the dark as to a good initial size: it's small enough
// that it shouldn't waste memory for infrequently used connections, yet
// large enough that the exponential growth should happen nicely when it's
// needed.
// TODO(ctiller): tune this
grpc_chttp2_stream_map_init(&stream_map, 8);
grpc_slice_buffer_init(&read_buffer);
@ -468,7 +466,7 @@ grpc_chttp2_transport::grpc_chttp2_transport(
}
grpc_chttp2_hpack_compressor_init(&hpack_compressor);
grpc_slice_buffer_init(&qbuf);
/* copy in initial settings to all setting sets */
// copy in initial settings to all setting sets
size_t i;
int j;
for (i = 0; i < GRPC_CHTTP2_NUM_SETTINGS; i++) {
@ -479,7 +477,7 @@ grpc_chttp2_transport::grpc_chttp2_transport(
grpc_chttp2_hpack_parser_init(&hpack_parser);
grpc_chttp2_goaway_parser_init(&goaway_parser);
/* configure http2 the way we like it */
// configure http2 the way we like it
if (is_client) {
queue_setting_update(this, GRPC_CHTTP2_SETTINGS_ENABLE_PUSH, 0);
queue_setting_update(this, GRPC_CHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS, 0);
@ -505,7 +503,7 @@ grpc_chttp2_transport::grpc_chttp2_transport(
enable_bdp = false;
}
/* No pings allowed before receiving a header or data frame. */
// No pings allowed before receiving a header or data frame.
ping_state.pings_before_data_required = 0;
ping_state.is_delayed_ping_timer_set = false;
ping_state.last_ping_sent_time = GRPC_MILLIS_INF_PAST;
@ -582,11 +580,11 @@ static void close_transport_locked(grpc_chttp2_transport* t,
break;
case GRPC_CHTTP2_KEEPALIVE_STATE_DYING:
case GRPC_CHTTP2_KEEPALIVE_STATE_DISABLED:
/* keepalive timers are not set in these two states */
// keepalive timers are not set in these two states
break;
}
/* flush writable stream list to avoid dangling references */
// flush writable stream list to avoid dangling references
grpc_chttp2_stream* s;
while (grpc_chttp2_list_pop_writable_stream(t, &s)) {
GRPC_CHTTP2_STREAM_UNREF(s, "chttp2_writing:close");
@ -619,9 +617,9 @@ void grpc_chttp2_stream_unref(grpc_chttp2_stream* s) {
#endif
grpc_chttp2_stream::Reffer::Reffer(grpc_chttp2_stream* s) {
/* We reserve one 'active stream' that's dropped when the stream is
read-closed. The others are for Chttp2IncomingByteStreams that are
actively reading */
// We reserve one 'active stream' that's dropped when the stream is
// read-closed. The others are for Chttp2IncomingByteStreams that are
// actively reading
GRPC_CHTTP2_STREAM_REF(s, "chttp2");
GRPC_CHTTP2_REF_TRANSPORT(s->t, "stream");
}
@ -777,9 +775,9 @@ grpc_chttp2_stream* grpc_chttp2_parsing_accept_stream(grpc_chttp2_transport* t,
return accepting;
}
/*******************************************************************************
* OUTPUT PROCESSING
*/
//
// OUTPUT PROCESSING
//
static const char* write_state_name(grpc_chttp2_write_state st) {
switch (st) {
@ -800,12 +798,12 @@ static void set_write_state(grpc_chttp2_transport* t,
t->is_client ? "CLIENT" : "SERVER", t->peer_string,
write_state_name(t->write_state), write_state_name(st), reason));
t->write_state = st;
/* If the state is being reset back to idle, it means a write was just
* finished. Make sure all the run_after_write closures are scheduled.
*
* This is also our chance to close the transport if the transport was marked
* to be closed after all writes finish (for example, if we received a go-away
* from peer while we had some pending writes) */
// If the state is being reset back to idle, it means a write was just
// finished. Make sure all the run_after_write closures are scheduled.
//
// This is also our chance to close the transport if the transport was marked
// to be closed after all writes finish (for example, if we received a go-away
// from peer while we had some pending writes)
if (st == GRPC_CHTTP2_WRITE_STATE_IDLE) {
grpc_core::ExecCtx::RunList(DEBUG_LOCATION, &t->run_after_write);
if (t->close_transport_on_writes_finished != nullptr) {
@ -892,22 +890,22 @@ void grpc_chttp2_initiate_write(grpc_chttp2_transport* t,
set_write_state(t, GRPC_CHTTP2_WRITE_STATE_WRITING,
grpc_chttp2_initiate_write_reason_string(reason));
GRPC_CHTTP2_REF_TRANSPORT(t, "writing");
/* Note that the 'write_action_begin_locked' closure is being scheduled
* on the 'finally_scheduler' of t->combiner. This means that
* 'write_action_begin_locked' is called only *after* all the other
* closures (some of which are potentially initiating more writes on the
* transport) are executed on the t->combiner.
*
* The reason for scheduling on finally_scheduler is to make sure we batch
* as many writes as possible. 'write_action_begin_locked' is the function
* that gathers all the relevant bytes (which are at various places in the
* grpc_chttp2_transport structure) and append them to 'outbuf' field in
* grpc_chttp2_transport thereby batching what would have been potentially
* multiple write operations.
*
* Also, 'write_action_begin_locked' only gathers the bytes into outbuf.
* It does not call the endpoint to write the bytes. That is done by the
* 'write_action' (which is scheduled by 'write_action_begin_locked') */
// Note that the 'write_action_begin_locked' closure is being scheduled
// on the 'finally_scheduler' of t->combiner. This means that
// 'write_action_begin_locked' is called only *after* all the other
// closures (some of which are potentially initiating more writes on the
// transport) are executed on the t->combiner.
//
// The reason for scheduling on finally_scheduler is to make sure we batch
// as many writes as possible. 'write_action_begin_locked' is the function
// that gathers all the relevant bytes (which are at various places in the
// grpc_chttp2_transport structure) and append them to 'outbuf' field in
// grpc_chttp2_transport thereby batching what would have been potentially
// multiple write operations.
//
// Also, 'write_action_begin_locked' only gathers the bytes into outbuf.
// It does not call the endpoint to write the bytes. That is done by the
// 'write_action' (which is scheduled by 'write_action_begin_locked')
t->combiner->FinallyRun(
GRPC_CLOSURE_INIT(&t->write_action_begin_locked,
write_action_begin_locked, t, nullptr),
@ -959,9 +957,9 @@ static void write_action_begin_locked(void* gt, grpc_error* /*error_ignored*/) {
write_action(t, GRPC_ERROR_NONE);
if (t->reading_paused_on_pending_induced_frames) {
GPR_ASSERT(t->num_pending_induced_frames == 0);
/* We had paused reading, because we had many induced frames (SETTINGS
* ACK, PINGS ACK and RST_STREAMS) pending in t->qbuf. Now that we have
* been able to flush qbuf, we can resume reading. */
// We had paused reading, because we had many induced frames (SETTINGS
// ACK, PINGS ACK and RST_STREAMS) pending in t->qbuf. Now that we have
// been able to flush qbuf, we can resume reading.
GRPC_CHTTP2_IF_TRACING(gpr_log(
GPR_INFO,
"transport %p : Resuming reading after being paused due to too "
@ -996,8 +994,8 @@ static void write_action_end(void* tp, grpc_error* error) {
GRPC_ERROR_REF(error));
}
/* Callback from the grpc_endpoint after bytes have been written by calling
* sendmsg */
// Callback from the grpc_endpoint after bytes have been written by calling
// sendmsg
static void write_action_end_locked(void* tp, grpc_error* error) {
GPR_TIMER_SCOPE("terminate_writing_with_lock", 0);
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(tp);
@ -1083,16 +1081,16 @@ void grpc_chttp2_add_incoming_goaway(grpc_chttp2_transport* t,
GRPC_CHTTP2_IF_TRACING(
gpr_log(GPR_INFO, "transport %p got goaway with last stream id %d", t,
last_stream_id));
/* We want to log this irrespective of whether http tracing is enabled if we
* received a GOAWAY with a non NO_ERROR code. */
// We want to log this irrespective of whether http tracing is enabled if we
// received a GOAWAY with a non NO_ERROR code.
if (goaway_error != GRPC_HTTP2_NO_ERROR) {
gpr_log(GPR_INFO, "%s: Got goaway [%d] err=%s", t->peer_string,
goaway_error, grpc_error_string(t->goaway_error));
}
/* When a client receives a GOAWAY with error code ENHANCE_YOUR_CALM and debug
* data equal to "too_many_pings", it should log the occurrence at a log level
* that is enabled by default and double the configured KEEPALIVE_TIME used
* for new connections on that channel. */
// When a client receives a GOAWAY with error code ENHANCE_YOUR_CALM and debug
// data equal to "too_many_pings", it should log the occurrence at a log level
// that is enabled by default and double the configured KEEPALIVE_TIME used
// for new connections on that channel.
if (GPR_UNLIKELY(t->is_client &&
goaway_error == GRPC_HTTP2_ENHANCE_YOUR_CALM &&
grpc_slice_str_cmp(goaway_text, "too_many_pings") == 0)) {
@ -1109,15 +1107,15 @@ void grpc_chttp2_add_incoming_goaway(grpc_chttp2_transport* t,
KEEPALIVE_TIME_BACKOFF_MULTIPLIER);
}
absl::Status status = grpc_error_to_absl_status(t->goaway_error);
/* lie: use transient failure from the transport to indicate goaway has been
* received */
// lie: use transient failure from the transport to indicate goaway has been
// received.
connectivity_state_set(t, GRPC_CHANNEL_TRANSIENT_FAILURE, status,
"got_goaway");
}
static void maybe_start_some_streams(grpc_chttp2_transport* t) {
grpc_chttp2_stream* s;
/* cancel out streams that haven't yet started if we have received a GOAWAY */
// cancel out streams that haven't yet started if we have received a GOAWAY
if (t->goaway_error != GRPC_ERROR_NONE) {
while (grpc_chttp2_list_pop_waiting_for_concurrency(t, &s)) {
grpc_chttp2_cancel_stream(
@ -1128,14 +1126,14 @@ static void maybe_start_some_streams(grpc_chttp2_transport* t) {
}
return;
}
/* start streams where we have free grpc_chttp2_stream ids and free
* concurrency */
// start streams where we have free grpc_chttp2_stream ids and free
// * concurrency
while (t->next_stream_id <= MAX_CLIENT_STREAM_ID &&
grpc_chttp2_stream_map_size(&t->stream_map) <
t->settings[GRPC_PEER_SETTINGS]
[GRPC_CHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS] &&
grpc_chttp2_list_pop_waiting_for_concurrency(t, &s)) {
/* safe since we can't (legally) be parsing this stream yet */
// safe since we can't (legally) be parsing this stream yet
GRPC_CHTTP2_IF_TRACING(gpr_log(
GPR_INFO,
"HTTP:%s: Transport %p allocating new grpc_chttp2_stream %p to id %d",
@ -1157,7 +1155,7 @@ static void maybe_start_some_streams(grpc_chttp2_transport* t) {
grpc_chttp2_mark_stream_writable(t, s);
grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_START_NEW_STREAM);
}
/* cancel out streams that will never be started */
// cancel out streams that will never be started
if (t->next_stream_id >= MAX_CLIENT_STREAM_ID) {
while (grpc_chttp2_list_pop_waiting_for_concurrency(t, &s)) {
grpc_chttp2_cancel_stream(
@ -1169,12 +1167,12 @@ static void maybe_start_some_streams(grpc_chttp2_transport* t) {
}
}
/* Flag that this closure barrier may be covering a write in a pollset, and so
we should not complete this closure until we can prove that the write got
scheduled */
// Flag that this closure barrier may be covering a write in a pollset, and so
// we should not complete this closure until we can prove that the write got
// scheduled
#define CLOSURE_BARRIER_MAY_COVER_WRITE (1 << 0)
/* First bit of the reference count, stored in the high order bits (with the low
bits being used for flags defined above) */
// First bit of the reference count, stored in the high order bits (with the low
// bits being used for flags defined above)
#define CLOSURE_BARRIER_FIRST_REF_BIT (1 << 16)
static grpc_closure* add_closure_barrier(grpc_closure* closure) {
@ -1266,7 +1264,7 @@ static void continue_fetching_send_locked(grpc_chttp2_transport* t,
grpc_chttp2_stream* s) {
for (;;) {
if (s->fetching_send_message == nullptr) {
/* Stream was cancelled before message fetch completed */
// Stream was cancelled before message fetch completed
abort(); /* TODO(ctiller): what cleanup here? */
return; /* early out */
}
@ -1396,7 +1394,7 @@ static void perform_stream_op_locked(void* stream_op,
GPR_ASSERT(s->send_initial_metadata_finished == nullptr);
on_complete->next_data.scratch |= CLOSURE_BARRIER_MAY_COVER_WRITE;
/* Identify stream compression */
// Identify stream compression
if (op_payload->send_initial_metadata.send_initial_metadata->idx.named
.content_encoding == nullptr ||
grpc_stream_compression_method_parse(
@ -1569,8 +1567,8 @@ static void perform_stream_op_locked(void* stream_op,
"stream was closed"),
"send_trailing_metadata_finished");
} else if (s->id != 0) {
/* TODO(ctiller): check if there's flow control for any outstanding
bytes before going writable */
// TODO(ctiller): check if there's flow control for any outstanding
// bytes before going writable
grpc_chttp2_mark_stream_writable(t, s);
grpc_chttp2_initiate_write(
t, GRPC_CHTTP2_INITIATE_WRITE_SEND_TRAILING_METADATA);
@ -1672,8 +1670,8 @@ static void perform_stream_op(grpc_transport* gt, grpc_stream* gs,
}
static void cancel_pings(grpc_chttp2_transport* t, grpc_error* error) {
/* callback remaining pings: they're not allowed to call into the transport,
and maybe they hold resources that need to be freed */
// callback remaining pings: they're not allowed to call into the transport,
// and maybe they hold resources that need to be freed
grpc_chttp2_ping_queue* pq = &t->ping_queue;
GPR_ASSERT(error != GRPC_ERROR_NONE);
for (size_t j = 0; j < GRPC_CHTTP2_PCL_COUNT; j++) {
@ -1699,11 +1697,9 @@ static void send_ping_locked(grpc_chttp2_transport* t,
GRPC_ERROR_NONE);
}
/*
* Specialized form of send_ping_locked for keepalive ping. If there is already
* a ping in progress, the keepalive ping would piggyback onto that ping,
* instead of waiting for that ping to complete and then starting a new ping.
*/
// Specialized form of send_ping_locked for keepalive ping. If there is already
// a ping in progress, the keepalive ping would piggyback onto that ping,
// instead of waiting for that ping to complete and then starting a new ping.
static void send_keepalive_ping_locked(grpc_chttp2_transport* t) {
if (t->closed_with_error != GRPC_ERROR_NONE) {
t->combiner->Run(GRPC_CLOSURE_INIT(&t->start_keepalive_ping_locked,
@ -1717,7 +1713,7 @@ static void send_keepalive_ping_locked(grpc_chttp2_transport* t) {
}
grpc_chttp2_ping_queue* pq = &t->ping_queue;
if (!grpc_closure_list_empty(pq->lists[GRPC_CHTTP2_PCL_INFLIGHT])) {
/* There is a ping in flight. Add yourself to the inflight closure list. */
// There is a ping in flight. Add yourself to the inflight closure list.
t->combiner->Run(GRPC_CLOSURE_INIT(&t->start_keepalive_ping_locked,
start_keepalive_ping_locked, t, nullptr),
GRPC_ERROR_REF(t->closed_with_error));
@ -1772,7 +1768,7 @@ void grpc_chttp2_ack_ping(grpc_chttp2_transport* t, uint64_t id) {
}
static void send_goaway(grpc_chttp2_transport* t, grpc_error* error) {
/* We want to log this irrespective of whether http tracing is enabled */
// We want to log this irrespective of whether http tracing is enabled
gpr_log(GPR_INFO, "%s: Sending goaway err=%s", t->peer_string,
grpc_error_string(error));
t->sent_goaway_state = GRPC_CHTTP2_GOAWAY_SEND_SCHEDULED;
@ -1794,7 +1790,7 @@ void grpc_chttp2_add_ping_strike(grpc_chttp2_transport* t) {
grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("too_many_pings"),
GRPC_ERROR_INT_HTTP2_ERROR, GRPC_HTTP2_ENHANCE_YOUR_CALM));
/*The transport will be closed after the write is done */
// The transport will be closed after the write is done
close_transport_locked(
t, grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Too many pings"),
@ -1869,9 +1865,9 @@ static void perform_transport_op(grpc_transport* gt, grpc_transport_op* op) {
GRPC_ERROR_NONE);
}
/*******************************************************************************
* INPUT PROCESSING - GENERAL
*/
//
// INPUT PROCESSING - GENERAL
//
void grpc_chttp2_maybe_complete_recv_initial_metadata(
grpc_chttp2_transport* /*t*/, grpc_chttp2_stream* s) {
@ -1991,8 +1987,8 @@ void grpc_chttp2_maybe_complete_recv_trailing_metadata(grpc_chttp2_transport* t,
s->unprocessed_incoming_frames_buffer.length > 0;
if (s->read_closed && s->frame_storage.length > 0 && !pending_data &&
!s->seen_error && s->recv_trailing_metadata_finished != nullptr) {
/* Maybe some SYNC_FLUSH data is left in frame_storage. Consume them and
* maybe decompress the next 5 bytes in the stream. */
// Maybe some SYNC_FLUSH data is left in frame_storage. Consume them and
// maybe decompress the next 5 bytes in the stream.
if (s->stream_decompression_method ==
GRPC_STREAM_COMPRESSION_IDENTITY_DECOMPRESS) {
grpc_slice_buffer_move_first(
@ -2114,12 +2110,12 @@ void grpc_chttp2_fake_status(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
if (status != GRPC_STATUS_OK) {
s->seen_error = true;
}
/* stream_global->recv_trailing_metadata_finished gives us a
last chance replacement: we've received trailing metadata,
but something more important has become available to signal
to the upper layers - drop what we've got, and then publish
what we want - which is safe because we haven't told anyone
about the metadata yet */
// stream_global->recv_trailing_metadata_finished gives us a
// last chance replacement: we've received trailing metadata,
// but something more important has become available to signal
// to the upper layers - drop what we've got, and then publish
// what we want - which is safe because we haven't told anyone
// about the metadata yet
if (s->published_metadata[1] == GRPC_METADATA_NOT_PUBLISHED ||
s->recv_trailing_metadata_finished != nullptr) {
char status_string[GPR_LTOA_MIN_BUFSIZE];
@ -2211,7 +2207,7 @@ void grpc_chttp2_mark_stream_closed(grpc_chttp2_transport* t,
grpc_chttp2_stream* s, int close_reads,
int close_writes, grpc_error* error) {
if (s->read_closed && s->write_closed) {
/* already closed, but we should still fake the status if needed. */
// already closed, but we should still fake the status if needed.
grpc_error* overall_error = removal_error(error, s, "Stream removed");
if (overall_error != GRPC_ERROR_NONE) {
grpc_chttp2_fake_status(t, s, overall_error);
@ -2238,7 +2234,7 @@ void grpc_chttp2_mark_stream_closed(grpc_chttp2_transport* t,
if (s->id != 0) {
remove_stream(t, s->id, GRPC_ERROR_REF(overall_error));
} else {
/* Purge streams waiting on concurrency still waiting for id assignment */
// Purge streams waiting on concurrency still waiting for id assignment
grpc_chttp2_list_remove_waiting_for_concurrency(t, s);
}
if (overall_error != GRPC_ERROR_NONE) {
@ -2277,12 +2273,12 @@ static void close_from_api(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
GPR_ASSERT(grpc_status >= 0 && (int)grpc_status < 100);
/* Hand roll a header block.
This is unnecessarily ugly - at some point we should find a more
elegant solution.
It's complicated by the fact that our send machinery would be dead by
the time we got around to sending this, so instead we ignore HPACK
compression and just write the uncompressed bytes onto the wire. */
// Hand roll a header block.
// This is unnecessarily ugly - at some point we should find a more
// elegant solution.
// It's complicated by the fact that our send machinery would be dead by
// the time we got around to sending this, so instead we ignore HPACK
// compression and just write the uncompressed bytes onto the wire.
if (!s->sent_initial_metadata) {
http_status_hdr = GRPC_SLICE_MALLOC(13);
p = GRPC_SLICE_START_PTR(http_status_hdr);
@ -2443,9 +2439,9 @@ static void end_all_the_calls(grpc_chttp2_transport* t, grpc_error* error) {
GRPC_ERROR_UNREF(error);
}
/*******************************************************************************
* INPUT PROCESSING - PARSING
*/
//
// INPUT PROCESSING - PARSING
//
template <class F>
static void WithUrgency(grpc_chttp2_transport* t,
@ -2580,8 +2576,8 @@ static void read_action_locked(void* tp, grpc_error* error) {
"Transport closed", &t->closed_with_error, 1);
}
if (error != GRPC_ERROR_NONE) {
/* If a goaway frame was received, this might be the reason why the read
* failed. Add this info to the error */
// If a goaway frame was received, this might be the reason why the read
// failed. Add this info to the error
if (t->goaway_error != GRPC_ERROR_NONE) {
error = grpc_error_add_child(error, GRPC_ERROR_REF(t->goaway_error));
}
@ -2590,7 +2586,7 @@ static void read_action_locked(void* tp, grpc_error* error) {
t->endpoint_reading = 0;
} else if (t->closed_with_error == GRPC_ERROR_NONE) {
keep_reading = true;
/* Since we have read a byte, reset the keepalive timer */
// Since we have read a byte, reset the keepalive timer
if (t->keepalive_state == GRPC_CHTTP2_KEEPALIVE_STATE_WAITING) {
grpc_timer_cancel(&t->keepalive_ping_timer);
}
@ -2651,7 +2647,7 @@ static void start_bdp_ping_locked(void* tp, grpc_error* error) {
if (error != GRPC_ERROR_NONE || t->closed_with_error != GRPC_ERROR_NONE) {
return;
}
/* Reset the keepalive ping timer */
// Reset the keepalive ping timer
if (t->keepalive_state == GRPC_CHTTP2_KEEPALIVE_STATE_WAITING) {
grpc_timer_cancel(&t->keepalive_ping_timer);
}
@ -2677,8 +2673,8 @@ static void finish_bdp_ping_locked(void* tp, grpc_error* error) {
return;
}
if (!t->bdp_ping_started) {
/* start_bdp_ping_locked has not been run yet. Schedule
* finish_bdp_ping_locked to be run later. */
// start_bdp_ping_locked has not been run yet. Schedule
// finish_bdp_ping_locked to be run later.
t->combiner->Run(GRPC_CLOSURE_INIT(&t->finish_bdp_ping_locked,
finish_bdp_ping_locked, t, nullptr),
GRPC_ERROR_REF(error));
@ -2811,7 +2807,7 @@ static void init_keepalive_ping_locked(void* arg, grpc_error* error) {
&t->init_keepalive_ping_locked);
}
} else if (error == GRPC_ERROR_CANCELLED) {
/* The keepalive ping timer may be cancelled by bdp */
// The keepalive ping timer may be cancelled by bdp
GRPC_CHTTP2_REF_TRANSPORT(t, "init keepalive ping");
GRPC_CLOSURE_INIT(&t->init_keepalive_ping_locked, init_keepalive_ping, t,
grpc_schedule_on_exec_ctx);
@ -2866,8 +2862,8 @@ static void finish_keepalive_ping_locked(void* arg, grpc_error* error) {
gpr_log(GPR_INFO, "%s: Finish keepalive ping", t->peer_string);
}
if (!t->keepalive_ping_started) {
/* start_keepalive_ping_locked has not run yet. Reschedule
* finish_keepalive_ping_locked for it to be run later. */
// start_keepalive_ping_locked has not run yet. Reschedule
// finish_keepalive_ping_locked for it to be run later.
t->combiner->Run(
GRPC_CLOSURE_INIT(&t->finish_keepalive_ping_locked,
finish_keepalive_ping_locked, t, nullptr),
@ -2910,8 +2906,8 @@ static void keepalive_watchdog_fired_locked(void* arg, grpc_error* error) {
GRPC_STATUS_UNAVAILABLE));
}
} else {
/* The watchdog timer should have been cancelled by
* finish_keepalive_ping_locked. */
// The watchdog timer should have been cancelled by
// finish_keepalive_ping_locked.
if (GPR_UNLIKELY(error != GRPC_ERROR_CANCELLED)) {
gpr_log(GPR_ERROR, "keepalive_ping_end state error: %d (expect: %d)",
t->keepalive_state, GRPC_CHTTP2_KEEPALIVE_STATE_PINGING);
@ -2920,9 +2916,9 @@ static void keepalive_watchdog_fired_locked(void* arg, grpc_error* error) {
GRPC_CHTTP2_UNREF_TRANSPORT(t, "keepalive watchdog");
}
/*******************************************************************************
* CALLBACK LOOP
*/
//
// CALLBACK LOOP
//
static void connectivity_state_set(grpc_chttp2_transport* t,
grpc_connectivity_state state,
@ -2933,9 +2929,9 @@ static void connectivity_state_set(grpc_chttp2_transport* t,
t->state_tracker.SetState(state, status, reason);
}
/*******************************************************************************
* POLLSET STUFF
*/
//
// POLLSET STUFF
//
static void set_pollset(grpc_transport* gt, grpc_stream* /*gs*/,
grpc_pollset* pollset) {
@ -2949,9 +2945,9 @@ static void set_pollset_set(grpc_transport* gt, grpc_stream* /*gs*/,
grpc_endpoint_add_to_pollset_set(t->ep, pollset_set);
}
/*******************************************************************************
* BYTE STREAM
*/
//
// BYTE STREAM
//
static void reset_byte_stream(void* arg, grpc_error* error) {
grpc_chttp2_stream* s = static_cast<grpc_chttp2_stream*>(arg);
@ -3039,7 +3035,7 @@ void Chttp2IncomingByteStream::NextLocked(void* arg,
s->data_parser.parsing_frame = nullptr;
}
} else {
/* Should never reach here. */
// Should never reach here.
GPR_ASSERT(false);
}
} else {
@ -3168,9 +3164,9 @@ void Chttp2IncomingByteStream::Shutdown(grpc_error* error) {
} // namespace grpc_core
/*******************************************************************************
* RESOURCE QUOTAS
*/
//
// RESOURCE QUOTAS
//
static void post_benign_reclaimer(grpc_chttp2_transport* t) {
if (!t->benign_reclaimer_registered) {
@ -3205,8 +3201,8 @@ static void benign_reclaimer_locked(void* arg, grpc_error* error) {
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(arg);
if (error == GRPC_ERROR_NONE &&
grpc_chttp2_stream_map_size(&t->stream_map) == 0) {
/* Channel with no active streams: send a goaway to try and make it
* disconnect cleanly */
// Channel with no active streams: send a goaway to try and make it
// disconnect cleanly
if (GRPC_TRACE_FLAG_ENABLED(grpc_resource_quota_trace)) {
gpr_log(GPR_INFO, "HTTP2: %s - send goaway to free memory",
t->peer_string);
@ -3254,10 +3250,10 @@ static void destructive_reclaimer_locked(void* arg, grpc_error* error) {
GRPC_ERROR_INT_HTTP2_ERROR,
GRPC_HTTP2_ENHANCE_YOUR_CALM));
if (n > 1) {
/* Since we cancel one stream per destructive reclamation, if
there are more streams left, we can immediately post a new
reclaimer in case the resource quota needs to free more
memory */
// Since we cancel one stream per destructive reclamation, if
// there are more streams left, we can immediately post a new
// reclaimer in case the resource quota needs to free more
// memory
post_destructive_reclaimer(t);
}
}
@ -3268,9 +3264,9 @@ static void destructive_reclaimer_locked(void* arg, grpc_error* error) {
GRPC_CHTTP2_UNREF_TRANSPORT(t, "destructive_reclaimer");
}
/*******************************************************************************
* MONITORING
*/
//
// MONITORING
//
const char* grpc_chttp2_initiate_write_reason_string(
grpc_chttp2_initiate_write_reason reason) {

@ -310,27 +310,26 @@ void ServerNode::RemoveChildListenSocket(intptr_t child_uuid) {
std::string ServerNode::RenderServerSockets(intptr_t start_socket_id,
intptr_t max_results) {
GPR_ASSERT(start_socket_id >= 0);
GPR_ASSERT(max_results >= 0);
// If user does not set max_results, we choose 500.
size_t pagination_limit = max_results == 0 ? 500 : max_results;
Json::Object object;
{
MutexLock lock(&child_mu_);
size_t sockets_rendered = 0;
if (!child_sockets_.empty()) {
// Create list of socket refs.
Json::Array array;
const size_t limit = GPR_MIN(child_sockets_.size(), pagination_limit);
for (auto it = child_sockets_.lower_bound(start_socket_id);
it != child_sockets_.end() && sockets_rendered < limit;
++it, ++sockets_rendered) {
array.emplace_back(Json::Object{
{"socketId", std::to_string(it->first)},
{"name", it->second->name()},
});
}
object["socketRef"] = std::move(array);
// Create list of socket refs.
Json::Array array;
auto it = child_sockets_.lower_bound(start_socket_id);
for (; it != child_sockets_.end() && sockets_rendered < pagination_limit;
++it, ++sockets_rendered) {
array.emplace_back(Json::Object{
{"socketId", std::to_string(it->first)},
{"name", it->second->name()},
});
}
if (sockets_rendered == child_sockets_.size()) object["end"] = true;
object["socketRef"] = std::move(array);
if (it == child_sockets_.end()) object["end"] = true;
}
Json json = std::move(object);
return json.Dump();

@ -208,10 +208,12 @@ char* grpc_channelz_get_server(intptr_t server_id) {
char* grpc_channelz_get_server_sockets(intptr_t server_id,
intptr_t start_socket_id,
intptr_t max_results) {
// Validate inputs before handing them of to the renderer.
grpc_core::RefCountedPtr<grpc_core::channelz::BaseNode> base_node =
grpc_core::channelz::ChannelzRegistry::Get(server_id);
if (base_node == nullptr ||
base_node->type() != grpc_core::channelz::BaseNode::EntityType::kServer) {
base_node->type() != grpc_core::channelz::BaseNode::EntityType::kServer ||
start_socket_id < 0 || max_results < 0) {
return nullptr;
}
// This cast is ok since we have just checked to make sure base_node is

@ -37,7 +37,6 @@
#include "src/core/lib/iomgr/ev_epollex_linux.h"
#include "src/core/lib/iomgr/ev_poll_posix.h"
#include "src/core/lib/iomgr/internal_errqueue.h"
#include "src/core/lib/iomgr/iomgr.h"
GPR_GLOBAL_CONFIG_DEFINE_STRING(
grpc_poll_strategy, "all",
@ -108,7 +107,6 @@ const grpc_event_engine_vtable* init_non_polling(bool explicit_request) {
auto ret = grpc_init_poll_posix(explicit_request);
real_poll_function = grpc_poll_function;
grpc_poll_function = dummy_poll;
grpc_iomgr_mark_non_polling_internal();
return ret;
}

@ -31,7 +31,6 @@
#include "src/core/lib/gpr/string.h"
#include "src/core/lib/gpr/useful.h"
#include "src/core/lib/gprpp/atomic.h"
#include "src/core/lib/gprpp/global_config.h"
#include "src/core/lib/gprpp/thd.h"
#include "src/core/lib/iomgr/buffer_list.h"
@ -51,7 +50,6 @@ static gpr_cv g_rcv;
static int g_shutdown;
static grpc_iomgr_object g_root_object;
static bool g_grpc_abort_on_leaks;
static grpc_core::Atomic<bool> g_iomgr_non_polling{false};
void grpc_iomgr_init() {
grpc_core::ExecCtx exec_ctx;
@ -194,11 +192,3 @@ void grpc_iomgr_unregister_object(grpc_iomgr_object* obj) {
}
bool grpc_iomgr_abort_on_leaks(void) { return g_grpc_abort_on_leaks; }
bool grpc_iomgr_non_polling() {
return g_iomgr_non_polling.Load(grpc_core::MemoryOrder::SEQ_CST);
}
void grpc_iomgr_mark_non_polling_internal() {
g_iomgr_non_polling.Store(true, grpc_core::MemoryOrder::SEQ_CST);
}

@ -45,16 +45,6 @@ void grpc_iomgr_shutdown_background_closure();
*/
bool grpc_iomgr_run_in_background();
/* Returns true if polling engine is non-polling, false otherwise.
* Currently only 'none' is non-polling.
*/
bool grpc_iomgr_non_polling();
/* Mark the polling engine as non-polling. For internal use only.
* Currently only 'none' is non-polling.
*/
void grpc_iomgr_mark_non_polling_internal();
/** Returns true if the caller is a worker thread for any background poller. */
bool grpc_iomgr_is_any_background_poller_thread();

@ -39,7 +39,6 @@
#include "src/core/lib/gpr/string.h"
#include "src/core/lib/gpr/tls.h"
#include "src/core/lib/gprpp/atomic.h"
#include "src/core/lib/iomgr/closure.h"
#include "src/core/lib/iomgr/executor.h"
#include "src/core/lib/iomgr/pollset.h"
#include "src/core/lib/iomgr/timer.h"
@ -209,9 +208,6 @@ struct cq_vtable {
void* reserved);
grpc_event (*pluck)(grpc_completion_queue* cq, void* tag,
gpr_timespec deadline, void* reserved);
// TODO(vjpai): Remove proxy_pollset once callback_alternative no longer
// needed.
grpc_pollset* (*proxy_pollset)(grpc_completion_queue* cq);
};
namespace {
@ -313,7 +309,7 @@ struct cq_pluck_data {
};
struct cq_callback_data {
explicit cq_callback_data(
cq_callback_data(
grpc_experimental_completion_queue_functor* shutdown_callback)
: shutdown_callback(shutdown_callback) {}
@ -338,81 +334,6 @@ struct cq_callback_data {
grpc_experimental_completion_queue_functor* shutdown_callback;
};
// TODO(vjpai): Remove all callback_alternative variants when event manager is
// the only supported poller.
struct cq_callback_alternative_data {
explicit cq_callback_alternative_data(
grpc_experimental_completion_queue_functor* shutdown_callback)
: implementation(SharedNextableCQ()),
shutdown_callback(shutdown_callback) {}
/* This just points to a single shared nextable CQ */
grpc_completion_queue* const implementation;
/** Number of outstanding events (+1 if not shut down)
Initial count is dropped by grpc_completion_queue_shutdown */
grpc_core::Atomic<intptr_t> pending_events{1};
/** 0 initially. 1 once we initiated shutdown */
bool shutdown_called = false;
/** A callback that gets invoked when the CQ completes shutdown */
grpc_experimental_completion_queue_functor* shutdown_callback;
static grpc_completion_queue* SharedNextableCQ() {
grpc_core::MutexLock lock(&*shared_cq_next_mu);
if (shared_cq_next == nullptr) {
shared_cq_next = grpc_completion_queue_create_for_next(nullptr);
int num_nexting_threads = GPR_CLAMP(gpr_cpu_num_cores(), 1, 32);
threads_remaining.Store(num_nexting_threads,
grpc_core::MemoryOrder::RELEASE);
for (int i = 0; i < num_nexting_threads; i++) {
grpc_core::Executor::Run(
GRPC_CLOSURE_CREATE(
[](void* arg, grpc_error* /*error*/) {
grpc_completion_queue* cq =
static_cast<grpc_completion_queue*>(arg);
while (true) {
grpc_event event = grpc_completion_queue_next(
cq, gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
if (event.type == GRPC_QUEUE_SHUTDOWN) {
break;
}
GPR_DEBUG_ASSERT(event.type == GRPC_OP_COMPLETE);
// We can always execute the callback inline rather than
// pushing it to another Executor thread because this
// thread is definitely running on an executor, does not
// hold any application locks before executing the callback,
// and cannot be entered recursively.
auto* functor = static_cast<
grpc_experimental_completion_queue_functor*>(event.tag);
functor->functor_run(functor, event.success);
}
if (threads_remaining.FetchSub(
1, grpc_core::MemoryOrder::ACQ_REL) == 1) {
grpc_completion_queue_destroy(cq);
}
},
shared_cq_next, nullptr),
GRPC_ERROR_NONE, grpc_core::ExecutorType::DEFAULT,
grpc_core::ExecutorJobType::LONG);
}
}
return shared_cq_next;
}
// Use manually-constructed Mutex to avoid static construction issues
static grpc_core::ManualConstructor<grpc_core::Mutex> shared_cq_next_mu;
static grpc_completion_queue*
shared_cq_next; // GUARDED_BY(shared_cq_next_mu)
static grpc_core::Atomic<int> threads_remaining;
};
grpc_core::ManualConstructor<grpc_core::Mutex>
cq_callback_alternative_data::shared_cq_next_mu;
grpc_completion_queue* cq_callback_alternative_data::shared_cq_next = nullptr;
grpc_core::Atomic<int> cq_callback_alternative_data::threads_remaining{0};
} // namespace
/* Completion queue structure */
@ -425,12 +346,6 @@ struct grpc_completion_queue {
const cq_vtable* vtable;
const cq_poller_vtable* poller_vtable;
// The pollset entry is allowed to enable proxy CQs like the
// callback_alternative.
// TODO(vjpai): Consider removing pollset and reverting to previous
// calculation of pollset once callback_alternative is no longer needed.
grpc_pollset* pollset;
#ifndef NDEBUG
void** outstanding_tags;
size_t outstanding_tag_count;
@ -445,17 +360,13 @@ struct grpc_completion_queue {
static void cq_finish_shutdown_next(grpc_completion_queue* cq);
static void cq_finish_shutdown_pluck(grpc_completion_queue* cq);
static void cq_finish_shutdown_callback(grpc_completion_queue* cq);
static void cq_finish_shutdown_callback_alternative(grpc_completion_queue* cq);
static void cq_shutdown_next(grpc_completion_queue* cq);
static void cq_shutdown_pluck(grpc_completion_queue* cq);
static void cq_shutdown_callback(grpc_completion_queue* cq);
static void cq_shutdown_callback_alternative(grpc_completion_queue* cq);
static bool cq_begin_op_for_next(grpc_completion_queue* cq, void* tag);
static bool cq_begin_op_for_pluck(grpc_completion_queue* cq, void* tag);
static bool cq_begin_op_for_callback(grpc_completion_queue* cq, void* tag);
static bool cq_begin_op_for_callback_alternative(grpc_completion_queue* cq,
void* tag);
// A cq_end_op function is called when an operation on a given CQ with
// a given tag has completed. The storage argument is a reference to the
@ -478,20 +389,12 @@ static void cq_end_op_for_callback(
void (*done)(void* done_arg, grpc_cq_completion* storage), void* done_arg,
grpc_cq_completion* storage, bool internal);
static void cq_end_op_for_callback_alternative(
grpc_completion_queue* cq, void* tag, grpc_error* error,
void (*done)(void* done_arg, grpc_cq_completion* storage), void* done_arg,
grpc_cq_completion* storage, bool internal);
static grpc_event cq_next(grpc_completion_queue* cq, gpr_timespec deadline,
void* reserved);
static grpc_event cq_pluck(grpc_completion_queue* cq, void* tag,
gpr_timespec deadline, void* reserved);
static grpc_pollset* cq_proxy_pollset_for_callback_alternative(
grpc_completion_queue* cq);
// Note that cq_init_next and cq_init_pluck do not use the shutdown_callback
static void cq_init_next(
void* data, grpc_experimental_completion_queue_functor* shutdown_callback);
@ -499,39 +402,29 @@ static void cq_init_pluck(
void* data, grpc_experimental_completion_queue_functor* shutdown_callback);
static void cq_init_callback(
void* data, grpc_experimental_completion_queue_functor* shutdown_callback);
// poller becomes only option.
static void cq_init_callback_alternative(
void* data, grpc_experimental_completion_queue_functor* shutdown_callback);
static void cq_destroy_next(void* data);
static void cq_destroy_pluck(void* data);
static void cq_destroy_callback(void* data);
static void cq_destroy_callback_alternative(void* data);
/* Completion queue vtables based on the completion-type */
// TODO(vjpai): Make this const again once we stop needing callback_alternative
static cq_vtable g_polling_cq_vtable[] = {
static const cq_vtable g_cq_vtable[] = {
/* GRPC_CQ_NEXT */
{GRPC_CQ_NEXT, sizeof(cq_next_data), cq_init_next, cq_shutdown_next,
cq_destroy_next, cq_begin_op_for_next, cq_end_op_for_next, cq_next,
nullptr, nullptr},
nullptr},
/* GRPC_CQ_PLUCK */
{GRPC_CQ_PLUCK, sizeof(cq_pluck_data), cq_init_pluck, cq_shutdown_pluck,
cq_destroy_pluck, cq_begin_op_for_pluck, cq_end_op_for_pluck, nullptr,
cq_pluck, nullptr},
cq_pluck},
/* GRPC_CQ_CALLBACK */
{GRPC_CQ_CALLBACK, sizeof(cq_callback_data), cq_init_callback,
cq_shutdown_callback, cq_destroy_callback, cq_begin_op_for_callback,
cq_end_op_for_callback, nullptr, nullptr, nullptr},
cq_end_op_for_callback, nullptr, nullptr},
};
// Separate vtable for non-polling cqs, assign at init
static cq_vtable g_nonpolling_cq_vtable[sizeof(g_polling_cq_vtable) /
sizeof(g_polling_cq_vtable[0])];
#define DATA_FROM_CQ(cq) ((void*)(cq + 1))
#define INLINE_POLLSET_FROM_CQ(cq) \
#define POLLSET_FROM_CQ(cq) \
((grpc_pollset*)(cq->vtable->data_size + (char*)DATA_FROM_CQ(cq)))
#define POLLSET_FROM_CQ(cq) (cq->pollset)
grpc_core::TraceFlag grpc_cq_pluck_trace(false, "queue_pluck");
@ -550,46 +443,6 @@ static void on_pollset_shutdown_done(void* cq, grpc_error* error);
void grpc_cq_global_init() {
gpr_tls_init(&g_cached_event);
gpr_tls_init(&g_cached_cq);
g_nonpolling_cq_vtable[GRPC_CQ_NEXT] = g_polling_cq_vtable[GRPC_CQ_NEXT];
g_nonpolling_cq_vtable[GRPC_CQ_PLUCK] = g_polling_cq_vtable[GRPC_CQ_PLUCK];
g_nonpolling_cq_vtable[GRPC_CQ_CALLBACK] =
g_polling_cq_vtable[GRPC_CQ_CALLBACK];
}
// TODO(vjpai): Remove when callback_alternative is no longer needed
void grpc_cq_init() {
// If the iomgr runs in the background, we can use the preferred callback CQ.
// If the iomgr is non-polling, we cannot use the alternative callback CQ.
if (!grpc_iomgr_run_in_background() && !grpc_iomgr_non_polling()) {
cq_callback_alternative_data::shared_cq_next_mu.Init();
g_polling_cq_vtable[GRPC_CQ_CALLBACK] = {
GRPC_CQ_CALLBACK,
sizeof(cq_callback_alternative_data),
cq_init_callback_alternative,
cq_shutdown_callback_alternative,
cq_destroy_callback_alternative,
cq_begin_op_for_callback_alternative,
cq_end_op_for_callback_alternative,
nullptr,
nullptr,
cq_proxy_pollset_for_callback_alternative};
}
}
// TODO(vjpai): Remove when callback_alternative is no longer needed
void grpc_cq_shutdown() {
if (!grpc_iomgr_run_in_background() && !grpc_iomgr_non_polling()) {
{
grpc_core::MutexLock lock(
&*cq_callback_alternative_data::shared_cq_next_mu);
if (cq_callback_alternative_data::shared_cq_next != nullptr) {
grpc_completion_queue_shutdown(
cq_callback_alternative_data::shared_cq_next);
}
cq_callback_alternative_data::shared_cq_next = nullptr;
}
cq_callback_alternative_data::shared_cq_next_mu.Destroy();
}
}
void grpc_completion_queue_thread_local_cache_init(grpc_completion_queue* cq) {
@ -668,9 +521,7 @@ grpc_completion_queue* grpc_completion_queue_create_internal(
"polling_type=%d)",
2, (completion_type, polling_type));
const cq_vtable* vtable = (polling_type == GRPC_CQ_NON_POLLING)
? &g_nonpolling_cq_vtable[completion_type]
: &g_polling_cq_vtable[completion_type];
const cq_vtable* vtable = &g_cq_vtable[completion_type];
const cq_poller_vtable* poller_vtable =
&g_poller_vtable_by_poller_type[polling_type];
@ -687,18 +538,9 @@ grpc_completion_queue* grpc_completion_queue_create_internal(
/* One for destroy(), one for pollset_shutdown */
new (&cq->owning_refs) grpc_core::RefCount(2);
poller_vtable->init(POLLSET_FROM_CQ(cq), &cq->mu);
vtable->init(DATA_FROM_CQ(cq), shutdown_callback);
// TODO(vjpai): When callback_alternative is no longer needed, cq->pollset can
// be removed and the nullptr proxy_pollset value below can be the definition
// of POLLSET_FROM_CQ.
cq->pollset = cq->vtable->proxy_pollset == nullptr
? INLINE_POLLSET_FROM_CQ(cq)
: cq->vtable->proxy_pollset(cq);
// Init the inline pollset. If a proxy CQ is used, the proxy pollset will be
// init'ed in its CQ init.
cq->poller_vtable->init(INLINE_POLLSET_FROM_CQ(cq), &cq->mu);
GRPC_CLOSURE_INIT(&cq->pollset_shutdown_done, on_pollset_shutdown_done, cq,
grpc_schedule_on_exec_ctx);
return cq;
@ -736,17 +578,6 @@ static void cq_destroy_callback(void* data) {
cqd->~cq_callback_data();
}
static void cq_init_callback_alternative(
void* data, grpc_experimental_completion_queue_functor* shutdown_callback) {
new (data) cq_callback_alternative_data(shutdown_callback);
}
static void cq_destroy_callback_alternative(void* data) {
cq_callback_alternative_data* cqd =
static_cast<cq_callback_alternative_data*>(data);
cqd->~cq_callback_alternative_data();
}
grpc_cq_completion_type grpc_get_cq_completion_type(grpc_completion_queue* cq) {
return cq->vtable->cq_completion_type;
}
@ -787,9 +618,7 @@ void grpc_cq_internal_unref(grpc_completion_queue* cq) {
#endif
if (GPR_UNLIKELY(cq->owning_refs.Unref(debug_location, reason))) {
cq->vtable->destroy(DATA_FROM_CQ(cq));
// Only destroy the inlined pollset. If a proxy CQ is used, the proxy
// pollset will be destroyed by the proxy CQ.
cq->poller_vtable->destroy(INLINE_POLLSET_FROM_CQ(cq));
cq->poller_vtable->destroy(POLLSET_FROM_CQ(cq));
#ifndef NDEBUG
gpr_free(cq->outstanding_tags);
#endif
@ -840,14 +669,6 @@ static bool cq_begin_op_for_callback(grpc_completion_queue* cq, void* /*tag*/) {
return cqd->pending_events.IncrementIfNonzero();
}
static bool cq_begin_op_for_callback_alternative(grpc_completion_queue* cq,
void* tag) {
cq_callback_alternative_data* cqd =
static_cast<cq_callback_alternative_data*> DATA_FROM_CQ(cq);
return grpc_cq_begin_op(cqd->implementation, tag) &&
cqd->pending_events.IncrementIfNonzero();
}
bool grpc_cq_begin_op(grpc_completion_queue* cq, void* tag) {
#ifndef NDEBUG
gpr_mu_lock(cq->mu);
@ -1011,7 +832,7 @@ static void cq_end_op_for_pluck(
GRPC_ERROR_UNREF(error);
}
void functor_callback(void* arg, grpc_error* error) {
static void functor_callback(void* arg, grpc_error* error) {
auto* functor = static_cast<grpc_experimental_completion_queue_functor*>(arg);
functor->functor_run(functor, error == GRPC_ERROR_NONE);
}
@ -1071,40 +892,6 @@ static void cq_end_op_for_callback(
GRPC_CLOSURE_CREATE(functor_callback, functor, nullptr), error);
}
static void cq_end_op_for_callback_alternative(
grpc_completion_queue* cq, void* tag, grpc_error* error,
void (*done)(void* done_arg, grpc_cq_completion* storage), void* done_arg,
grpc_cq_completion* storage, bool internal) {
GPR_TIMER_SCOPE("cq_end_op_for_callback_alternative", 0);
cq_callback_alternative_data* cqd =
static_cast<cq_callback_alternative_data*> DATA_FROM_CQ(cq);
if (GRPC_TRACE_FLAG_ENABLED(grpc_api_trace) ||
(GRPC_TRACE_FLAG_ENABLED(grpc_trace_operation_failures) &&
error != GRPC_ERROR_NONE)) {
const char* errmsg = grpc_error_string(error);
GRPC_API_TRACE(
"cq_end_op_for_callback_alternative(cq=%p, tag=%p, error=%s, "
"done=%p, done_arg=%p, storage=%p)",
6, (cq, tag, errmsg, done, done_arg, storage));
if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_operation_failures) &&
error != GRPC_ERROR_NONE) {
gpr_log(GPR_ERROR, "Operation failed: tag=%p, error=%s", tag, errmsg);
}
}
// Pass through the actual work to the internal nextable CQ
grpc_cq_end_op(cqd->implementation, tag, error, done, done_arg, storage,
internal);
cq_check_tag(cq, tag, true); /* Used in debug builds only */
if (cqd->pending_events.FetchSub(1, grpc_core::MemoryOrder::ACQ_REL) == 1) {
cq_finish_shutdown_callback_alternative(cq);
}
}
void grpc_cq_end_op(grpc_completion_queue* cq, void* tag, grpc_error* error,
void (*done)(void* done_arg, grpc_cq_completion* storage),
void* done_arg, grpc_cq_completion* storage,
@ -1112,13 +899,6 @@ void grpc_cq_end_op(grpc_completion_queue* cq, void* tag, grpc_error* error,
cq->vtable->end_op(cq, tag, error, done, done_arg, storage, internal);
}
static grpc_pollset* cq_proxy_pollset_for_callback_alternative(
grpc_completion_queue* cq) {
cq_callback_alternative_data* cqd =
static_cast<cq_callback_alternative_data*>(DATA_FROM_CQ(cq));
return POLLSET_FROM_CQ(cqd->implementation);
}
struct cq_is_finished_arg {
gpr_atm last_seen_things_queued_ever;
grpc_completion_queue* cq;
@ -1599,21 +1379,6 @@ static void cq_finish_shutdown_callback(grpc_completion_queue* cq) {
GRPC_ERROR_NONE);
}
static void cq_finish_shutdown_callback_alternative(grpc_completion_queue* cq) {
cq_callback_alternative_data* cqd =
static_cast<cq_callback_alternative_data*> DATA_FROM_CQ(cq);
auto* callback = cqd->shutdown_callback;
GPR_ASSERT(cqd->shutdown_called);
// Shutdown the non-proxy pollset
cq->poller_vtable->shutdown(INLINE_POLLSET_FROM_CQ(cq),
&cq->pollset_shutdown_done);
grpc_core::Executor::Run(
GRPC_CLOSURE_CREATE(functor_callback, callback, nullptr),
GRPC_ERROR_NONE);
}
static void cq_shutdown_callback(grpc_completion_queue* cq) {
cq_callback_data* cqd = static_cast<cq_callback_data*> DATA_FROM_CQ(cq);
@ -1640,33 +1405,6 @@ static void cq_shutdown_callback(grpc_completion_queue* cq) {
GRPC_CQ_INTERNAL_UNREF(cq, "shutting_down (callback cq)");
}
static void cq_shutdown_callback_alternative(grpc_completion_queue* cq) {
cq_callback_alternative_data* cqd =
static_cast<cq_callback_alternative_data*> DATA_FROM_CQ(cq);
/* Need an extra ref for cq here because:
* We call cq_finish_shutdown_callback() below, which calls pollset shutdown.
* Pollset shutdown decrements the cq ref count which can potentially destroy
* the cq (if that happens to be the last ref).
* Creating an extra ref here prevents the cq from getting destroyed while
* this function is still active */
GRPC_CQ_INTERNAL_REF(cq, "shutting_down (callback cq)");
gpr_mu_lock(cq->mu);
if (cqd->shutdown_called) {
gpr_mu_unlock(cq->mu);
GRPC_CQ_INTERNAL_UNREF(cq, "shutting_down (callback cq)");
return;
}
cqd->shutdown_called = true;
if (cqd->pending_events.FetchSub(1, grpc_core::MemoryOrder::ACQ_REL) == 1) {
gpr_mu_unlock(cq->mu);
cq_finish_shutdown_callback_alternative(cq);
} else {
gpr_mu_unlock(cq->mu);
}
GRPC_CQ_INTERNAL_UNREF(cq, "shutting_down (callback cq)");
}
/* Shutdown simply drops a ref that we reserved at creation time; if we drop
to zero here, then enter shutdown mode and wake up any waiters */
void grpc_completion_queue_shutdown(grpc_completion_queue* cq) {

@ -69,14 +69,6 @@ void grpc_cq_internal_unref(grpc_completion_queue* cc);
/* Initializes global variables used by completion queues */
void grpc_cq_global_init();
// Completion queue initializations that must be done after iomgr
// TODO(vjpai): Remove when callback_alternative is no longer needed.
void grpc_cq_init();
// Completion queue shutdowns that must be done before iomgr shutdown.
// TODO(vjpai): Remove when callback_alternative is no longer needed.
void grpc_cq_shutdown();
/* Flag that an operation is beginning: the completion channel will not finish
shutdown until a corrensponding grpc_cq_end_* call is made.
\a tag is currently used only in debug builds. Return true on success, and

@ -144,7 +144,6 @@ void grpc_init(void) {
grpc_core::ApplicationCallbackExecCtx::GlobalInit();
grpc_core::ExecCtx::GlobalInit();
grpc_iomgr_init();
grpc_cq_init();
gpr_timers_global_init();
grpc_core::HandshakerRegistry::Init();
grpc_security_init();
@ -170,7 +169,6 @@ void grpc_shutdown_internal_locked(void) {
int i;
{
grpc_core::ExecCtx exec_ctx(0);
grpc_cq_shutdown();
grpc_iomgr_shutdown_background_closure();
{
grpc_timer_manager_set_threading(false); // shutdown timer_manager thread

@ -1894,8 +1894,11 @@ tsi_result tsi_create_ssl_client_handshaker_factory_with_options(
#else
ssl_context = SSL_CTX_new(TLSv1_2_method());
#endif
// TODO(mattstev): Re-enable TLS 1.3 by using |options.min_tls_version| and
// |options.max_tls_version|, rather than hardcoding in TLS 1.2 as the min and
// max.
result = tsi_set_min_and_max_tls_versions(
ssl_context, options->min_tls_version, options->max_tls_version);
ssl_context, tsi_tls_version::TSI_TLS1_2, tsi_tls_version::TSI_TLS1_2);
if (result != TSI_OK) return result;
if (ssl_context == nullptr) {
gpr_log(GPR_ERROR, "Could not create ssl context.");
@ -2061,9 +2064,12 @@ tsi_result tsi_create_ssl_server_handshaker_factory_with_options(
#else
impl->ssl_contexts[i] = SSL_CTX_new(TLSv1_2_method());
#endif
// TODO(mattstev): Re-enable TLS 1.3 by using |options.min_tls_version|
// and |options.max_tls_version|, rather than hardcoding in TLS 1.2 as the
// min and max.
result = tsi_set_min_and_max_tls_versions(impl->ssl_contexts[i],
options->min_tls_version,
options->max_tls_version);
tsi_tls_version::TSI_TLS1_2,
tsi_tls_version::TSI_TLS1_2);
if (result != TSI_OK) return result;
if (impl->ssl_contexts[i] == nullptr) {
gpr_log(GPR_ERROR, "Could not create ssl context.");

@ -73,7 +73,7 @@ ClientContext::~ClientContext() {
}
void ClientContext::set_credentials(
const std::shared_ptr<grpc_impl::CallCredentials>& creds) {
const std::shared_ptr<grpc::CallCredentials>& creds) {
creds_ = creds;
// If call_ is set, we have already created the call, and set the call
// credentials. This should only be done before we have started the batch

@ -26,15 +26,15 @@
#include "src/cpp/client/create_channel_internal.h"
namespace grpc_impl {
std::shared_ptr<grpc::Channel> CreateChannelImpl(
const std::string& target,
namespace grpc {
std::shared_ptr<grpc::Channel> CreateChannel(
const grpc::string& target,
const std::shared_ptr<grpc::ChannelCredentials>& creds) {
return CreateCustomChannelImpl(target, creds, grpc::ChannelArguments());
return CreateCustomChannel(target, creds, grpc::ChannelArguments());
}
std::shared_ptr<grpc::Channel> CreateCustomChannelImpl(
const std::string& target,
std::shared_ptr<grpc::Channel> CreateCustomChannel(
const grpc::string& target,
const std::shared_ptr<grpc::ChannelCredentials>& creds,
const grpc::ChannelArguments& args) {
grpc::GrpcLibraryCodegen
@ -82,4 +82,4 @@ std::shared_ptr<grpc::Channel> CreateCustomChannelWithInterceptors(
}
} // namespace experimental
} // namespace grpc_impl
} // namespace grpc

@ -19,7 +19,7 @@
#include <grpcpp/impl/grpc_library.h>
#include <grpcpp/security/credentials.h>
namespace grpc_impl {
namespace grpc {
static grpc::internal::GrpcLibraryInitializer g_gli_initializer;
ChannelCredentials::ChannelCredentials() { g_gli_initializer.summon(); }
@ -30,4 +30,4 @@ CallCredentials::CallCredentials() { g_gli_initializer.summon(); }
CallCredentials::~CallCredentials() {}
} // namespace grpc_impl
} // namespace grpc

@ -55,10 +55,9 @@ class CronetChannelCredentialsImpl final : public ChannelCredentials {
}
void* engine_;
};
} // namespace grpc
namespace grpc_impl {
std::shared_ptr<ChannelCredentials> CronetChannelCredentials(void* engine) {
return std::shared_ptr<ChannelCredentials>(
new grpc::CronetChannelCredentialsImpl(engine));
}
} // namespace grpc_impl
} // namespace grpc

@ -24,7 +24,7 @@
#include <grpcpp/support/config.h>
#include "src/cpp/client/create_channel_internal.h"
namespace grpc_impl {
namespace grpc {
namespace {
class InsecureChannelCredentialsImpl final : public ChannelCredentials {
@ -59,4 +59,4 @@ std::shared_ptr<ChannelCredentials> InsecureChannelCredentials() {
new InsecureChannelCredentialsImpl());
}
} // namespace grpc_impl
} // namespace grpc

@ -38,7 +38,7 @@
#include "src/cpp/client/create_channel_internal.h"
#include "src/cpp/common/secure_auth_context.h"
namespace grpc_impl {
namespace grpc {
static grpc::internal::GrpcLibraryInitializer g_gli_initializer;
SecureChannelCredentials::SecureChannelCredentials(
@ -388,9 +388,6 @@ std::shared_ptr<CallCredentials> MetadataCredentialsFromPlugin(
c_plugin, GRPC_PRIVACY_AND_INTEGRITY, nullptr));
}
} // namespace grpc_impl
namespace grpc {
namespace {
void DeleteWrapper(void* wrapper, grpc_error* /*ignored*/) {
MetadataCredentialsPluginWrapper* w =

@ -22,7 +22,6 @@
#include <grpc/grpc_security.h>
#include <grpcpp/security/credentials.h>
#include <grpcpp/security/credentials_impl.h>
#include <grpcpp/security/tls_credentials_options.h>
#include <grpcpp/support/config.h>
@ -33,6 +32,9 @@
namespace grpc_impl {
class Channel;
} // namespace grpc_impl
namespace grpc {
class SecureChannelCredentials final : public ChannelCredentials {
public:
@ -85,10 +87,6 @@ grpc_sts_credentials_options StsCredentialsCppToCoreOptions(
} // namespace experimental
} // namespace grpc_impl
namespace grpc {
class MetadataCredentialsPluginWrapper final : private GrpcLibraryCodegen {
public:
static void Destroy(void* wrapper);

@ -23,7 +23,7 @@
#include "src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h"
#include "src/cpp/common/tls_credentials_options_util.h"
namespace grpc_impl {
namespace grpc {
namespace experimental {
/** TLS key materials config API implementation **/
@ -340,4 +340,4 @@ TlsCredentialsOptions::TlsCredentialsOptions(
TlsCredentialsOptions::~TlsCredentialsOptions() {}
} // namespace experimental
} // namespace grpc_impl
} // namespace grpc

@ -21,7 +21,7 @@
#include <grpcpp/security/tls_credentials_options.h>
#include "src/cpp/common/tls_credentials_options_util.h"
namespace grpc_impl {
namespace grpc {
namespace experimental {
/** Converts the Cpp key materials to C key materials; this allocates memory for
@ -146,4 +146,4 @@ void TlsServerAuthorizationCheckArgDestroyContext(void* context) {
}
} // namespace experimental
} // namespace grpc_impl
} // namespace grpc

@ -24,7 +24,7 @@
#include "src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h"
namespace grpc_impl {
namespace grpc {
namespace experimental {
/** The following function is exposed for testing purposes. **/
@ -53,6 +53,6 @@ void TlsCredentialReloadArgDestroyContext(void* context);
void TlsServerAuthorizationCheckArgDestroyContext(void* context);
} // namespace experimental
} // namespace grpc_impl
} // namespace grpc
#endif // GRPC_INTERNAL_CPP_COMMON_TLS_CREDENTIALS_OPTIONS_UTIL_H

@ -145,7 +145,7 @@ std::shared_ptr<ServerCredentials> LocalServerCredentials(
}
std::shared_ptr<ServerCredentials> TlsServerCredentials(
const grpc_impl::experimental::TlsCredentialsOptions& options) {
const grpc::experimental::TlsCredentialsOptions& options) {
grpc::GrpcLibraryCodegen init;
return std::shared_ptr<ServerCredentials>(new SecureServerCredentials(
grpc_tls_server_credentials_create(options.c_credentials_options())));

@ -50,7 +50,7 @@ extern HashTable grpc_persistent_list;
extern HashTable grpc_target_upper_bound_map;
void free_grpc_channel_wrapper(grpc_channel_wrapper* channel, bool free_channel) {
if (free_channel) {
if (free_channel && channel->wrapped) {
grpc_channel_destroy(channel->wrapped);
channel->wrapped = NULL;
}

@ -159,6 +159,7 @@ void destroy_grpc_channels() {
wrapped_channel.wrapper = le->channel;
grpc_channel_wrapper *channel = wrapped_channel.wrapper;
grpc_channel_destroy(channel->wrapped);
channel->wrapped = NULL;
PHP_GRPC_HASH_FOREACH_END()
}

@ -42,18 +42,10 @@ grpc_proto_library(
],
well_known_protos = True,
deps = [
":percent_proto",
"percent_proto",
],
)
grpc_proto_library(
name = "status_proto",
srcs = [
"status.proto",
],
well_known_protos = True,
)
grpc_proto_library(
name = "discovery_proto",
srcs = [
@ -61,8 +53,7 @@ grpc_proto_library(
],
well_known_protos = True,
deps = [
":base_proto",
":status_proto",
"base_proto",
],
)
@ -74,7 +65,7 @@ grpc_proto_library(
has_services = True,
well_known_protos = True,
deps = [
":discovery_proto",
"discovery_proto",
],
)
@ -91,7 +82,7 @@ grpc_proto_library(
"cluster.proto",
],
deps = [
":config_source_proto",
"config_source_proto",
],
)
@ -102,9 +93,9 @@ grpc_proto_library(
],
well_known_protos = True,
deps = [
":address_proto",
":base_proto",
":percent_proto",
"address_proto",
"base_proto",
"percent_proto",
],
)
@ -123,8 +114,8 @@ grpc_proto_library(
],
well_known_protos = True,
deps = [
":address_proto",
":base_proto",
"address_proto",
"base_proto",
],
)
@ -136,8 +127,8 @@ grpc_proto_library(
has_services = True,
well_known_protos = True,
deps = [
":base_proto",
":load_report_proto",
"base_proto",
"load_report_proto",
],
)
@ -169,10 +160,10 @@ grpc_proto_library(
],
well_known_protos = True,
deps = [
":base_proto",
":percent_proto",
":range_proto",
":regex_proto",
"base_proto",
"percent_proto",
"range_proto",
"regex_proto",
],
)
@ -182,7 +173,7 @@ grpc_proto_library(
"http_connection_manager.proto",
],
deps = [
":config_source_proto",
":route_proto",
"config_source_proto",
"route_proto",
],
)

@ -21,7 +21,20 @@ package envoy.service.discovery.v3;
import "src/proto/grpc/testing/xds/v3/base.proto";
import "google/protobuf/any.proto";
import "src/proto/grpc/testing/xds/v3/status.proto";
message Status {
// The status code, which should be an enum value of [google.rpc.Code][].
int32 code = 1;
// A developer-facing error message, which should be in English. Any
// user-facing error message should be localized and sent in the
// [google.rpc.Status.details][] field, or localized by the client.
string message = 2;
// A list of messages that carry the error details. There is a common set of
// message types for APIs to use.
repeated google.protobuf.Any details = 3;
}
// [#protodoc-title: Common discovery API components]
@ -66,7 +79,7 @@ message DiscoveryRequest {
// failed to update configuration. The *message* field in *error_details* provides the Envoy
// internal exception related to the failure. It is only intended for consumption during manual
// debugging, the string provided is not guaranteed to be stable across Envoy versions.
google.rpc.Status error_detail = 6;
Status error_detail = 6;
}
// [#next-free-field: 7]

@ -1,89 +0,0 @@
// Copyright 2020 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.
// Local copy of Google status proto file, used for testing only.
syntax = "proto3";
package google.rpc;
import "google/protobuf/any.proto";
// The `Status` type defines a logical error model that is suitable for different
// programming environments, including REST APIs and RPC APIs. It is used by
// [gRPC](https://github.com/grpc). The error model is designed to be:
//
// - Simple to use and understand for most users
// - Flexible enough to meet unexpected needs
//
// # Overview
//
// The `Status` message contains three pieces of data: error code, error message,
// and error details. The error code should be an enum value of
// [google.rpc.Code][google.rpc.Code], but it may accept additional error codes if needed. The
// error message should be a developer-facing English message that helps
// developers *understand* and *resolve* the error. If a localized user-facing
// error message is needed, put the localized message in the error details or
// localize it in the client. The optional error details may contain arbitrary
// information about the error. There is a predefined set of error detail types
// in the package `google.rpc` that can be used for common error conditions.
//
// # Language mapping
//
// The `Status` message is the logical representation of the error model, but it
// is not necessarily the actual wire format. When the `Status` message is
// exposed in different client libraries and different wire protocols, it can be
// mapped differently. For example, it will likely be mapped to some exceptions
// in Java, but more likely mapped to some error codes in C.
//
// # Other uses
//
// The error model and the `Status` message can be used in a variety of
// environments, either with or without APIs, to provide a
// consistent developer experience across different environments.
//
// Example uses of this error model include:
//
// - Partial errors. If a service needs to return partial errors to the client,
// it may embed the `Status` in the normal response to indicate the partial
// errors.
//
// - Workflow errors. A typical workflow has multiple steps. Each step may
// have a `Status` message for error reporting.
//
// - Batch operations. If a client uses batch request and batch response, the
// `Status` message should be used directly inside batch response, one for
// each error sub-response.
//
// - Asynchronous operations. If an API call embeds asynchronous operation
// results in its response, the status of those operations should be
// represented directly using the `Status` message.
//
// - Logging. If some API errors are stored in logs, the message `Status` could
// be used directly after any stripping needed for security/privacy reasons.
message Status {
// The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code].
int32 code = 1;
// A developer-facing error message, which should be in English. Any
// user-facing error message should be localized and sent in the
// [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client.
string message = 2;
// A list of messages that carry the error details. There is a common set of
// message types for APIs to use.
repeated google.protobuf.Any details = 3;
}

@ -516,6 +516,14 @@ CORE_SOURCE_FILES = [
'third_party/abseil-cpp/absl/strings/str_split.cc',
'third_party/abseil-cpp/absl/strings/string_view.cc',
'third_party/abseil-cpp/absl/strings/substitute.cc',
'third_party/abseil-cpp/absl/synchronization/barrier.cc',
'third_party/abseil-cpp/absl/synchronization/blocking_counter.cc',
'third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.cc',
'third_party/abseil-cpp/absl/synchronization/internal/graphcycles.cc',
'third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.cc',
'third_party/abseil-cpp/absl/synchronization/internal/waiter.cc',
'third_party/abseil-cpp/absl/synchronization/mutex.cc',
'third_party/abseil-cpp/absl/synchronization/notification.cc',
'third_party/abseil-cpp/absl/time/civil_time.cc',
'third_party/abseil-cpp/absl/time/clock.cc',
'third_party/abseil-cpp/absl/time/duration.cc',

@ -49,15 +49,6 @@ def create_server_creds
true) # force client auth
end
# Useful to update a value within a do block
class MutableValue
attr_accessor :value
def initialize(value)
@value = value
end
end
def run_rpc_expect_unavailable(stub)
exception = nil
begin

@ -49,15 +49,6 @@ def create_server_creds
true) # force client auth
end
# Useful to update a value within a do block
class MutableValue
attr_accessor :value
def initialize(value)
@value = value
end
end
# rubocop:disable Metrics/AbcSize
# rubocop:disable Metrics/MethodLength
def main
@ -136,10 +127,16 @@ def main
STDERR.puts 'now perform another RPC and expect OK...'
stub.echo(Echo::EchoRequest.new(request: 'hello'), deadline: Time.now + 10)
jwt_aud_uri_extraction_success_count_mu.synchronize do
if jwt_aud_uri_extraction_success_count.value != 2003
if jwt_aud_uri_extraction_success_count.value < 4
fail "Expected auth metadata plugin callback to be ran with the jwt_aud_uri
parameter matching its expected value at least 4 times (at least 1 out of the 2000
initial expected-to-timeout RPCs should have caused this by now, and all three of the
successful RPCs should have caused this). This test isn't doing what it's meant to do."
end
unless jwt_aud_uri_failure_values.empty?
fail "Expected to get jwt_aud_uri:#{expected_jwt_aud_uri} passed to call creds
user callback 2003 times, but it was only passed to the call creds user callback
#{jwt_aud_uri_extraction_success_count.value} times. This suggests that either:
user callback every time that it was invoked, but it did not match the expected value
in #{jwt_aud_uri_failure_values.size} invocations. This suggests that either:
a) the expected jwt_aud_uri value is incorrect
b) there is some corruption of the jwt_aud_uri argument
Here are are the values of the jwt_aud_uri parameter that were passed to the call

@ -31,8 +31,17 @@ def main
sleep 3
begin
Timeout.timeout(10) do
control_stub.shutdown(ClientControl::Void.new)
Timeout.timeout(20) do
loop do
begin
control_stub.shutdown(ClientControl::Void.new)
break
rescue GRPC::BadStatus => e
STDERR.puts "control_stub.shutdown RPC received error:|#{e}|. " \
"This could mean that that child process e.g. isn't running yet, " \
"so we'll retry the RPC"
end
end
Process.wait(client_pid)
end
rescue Timeout::Error

@ -33,12 +33,47 @@ require_relative '../spec/support/helpers'
include GRPC::Spec::Helpers
# Useful to update a value within a do block
class MutableValue
attr_accessor :value
def initialize(value)
@value = value
end
end
# GreeterServer is simple server that implements the Helloworld Greeter server.
# This service also has a mechanism to wait for a timeout until the first
# RPC has been received, which is useful for synchronizing between parent
# and child processes.
class EchoServerImpl < Echo::EchoServer::Service
def initialize
@first_rpc_received_mu = Mutex.new
@first_rpc_received_cv = ConditionVariable.new
@first_rpc_received = MutableValue.new(false)
end
# say_hello implements the SayHello rpc method.
def echo(echo_req, _)
@first_rpc_received_mu.synchronize do
@first_rpc_received.value = true
@first_rpc_received_cv.broadcast
end
Echo::EchoReply.new(response: echo_req.request)
end
def wait_for_first_rpc_received(timeout_seconds)
Timeout.timeout(timeout_seconds) do
@first_rpc_received_mu.synchronize do
until @first_rpc_received.value
@first_rpc_received_cv.wait(@first_rpc_received_mu)
end
end
end
rescue => e
fail "Received error:|#{e}| while waiting for #{timeout_seconds} " \
'seconds to receive the first RPC'
end
end
# ServerRunner starts an "echo server" that test clients can make calls to

@ -19,51 +19,23 @@
require_relative './end2end_common'
# A service that calls back it's received_rpc_callback
# upon receiving an RPC. Used for synchronization/waiting
# for child process to start.
class ClientStartedService < Echo::EchoServer::Service
def initialize(received_rpc_callback)
@received_rpc_callback = received_rpc_callback
end
def echo(echo_req, _)
@received_rpc_callback.call unless @received_rpc_callback.nil?
@received_rpc_callback = nil
Echo::EchoReply.new(response: echo_req.request)
end
end
def main
STDERR.puts 'start server'
client_started = false
client_started_mu = Mutex.new
client_started_cv = ConditionVariable.new
received_rpc_callback = proc do
client_started_mu.synchronize do
client_started = true
client_started_cv.signal
end
end
client_started_service = ClientStartedService.new(received_rpc_callback)
server_runner = ServerRunner.new(client_started_service)
echo_service = EchoServerImpl.new
server_runner = ServerRunner.new(echo_service)
server_port = server_runner.run
STDERR.puts 'start client'
control_stub, client_pid = start_client('graceful_sig_handling_client.rb', server_port)
client_started_mu.synchronize do
client_started_cv.wait(client_started_mu) until client_started
end
# use receipt of one RPC to indicate that the child process is
# ready
echo_service.wait_for_first_rpc_received(20)
# now get the client to send an RPC
control_stub.do_echo_rpc(
ClientControl::DoEchoRpcRequest.new(request: 'hello'))
STDERR.puts 'killing client'
Process.kill('SIGINT', client_pid)
Process.wait(client_pid)
client_exit_status = $CHILD_STATUS
if client_exit_status.exited?
if client_exit_status.exitstatus != 0
STDERR.puts 'Client did not close gracefully'
@ -75,7 +47,6 @@ def main
end
STDERR.puts 'Client ended gracefully'
# no need to call cleanup, client should already be dead
server_runner.stop
end

@ -19,43 +19,16 @@
require_relative './end2end_common'
# A service that calls back it's received_rpc_callback
# upon receiving an RPC. Used for synchronization/waiting
# for child process to start.
class ClientStartedService < Echo::EchoServer::Service
def initialize(received_rpc_callback)
@received_rpc_callback = received_rpc_callback
end
def echo(echo_req, _)
@received_rpc_callback.call unless @received_rpc_callback.nil?
@received_rpc_callback = nil
Echo::EchoReply.new(response: echo_req.request)
end
end
def main
STDERR.puts 'start server'
client_started = false
client_started_mu = Mutex.new
client_started_cv = ConditionVariable.new
received_rpc_callback = proc do
client_started_mu.synchronize do
client_started = true
client_started_cv.signal
end
end
client_started_service = ClientStartedService.new(received_rpc_callback)
server_runner = ServerRunner.new(client_started_service)
echo_service = EchoServerImpl.new
server_runner = ServerRunner.new(echo_service)
server_port = server_runner.run
STDERR.puts 'start client'
control_stub, client_pid = start_client('./graceful_sig_stop_client.rb', server_port)
client_started_mu.synchronize do
client_started_cv.wait(client_started_mu) until client_started
end
# use receipt of one RPC to indicate that the child process is
# ready
echo_service.wait_for_first_rpc_received(20)
cleanup(control_stub, client_pid, server_runner)
end

@ -19,43 +19,16 @@
require_relative './end2end_common'
# A service that calls back it's received_rpc_callback
# upon receiving an RPC. Used for synchronization/waiting
# for child process to start.
class ClientStartedService < Echo::EchoServer::Service
def initialize(received_rpc_callback)
@received_rpc_callback = received_rpc_callback
end
def echo(echo_req, _)
@received_rpc_callback.call unless @received_rpc_callback.nil?
@received_rpc_callback = nil
Echo::EchoReply.new(response: echo_req.request)
end
end
def main
STDERR.puts 'start server'
client_started = false
client_started_mu = Mutex.new
client_started_cv = ConditionVariable.new
received_rpc_callback = proc do
client_started_mu.synchronize do
client_started = true
client_started_cv.signal
end
end
client_started_service = ClientStartedService.new(received_rpc_callback)
server_runner = ServerRunner.new(client_started_service)
echo_service = EchoServerImpl.new
server_runner = ServerRunner.new(echo_service)
server_port = server_runner.run
STDERR.puts 'start client'
control_stub, client_pid = start_client('sig_handling_client.rb', server_port)
client_started_mu.synchronize do
client_started_cv.wait(client_started_mu) until client_started
end
# use receipt of one RPC to indicate that the child process is
# ready
echo_service.wait_for_first_rpc_received(20)
count = 0
while count < 5
control_stub.do_echo_rpc(
@ -64,7 +37,6 @@ def main
Process.kill('SIGINT', client_pid)
count += 1
end
cleanup(control_stub, client_pid, server_runner)
end

@ -34,6 +34,16 @@ def main
trap('SIGINT') { exit 0 }
STDERR.puts 'sig_int_during_channel_watch_client.rb: SIGINT trap has been set'
# First, notify the parent process that we're ready for a SIGINT by sending
# an RPC
begin
stub = Echo::EchoServer::Stub.new(
"localhost:#{server_port}", :this_channel_is_insecure)
stub.echo(ClientControl::DoEchoRpcRequest.new)
rescue => e
fail "received error:|#{e}| while sending an RPC to the parent process " \
'to indicate that the SIGINT trap has been set'
end
thd = Thread.new do
child_thread_channel = GRPC::Core::Channel.new("localhost:#{server_port}",

@ -21,16 +21,19 @@ require_relative './end2end_common'
def main
STDERR.puts 'start server'
server_runner = ServerRunner.new(EchoServerImpl)
echo_service = EchoServerImpl.new
server_runner = ServerRunner.new(echo_service)
server_port = server_runner.run
STDERR.puts 'start client'
_, client_pid = start_client('sig_int_during_channel_watch_client.rb',
server_port)
# use receipt of one RPC to indicate that the child process is
# ready for a SIGINT
echo_service.wait_for_first_rpc_received(20)
# give time for the client to get into the middle
# of a channel state watch call
sleep 1
Process.kill('SIGINT', client_pid)
begin
Timeout.timeout(10) do
Process.wait(client_pid)
@ -43,12 +46,10 @@ def main
raise 'Timed out waiting for client process. It likely hangs when a ' \
'SIGINT is sent while there is an active connectivity_state call'
end
client_exit_code = $CHILD_STATUS
if client_exit_code != 0
fail "sig_int_during_channel_watch_client failed: #{client_exit_code}"
end
server_runner.stop
end

@ -26,7 +26,7 @@
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
#include "grpcpp/security/credentials_impl.h"
#include "grpcpp/security/credentials.h"
#include "src/core/lib/iomgr/error.h"
#include "src/core/lib/iomgr/load_file.h"
#include "src/core/lib/security/credentials/credentials.h"
@ -36,10 +36,9 @@
#include "test/core/util/cmdline.h"
static grpc_call_credentials* create_sts_creds(const char* json_file_path) {
grpc_impl::experimental::StsCredentialsOptions options;
grpc::experimental::StsCredentialsOptions options;
if (strlen(json_file_path) == 0) {
auto status =
grpc_impl::experimental::StsCredentialsOptionsFromEnv(&options);
auto status = grpc::experimental::StsCredentialsOptionsFromEnv(&options);
if (!status.ok()) {
gpr_log(GPR_ERROR, "%s", status.error_message().c_str());
return nullptr;
@ -48,7 +47,7 @@ static grpc_call_credentials* create_sts_creds(const char* json_file_path) {
grpc_slice sts_options_slice;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"load_file", grpc_load_file(json_file_path, 1, &sts_options_slice)));
auto status = grpc_impl::experimental::StsCredentialsOptionsFromJson(
auto status = grpc::experimental::StsCredentialsOptionsFromJson(
reinterpret_cast<const char*>(GRPC_SLICE_START_PTR(sts_options_slice)),
&options);
gpr_slice_unref(sts_options_slice);
@ -58,7 +57,7 @@ static grpc_call_credentials* create_sts_creds(const char* json_file_path) {
}
}
grpc_sts_credentials_options opts =
grpc_impl::experimental::StsCredentialsCppToCoreOptions(options);
grpc::experimental::StsCredentialsCppToCoreOptions(options);
grpc_call_credentials* result = grpc_sts_credentials_create(&opts, nullptr);
return result;
}

@ -246,8 +246,8 @@ TEST(CachingByteStream, SharedCache) {
} // namespace grpc_core
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
grpc::testing::TestEnvironment env(argc, argv);
::testing::InitGoogleTest(&argc, argv);
grpc_init();
int retval = RUN_ALL_TESTS();
grpc_shutdown();

@ -233,8 +233,8 @@ TEST(StateTracker, DoNotNotifyShutdownAtDestructionIfAlreadyInShutdown) {
} // namespace grpc_core
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
grpc::testing::TestEnvironment env(argc, argv);
::testing::InitGoogleTest(&argc, argv);
grpc_init();
grpc_core::testing::grpc_tracer_enable_flag(
&grpc_core::grpc_connectivity_state_trace);

@ -42,9 +42,9 @@ TEST(StaticMetadataTest, ReadAllStaticElements) {
} // namespace grpc_core
int main(int argc, char** argv) {
grpc::testing::TestEnvironment env(argc, argv);
::testing::InitGoogleTest(&argc, argv);
grpc_init();
grpc::testing::TestEnvironment env(argc, argv);
int retval = RUN_ALL_TESTS();
grpc_shutdown();
return retval;

@ -162,8 +162,6 @@ static void test_http2_status_to_grpc_status() {
}
int main(int argc, char** argv) {
int i;
grpc::testing::TestEnvironment env(argc, argv);
grpc_init();
@ -173,7 +171,7 @@ int main(int argc, char** argv) {
test_http2_status_to_grpc_status();
/* check all status values can be converted */
for (i = 0; i <= 999; i++) {
for (int i = 0; i <= 999; i++) {
grpc_http2_status_to_grpc_status(i);
}

@ -17,11 +17,11 @@
*/
#include "src/core/lib/transport/status_metadata.h"
#include "src/core/lib/transport/static_metadata.h"
#include "test/core/util/test_config.h"
#include <gtest/gtest.h>
#include "src/core/lib/transport/static_metadata.h"
namespace {
TEST(GetStatusCodeFromMetadata, OK) {
@ -56,6 +56,7 @@ TEST(GetStatusCodeFromMetadata, Unparseable) {
} // namespace
int main(int argc, char** argv) {
grpc::testing::TestEnvironment env(argc, argv);
::testing::InitGoogleTest(&argc, argv);
grpc_init();
int ret = RUN_ALL_TESTS();

@ -969,9 +969,8 @@ void ssl_tsi_test_extract_cert_chain() {
int main(int argc, char** argv) {
grpc::testing::TestEnvironment env(argc, argv);
grpc_init();
const size_t number_tls_versions = 2;
const tsi_tls_version tls_versions[] = {tsi_tls_version::TSI_TLS1_2,
tsi_tls_version::TSI_TLS1_3};
const size_t number_tls_versions = 1;
const tsi_tls_version tls_versions[] = {tsi_tls_version::TSI_TLS1_2};
for (size_t i = 0; i < number_tls_versions; i++) {
// Set the TLS version to be used in the tests.
test_tls_version = tls_versions[i];

@ -34,15 +34,14 @@
namespace {
typedef class ::grpc_impl::experimental::TlsKeyMaterialsConfig
TlsKeyMaterialsConfig;
typedef class ::grpc_impl::experimental::TlsCredentialReloadArg
typedef class ::grpc::experimental::TlsKeyMaterialsConfig TlsKeyMaterialsConfig;
typedef class ::grpc::experimental::TlsCredentialReloadArg
TlsCredentialReloadArg;
typedef struct ::grpc_impl::experimental::TlsCredentialReloadInterface
typedef struct ::grpc::experimental::TlsCredentialReloadInterface
TlsCredentialReloadInterface;
typedef class ::grpc_impl::experimental::TlsServerAuthorizationCheckArg
typedef class ::grpc::experimental::TlsServerAuthorizationCheckArg
TlsServerAuthorizationCheckArg;
typedef struct ::grpc_impl::experimental::TlsServerAuthorizationCheckInterface
typedef struct ::grpc::experimental::TlsServerAuthorizationCheckInterface
TlsServerAuthorizationCheckInterface;
static void tls_credential_reload_callback(
@ -131,7 +130,7 @@ TEST_F(CredentialsTest, StsCredentialsOptionsCppToCore) {
options.actor_token_path = "/foo/baz";
options.actor_token_type = "even_nicer_token_type";
grpc_sts_credentials_options core_opts =
grpc_impl::experimental::StsCredentialsCppToCoreOptions(options);
grpc::experimental::StsCredentialsCppToCoreOptions(options);
EXPECT_EQ(options.token_exchange_service_uri,
core_opts.token_exchange_service_uri);
EXPECT_EQ(options.resource, core_opts.resource);
@ -271,8 +270,7 @@ TEST_F(CredentialsTest, StsCredentialsOptionsFromEnv) {
gpr_unsetenv("STS_CREDENTIALS");
}
typedef class ::grpc_impl::experimental::TlsKeyMaterialsConfig
TlsKeyMaterialsConfig;
typedef class ::grpc::experimental::TlsKeyMaterialsConfig TlsKeyMaterialsConfig;
TEST_F(CredentialsTest, TlsKeyMaterialsConfigCppToC) {
std::shared_ptr<TlsKeyMaterialsConfig> config(new TlsKeyMaterialsConfig());
@ -304,9 +302,9 @@ TEST_F(CredentialsTest, TlsKeyMaterialsModifiers) {
EXPECT_STREQ(list[0].cert_chain.c_str(), "cert_chain");
}
typedef class ::grpc_impl::experimental::TlsCredentialReloadArg
typedef class ::grpc::experimental::TlsCredentialReloadArg
TlsCredentialReloadArg;
typedef class ::grpc_impl::experimental::TlsCredentialReloadConfig
typedef class ::grpc::experimental::TlsCredentialReloadConfig
TlsCredentialReloadConfig;
TEST_F(CredentialsTest, TlsCredentialReloadArgCallback) {
@ -433,9 +431,9 @@ TEST_F(CredentialsTest, TlsCredentialReloadConfigCppToC) {
delete config.c_config();
}
typedef class ::grpc_impl::experimental::TlsServerAuthorizationCheckArg
typedef class ::grpc::experimental::TlsServerAuthorizationCheckArg
TlsServerAuthorizationCheckArg;
typedef class ::grpc_impl::experimental::TlsServerAuthorizationCheckConfig
typedef class ::grpc::experimental::TlsServerAuthorizationCheckConfig
TlsServerAuthorizationCheckConfig;
TEST_F(CredentialsTest, TlsServerAuthorizationCheckArgCallback) {
@ -550,8 +548,7 @@ TEST_F(CredentialsTest, TlsServerAuthorizationCheckConfigCppToC) {
delete config.c_config();
}
typedef class ::grpc_impl::experimental::TlsCredentialsOptions
TlsCredentialsOptions;
typedef class ::grpc::experimental::TlsCredentialsOptions TlsCredentialsOptions;
TEST_F(CredentialsTest, TlsCredentialsOptionsCppToC) {
std::shared_ptr<TlsKeyMaterialsConfig> key_materials_config(
@ -681,7 +678,7 @@ TEST_F(CredentialsTest, LoadTlsChannelCredentials) {
TlsCredentialsOptions options = TlsCredentialsOptions(
GRPC_TLS_SERVER_VERIFICATION, nullptr, credential_reload_config,
server_authorization_check_config);
std::shared_ptr<grpc_impl::ChannelCredentials> channel_credentials =
std::shared_ptr<grpc::ChannelCredentials> channel_credentials =
grpc::experimental::TlsCredentials(options);
GPR_ASSERT(channel_credentials.get() != nullptr);
}

@ -45,6 +45,17 @@
#include "test/cpp/util/string_ref_helper.h"
#include "test/cpp/util/test_credentials_provider.h"
// MAYBE_SKIP_TEST is a macro to determine if this particular test configuration
// should be skipped based on a decision made at SetUp time. In particular, any
// callback tests can only be run if the iomgr can run in the background or if
// the transport is in-process.
#define MAYBE_SKIP_TEST \
do { \
if (do_not_test_) { \
return; \
} \
} while (0)
namespace grpc {
namespace testing {
namespace {
@ -119,6 +130,10 @@ class ClientCallbackEnd2endTest
server_ = builder.BuildAndStart();
is_server_started_ = true;
if (GetParam().protocol == Protocol::TCP &&
!grpc_iomgr_run_in_background()) {
do_not_test_ = true;
}
}
void ResetStub() {
@ -352,6 +367,7 @@ class ClientCallbackEnd2endTest
rpc.Await();
}
}
bool do_not_test_{false};
bool is_server_started_{false};
int picked_port_{0};
std::shared_ptr<Channel> channel_;
@ -364,11 +380,13 @@ class ClientCallbackEnd2endTest
};
TEST_P(ClientCallbackEnd2endTest, SimpleRpc) {
MAYBE_SKIP_TEST;
ResetStub();
SendRpcs(1, false);
}
TEST_P(ClientCallbackEnd2endTest, SimpleRpcExpectedError) {
MAYBE_SKIP_TEST;
ResetStub();
EchoRequest request;
@ -403,6 +421,7 @@ TEST_P(ClientCallbackEnd2endTest, SimpleRpcExpectedError) {
}
TEST_P(ClientCallbackEnd2endTest, SimpleRpcUnderLockNested) {
MAYBE_SKIP_TEST;
ResetStub();
std::mutex mu1, mu2, mu3;
std::condition_variable cv;
@ -453,6 +472,7 @@ TEST_P(ClientCallbackEnd2endTest, SimpleRpcUnderLockNested) {
}
TEST_P(ClientCallbackEnd2endTest, SimpleRpcUnderLock) {
MAYBE_SKIP_TEST;
ResetStub();
std::mutex mu;
std::condition_variable cv;
@ -480,16 +500,19 @@ TEST_P(ClientCallbackEnd2endTest, SimpleRpcUnderLock) {
}
TEST_P(ClientCallbackEnd2endTest, SequentialRpcs) {
MAYBE_SKIP_TEST;
ResetStub();
SendRpcs(10, false);
}
TEST_P(ClientCallbackEnd2endTest, SequentialRpcsRawReq) {
MAYBE_SKIP_TEST;
ResetStub();
SendRpcsRawReq(10);
}
TEST_P(ClientCallbackEnd2endTest, SendClientInitialMetadata) {
MAYBE_SKIP_TEST;
ResetStub();
SimpleRequest request;
SimpleResponse response;
@ -516,43 +539,51 @@ TEST_P(ClientCallbackEnd2endTest, SendClientInitialMetadata) {
}
TEST_P(ClientCallbackEnd2endTest, SimpleRpcWithBinaryMetadata) {
MAYBE_SKIP_TEST;
ResetStub();
SendRpcs(1, true);
}
TEST_P(ClientCallbackEnd2endTest, SequentialRpcsWithVariedBinaryMetadataValue) {
MAYBE_SKIP_TEST;
ResetStub();
SendRpcs(10, true);
}
TEST_P(ClientCallbackEnd2endTest, SequentialGenericRpcs) {
MAYBE_SKIP_TEST;
ResetStub();
SendRpcsGeneric(10, false);
}
TEST_P(ClientCallbackEnd2endTest, SequentialGenericRpcsAsBidi) {
MAYBE_SKIP_TEST;
ResetStub();
SendGenericEchoAsBidi(10, 1, /*do_writes_done=*/true);
}
TEST_P(ClientCallbackEnd2endTest, SequentialGenericRpcsAsBidiWithReactorReuse) {
MAYBE_SKIP_TEST;
ResetStub();
SendGenericEchoAsBidi(10, 10, /*do_writes_done=*/true);
}
TEST_P(ClientCallbackEnd2endTest, GenericRpcNoWritesDone) {
MAYBE_SKIP_TEST;
ResetStub();
SendGenericEchoAsBidi(1, 1, /*do_writes_done=*/false);
}
#if GRPC_ALLOW_EXCEPTIONS
TEST_P(ClientCallbackEnd2endTest, ExceptingRpc) {
MAYBE_SKIP_TEST;
ResetStub();
SendRpcsGeneric(10, true);
}
#endif
TEST_P(ClientCallbackEnd2endTest, MultipleRpcsWithVariedBinaryMetadataValue) {
MAYBE_SKIP_TEST;
ResetStub();
std::vector<std::thread> threads;
threads.reserve(10);
@ -565,6 +596,7 @@ TEST_P(ClientCallbackEnd2endTest, MultipleRpcsWithVariedBinaryMetadataValue) {
}
TEST_P(ClientCallbackEnd2endTest, MultipleRpcs) {
MAYBE_SKIP_TEST;
ResetStub();
std::vector<std::thread> threads;
threads.reserve(10);
@ -577,6 +609,7 @@ TEST_P(ClientCallbackEnd2endTest, MultipleRpcs) {
}
TEST_P(ClientCallbackEnd2endTest, CancelRpcBeforeStart) {
MAYBE_SKIP_TEST;
ResetStub();
EchoRequest request;
EchoResponse response;
@ -605,6 +638,7 @@ TEST_P(ClientCallbackEnd2endTest, CancelRpcBeforeStart) {
}
TEST_P(ClientCallbackEnd2endTest, RequestEchoServerCancel) {
MAYBE_SKIP_TEST;
ResetStub();
EchoRequest request;
EchoResponse response;
@ -735,6 +769,7 @@ class WriteClient : public grpc::experimental::ClientWriteReactor<EchoRequest> {
};
TEST_P(ClientCallbackEnd2endTest, RequestStream) {
MAYBE_SKIP_TEST;
ResetStub();
WriteClient test{stub_.get(), DO_NOT_CANCEL, 3};
test.Await();
@ -745,6 +780,7 @@ TEST_P(ClientCallbackEnd2endTest, RequestStream) {
}
TEST_P(ClientCallbackEnd2endTest, ClientCancelsRequestStream) {
MAYBE_SKIP_TEST;
ResetStub();
WriteClient test{stub_.get(), DO_NOT_CANCEL, 3, ClientCancelInfo{2}};
test.Await();
@ -756,6 +792,7 @@ TEST_P(ClientCallbackEnd2endTest, ClientCancelsRequestStream) {
// Server to cancel before doing reading the request
TEST_P(ClientCallbackEnd2endTest, RequestStreamServerCancelBeforeReads) {
MAYBE_SKIP_TEST;
ResetStub();
WriteClient test{stub_.get(), CANCEL_BEFORE_PROCESSING, 1};
test.Await();
@ -767,6 +804,7 @@ TEST_P(ClientCallbackEnd2endTest, RequestStreamServerCancelBeforeReads) {
// Server to cancel while reading a request from the stream in parallel
TEST_P(ClientCallbackEnd2endTest, RequestStreamServerCancelDuringRead) {
MAYBE_SKIP_TEST;
ResetStub();
WriteClient test{stub_.get(), CANCEL_DURING_PROCESSING, 10};
test.Await();
@ -779,6 +817,7 @@ TEST_P(ClientCallbackEnd2endTest, RequestStreamServerCancelDuringRead) {
// Server to cancel after reading all the requests but before returning to the
// client
TEST_P(ClientCallbackEnd2endTest, RequestStreamServerCancelAfterReads) {
MAYBE_SKIP_TEST;
ResetStub();
WriteClient test{stub_.get(), CANCEL_AFTER_PROCESSING, 4};
test.Await();
@ -789,6 +828,7 @@ TEST_P(ClientCallbackEnd2endTest, RequestStreamServerCancelAfterReads) {
}
TEST_P(ClientCallbackEnd2endTest, UnaryReactor) {
MAYBE_SKIP_TEST;
ResetStub();
class UnaryClient : public grpc::experimental::ClientUnaryReactor {
public:
@ -847,6 +887,7 @@ TEST_P(ClientCallbackEnd2endTest, UnaryReactor) {
}
TEST_P(ClientCallbackEnd2endTest, GenericUnaryReactor) {
MAYBE_SKIP_TEST;
ResetStub();
const std::string kMethodName("/grpc.testing.EchoTestService/Echo");
class UnaryClient : public grpc::experimental::ClientUnaryReactor {
@ -1012,6 +1053,7 @@ class ReadClient : public grpc::experimental::ClientReadReactor<EchoResponse> {
};
TEST_P(ClientCallbackEnd2endTest, ResponseStream) {
MAYBE_SKIP_TEST;
ResetStub();
ReadClient test{stub_.get(), DO_NOT_CANCEL};
test.Await();
@ -1022,6 +1064,7 @@ TEST_P(ClientCallbackEnd2endTest, ResponseStream) {
}
TEST_P(ClientCallbackEnd2endTest, ClientCancelsResponseStream) {
MAYBE_SKIP_TEST;
ResetStub();
ReadClient test{stub_.get(), DO_NOT_CANCEL, ClientCancelInfo{2}};
test.Await();
@ -1031,6 +1074,7 @@ TEST_P(ClientCallbackEnd2endTest, ClientCancelsResponseStream) {
// Server to cancel before sending any response messages
TEST_P(ClientCallbackEnd2endTest, ResponseStreamServerCancelBefore) {
MAYBE_SKIP_TEST;
ResetStub();
ReadClient test{stub_.get(), CANCEL_BEFORE_PROCESSING};
test.Await();
@ -1042,6 +1086,7 @@ TEST_P(ClientCallbackEnd2endTest, ResponseStreamServerCancelBefore) {
// Server to cancel while writing a response to the stream in parallel
TEST_P(ClientCallbackEnd2endTest, ResponseStreamServerCancelDuring) {
MAYBE_SKIP_TEST;
ResetStub();
ReadClient test{stub_.get(), CANCEL_DURING_PROCESSING};
test.Await();
@ -1054,6 +1099,7 @@ TEST_P(ClientCallbackEnd2endTest, ResponseStreamServerCancelDuring) {
// Server to cancel after writing all the respones to the stream but before
// returning to the client
TEST_P(ClientCallbackEnd2endTest, ResponseStreamServerCancelAfter) {
MAYBE_SKIP_TEST;
ResetStub();
ReadClient test{stub_.get(), CANCEL_AFTER_PROCESSING};
test.Await();
@ -1218,6 +1264,7 @@ class BidiClient
};
TEST_P(ClientCallbackEnd2endTest, BidiStream) {
MAYBE_SKIP_TEST;
ResetStub();
BidiClient test(stub_.get(), DO_NOT_CANCEL,
kServerDefaultResponseStreamsToSend,
@ -1230,6 +1277,7 @@ TEST_P(ClientCallbackEnd2endTest, BidiStream) {
}
TEST_P(ClientCallbackEnd2endTest, BidiStreamFirstWriteAsync) {
MAYBE_SKIP_TEST;
ResetStub();
BidiClient test(stub_.get(), DO_NOT_CANCEL,
kServerDefaultResponseStreamsToSend,
@ -1242,6 +1290,7 @@ TEST_P(ClientCallbackEnd2endTest, BidiStreamFirstWriteAsync) {
}
TEST_P(ClientCallbackEnd2endTest, BidiStreamCorked) {
MAYBE_SKIP_TEST;
ResetStub();
BidiClient test(stub_.get(), DO_NOT_CANCEL,
kServerDefaultResponseStreamsToSend,
@ -1254,6 +1303,7 @@ TEST_P(ClientCallbackEnd2endTest, BidiStreamCorked) {
}
TEST_P(ClientCallbackEnd2endTest, BidiStreamCorkedFirstWriteAsync) {
MAYBE_SKIP_TEST;
ResetStub();
BidiClient test(stub_.get(), DO_NOT_CANCEL,
kServerDefaultResponseStreamsToSend,
@ -1266,6 +1316,7 @@ TEST_P(ClientCallbackEnd2endTest, BidiStreamCorkedFirstWriteAsync) {
}
TEST_P(ClientCallbackEnd2endTest, ClientCancelsBidiStream) {
MAYBE_SKIP_TEST;
ResetStub();
BidiClient test(stub_.get(), DO_NOT_CANCEL,
kServerDefaultResponseStreamsToSend,
@ -1280,6 +1331,7 @@ TEST_P(ClientCallbackEnd2endTest, ClientCancelsBidiStream) {
// Server to cancel before reading/writing any requests/responses on the stream
TEST_P(ClientCallbackEnd2endTest, BidiStreamServerCancelBefore) {
MAYBE_SKIP_TEST;
ResetStub();
BidiClient test(stub_.get(), CANCEL_BEFORE_PROCESSING, /*num_msgs_to_send=*/2,
/*cork_metadata=*/false, /*first_write_async=*/false);
@ -1293,6 +1345,7 @@ TEST_P(ClientCallbackEnd2endTest, BidiStreamServerCancelBefore) {
// Server to cancel while reading/writing requests/responses on the stream in
// parallel
TEST_P(ClientCallbackEnd2endTest, BidiStreamServerCancelDuring) {
MAYBE_SKIP_TEST;
ResetStub();
BidiClient test(stub_.get(), CANCEL_DURING_PROCESSING,
/*num_msgs_to_send=*/10, /*cork_metadata=*/false,
@ -1307,6 +1360,7 @@ TEST_P(ClientCallbackEnd2endTest, BidiStreamServerCancelDuring) {
// Server to cancel after reading/writing all requests/responses on the stream
// but before returning to the client
TEST_P(ClientCallbackEnd2endTest, BidiStreamServerCancelAfter) {
MAYBE_SKIP_TEST;
ResetStub();
BidiClient test(stub_.get(), CANCEL_AFTER_PROCESSING, /*num_msgs_to_send=*/5,
/*cork_metadata=*/false, /*first_write_async=*/false);
@ -1318,6 +1372,7 @@ TEST_P(ClientCallbackEnd2endTest, BidiStreamServerCancelAfter) {
}
TEST_P(ClientCallbackEnd2endTest, SimultaneousReadAndWritesDone) {
MAYBE_SKIP_TEST;
ResetStub();
class Client : public grpc::experimental::ClientBidiReactor<EchoRequest,
EchoResponse> {
@ -1365,6 +1420,7 @@ TEST_P(ClientCallbackEnd2endTest, SimultaneousReadAndWritesDone) {
}
TEST_P(ClientCallbackEnd2endTest, UnimplementedRpc) {
MAYBE_SKIP_TEST;
ChannelArguments args;
const auto& channel_creds = GetCredentialsProvider()->GetChannelCredentials(
GetParam().credentials_type, &args);
@ -1399,6 +1455,7 @@ TEST_P(ClientCallbackEnd2endTest, UnimplementedRpc) {
TEST_P(ClientCallbackEnd2endTest,
ResponseStreamExtraReactionFlowReadsUntilDone) {
MAYBE_SKIP_TEST;
ResetStub();
class ReadAllIncomingDataClient
: public grpc::experimental::ClientReadReactor<EchoResponse> {
@ -1527,5 +1584,8 @@ INSTANTIATE_TEST_SUITE_P(ClientCallbackEnd2endTest, ClientCallbackEnd2endTest,
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
grpc::testing::TestEnvironment env(argc, argv);
return RUN_ALL_TESTS();
grpc_init();
int ret = RUN_ALL_TESTS();
grpc_shutdown();
return ret;
}

@ -62,6 +62,17 @@ using grpc::testing::EchoResponse;
using grpc::testing::kTlsCredentialsType;
using std::chrono::system_clock;
// MAYBE_SKIP_TEST is a macro to determine if this particular test configuration
// should be skipped based on a decision made at SetUp time. In particular,
// tests that use the callback server can only be run if the iomgr can run in
// the background or if the transport is in-process.
#define MAYBE_SKIP_TEST \
do { \
if (do_not_test_) { \
return; \
} \
} while (0)
namespace grpc {
namespace testing {
namespace {
@ -316,6 +327,14 @@ class End2endTest : public ::testing::TestWithParam<TestScenario> {
GetParam().Log();
}
void SetUp() override {
if (GetParam().callback_server && !GetParam().inproc &&
!grpc_iomgr_run_in_background()) {
do_not_test_ = true;
return;
}
}
void TearDown() override {
if (is_server_started_) {
server_->Shutdown();
@ -450,6 +469,7 @@ class End2endTest : public ::testing::TestWithParam<TestScenario> {
DummyInterceptor::Reset();
}
bool do_not_test_{false};
bool is_server_started_;
std::shared_ptr<Channel> channel_;
std::unique_ptr<grpc::testing::EchoTestService::Stub> stub_;
@ -505,6 +525,7 @@ class End2endServerTryCancelTest : public End2endTest {
// NOTE: Do not call this function with server_try_cancel == DO_NOT_CANCEL.
void TestRequestStreamServerCancel(
ServerTryCancelRequestPhase server_try_cancel, int num_msgs_to_send) {
MAYBE_SKIP_TEST;
RestartServer(std::shared_ptr<AuthMetadataProcessor>());
ResetStub();
EchoRequest request;
@ -583,6 +604,7 @@ class End2endServerTryCancelTest : public End2endTest {
// NOTE: Do not call this function with server_try_cancel == DO_NOT_CANCEL.
void TestResponseStreamServerCancel(
ServerTryCancelRequestPhase server_try_cancel) {
MAYBE_SKIP_TEST;
RestartServer(std::shared_ptr<AuthMetadataProcessor>());
ResetStub();
EchoRequest request;
@ -664,6 +686,7 @@ class End2endServerTryCancelTest : public End2endTest {
// NOTE: Do not call this function with server_try_cancel == DO_NOT_CANCEL.
void TestBidiStreamServerCancel(ServerTryCancelRequestPhase server_try_cancel,
int num_messages) {
MAYBE_SKIP_TEST;
RestartServer(std::shared_ptr<AuthMetadataProcessor>());
ResetStub();
EchoRequest request;
@ -739,6 +762,7 @@ class End2endServerTryCancelTest : public End2endTest {
};
TEST_P(End2endServerTryCancelTest, RequestEchoServerCancel) {
MAYBE_SKIP_TEST;
ResetStub();
EchoRequest request;
EchoResponse response;
@ -801,6 +825,7 @@ TEST_P(End2endServerTryCancelTest, BidiStreamServerCancelAfter) {
}
TEST_P(End2endTest, SimpleRpcWithCustomUserAgentPrefix) {
MAYBE_SKIP_TEST;
// User-Agent is an HTTP header for HTTP transports only
if (GetParam().inproc) {
return;
@ -824,6 +849,7 @@ TEST_P(End2endTest, SimpleRpcWithCustomUserAgentPrefix) {
}
TEST_P(End2endTest, MultipleRpcsWithVariedBinaryMetadataValue) {
MAYBE_SKIP_TEST;
ResetStub();
std::vector<std::thread> threads;
threads.reserve(10);
@ -836,6 +862,7 @@ TEST_P(End2endTest, MultipleRpcsWithVariedBinaryMetadataValue) {
}
TEST_P(End2endTest, MultipleRpcs) {
MAYBE_SKIP_TEST;
ResetStub();
std::vector<std::thread> threads;
threads.reserve(10);
@ -848,6 +875,7 @@ TEST_P(End2endTest, MultipleRpcs) {
}
TEST_P(End2endTest, ManyStubs) {
MAYBE_SKIP_TEST;
ResetStub();
ChannelTestPeer peer(channel_.get());
int registered_calls_pre = peer.registered_calls();
@ -860,6 +888,7 @@ TEST_P(End2endTest, ManyStubs) {
}
TEST_P(End2endTest, EmptyBinaryMetadata) {
MAYBE_SKIP_TEST;
ResetStub();
EchoRequest request;
EchoResponse response;
@ -872,6 +901,7 @@ TEST_P(End2endTest, EmptyBinaryMetadata) {
}
TEST_P(End2endTest, ReconnectChannel) {
MAYBE_SKIP_TEST;
if (GetParam().inproc) {
return;
}
@ -899,6 +929,7 @@ TEST_P(End2endTest, ReconnectChannel) {
}
TEST_P(End2endTest, RequestStreamOneRequest) {
MAYBE_SKIP_TEST;
ResetStub();
EchoRequest request;
EchoResponse response;
@ -915,6 +946,7 @@ TEST_P(End2endTest, RequestStreamOneRequest) {
}
TEST_P(End2endTest, RequestStreamOneRequestWithCoalescingApi) {
MAYBE_SKIP_TEST;
ResetStub();
EchoRequest request;
EchoResponse response;
@ -930,6 +962,7 @@ TEST_P(End2endTest, RequestStreamOneRequestWithCoalescingApi) {
}
TEST_P(End2endTest, RequestStreamTwoRequests) {
MAYBE_SKIP_TEST;
ResetStub();
EchoRequest request;
EchoResponse response;
@ -946,6 +979,7 @@ TEST_P(End2endTest, RequestStreamTwoRequests) {
}
TEST_P(End2endTest, RequestStreamTwoRequestsWithWriteThrough) {
MAYBE_SKIP_TEST;
ResetStub();
EchoRequest request;
EchoResponse response;
@ -962,6 +996,7 @@ TEST_P(End2endTest, RequestStreamTwoRequestsWithWriteThrough) {
}
TEST_P(End2endTest, RequestStreamTwoRequestsWithCoalescingApi) {
MAYBE_SKIP_TEST;
ResetStub();
EchoRequest request;
EchoResponse response;
@ -978,6 +1013,7 @@ TEST_P(End2endTest, RequestStreamTwoRequestsWithCoalescingApi) {
}
TEST_P(End2endTest, ResponseStream) {
MAYBE_SKIP_TEST;
ResetStub();
EchoRequest request;
EchoResponse response;
@ -996,6 +1032,7 @@ TEST_P(End2endTest, ResponseStream) {
}
TEST_P(End2endTest, ResponseStreamWithCoalescingApi) {
MAYBE_SKIP_TEST;
ResetStub();
EchoRequest request;
EchoResponse response;
@ -1017,6 +1054,7 @@ TEST_P(End2endTest, ResponseStreamWithCoalescingApi) {
// This was added to prevent regression from issue:
// https://github.com/grpc/grpc/issues/11546
TEST_P(End2endTest, ResponseStreamWithEverythingCoalesced) {
MAYBE_SKIP_TEST;
ResetStub();
EchoRequest request;
EchoResponse response;
@ -1038,6 +1076,7 @@ TEST_P(End2endTest, ResponseStreamWithEverythingCoalesced) {
}
TEST_P(End2endTest, BidiStream) {
MAYBE_SKIP_TEST;
ResetStub();
EchoRequest request;
EchoResponse response;
@ -1062,6 +1101,7 @@ TEST_P(End2endTest, BidiStream) {
}
TEST_P(End2endTest, BidiStreamWithCoalescingApi) {
MAYBE_SKIP_TEST;
ResetStub();
EchoRequest request;
EchoResponse response;
@ -1097,6 +1137,7 @@ TEST_P(End2endTest, BidiStreamWithCoalescingApi) {
// This was added to prevent regression from issue:
// https://github.com/grpc/grpc/issues/11546
TEST_P(End2endTest, BidiStreamWithEverythingCoalesced) {
MAYBE_SKIP_TEST;
ResetStub();
EchoRequest request;
EchoResponse response;
@ -1122,6 +1163,7 @@ TEST_P(End2endTest, BidiStreamWithEverythingCoalesced) {
// Talk to the two services with the same name but different package names.
// The two stubs are created on the same channel.
TEST_P(End2endTest, DiffPackageServices) {
MAYBE_SKIP_TEST;
ResetStub();
EchoRequest request;
EchoResponse response;
@ -1150,6 +1192,7 @@ void CancelRpc(ClientContext* context, int delay_us, ServiceType* service) {
}
TEST_P(End2endTest, CancelRpcBeforeStart) {
MAYBE_SKIP_TEST;
ResetStub();
EchoRequest request;
EchoResponse response;
@ -1165,6 +1208,7 @@ TEST_P(End2endTest, CancelRpcBeforeStart) {
}
TEST_P(End2endTest, CancelRpcAfterStart) {
MAYBE_SKIP_TEST;
ResetStub();
EchoRequest request;
EchoResponse response;
@ -1201,6 +1245,7 @@ TEST_P(End2endTest, CancelRpcAfterStart) {
// Client cancels request stream after sending two messages
TEST_P(End2endTest, ClientCancelsRequestStream) {
MAYBE_SKIP_TEST;
ResetStub();
EchoRequest request;
EchoResponse response;
@ -1224,6 +1269,7 @@ TEST_P(End2endTest, ClientCancelsRequestStream) {
// Client cancels server stream after sending some messages
TEST_P(End2endTest, ClientCancelsResponseStream) {
MAYBE_SKIP_TEST;
ResetStub();
EchoRequest request;
EchoResponse response;
@ -1259,6 +1305,7 @@ TEST_P(End2endTest, ClientCancelsResponseStream) {
// Client cancels bidi stream after sending some messages
TEST_P(End2endTest, ClientCancelsBidi) {
MAYBE_SKIP_TEST;
ResetStub();
EchoRequest request;
EchoResponse response;
@ -1294,6 +1341,7 @@ TEST_P(End2endTest, ClientCancelsBidi) {
}
TEST_P(End2endTest, RpcMaxMessageSize) {
MAYBE_SKIP_TEST;
ResetStub();
EchoRequest request;
EchoResponse response;
@ -1316,6 +1364,7 @@ void ReaderThreadFunc(ClientReaderWriter<EchoRequest, EchoResponse>* stream,
// Run a Read and a WritesDone simultaneously.
TEST_P(End2endTest, SimultaneousReadWritesDone) {
MAYBE_SKIP_TEST;
ResetStub();
ClientContext context;
gpr_event ev;
@ -1330,6 +1379,7 @@ TEST_P(End2endTest, SimultaneousReadWritesDone) {
}
TEST_P(End2endTest, ChannelState) {
MAYBE_SKIP_TEST;
if (GetParam().inproc) {
return;
}
@ -1380,6 +1430,7 @@ TEST_P(End2endTest, ChannelStateTimeout) {
// Talking to a non-existing service.
TEST_P(End2endTest, NonExistingService) {
MAYBE_SKIP_TEST;
ResetChannel();
std::unique_ptr<grpc::testing::UnimplementedEchoService::Stub> stub;
stub = grpc::testing::UnimplementedEchoService::NewStub(channel_);
@ -1397,6 +1448,7 @@ TEST_P(End2endTest, NonExistingService) {
// Ask the server to send back a serialized proto in trailer.
// This is an example of setting error details.
TEST_P(End2endTest, BinaryTrailerTest) {
MAYBE_SKIP_TEST;
ResetStub();
EchoRequest request;
EchoResponse response;
@ -1423,6 +1475,7 @@ TEST_P(End2endTest, BinaryTrailerTest) {
}
TEST_P(End2endTest, ExpectErrorTest) {
MAYBE_SKIP_TEST;
ResetStub();
std::vector<ErrorStatus> expected_status;
@ -1474,11 +1527,13 @@ class ProxyEnd2endTest : public End2endTest {
};
TEST_P(ProxyEnd2endTest, SimpleRpc) {
MAYBE_SKIP_TEST;
ResetStub();
SendRpc(stub_.get(), 1, false);
}
TEST_P(ProxyEnd2endTest, SimpleRpcWithEmptyMessages) {
MAYBE_SKIP_TEST;
ResetStub();
EchoRequest request;
EchoResponse response;
@ -1489,6 +1544,7 @@ TEST_P(ProxyEnd2endTest, SimpleRpcWithEmptyMessages) {
}
TEST_P(ProxyEnd2endTest, MultipleRpcs) {
MAYBE_SKIP_TEST;
ResetStub();
std::vector<std::thread> threads;
threads.reserve(10);
@ -1502,6 +1558,7 @@ TEST_P(ProxyEnd2endTest, MultipleRpcs) {
// Set a 10us deadline and make sure proper error is returned.
TEST_P(ProxyEnd2endTest, RpcDeadlineExpires) {
MAYBE_SKIP_TEST;
ResetStub();
EchoRequest request;
EchoResponse response;
@ -1527,6 +1584,7 @@ TEST_P(ProxyEnd2endTest, RpcDeadlineExpires) {
// Set a long but finite deadline.
TEST_P(ProxyEnd2endTest, RpcLongDeadline) {
MAYBE_SKIP_TEST;
ResetStub();
EchoRequest request;
EchoResponse response;
@ -1543,6 +1601,7 @@ TEST_P(ProxyEnd2endTest, RpcLongDeadline) {
// Ask server to echo back the deadline it sees.
TEST_P(ProxyEnd2endTest, EchoDeadline) {
MAYBE_SKIP_TEST;
ResetStub();
EchoRequest request;
EchoResponse response;
@ -1568,6 +1627,7 @@ TEST_P(ProxyEnd2endTest, EchoDeadline) {
// Ask server to echo back the deadline it sees. The rpc has no deadline.
TEST_P(ProxyEnd2endTest, EchoDeadlineForNoDeadlineRpc) {
MAYBE_SKIP_TEST;
ResetStub();
EchoRequest request;
EchoResponse response;
@ -1583,6 +1643,7 @@ TEST_P(ProxyEnd2endTest, EchoDeadlineForNoDeadlineRpc) {
}
TEST_P(ProxyEnd2endTest, UnimplementedRpc) {
MAYBE_SKIP_TEST;
ResetStub();
EchoRequest request;
EchoResponse response;
@ -1598,6 +1659,7 @@ TEST_P(ProxyEnd2endTest, UnimplementedRpc) {
// Client cancels rpc after 10ms
TEST_P(ProxyEnd2endTest, ClientCancelsRpc) {
MAYBE_SKIP_TEST;
ResetStub();
EchoRequest request;
EchoResponse response;
@ -1632,6 +1694,7 @@ TEST_P(ProxyEnd2endTest, ClientCancelsRpc) {
// Server cancels rpc after 1ms
TEST_P(ProxyEnd2endTest, ServerCancelsRpc) {
MAYBE_SKIP_TEST;
ResetStub();
EchoRequest request;
EchoResponse response;
@ -1646,6 +1709,7 @@ TEST_P(ProxyEnd2endTest, ServerCancelsRpc) {
// Make the response larger than the flow control window.
TEST_P(ProxyEnd2endTest, HugeResponse) {
MAYBE_SKIP_TEST;
ResetStub();
EchoRequest request;
EchoResponse response;
@ -1663,6 +1727,7 @@ TEST_P(ProxyEnd2endTest, HugeResponse) {
}
TEST_P(ProxyEnd2endTest, Peer) {
MAYBE_SKIP_TEST;
// Peer is not meaningful for inproc
if (GetParam().inproc) {
return;
@ -1691,6 +1756,7 @@ class SecureEnd2endTest : public End2endTest {
};
TEST_P(SecureEnd2endTest, SimpleRpcWithHost) {
MAYBE_SKIP_TEST;
ResetStub();
EchoRequest request;
@ -1722,6 +1788,7 @@ bool MetadataContains(
}
TEST_P(SecureEnd2endTest, BlockingAuthMetadataPluginAndProcessorSuccess) {
MAYBE_SKIP_TEST;
auto* processor = new TestAuthMetadataProcessor(true);
StartServer(std::shared_ptr<AuthMetadataProcessor>(processor));
ResetStub();
@ -1747,6 +1814,7 @@ TEST_P(SecureEnd2endTest, BlockingAuthMetadataPluginAndProcessorSuccess) {
}
TEST_P(SecureEnd2endTest, BlockingAuthMetadataPluginAndProcessorFailure) {
MAYBE_SKIP_TEST;
auto* processor = new TestAuthMetadataProcessor(true);
StartServer(std::shared_ptr<AuthMetadataProcessor>(processor));
ResetStub();
@ -1762,6 +1830,7 @@ TEST_P(SecureEnd2endTest, BlockingAuthMetadataPluginAndProcessorFailure) {
}
TEST_P(SecureEnd2endTest, SetPerCallCredentials) {
MAYBE_SKIP_TEST;
ResetStub();
EchoRequest request;
EchoResponse response;
@ -1812,6 +1881,7 @@ class CredentialsInterceptorFactory
};
TEST_P(SecureEnd2endTest, CallCredentialsInterception) {
MAYBE_SKIP_TEST;
if (!GetParam().use_interceptors) {
return;
}
@ -1841,6 +1911,7 @@ TEST_P(SecureEnd2endTest, CallCredentialsInterception) {
}
TEST_P(SecureEnd2endTest, CallCredentialsInterceptionWithSetCredentials) {
MAYBE_SKIP_TEST;
if (!GetParam().use_interceptors) {
return;
}
@ -1875,6 +1946,7 @@ TEST_P(SecureEnd2endTest, CallCredentialsInterceptionWithSetCredentials) {
}
TEST_P(SecureEnd2endTest, OverridePerCallCredentials) {
MAYBE_SKIP_TEST;
ResetStub();
EchoRequest request;
EchoResponse response;
@ -1912,6 +1984,7 @@ TEST_P(SecureEnd2endTest, OverridePerCallCredentials) {
}
TEST_P(SecureEnd2endTest, AuthMetadataPluginKeyFailure) {
MAYBE_SKIP_TEST;
ResetStub();
EchoRequest request;
EchoResponse response;
@ -1932,6 +2005,7 @@ TEST_P(SecureEnd2endTest, AuthMetadataPluginKeyFailure) {
}
TEST_P(SecureEnd2endTest, AuthMetadataPluginValueFailure) {
MAYBE_SKIP_TEST;
ResetStub();
EchoRequest request;
EchoResponse response;
@ -1951,6 +2025,7 @@ TEST_P(SecureEnd2endTest, AuthMetadataPluginValueFailure) {
}
TEST_P(SecureEnd2endTest, AuthMetadataPluginWithDeadline) {
MAYBE_SKIP_TEST;
ResetStub();
EchoRequest request;
request.mutable_param()->set_skip_cancelled_check(true);
@ -1976,6 +2051,7 @@ TEST_P(SecureEnd2endTest, AuthMetadataPluginWithDeadline) {
}
TEST_P(SecureEnd2endTest, AuthMetadataPluginWithCancel) {
MAYBE_SKIP_TEST;
ResetStub();
EchoRequest request;
request.mutable_param()->set_skip_cancelled_check(true);
@ -2004,6 +2080,7 @@ TEST_P(SecureEnd2endTest, AuthMetadataPluginWithCancel) {
}
TEST_P(SecureEnd2endTest, NonBlockingAuthMetadataPluginFailure) {
MAYBE_SKIP_TEST;
ResetStub();
EchoRequest request;
EchoResponse response;
@ -2027,6 +2104,7 @@ TEST_P(SecureEnd2endTest, NonBlockingAuthMetadataPluginFailure) {
}
TEST_P(SecureEnd2endTest, NonBlockingAuthMetadataPluginAndProcessorSuccess) {
MAYBE_SKIP_TEST;
auto* processor = new TestAuthMetadataProcessor(false);
StartServer(std::shared_ptr<AuthMetadataProcessor>(processor));
ResetStub();
@ -2055,6 +2133,7 @@ TEST_P(SecureEnd2endTest, NonBlockingAuthMetadataPluginAndProcessorSuccess) {
}
TEST_P(SecureEnd2endTest, NonBlockingAuthMetadataPluginAndProcessorFailure) {
MAYBE_SKIP_TEST;
auto* processor = new TestAuthMetadataProcessor(false);
StartServer(std::shared_ptr<AuthMetadataProcessor>(processor));
ResetStub();
@ -2073,6 +2152,7 @@ TEST_P(SecureEnd2endTest, NonBlockingAuthMetadataPluginAndProcessorFailure) {
}
TEST_P(SecureEnd2endTest, BlockingAuthMetadataPluginFailure) {
MAYBE_SKIP_TEST;
ResetStub();
EchoRequest request;
EchoResponse response;
@ -2096,6 +2176,7 @@ TEST_P(SecureEnd2endTest, BlockingAuthMetadataPluginFailure) {
}
TEST_P(SecureEnd2endTest, CompositeCallCreds) {
MAYBE_SKIP_TEST;
ResetStub();
EchoRequest request;
EchoResponse response;
@ -2128,6 +2209,7 @@ TEST_P(SecureEnd2endTest, CompositeCallCreds) {
}
TEST_P(SecureEnd2endTest, ClientAuthContext) {
MAYBE_SKIP_TEST;
ResetStub();
EchoRequest request;
EchoResponse response;
@ -2172,6 +2254,7 @@ class ResourceQuotaEnd2endTest : public End2endTest {
};
TEST_P(ResourceQuotaEnd2endTest, SimpleRequest) {
MAYBE_SKIP_TEST;
ResetStub();
EchoRequest request;
@ -2269,5 +2352,6 @@ INSTANTIATE_TEST_SUITE_P(
int main(int argc, char** argv) {
grpc::testing::TestEnvironment env(argc, argv);
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
int ret = RUN_ALL_TESTS();
return ret;
}

@ -114,7 +114,8 @@ void MakeAsyncCQCall(const std::shared_ptr<Channel>& channel) {
EXPECT_TRUE(recv_status.ok());
}
void MakeAsyncCQClientStreamingCall(const std::shared_ptr<Channel>& channel) {
void MakeAsyncCQClientStreamingCall(
const std::shared_ptr<Channel>& /*channel*/) {
// TODO(yashykt) : Fill this out
}
@ -146,7 +147,7 @@ void MakeAsyncCQServerStreamingCall(const std::shared_ptr<Channel>& channel) {
EXPECT_TRUE(recv_status.ok());
}
void MakeAsyncCQBidiStreamingCall(const std::shared_ptr<Channel>& channel) {
void MakeAsyncCQBidiStreamingCall(const std::shared_ptr<Channel>& /*channel*/) {
// TODO(yashykt) : Fill this out
}

@ -45,6 +45,17 @@
#include "test/core/util/test_config.h"
#include "test/cpp/util/test_credentials_provider.h"
// MAYBE_SKIP_TEST is a macro to determine if this particular test configuration
// should be skipped based on a decision made at SetUp time. In particular, any
// callback tests can only be run if the iomgr can run in the background or if
// the transport is in-process.
#define MAYBE_SKIP_TEST \
do { \
if (do_not_test_) { \
return; \
} \
} while (0)
namespace grpc {
namespace testing {
namespace {
@ -106,7 +117,15 @@ void TestScenario::Log() const {
class MessageAllocatorEnd2endTestBase
: public ::testing::TestWithParam<TestScenario> {
protected:
MessageAllocatorEnd2endTestBase() { GetParam().Log(); }
MessageAllocatorEnd2endTestBase() {
GetParam().Log();
if (GetParam().protocol == Protocol::TCP) {
if (!grpc_iomgr_run_in_background()) {
do_not_test_ = true;
return;
}
}
}
~MessageAllocatorEnd2endTestBase() = default;
@ -191,6 +210,7 @@ class MessageAllocatorEnd2endTestBase
}
}
bool do_not_test_{false};
int picked_port_{0};
std::shared_ptr<Channel> channel_;
std::unique_ptr<EchoTestService::Stub> stub_;
@ -202,6 +222,7 @@ class MessageAllocatorEnd2endTestBase
class NullAllocatorTest : public MessageAllocatorEnd2endTestBase {};
TEST_P(NullAllocatorTest, SimpleRpc) {
MAYBE_SKIP_TEST;
CreateServer(nullptr);
ResetStub();
SendRpcs(1);
@ -257,6 +278,7 @@ class SimpleAllocatorTest : public MessageAllocatorEnd2endTestBase {
};
TEST_P(SimpleAllocatorTest, SimpleRpc) {
MAYBE_SKIP_TEST;
const int kRpcCount = 10;
std::unique_ptr<SimpleAllocator> allocator(new SimpleAllocator);
CreateServer(allocator.get());
@ -271,6 +293,7 @@ TEST_P(SimpleAllocatorTest, SimpleRpc) {
}
TEST_P(SimpleAllocatorTest, RpcWithEarlyFreeRequest) {
MAYBE_SKIP_TEST;
const int kRpcCount = 10;
std::unique_ptr<SimpleAllocator> allocator(new SimpleAllocator);
auto mutator = [](experimental::RpcAllocatorState* allocator_state,
@ -295,6 +318,7 @@ TEST_P(SimpleAllocatorTest, RpcWithEarlyFreeRequest) {
}
TEST_P(SimpleAllocatorTest, RpcWithReleaseRequest) {
MAYBE_SKIP_TEST;
const int kRpcCount = 10;
std::unique_ptr<SimpleAllocator> allocator(new SimpleAllocator);
std::vector<EchoRequest*> released_requests;
@ -354,6 +378,7 @@ class ArenaAllocatorTest : public MessageAllocatorEnd2endTestBase {
};
TEST_P(ArenaAllocatorTest, SimpleRpc) {
MAYBE_SKIP_TEST;
const int kRpcCount = 10;
std::unique_ptr<ArenaAllocator> allocator(new ArenaAllocator);
CreateServer(allocator.get());
@ -404,6 +429,10 @@ INSTANTIATE_TEST_SUITE_P(ArenaAllocatorTest, ArenaAllocatorTest,
int main(int argc, char** argv) {
grpc::testing::TestEnvironment env(argc, argv);
// The grpc_init is to cover the MAYBE_SKIP_TEST.
grpc_init();
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
int ret = RUN_ALL_TESTS();
grpc_shutdown();
return ret;
}

@ -16,6 +16,7 @@
*
*/
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <map>
@ -41,7 +42,8 @@
#include "test/core/util/test_config.h"
#include "test/cpp/util/test_config.h"
DEFINE_bool(fail_on_failed_rpc, false, "Fail client if any RPCs fail.");
DEFINE_bool(fail_on_failed_rpc, false,
"Fail client if any RPCs fail after first successful RPC.");
DEFINE_int32(num_channels, 1, "Number of channels.");
DEFINE_bool(print_response, false, "Write RPC response to stdout.");
DEFINE_int32(qps, 1, "Qps per channel.");
@ -80,6 +82,8 @@ int global_request_id;
std::set<XdsStatsWatcher*> watchers;
// Mutex for global_request_id and watchers
std::mutex mu;
// Whether at least one RPC has succeeded, indicating xDS resolution completed.
std::atomic<bool> one_rpc_succeeded(false);
/** Records the remote peer distribution for a given range of RPCs. */
class XdsStatsWatcher {
@ -223,7 +227,7 @@ class TestClient {
std::cout << "RPC failed: " << call->status.error_code() << ": "
<< call->status.error_message() << std::endl;
}
if (FLAGS_fail_on_failed_rpc) {
if (FLAGS_fail_on_failed_rpc && one_rpc_succeeded.load()) {
abort();
}
} else {
@ -239,6 +243,7 @@ class TestClient {
std::cout << "Greeting: Hello world, this is " << hostname
<< ", from " << call->context.peer() << std::endl;
}
one_rpc_succeeded = true;
}
delete call;

@ -69,11 +69,6 @@ BENCHMARK(BM_CreateDestroyCore);
static void DoneWithCompletionOnStack(void* /*arg*/,
grpc_cq_completion* /*completion*/) {}
static void DoneWithCompletionOnHeap(void* /*arg*/,
grpc_cq_completion* completion) {
delete completion;
}
class DummyTag final : public internal::CompletionQueueTag {
public:
bool FinalizeResult(void** /*tag*/, bool* /*status*/) override {
@ -210,15 +205,8 @@ static void BM_Callback_CQ_Pass1Core(benchmark::State& state) {
gpr_cv_init(&shutdown_cv);
bool got_shutdown = false;
ShutdownCallback shutdown_cb(&got_shutdown);
// This test with stack-allocated completions only works for non-polling or
// EM-polling callback core CQs. For generality, test with non-polling.
grpc_completion_queue_attributes attr;
attr.version = 2;
attr.cq_completion_type = GRPC_CQ_CALLBACK;
attr.cq_polling_type = GRPC_CQ_NON_POLLING;
attr.cq_shutdown_cb = &shutdown_cb;
grpc_completion_queue* cc = grpc_completion_queue_create(
grpc_completion_queue_factory_lookup(&attr), &attr, nullptr);
grpc_completion_queue* cc =
grpc_completion_queue_create_for_callback(&shutdown_cb, nullptr);
for (auto _ : state) {
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
grpc_core::ExecCtx exec_ctx;
@ -252,53 +240,7 @@ static void BM_Callback_CQ_Pass1Core(benchmark::State& state) {
gpr_cv_destroy(&shutdown_cv);
gpr_mu_destroy(&shutdown_mu);
}
static void BM_Callback_CQ_Pass1CoreHeapCompletion(benchmark::State& state) {
TrackCounters track_counters;
int iteration = 0, current_iterations = 0;
TagCallback tag_cb(&iteration);
gpr_mu_init(&mu);
gpr_cv_init(&cv);
gpr_mu_init(&shutdown_mu);
gpr_cv_init(&shutdown_cv);
bool got_shutdown = false;
ShutdownCallback shutdown_cb(&got_shutdown);
grpc_completion_queue* cc =
grpc_completion_queue_create_for_callback(&shutdown_cb, nullptr);
for (auto _ : state) {
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
grpc_core::ExecCtx exec_ctx;
grpc_cq_completion* completion = new grpc_cq_completion;
GPR_ASSERT(grpc_cq_begin_op(cc, &tag_cb));
grpc_cq_end_op(cc, &tag_cb, GRPC_ERROR_NONE, DoneWithCompletionOnHeap,
nullptr, completion);
}
shutdown_and_destroy(cc);
gpr_mu_lock(&mu);
current_iterations = static_cast<int>(state.iterations());
while (current_iterations != iteration) {
// Wait for all the callbacks to complete.
gpr_cv_wait(&cv, &mu, gpr_inf_future(GPR_CLOCK_REALTIME));
}
gpr_mu_unlock(&mu);
gpr_mu_lock(&shutdown_mu);
while (!got_shutdown) {
// Wait for the shutdown callback to complete.
gpr_cv_wait(&shutdown_cv, &shutdown_mu, gpr_inf_future(GPR_CLOCK_REALTIME));
}
gpr_mu_unlock(&shutdown_mu);
GPR_ASSERT(got_shutdown);
GPR_ASSERT(iteration == static_cast<int>(state.iterations()));
track_counters.Finish(state);
gpr_cv_destroy(&cv);
gpr_mu_destroy(&mu);
gpr_cv_destroy(&shutdown_cv);
gpr_mu_destroy(&shutdown_mu);
}
BENCHMARK(BM_Callback_CQ_Pass1Core);
BENCHMARK(BM_Callback_CQ_Pass1CoreHeapCompletion);
} // namespace testing
} // namespace grpc

@ -940,7 +940,6 @@ include/grpcpp/client_context.h \
include/grpcpp/completion_queue.h \
include/grpcpp/completion_queue_impl.h \
include/grpcpp/create_channel.h \
include/grpcpp/create_channel_impl.h \
include/grpcpp/create_channel_posix.h \
include/grpcpp/ext/health_check_service_server_builder_option.h \
include/grpcpp/generic/async_generic_service.h \
@ -1024,7 +1023,6 @@ include/grpcpp/resource_quota.h \
include/grpcpp/security/auth_context.h \
include/grpcpp/security/auth_metadata_processor.h \
include/grpcpp/security/credentials.h \
include/grpcpp/security/credentials_impl.h \
include/grpcpp/security/server_credentials.h \
include/grpcpp/security/tls_credentials_options.h \
include/grpcpp/server.h \

@ -940,7 +940,6 @@ include/grpcpp/client_context.h \
include/grpcpp/completion_queue.h \
include/grpcpp/completion_queue_impl.h \
include/grpcpp/create_channel.h \
include/grpcpp/create_channel_impl.h \
include/grpcpp/create_channel_posix.h \
include/grpcpp/ext/health_check_service_server_builder_option.h \
include/grpcpp/generic/async_generic_service.h \
@ -1024,7 +1023,6 @@ include/grpcpp/resource_quota.h \
include/grpcpp/security/auth_context.h \
include/grpcpp/security/auth_metadata_processor.h \
include/grpcpp/security/credentials.h \
include/grpcpp/security/credentials_impl.h \
include/grpcpp/security/server_credentials.h \
include/grpcpp/security/tls_credentials_options.h \
include/grpcpp/server.h \

@ -48,12 +48,19 @@ touch "$TOOLS_DIR"/src/proto/grpc/testing/__init__.py
bazel build test/cpp/interop:xds_interop_client
# Test cases "path_matching" and "header_matching" are not included in "all",
# because not all interop clients in all languages support these new tests.
#
# TODO: remove "path_matching" and "header_matching" from --test_case after
# they are added into "all".
GRPC_VERBOSITY=debug GRPC_TRACE=xds_client,xds_resolver,xds_routing_lb,cds_lb,eds_lb,priority_lb,weighted_target_lb,lrs_lb "$PYTHON" \
tools/run_tests/run_xds_tests.py \
--test_case=all \
--test_case="all,path_matching,header_matching" \
--project_id=grpc-testing \
--source_image=projects/grpc-testing/global/images/xds-test-server \
--source_image=projects/grpc-testing/global/images/xds-test-server-2 \
--path_to_server_binary=/java_server/grpc-java/interop-testing/build/install/grpc-interop-testing/bin/xds-test-server \
--gcp_suffix=$(date '+%s') \
--verbose \
--client_cmd='bazel-bin/test/cpp/interop/xds_interop_client --server=xds:///{server_uri} --stats_port={stats_port} --qps={qps} {fail_on_failed_rpc}'
--client_cmd='bazel-bin/test/cpp/interop/xds_interop_client --server=xds:///{server_uri} --stats_port={stats_port} --qps={qps} {fail_on_failed_rpc} \
{rpcs_to_send} \
{metadata_to_send}'

@ -56,17 +56,28 @@ _TEST_CASES = [
'secondary_locality_gets_requests_on_primary_failure',
'traffic_splitting',
]
# Valid test cases, but not in all. So the tests can only run manually, and
# aren't enabled automatically for all languages.
#
# TODO: Move them into _TEST_CASES when support is ready in all languages.
_ADDITIONAL_TEST_CASES = ['path_matching', 'header_matching']
def parse_test_cases(arg):
if arg == 'all':
return _TEST_CASES
if arg == '':
return []
test_cases = arg.split(',')
if all([test_case in _TEST_CASES for test_case in test_cases]):
return test_cases
raise Exception('Failed to parse test cases %s' % arg)
arg_split = arg.split(',')
test_cases = set()
all_test_cases = _TEST_CASES + _ADDITIONAL_TEST_CASES
for arg in arg_split:
if arg == "all":
test_cases = test_cases.union(_TEST_CASES)
else:
test_cases = test_cases.union([arg])
if not all([test_case in all_test_cases for test_case in test_cases]):
raise Exception('Failed to parse test cases %s' % arg)
# Perserve order.
return [x for x in all_test_cases if x in test_cases]
def parse_port_range(port_arg):
@ -89,8 +100,10 @@ argp.add_argument(
'--test_case',
default='ping_pong',
type=parse_test_cases,
help='Comma-separated list of test cases to run, or \'all\' to run every '
'test. Available tests: %s' % ' '.join(_TEST_CASES))
help='Comma-separated list of test cases to run. Available tests: %s, '
'(or \'all\' to run every test). '
'Alternative tests not included in \'all\': %s' %
(','.join(_TEST_CASES), ','.join(_ADDITIONAL_TEST_CASES)))
argp.add_argument(
'--bootstrap_file',
default='',
@ -237,6 +250,12 @@ _BOOTSTRAP_TEMPLATE = """
_TESTS_TO_FAIL_ON_RPC_FAILURE = [
'new_instance_group_receives_traffic', 'ping_pong', 'round_robin'
]
# Tests that run UnaryCall and EmptyCall.
_TESTS_TO_RUN_MULTIPLE_RPCS = ['path_matching', 'header_matching']
# Tests that make UnaryCall with test metadata.
_TESTS_TO_SEND_METADATA = ['header_matching']
_TEST_METADATA_KEY = 'xds_md'
_TEST_METADATA_VALUE = 'exact_match'
_PATH_MATCHER_NAME = 'path-matcher'
_BASE_TEMPLATE_NAME = 'test-template'
_BASE_INSTANCE_GROUP_NAME = 'test-ig'
@ -348,6 +367,29 @@ def compare_distributions(actual_distribution, expected_distribution,
return True
def compare_expected_instances(stats, expected_instances):
"""Compare if stats have expected instances for each type of RPC.
Args:
stats: LoadBalancerStatsResponse reported by interop client.
expected_instances: a dict with key as the RPC type (string), value as
the expected backend instances (list of strings).
Returns:
Returns true if the instances are expected. False if not.
"""
for rpc_type, expected_peers in expected_instances.items():
rpcs_by_peer_for_type = stats.rpcs_by_method[rpc_type]
rpcs_by_peer = rpcs_by_peer_for_type.rpcs_by_peer if rpcs_by_peer_for_type else None
logger.debug('rpc: %s, by_peer: %s', rpc_type, rpcs_by_peer)
peers = list(rpcs_by_peer.keys())
if set(peers) != set(expected_peers):
logger.info('unexpected peers for %s, got %s, want %s', rpc_type,
peers, expected_peers)
return False
return True
def test_backends_restart(gcp, backend_service, instance_group):
logger.info('Running test_backends_restart')
instance_names = get_instance_names(gcp, instance_group)
@ -534,7 +576,7 @@ def test_round_robin(gcp, backend_service, instance_group):
if abs(stats.rpcs_by_peer[instance] - expected_requests) > threshold:
raise Exception(
'RPC peer distribution differs from expected by more than %d '
'for instance %s (%s)', threshold, instance, stats)
'for instance %s (%s)' % (threshold, instance, stats))
def test_secondary_locality_gets_no_requests_on_partial_primary_failure(
@ -629,19 +671,20 @@ def test_secondary_locality_gets_requests_on_primary_failure(
patch_backend_instances(gcp, backend_service, [primary_instance_group])
def test_traffic_splitting(gcp, original_backend_service, instance_group,
alternate_backend_service, same_zone_instance_group):
# This test start with all traffic going to original_backend_service. Then
# it updates URL-map to set default action to traffic splitting between
# original and alternate. It waits for all backends in both services to
# receive traffic, then verifies that weights are expected.
logger.info('Running test_traffic_splitting')
def prepare_services_for_urlmap_tests(gcp, original_backend_service,
instance_group, alternate_backend_service,
same_zone_instance_group):
'''
This function prepares the services to be ready for tests that modifies
urlmaps.
Returns:
Returns original and alternate backend names as lists of strings.
'''
# The config validation for proxyless doesn't allow setting
# default_route_action. To test traffic splitting, we need to set the
# route action to weighted clusters. Disable validate
# validate_for_proxyless for this test. This can be removed when
# validation accepts default_route_action.
# default_route_action or route_rules. Disable validate
# validate_for_proxyless for this test. This can be removed when validation
# accepts default_route_action.
logger.info('disabling validate_for_proxyless in target proxy')
set_validate_for_proxyless(gcp, False)
@ -665,6 +708,20 @@ def test_traffic_splitting(gcp, original_backend_service, instance_group,
logger.info('waiting for traffic to all go to original backends')
wait_until_all_rpcs_go_to_given_backends(original_backend_instances,
_WAIT_FOR_STATS_SEC)
return original_backend_instances, alternate_backend_instances
def test_traffic_splitting(gcp, original_backend_service, instance_group,
alternate_backend_service, same_zone_instance_group):
# This test start with all traffic going to original_backend_service. Then
# it updates URL-map to set default action to traffic splitting between
# original and alternate. It waits for all backends in both services to
# receive traffic, then verifies that weights are expected.
logger.info('Running test_traffic_splitting')
original_backend_instances, alternate_backend_instances = prepare_services_for_urlmap_tests(
gcp, original_backend_service, instance_group,
alternate_backend_service, same_zone_instance_group)
try:
# Patch urlmap, change route action to traffic splitting between
@ -717,8 +774,8 @@ def test_traffic_splitting(gcp, original_backend_service, instance_group,
logger.info(e)
if i == retry_count - 1:
raise Exception(
'RPC distribution (%s) differs from expected (%s)',
got_instance_percentage, expected_instance_percentage)
'RPC distribution (%s) differs from expected (%s)' %
(got_instance_percentage, expected_instance_percentage))
else:
logger.info("success")
break
@ -728,6 +785,157 @@ def test_traffic_splitting(gcp, original_backend_service, instance_group,
set_validate_for_proxyless(gcp, True)
def test_path_matching(gcp, original_backend_service, instance_group,
alternate_backend_service, same_zone_instance_group):
# This test start with all traffic (UnaryCall and EmptyCall) going to
# original_backend_service.
#
# Then it updates URL-map to add routes, to make UnaryCall and EmptyCall to
# go different backends. It waits for all backends in both services to
# receive traffic, then verifies that traffic goes to the expected
# backends.
logger.info('Running test_path_matching')
original_backend_instances, alternate_backend_instances = prepare_services_for_urlmap_tests(
gcp, original_backend_service, instance_group,
alternate_backend_service, same_zone_instance_group)
try:
# A list of tuples (route_rules, expected_instances).
test_cases = [
(
[{
'priority': 0,
# FullPath EmptyCall -> alternate_backend_service.
'matchRules': [{
'fullPathMatch': '/grpc.testing.TestService/EmptyCall'
}],
'service': alternate_backend_service.url
}],
{
"EmptyCall": alternate_backend_instances,
"UnaryCall": original_backend_instances
}),
(
[{
'priority': 0,
# Prefix UnaryCall -> alternate_backend_service.
'matchRules': [{
'prefixMatch': '/grpc.testing.TestService/Unary'
}],
'service': alternate_backend_service.url
}],
{
"UnaryCall": alternate_backend_instances,
"EmptyCall": original_backend_instances
})
]
for (route_rules, expected_instances) in test_cases:
logger.info('patching url map with %s -> alternative',
route_rules[0]['matchRules'])
patch_url_map_backend_service(gcp,
original_backend_service,
route_rules=route_rules)
# Wait for traffic to go to both services.
logger.info(
'waiting for traffic to go to all backends (including alternate)'
)
wait_until_all_rpcs_go_to_given_backends(
original_backend_instances + alternate_backend_instances,
_WAIT_FOR_STATS_SEC)
retry_count = 10
# Each attempt takes about 10 seconds, 10 retries is equivalent to 100
# seconds timeout.
for i in range(retry_count):
stats = get_client_stats(_NUM_TEST_RPCS, _WAIT_FOR_STATS_SEC)
if not stats.rpcs_by_method:
raise ValueError(
'stats.rpcs_by_method is None, the interop client stats service does not support this test case'
)
logger.info('attempt %d', i)
if compare_expected_instances(stats, expected_instances):
logger.info("success")
break
finally:
patch_url_map_backend_service(gcp, original_backend_service)
patch_backend_instances(gcp, alternate_backend_service, [])
set_validate_for_proxyless(gcp, True)
def test_header_matching(gcp, original_backend_service, instance_group,
alternate_backend_service, same_zone_instance_group):
# This test start with all traffic (UnaryCall and EmptyCall) going to
# original_backend_service.
#
# Then it updates URL-map to add routes, to make RPCs with test headers to
# go to different backends. It waits for all backends in both services to
# receive traffic, then verifies that traffic goes to the expected
# backends.
logger.info('Running test_header_matching')
original_backend_instances, alternate_backend_instances = prepare_services_for_urlmap_tests(
gcp, original_backend_service, instance_group,
alternate_backend_service, same_zone_instance_group)
try:
# A list of tuples (route_rules, expected_instances).
test_cases = [(
[{
'priority': 0,
# Header ExactMatch -> alternate_backend_service.
# EmptyCall is sent with the metadata.
'matchRules': [{
'prefixMatch':
'/',
'headerMatches': [{
'headerName': _TEST_METADATA_KEY,
'exactMatch': _TEST_METADATA_VALUE
}]
}],
'service': alternate_backend_service.url
}],
{
"EmptyCall": alternate_backend_instances,
"UnaryCall": original_backend_instances
})]
for (route_rules, expected_instances) in test_cases:
logger.info('patching url map with %s -> alternative',
route_rules[0]['matchRules'])
patch_url_map_backend_service(gcp,
original_backend_service,
route_rules=route_rules)
# Wait for traffic to go to both services.
logger.info(
'waiting for traffic to go to all backends (including alternate)'
)
wait_until_all_rpcs_go_to_given_backends(
original_backend_instances + alternate_backend_instances,
_WAIT_FOR_STATS_SEC)
retry_count = 10
# Each attempt takes about 10 seconds, 10 retries is equivalent to 100
# seconds timeout.
for i in range(retry_count):
stats = get_client_stats(_NUM_TEST_RPCS, _WAIT_FOR_STATS_SEC)
if not stats.rpcs_by_method:
raise ValueError(
'stats.rpcs_by_method is None, the interop client stats service does not support this test case'
)
logger.info('attempt %d', i)
if compare_expected_instances(stats, expected_instances):
logger.info("success")
break
finally:
patch_url_map_backend_service(gcp, original_backend_service)
patch_backend_instances(gcp, alternate_backend_service, [])
set_validate_for_proxyless(gcp, True)
def set_serving_status(instances, service_port, serving):
for instance in instances:
with grpc.insecure_channel('%s:%d' %
@ -1208,7 +1416,8 @@ def resize_instance_group(gcp,
def patch_url_map_backend_service(gcp,
backend_service=None,
services_with_weights=None):
services_with_weights=None,
route_rules=None):
'''change url_map's backend service
Only one of backend_service and service_with_weights can be not None.
@ -1230,6 +1439,7 @@ def patch_url_map_backend_service(gcp,
'name': _PATH_MATCHER_NAME,
'defaultService': default_service,
'defaultRouteAction': default_route_action,
'routeRules': route_rules,
}]
}
logger.debug('Sending GCP request with body=%s', config)
@ -1266,8 +1476,8 @@ def wait_for_global_operation(gcp,
raise Exception(result['error'])
return
time.sleep(2)
raise Exception('Operation %s did not complete within %d', operation,
timeout_sec)
raise Exception('Operation %s did not complete within %d' %
(operation, timeout_sec))
def wait_for_zone_operation(gcp,
@ -1284,8 +1494,8 @@ def wait_for_zone_operation(gcp,
raise Exception(result['error'])
return
time.sleep(2)
raise Exception('Operation %s did not complete within %d', operation,
timeout_sec)
raise Exception('Operation %s did not complete within %d' %
(operation, timeout_sec))
def wait_for_healthy_backends(gcp,
@ -1314,15 +1524,6 @@ def wait_for_healthy_backends(gcp,
(timeout_sec, result))
def wait_for_config_propagation(gcp, instance_group, client_cmd, client_env):
"""Use client to verify config propagation from GCP->TD->client"""
instance_names = get_instance_names(gcp, instance_group)
client_process = subprocess.Popen(shlex.split(client_cmd), env=client_env)
wait_until_all_rpcs_go_to_given_backends(instance_names,
_WAIT_FOR_VALID_CONFIG_SEC)
client_process.terminate()
def get_instance_names(gcp, instance_group):
instance_names = []
result = gcp.compute.instanceGroups().listInstances(
@ -1504,22 +1705,32 @@ try:
test_log_filename = os.path.join(log_dir, _SPONGE_LOG_NAME)
test_log_file = open(test_log_filename, 'w+')
client_process = None
if test_case in _TESTS_TO_RUN_MULTIPLE_RPCS:
rpcs_to_send = '--rpc="UnaryCall,EmptyCall"'
else:
rpcs_to_send = '--rpc="UnaryCall"'
if test_case in _TESTS_TO_SEND_METADATA:
metadata_to_send = '--metadata="EmptyCall:{key}:{value}"'.format(
key=_TEST_METADATA_KEY, value=_TEST_METADATA_VALUE)
else:
metadata_to_send = '--metadata=""'
if test_case in _TESTS_TO_FAIL_ON_RPC_FAILURE:
wait_for_config_propagation(
gcp, instance_group,
args.client_cmd.format(server_uri=server_uri,
stats_port=args.stats_port,
qps=args.qps,
fail_on_failed_rpc=False),
client_env)
fail_on_failed_rpc = '--fail_on_failed_rpc=true'
else:
fail_on_failed_rpc = '--fail_on_failed_rpc=false'
client_cmd = shlex.split(
args.client_cmd.format(server_uri=server_uri,
stats_port=args.stats_port,
qps=args.qps,
fail_on_failed_rpc=fail_on_failed_rpc))
client_cmd_formatted = args.client_cmd.format(
server_uri=server_uri,
stats_port=args.stats_port,
qps=args.qps,
fail_on_failed_rpc=fail_on_failed_rpc,
rpcs_to_send=rpcs_to_send,
metadata_to_send=metadata_to_send)
logger.debug('running client: %s', client_cmd_formatted)
client_cmd = shlex.split(client_cmd_formatted)
try:
client_process = subprocess.Popen(client_cmd,
env=client_env,
@ -1559,6 +1770,14 @@ try:
test_traffic_splitting(gcp, backend_service, instance_group,
alternate_backend_service,
same_zone_instance_group)
elif test_case == 'path_matching':
test_path_matching(gcp, backend_service, instance_group,
alternate_backend_service,
same_zone_instance_group)
elif test_case == 'header_matching':
test_header_matching(gcp, backend_service, instance_group,
alternate_backend_service,
same_zone_instance_group)
else:
logger.error('Unknown test case: %s', test_case)
sys.exit(1)

Loading…
Cancel
Save