diff --git a/BUILD b/BUILD index 933a70ec8fd..07f82aa91c5 100644 --- a/BUILD +++ b/BUILD @@ -296,7 +296,6 @@ GRPC_PUBLIC_HDRS = [ "include/grpc/grpc_posix.h", "include/grpc/grpc_security.h", "include/grpc/grpc_security_constants.h", - "include/grpc/passive_listener.h", "include/grpc/slice.h", "include/grpc/slice_buffer.h", "include/grpc/status.h", @@ -458,7 +457,6 @@ GRPCXX_PUBLIC_HDRS = [ "include/grpcpp/impl/service_type.h", "include/grpcpp/impl/status.h", "include/grpcpp/impl/sync.h", - "include/grpcpp/passive_listener.h", "include/grpcpp/resource_quota.h", "include/grpcpp/security/audit_logging.h", "include/grpcpp/security/tls_crl_provider.h", @@ -788,7 +786,6 @@ grpc_cc_library( "absl/base:log_severity", "absl/functional:any_invocable", "absl/log", - "absl/log:globals", "absl/memory", "absl/random", "absl/status", @@ -884,7 +881,7 @@ grpc_cc_library( grpc_cc_library( name = "grpc_public_hdrs", - hdrs = GRPC_PUBLIC_HDRS + GRPC_PUBLIC_EVENT_ENGINE_HDRS, + hdrs = GRPC_PUBLIC_HDRS, external_deps = [ "absl/status:statusor", "absl/strings", @@ -1502,6 +1499,9 @@ grpc_cc_library( "//src/core:lib/surface/byte_buffer.cc", "//src/core:lib/surface/byte_buffer_reader.cc", ], + external_deps = [ + "absl/log:check", + ], language = "c++", deps = [ "exec_ctx", @@ -1759,6 +1759,7 @@ grpc_cc_library( ], external_deps = [ "absl/base:core_headers", + "absl/log:check", "absl/status:statusor", "absl/strings", "absl/types:optional", @@ -1801,6 +1802,7 @@ grpc_cc_library( ], external_deps = [ "absl/base:core_headers", + "absl/log:check", "absl/status", "absl/status:statusor", "absl/types:optional", @@ -1847,6 +1849,7 @@ grpc_cc_library( ], external_deps = [ "absl/base:core_headers", + "absl/log:check", "absl/status:statusor", "absl/strings", "absl/types:optional", @@ -1888,6 +1891,7 @@ grpc_cc_library( "absl/container:flat_hash_map", "absl/container:flat_hash_set", "absl/hash", + "absl/log:check", "absl/random", "absl/status", "absl/status:statusor", @@ -2501,7 +2505,6 @@ grpc_cc_library( "//src/core:grpc_backend_metric_provider", "//src/core:grpc_crl_provider", "//src/core:grpc_service_config", - "//src/core:grpc_transport_chttp2_server", "//src/core:grpc_transport_inproc", "//src/core:json", "//src/core:json_reader", @@ -2560,7 +2563,6 @@ grpc_cc_library( "grpc_security_base", "grpc_service_config_impl", "grpc_trace", - "grpc_transport_chttp2", "grpc_unsecure", "grpcpp_backend_metric_recorder", "grpcpp_call_metric_recorder", @@ -2582,7 +2584,6 @@ grpc_cc_library( "//src/core:grpc_backend_metric_provider", "//src/core:grpc_insecure_credentials", "//src/core:grpc_service_config", - "//src/core:grpc_transport_chttp2_server", "//src/core:grpc_transport_inproc", "//src/core:ref_counted", "//src/core:resource_quota", @@ -4246,6 +4247,7 @@ grpc_cc_library( ], external_deps = [ "absl/base:core_headers", + "absl/log:check", "absl/status", "absl/status:statusor", "absl/strings", diff --git a/CMakeLists.txt b/CMakeLists.txt index db0ee660c84..bc07d003268 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1749,7 +1749,6 @@ target_link_libraries(gpr absl::flags_marshalling absl::any_invocable absl::check - absl::log_globals absl::log absl::memory absl::random_random @@ -2746,7 +2745,6 @@ foreach(_hdr include/grpc/impl/propagation_bits.h include/grpc/impl/slice_type.h include/grpc/load_reporting.h - include/grpc/passive_listener.h include/grpc/slice.h include/grpc/slice_buffer.h include/grpc/status.h @@ -3447,7 +3445,6 @@ foreach(_hdr include/grpc/impl/propagation_bits.h include/grpc/impl/slice_type.h include/grpc/load_reporting.h - include/grpc/passive_listener.h include/grpc/slice.h include/grpc/slice_buffer.h include/grpc/status.h @@ -4316,7 +4313,6 @@ foreach(_hdr include/grpcpp/impl/service_type.h include/grpcpp/impl/status.h include/grpcpp/impl/sync.h - include/grpcpp/passive_listener.h include/grpcpp/resource_quota.h include/grpcpp/security/audit_logging.h include/grpcpp/security/auth_context.h @@ -5057,7 +5053,6 @@ foreach(_hdr include/grpcpp/impl/service_type.h include/grpcpp/impl/status.h include/grpcpp/impl/sync.h - include/grpcpp/passive_listener.h include/grpcpp/resource_quota.h include/grpcpp/security/audit_logging.h include/grpcpp/security/auth_context.h @@ -5508,7 +5503,6 @@ foreach(_hdr include/grpc/impl/propagation_bits.h include/grpc/impl/slice_type.h include/grpc/load_reporting.h - include/grpc/passive_listener.h include/grpc/slice.h include/grpc/slice_buffer.h include/grpc/status.h @@ -26837,7 +26831,6 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/orca_load_report.grpc.pb.cc ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/orca_load_report.pb.h ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/orca_load_report.grpc.pb.h - test/core/event_engine/event_engine_test_utils.cc test/core/test_util/cmdline.cc test/core/test_util/fuzzer_util.cc test/core/test_util/grpc_profiler.cc @@ -36926,7 +36919,7 @@ generate_pkgconfig( "gpr" "gRPC platform support library" "${gRPC_CORE_VERSION}" - "absl_any_invocable absl_base absl_check absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_log absl_log_globals absl_log_severity absl_memory absl_optional absl_random_random absl_status absl_str_format absl_strings absl_synchronization absl_time absl_variant" + "absl_any_invocable absl_base absl_check absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_log absl_log_severity absl_memory absl_optional absl_random_random absl_status absl_str_format absl_strings absl_synchronization absl_time absl_variant" "" "-lgpr" "" @@ -36937,7 +36930,7 @@ generate_pkgconfig( "gRPC" "high performance general RPC framework" "${gRPC_CORE_VERSION}" - "absl_algorithm_container absl_any_invocable absl_base absl_bind_front absl_check absl_cleanup absl_config absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_log absl_log_globals absl_log_severity absl_memory absl_no_destructor absl_optional absl_random_bit_gen_ref absl_random_distributions absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant gpr" + "absl_algorithm_container absl_any_invocable absl_base absl_bind_front absl_check absl_cleanup absl_config absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_log absl_log_severity absl_memory absl_no_destructor absl_optional absl_random_bit_gen_ref absl_random_distributions absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant gpr" "libcares openssl re2 zlib" "-lgrpc" "-laddress_sorting -lupb_textformat_lib -lupb_json_lib -lupb_message_lib -lupb_mem_lib -lupb_base_lib -lutf8_range_lib" @@ -36948,7 +36941,7 @@ generate_pkgconfig( "gRPC unsecure" "high performance general RPC framework without SSL" "${gRPC_CORE_VERSION}" - "absl_algorithm_container absl_any_invocable absl_base absl_bind_front absl_check absl_cleanup absl_config absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_log absl_log_globals absl_log_severity absl_memory absl_no_destructor absl_optional absl_random_bit_gen_ref absl_random_distributions absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant gpr" + "absl_algorithm_container absl_any_invocable absl_base absl_bind_front absl_check absl_cleanup absl_config absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_log absl_log_severity absl_memory absl_no_destructor absl_optional absl_random_bit_gen_ref absl_random_distributions absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant gpr" "libcares zlib" "-lgrpc_unsecure" "-laddress_sorting -lupb_message_lib -lupb_mem_lib -lupb_base_lib -lutf8_range_lib" @@ -36959,7 +36952,7 @@ generate_pkgconfig( "gRPC++" "C++ wrapper for gRPC" "${gRPC_CPP_VERSION}" - "absl_algorithm_container absl_any_invocable absl_base absl_bind_front absl_check absl_cleanup absl_config absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_log absl_log_globals absl_log_severity absl_memory absl_no_destructor absl_optional absl_random_bit_gen_ref absl_random_distributions absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant gpr grpc" + "absl_algorithm_container absl_any_invocable absl_base absl_bind_front absl_check absl_cleanup absl_config absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_log absl_log_severity absl_memory absl_no_destructor absl_optional absl_random_bit_gen_ref absl_random_distributions absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant gpr grpc" "libcares openssl re2 zlib" "-lgrpc++" "-laddress_sorting -lupb_textformat_lib -lupb_json_lib -lupb_message_lib -lupb_mem_lib -lupb_base_lib -lutf8_range_lib" @@ -36970,7 +36963,7 @@ generate_pkgconfig( "gRPC++ unsecure" "C++ wrapper for gRPC without SSL" "${gRPC_CPP_VERSION}" - "absl_algorithm_container absl_any_invocable absl_base absl_bind_front absl_check absl_cleanup absl_config absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_log absl_log_globals absl_log_severity absl_memory absl_no_destructor absl_optional absl_random_bit_gen_ref absl_random_distributions absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant gpr grpc_unsecure" + "absl_algorithm_container absl_any_invocable absl_base absl_bind_front absl_check absl_cleanup absl_config absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_log absl_log_severity absl_memory absl_no_destructor absl_optional absl_random_bit_gen_ref absl_random_distributions absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant gpr grpc_unsecure" "libcares zlib" "-lgrpc++_unsecure" "-laddress_sorting -lupb_message_lib -lupb_mem_lib -lupb_base_lib -lutf8_range_lib" diff --git a/Makefile b/Makefile index 4f7baa753c5..b5f3f448d53 100644 --- a/Makefile +++ b/Makefile @@ -1775,7 +1775,6 @@ PUBLIC_HEADERS_C += \ include/grpc/impl/propagation_bits.h \ include/grpc/impl/slice_type.h \ include/grpc/load_reporting.h \ - include/grpc/passive_listener.h \ include/grpc/slice.h \ include/grpc/slice_buffer.h \ include/grpc/status.h \ diff --git a/Package.swift b/Package.swift index 9641ea457b9..9afca3494ca 100644 --- a/Package.swift +++ b/Package.swift @@ -93,7 +93,6 @@ let package = Package( "include/grpc/impl/propagation_bits.h", "include/grpc/impl/slice_type.h", "include/grpc/load_reporting.h", - "include/grpc/passive_listener.h", "include/grpc/slice.h", "include/grpc/slice_buffer.h", "include/grpc/status.h", diff --git a/build_autogenerated.yaml b/build_autogenerated.yaml index 954ba441fed..23c54fb841f 100644 --- a/build_autogenerated.yaml +++ b/build_autogenerated.yaml @@ -130,7 +130,6 @@ libs: - absl/flags:marshalling - absl/functional:any_invocable - absl/log:check - - absl/log:globals - absl/log:log - absl/memory:memory - absl/random:random @@ -198,7 +197,6 @@ libs: - include/grpc/impl/propagation_bits.h - include/grpc/impl/slice_type.h - include/grpc/load_reporting.h - - include/grpc/passive_listener.h - include/grpc/slice.h - include/grpc/slice_buffer.h - include/grpc/status.h @@ -2183,7 +2181,6 @@ libs: - include/grpc/impl/propagation_bits.h - include/grpc/impl/slice_type.h - include/grpc/load_reporting.h - - include/grpc/passive_listener.h - include/grpc/slice.h - include/grpc/slice_buffer.h - include/grpc/status.h @@ -3788,7 +3785,6 @@ libs: - include/grpcpp/impl/service_type.h - include/grpcpp/impl/status.h - include/grpcpp/impl/sync.h - - include/grpcpp/passive_listener.h - include/grpcpp/resource_quota.h - include/grpcpp/security/audit_logging.h - include/grpcpp/security/auth_context.h @@ -4216,7 +4212,6 @@ libs: - include/grpcpp/impl/service_type.h - include/grpcpp/impl/status.h - include/grpcpp/impl/sync.h - - include/grpcpp/passive_listener.h - include/grpcpp/resource_quota.h - include/grpcpp/security/audit_logging.h - include/grpcpp/security/auth_context.h @@ -4365,7 +4360,6 @@ libs: - include/grpc/impl/propagation_bits.h - include/grpc/impl/slice_type.h - include/grpc/load_reporting.h - - include/grpc/passive_listener.h - include/grpc/slice.h - include/grpc/slice_buffer.h - include/grpc/status.h @@ -17787,7 +17781,6 @@ targets: build: test language: c++ headers: - - test/core/event_engine/event_engine_test_utils.h - test/core/test_util/cmdline.h - test/core/test_util/evaluate_args_test_util.h - test/core/test_util/fuzzer_util.h @@ -17803,7 +17796,6 @@ targets: - src/proto/grpc/testing/echo_messages.proto - src/proto/grpc/testing/simple_messages.proto - src/proto/grpc/testing/xds/v3/orca_load_report.proto - - test/core/event_engine/event_engine_test_utils.cc - test/core/test_util/cmdline.cc - test/core/test_util/fuzzer_util.cc - test/core/test_util/grpc_profiler.cc diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 89639734113..9fd6d1f6d06 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -176,7 +176,6 @@ Pod::Spec.new do |s| 'include/grpcpp/impl/service_type.h', 'include/grpcpp/impl/status.h', 'include/grpcpp/impl/sync.h', - 'include/grpcpp/passive_listener.h', 'include/grpcpp/resource_quota.h', 'include/grpcpp/security/audit_logging.h', 'include/grpcpp/security/auth_context.h', @@ -245,7 +244,6 @@ Pod::Spec.new do |s| ss.dependency 'abseil/functional/function_ref', abseil_version ss.dependency 'abseil/hash/hash', abseil_version ss.dependency 'abseil/log/check', abseil_version - ss.dependency 'abseil/log/globals', abseil_version ss.dependency 'abseil/log/log', abseil_version ss.dependency 'abseil/memory/memory', abseil_version ss.dependency 'abseil/meta/type_traits', abseil_version diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 899134ecbfc..f15894c41d5 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -168,7 +168,6 @@ Pod::Spec.new do |s| 'include/grpc/impl/propagation_bits.h', 'include/grpc/impl/slice_type.h', 'include/grpc/load_reporting.h', - 'include/grpc/passive_listener.h', 'include/grpc/slice.h', 'include/grpc/slice_buffer.h', 'include/grpc/status.h', @@ -217,7 +216,6 @@ Pod::Spec.new do |s| ss.dependency 'abseil/functional/function_ref', abseil_version ss.dependency 'abseil/hash/hash', abseil_version ss.dependency 'abseil/log/check', abseil_version - ss.dependency 'abseil/log/globals', abseil_version ss.dependency 'abseil/log/log', abseil_version ss.dependency 'abseil/memory/memory', abseil_version ss.dependency 'abseil/meta/type_traits', abseil_version diff --git a/grpc.gemspec b/grpc.gemspec index c7ab3a9bccc..1247adbae75 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -99,7 +99,6 @@ Gem::Specification.new do |s| s.files += %w( include/grpc/impl/propagation_bits.h ) s.files += %w( include/grpc/impl/slice_type.h ) s.files += %w( include/grpc/load_reporting.h ) - s.files += %w( include/grpc/passive_listener.h ) s.files += %w( include/grpc/slice.h ) s.files += %w( include/grpc/slice_buffer.h ) s.files += %w( include/grpc/status.h ) diff --git a/include/grpc/module.modulemap b/include/grpc/module.modulemap index 30427e21d05..c9219532826 100644 --- a/include/grpc/module.modulemap +++ b/include/grpc/module.modulemap @@ -38,7 +38,6 @@ header "byte_buffer.h" header "impl/propagation_bits.h" header "impl/slice_type.h" header "load_reporting.h" - header "passive_listener.h" header "slice.h" header "slice_buffer.h" header "status.h" diff --git a/include/grpc/passive_listener.h b/include/grpc/passive_listener.h deleted file mode 100644 index fffc789dba0..00000000000 --- a/include/grpc/passive_listener.h +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2024 The gRPC Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#ifndef GRPC_PASSIVE_LISTENER_H -#define GRPC_PASSIVE_LISTENER_H - -#include - -#include -#include -// #include - -namespace grpc_core { -class Server; - -namespace experimental { -class PassiveListenerImpl; - -/// -- EXPERIMENTAL API -- -/// Interface for used for Server Endpoint injection. -class PassiveListener { - public: - virtual ~PassiveListener() = default; - /// -- EXPERIMENTAL API -- - /// - /// Takes an Endpoint for an established connection, and treats it as if the - /// connection had been accepted by the server. - /// - /// The server must be started before endpoints can be accepted. - virtual absl::Status AcceptConnectedEndpoint( - std::unique_ptr - endpoint) = 0; - - /// -- EXPERIMENTAL API -- - /// - /// Takes a connected file descriptor, and treats it as if the server had - /// accepted the connection itself. - /// - /// Returns a failure status if the server's active EventEngine does not - /// support Endpoint creation from fds. - virtual absl::Status AcceptConnectedFd(int fd) = 0; -}; - -} // namespace experimental -} // namespace grpc_core - -absl::Status grpc_server_add_passive_listener( - grpc_core::Server* server, grpc_server_credentials* credentials, - std::shared_ptr - passive_listener); - -#endif /* GRPC_PASSIVE_LISTENER_H */ diff --git a/include/grpcpp/passive_listener.h b/include/grpcpp/passive_listener.h deleted file mode 100644 index 8def9592b5e..00000000000 --- a/include/grpcpp/passive_listener.h +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2024 The gRPC Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#ifndef GRPCPP_PASSIVE_LISTENER_H -#define GRPCPP_PASSIVE_LISTENER_H - -#include - -namespace grpc { -namespace experimental { - -using grpc_core::experimental::PassiveListener; - -} // namespace experimental -} // namespace grpc - -#endif // GRPCPP_PASSIVE_LISTENER_H diff --git a/include/grpcpp/security/server_credentials.h b/include/grpcpp/security/server_credentials.h index e3f5c2bbbfe..fe8c546190d 100644 --- a/include/grpcpp/security/server_credentials.h +++ b/include/grpcpp/security/server_credentials.h @@ -84,7 +84,6 @@ class ServerCredentials : private grpc::internal::GrpcLibrary { // Needed for access to AddPortToServer. friend class Server; // Needed for access to c_creds_. - friend class ServerBuilder; friend std::shared_ptr grpc::XdsServerCredentials( const std::shared_ptr& fallback_credentials); diff --git a/include/grpcpp/server_builder.h b/include/grpcpp/server_builder.h index e66ca4301cd..e6266a90d98 100644 --- a/include/grpcpp/server_builder.h +++ b/include/grpcpp/server_builder.h @@ -25,17 +25,13 @@ #include #include -#include -#include #include #include #include #include #include #include -#include #include -#include #include #include #include @@ -295,18 +291,6 @@ class ServerBuilder { void EnableCallMetricRecording( experimental::ServerMetricRecorder* server_metric_recorder = nullptr); - // Creates a passive listener for Server Endpoint injection. - /// - /// \a PasiveListener lets applications provide pre-established connections - /// to gRPC Servers. The server will behave as if it accepted the connection - /// itself on its own listening addresses. - /// - /// This can be called multiple times to create passive listeners with - /// different server credentials. - ServerBuilder& AddPassiveListener( - std::shared_ptr creds, - std::unique_ptr& passive_listener); - private: ServerBuilder* builder_; }; @@ -380,17 +364,6 @@ class ServerBuilder { private: friend class grpc::testing::ServerBuilderPluginTest; - struct UnstartedPassiveListener { - std::weak_ptr - passive_listener; - std::shared_ptr credentials; - UnstartedPassiveListener( - std::weak_ptr listener, - std::shared_ptr creds) - : passive_listener(std::move(listener)), - credentials(std::move(creds)) {} - }; - struct SyncServerSettings { SyncServerSettings() : num_cqs(1), min_pollers(1), max_pollers(2), cq_timeout_msec(10000) {} @@ -415,7 +388,6 @@ class ServerBuilder { std::vector> options_; std::vector> services_; std::vector ports_; - std::vector unstarted_passive_listeners_; SyncServerSettings sync_server_settings_; diff --git a/package.xml b/package.xml index 9f37b132b12..f95df49ac37 100644 --- a/package.xml +++ b/package.xml @@ -81,7 +81,6 @@ - diff --git a/src/core/BUILD b/src/core/BUILD index 121dd1e52db..055c5b71373 100644 --- a/src/core/BUILD +++ b/src/core/BUILD @@ -1559,6 +1559,7 @@ grpc_cc_library( ], external_deps = [ "absl/hash", + "absl/log:check", "absl/strings", ], visibility = ["@grpc:alt_grpc_base_legacy"], @@ -1580,6 +1581,9 @@ grpc_cc_library( "lib/slice/slice_buffer.h", "//:include/grpc/slice_buffer.h", ], + external_deps = [ + "absl/log:check", + ], deps = [ "slice", "slice_refcount", @@ -2877,6 +2881,9 @@ grpc_cc_library( hdrs = [ "lib/slice/percent_encoding.h", ], + external_deps = [ + "absl/log:check", + ], deps = [ "bitset", "slice", @@ -3041,6 +3048,7 @@ grpc_cc_library( ], external_deps = [ "absl/functional:any_invocable", + "absl/log:check", "absl/strings", "absl/types:optional", ], @@ -3644,6 +3652,7 @@ grpc_cc_library( ], external_deps = [ "absl/base:core_headers", + "absl/log:check", "absl/status", "absl/status:statusor", "absl/types:optional", @@ -4755,6 +4764,7 @@ grpc_cc_library( "ext/filters/stateful_session/stateful_session_service_config_parser.h", ], external_deps = [ + "absl/log:check", "absl/status:statusor", "absl/strings", "absl/types:optional", @@ -6858,8 +6868,6 @@ grpc_cc_library( "connection_quota", "error", "error_utils", - "event_engine_extensions", - "event_engine_query_extensions", "grpc_insecure_credentials", "handshaker_registry", "iomgr_fwd", @@ -6904,6 +6912,7 @@ grpc_cc_library( "ext/transport/inproc/legacy_inproc_transport.h", ], external_deps = [ + "absl/log:check", "absl/status", "absl/status:statusor", "absl/strings", @@ -6954,6 +6963,7 @@ grpc_cc_library( "ext/transport/chaotic_good/frame.h", ], external_deps = [ + "absl/log:check", "absl/random:bit_gen_ref", "absl/status", "absl/status:statusor", @@ -7027,6 +7037,7 @@ grpc_cc_library( ], external_deps = [ "absl/functional:any_invocable", + "absl/log:check", "absl/status", "absl/status:statusor", "absl/strings", @@ -7186,6 +7197,7 @@ grpc_cc_library( external_deps = [ "absl/base:core_headers", "absl/container:flat_hash_map", + "absl/log:check", "absl/random", "absl/random:bit_gen_ref", "absl/status", @@ -7243,6 +7255,7 @@ grpc_cc_library( "absl/base:core_headers", "absl/container:flat_hash_map", "absl/functional:any_invocable", + "absl/log:check", "absl/random", "absl/random:bit_gen_ref", "absl/status", @@ -7574,6 +7587,7 @@ grpc_cc_library( ], external_deps = [ "absl/container:flat_hash_map", + "absl/log:check", "absl/random", "absl/random:bit_gen_ref", "absl/status", @@ -7638,6 +7652,7 @@ grpc_cc_library( "ext/transport/chaotic_good/client/chaotic_good_connector.h", ], external_deps = [ + "absl/log:check", "absl/random", "absl/random:bit_gen_ref", "absl/status", diff --git a/src/core/ext/filters/http/message_compress/compression_filter.cc b/src/core/ext/filters/http/message_compress/compression_filter.cc index 1ad6081ffac..b688b866cf9 100644 --- a/src/core/ext/filters/http/message_compress/compression_filter.cc +++ b/src/core/ext/filters/http/message_compress/compression_filter.cc @@ -22,6 +22,7 @@ #include #include +#include "absl/log/check.h" #include "absl/status/status.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" @@ -144,7 +145,7 @@ MessageHandle ChannelCompression::CompressMessage( const size_t after_size = tmp.Length(); const float savings_ratio = 1.0f - static_cast(after_size) / static_cast(before_size); - GPR_ASSERT(grpc_compression_algorithm_name(algorithm, &algo_name)); + CHECK(grpc_compression_algorithm_name(algorithm, &algo_name)); gpr_log(GPR_INFO, "Compressed[%s] %" PRIuPTR " bytes vs. %" PRIuPTR " bytes (%.2f%% savings)", @@ -158,7 +159,7 @@ MessageHandle ChannelCompression::CompressMessage( } else { if (GRPC_TRACE_FLAG_ENABLED(grpc_compression_trace)) { const char* algo_name; - GPR_ASSERT(grpc_compression_algorithm_name(algorithm, &algo_name)); + CHECK(grpc_compression_algorithm_name(algorithm, &algo_name)); gpr_log(GPR_INFO, "Algorithm '%s' enabled but decided not to compress. Input size: " "%" PRIuPTR, diff --git a/src/core/ext/filters/stateful_session/stateful_session_filter.cc b/src/core/ext/filters/stateful_session/stateful_session_filter.cc index b64affbb61f..5ae22cd864d 100644 --- a/src/core/ext/filters/stateful_session/stateful_session_filter.cc +++ b/src/core/ext/filters/stateful_session/stateful_session_filter.cc @@ -27,6 +27,7 @@ #include #include +#include "absl/log/check.h" #include "absl/strings/escaping.h" #include "absl/strings/match.h" #include "absl/strings/str_cat.h" @@ -143,7 +144,7 @@ absl::string_view GetClusterToUse( // Get cluster assigned by the XdsConfigSelector. auto cluster_attribute = service_config_call_data->GetCallAttribute(); - GPR_ASSERT(cluster_attribute != nullptr); + CHECK_NE(cluster_attribute, nullptr); auto current_cluster = cluster_attribute->cluster(); static constexpr absl::string_view kClusterPrefix = "cluster:"; // If prefix is not "cluster:", then we can't use cluster override. @@ -157,7 +158,7 @@ absl::string_view GetClusterToUse( // Use cluster from the cookie if it is configured for the route. auto route_data = service_config_call_data->GetCallAttribute(); - GPR_ASSERT(route_data != nullptr); + CHECK_NE(route_data, nullptr); // Cookie cluster was not configured for route - use the one from the // attribute if (!route_data->HasClusterForRoute(cluster_from_cookie)) { @@ -202,7 +203,7 @@ bool IsConfiguredPath(absl::string_view configured_path, // Check to see if the configured path matches the request path. const Slice* path_slice = client_initial_metadata.get_pointer(HttpPathMetadata()); - GPR_ASSERT(path_slice != nullptr); + CHECK_NE(path_slice, nullptr); absl::string_view path = path_slice->as_string_view(); // Matching criteria from // https://www.rfc-editor.org/rfc/rfc6265#section-5.1.4. @@ -227,13 +228,13 @@ void StatefulSessionFilter::Call::OnClientInitialMetadata( GetContext< grpc_call_context_element>()[GRPC_CONTEXT_SERVICE_CONFIG_CALL_DATA] .value); - GPR_ASSERT(service_config_call_data != nullptr); + CHECK_NE(service_config_call_data, nullptr); auto* method_params = static_cast( service_config_call_data->GetMethodParsedConfig( filter->service_config_parser_index_)); - GPR_ASSERT(method_params != nullptr); + CHECK_NE(method_params, nullptr); cookie_config_ = method_params->GetConfig(filter->index_); - GPR_ASSERT(cookie_config_ != nullptr); + CHECK_NE(cookie_config_, nullptr); if (!cookie_config_->name.has_value() || !IsConfiguredPath(cookie_config_->path, md)) { return; diff --git a/src/core/ext/gcp/metadata_query.cc b/src/core/ext/gcp/metadata_query.cc index 212a7639a03..24422cb780f 100644 --- a/src/core/ext/gcp/metadata_query.cc +++ b/src/core/ext/gcp/metadata_query.cc @@ -23,6 +23,7 @@ #include #include +#include "absl/log/check.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/str_format.h" @@ -73,7 +74,7 @@ MetadataQuery::MetadataQuery( GRPC_CLOSURE_INIT(&on_done_, OnDone, this, nullptr); auto uri = URI::Create("http", std::move(metadata_server_name), attribute_, {} /* query params */, "" /* fragment */); - GPR_ASSERT(uri.ok()); // params are hardcoded + CHECK(uri.ok()); // params are hardcoded grpc_http_request request; memset(&request, 0, sizeof(grpc_http_request)); grpc_http_header header = {const_cast("Metadata-Flavor"), diff --git a/src/core/ext/transport/binder/server/binder_server.cc b/src/core/ext/transport/binder/server/binder_server.cc index 617af5da802..dd47707fe5b 100644 --- a/src/core/ext/transport/binder/server/binder_server.cc +++ b/src/core/ext/transport/binder/server/binder_server.cc @@ -159,7 +159,7 @@ class BinderServerListener : public Server::ListenerInterface { on_destroy_done_ = on_destroy_done; } - void Orphan() override { Unref(); } + void Orphan() override { delete this; } ~BinderServerListener() override { ExecCtx::Get()->Flush(); @@ -239,8 +239,9 @@ bool AddBinderPort(const std::string& addr, grpc_server* server, } std::string conn_id = addr.substr(kBinderUriScheme.size()); Server* core_server = Server::FromC(server); - core_server->AddListener(MakeOrphanable( - core_server, conn_id, std::move(factory), security_policy)); + core_server->AddListener( + OrphanablePtr(new BinderServerListener( + core_server, conn_id, std::move(factory), security_policy))); return true; } diff --git a/src/core/ext/transport/chaotic_good/client/chaotic_good_connector.cc b/src/core/ext/transport/chaotic_good/client/chaotic_good_connector.cc index a7407791d00..d22d3bbb02c 100644 --- a/src/core/ext/transport/chaotic_good/client/chaotic_good_connector.cc +++ b/src/core/ext/transport/chaotic_good/client/chaotic_good_connector.cc @@ -18,6 +18,7 @@ #include #include +#include "absl/log/check.h" #include "absl/random/bit_gen_ref.h" #include "absl/status/status.h" #include "absl/status/statusor.h" @@ -78,7 +79,7 @@ ChaoticGoodConnector::ChaoticGoodConnector( handshake_mgr_(std::make_shared()) {} ChaoticGoodConnector::~ChaoticGoodConnector() { - GPR_ASSERT(notify_ == nullptr); + CHECK_EQ(notify_, nullptr); if (connect_activity_ != nullptr) { connect_activity_.reset(); } @@ -224,7 +225,7 @@ void ChaoticGoodConnector::Connect(const Args& args, Result* result, MutexLock lock(&mu_); result_ = result; if (is_shutdown_) { - GPR_ASSERT(notify_ == nullptr); + CHECK_EQ(notify_, nullptr); ExecCtx::Run(DEBUG_LOCATION, notify, GRPC_ERROR_CREATE("connector shutdown")); return; @@ -235,7 +236,7 @@ void ChaoticGoodConnector::Connect(const Args& args, Result* result, resolved_addr_ = EventEngine::ResolvedAddress( reinterpret_cast(args_.address->addr), args_.address->len); - GPR_ASSERT(resolved_addr_.value().address() != nullptr); + CHECK_NE(resolved_addr_.value().address(), nullptr); grpc_event_engine::experimental::EventEngine::OnConnectCallback on_connect = [self = RefAsSubclass()]( absl::StatusOr> @@ -299,7 +300,7 @@ void ChaoticGoodConnector::OnHandshakeDone(void* arg, grpc_error_handle error) { } } if (args->endpoint != nullptr) { - GPR_ASSERT(grpc_event_engine::experimental::grpc_is_event_engine_endpoint( + CHECK(grpc_event_engine::experimental::grpc_is_event_engine_endpoint( args->endpoint)); self->control_endpoint_ = PromiseEndpoint( grpc_event_engine::experimental:: diff --git a/src/core/ext/transport/chaotic_good/client_transport.cc b/src/core/ext/transport/chaotic_good/client_transport.cc index 6b3160e8182..cc1fd8b9a18 100644 --- a/src/core/ext/transport/chaotic_good/client_transport.cc +++ b/src/core/ext/transport/chaotic_good/client_transport.cc @@ -21,6 +21,7 @@ #include #include +#include "absl/log/check.h" #include "absl/random/bit_gen_ref.h" #include "absl/random/random.h" #include "absl/status/statusor.h" @@ -279,7 +280,7 @@ auto ChaoticGoodClientTransport::CallOutboundLoop(uint32_t stream_id, message_length % aligned_bytes == 0 ? 0 : aligned_bytes - message_length % aligned_bytes; - GPR_ASSERT((message_length + padding) % aligned_bytes == 0); + CHECK_EQ((message_length + padding) % aligned_bytes, 0u); frame.message = FragmentMessage(std::move(message), padding, message_length); return send_fragment(std::move(frame)); diff --git a/src/core/ext/transport/chaotic_good/frame.cc b/src/core/ext/transport/chaotic_good/frame.cc index a8aa5f18cad..e54465c29d3 100644 --- a/src/core/ext/transport/chaotic_good/frame.cc +++ b/src/core/ext/transport/chaotic_good/frame.cc @@ -20,6 +20,7 @@ #include #include +#include "absl/log/check.h" #include "absl/status/status.h" #include "absl/status/statusor.h" @@ -152,7 +153,7 @@ absl::StatusOr> ReadMetadata( Arena* arena) { if (!maybe_slices.ok()) return maybe_slices.status(); auto& slices = *maybe_slices; - GPR_ASSERT(arena != nullptr); + CHECK_NE(arena, nullptr); Arena::PoolPtr metadata = Arena::MakePooled(); parser->BeginFrame( metadata.get(), std::numeric_limits::max(), @@ -275,7 +276,7 @@ absl::Status ClientFragmentFrame::Deserialize(HPackParser* parser, } BufferPair ClientFragmentFrame::Serialize(HPackCompressor* encoder) const { - GPR_ASSERT(stream_id != 0); + CHECK_NE(stream_id, 0u); FrameSerializer serializer(FrameType::kFragment, stream_id); if (headers.get() != nullptr) { encoder->EncodeRawHeaders(*headers.get(), serializer.AddHeaders()); @@ -354,7 +355,7 @@ absl::Status ServerFragmentFrame::Deserialize(HPackParser* parser, } BufferPair ServerFragmentFrame::Serialize(HPackCompressor* encoder) const { - GPR_ASSERT(stream_id != 0); + CHECK_NE(stream_id, 0u); FrameSerializer serializer(FrameType::kFragment, stream_id); if (headers.get() != nullptr) { encoder->EncodeRawHeaders(*headers.get(), serializer.AddHeaders()); @@ -399,7 +400,7 @@ absl::Status CancelFrame::Deserialize(HPackParser*, const FrameHeader& header, } BufferPair CancelFrame::Serialize(HPackCompressor*) const { - GPR_ASSERT(stream_id != 0); + CHECK_NE(stream_id, 0u); FrameSerializer serializer(FrameType::kCancel, stream_id); return serializer.Finish(); } diff --git a/src/core/ext/transport/chaotic_good/server/chaotic_good_server.cc b/src/core/ext/transport/chaotic_good/server/chaotic_good_server.cc index 500ae102fcf..e00bcc1b379 100644 --- a/src/core/ext/transport/chaotic_good/server/chaotic_good_server.cc +++ b/src/core/ext/transport/chaotic_good/server/chaotic_good_server.cc @@ -21,6 +21,7 @@ #include #include +#include "absl/log/check.h" #include "absl/random/bit_gen_ref.h" #include "absl/status/status.h" #include "absl/status/statusor.h" @@ -102,8 +103,8 @@ absl::StatusOr ChaoticGoodServerListener::Bind( str.ok() ? str->c_str() : str.status().ToString().c_str()); } EventEngine::Listener::AcceptCallback accept_cb = - [self = RefAsSubclass()]( - std::unique_ptr ep, MemoryAllocator) { + [self = Ref()](std::unique_ptr ep, + MemoryAllocator) { ExecCtx exec_ctx; MutexLock lock(&self->mu_); if (self->shutdown_) return; @@ -116,7 +117,7 @@ absl::StatusOr ChaoticGoodServerListener::Bind( StatusToString(status).c_str()); } }; - GPR_ASSERT(event_engine_ != nullptr); + CHECK_NE(event_engine_, nullptr); auto ee_listener = event_engine_->CreateListener( std::move(accept_cb), std::move(shutdown_cb), grpc_event_engine::experimental::ChannelArgsEndpointConfig(args_), @@ -135,7 +136,7 @@ absl::StatusOr ChaoticGoodServerListener::Bind( } absl::Status ChaoticGoodServerListener::StartListening() { - GPR_ASSERT(ee_listener_ != nullptr); + CHECK(ee_listener_ != nullptr); auto status = ee_listener_->Start(); if (!status.ok()) { gpr_log(GPR_ERROR, "Start listening failed: %s", status.ToString().c_str()); @@ -148,8 +149,7 @@ absl::Status ChaoticGoodServerListener::StartListening() { ChaoticGoodServerListener::ActiveConnection::ActiveConnection( RefCountedPtr listener, std::unique_ptr endpoint) - : memory_allocator_(listener->memory_allocator_), - listener_(std::move(listener)) { + : memory_allocator_(listener->memory_allocator_), listener_(listener) { handshaking_state_ = MakeRefCounted(Ref()); handshaking_state_->Start(std::move(endpoint)); } @@ -384,7 +384,7 @@ auto ChaoticGoodServerListener::ActiveConnection::HandshakingState:: void ChaoticGoodServerListener::ActiveConnection::HandshakingState:: OnHandshakeDone(void* arg, grpc_error_handle error) { auto* args = static_cast(arg); - GPR_ASSERT(args != nullptr); + CHECK_NE(args, nullptr); RefCountedPtr self( static_cast(args->user_data)); grpc_slice_buffer_destroy(args->read_buffer); @@ -398,7 +398,7 @@ void ChaoticGoodServerListener::ActiveConnection::HandshakingState:: self->connection_->Done("Server handshake done but has empty endpoint."); return; } - GPR_ASSERT(grpc_event_engine::experimental::grpc_is_event_engine_endpoint( + CHECK(grpc_event_engine::experimental::grpc_is_event_engine_endpoint( args->endpoint)); auto ee_endpoint = grpc_event_engine::experimental::grpc_take_wrapped_event_engine_endpoint( @@ -503,7 +503,7 @@ int grpc_server_add_chaotic_good_port(grpc_server* server, const char* addr) { if (port_num == 0) { port_num = bind_result.value(); } else { - GPR_ASSERT(port_num == bind_result.value()); + CHECK(port_num == bind_result.value()); } core_server->AddListener(std::move(listener)); } diff --git a/src/core/ext/transport/chaotic_good/server/chaotic_good_server.h b/src/core/ext/transport/chaotic_good/server/chaotic_good_server.h index 0479016c15b..404bbbf946d 100644 --- a/src/core/ext/transport/chaotic_good/server/chaotic_good_server.h +++ b/src/core/ext/transport/chaotic_good/server/chaotic_good_server.h @@ -49,7 +49,9 @@ namespace grpc_core { namespace chaotic_good { -class ChaoticGoodServerListener final : public Server::ListenerInterface { +class ChaoticGoodServerListener final + : public Server::ListenerInterface, + public RefCounted { public: static absl::AnyInvocable DefaultConnectionIDGenerator() { return [bitgen = absl::BitGen()]() mutable { diff --git a/src/core/ext/transport/chaotic_good/server_transport.cc b/src/core/ext/transport/chaotic_good/server_transport.cc index 7975975203c..c139c6e44e0 100644 --- a/src/core/ext/transport/chaotic_good/server_transport.cc +++ b/src/core/ext/transport/chaotic_good/server_transport.cc @@ -18,6 +18,7 @@ #include #include +#include "absl/log/check.h" #include "absl/random/bit_gen_ref.h" #include "absl/random/random.h" #include "absl/status/status.h" @@ -72,7 +73,7 @@ auto ChaoticGoodServerTransport::TransportWriteLoop( auto ChaoticGoodServerTransport::PushFragmentIntoCall( CallInitiator call_initiator, ClientFragmentFrame frame, uint32_t stream_id) { - GPR_DEBUG_ASSERT(frame.headers == nullptr); + DCHECK(frame.headers == nullptr); if (grpc_chaotic_good_trace.enabled()) { gpr_log(GPR_INFO, "CHAOTIC_GOOD: PushFragmentIntoCall: frame=%s", frame.ToString().c_str()); @@ -167,7 +168,7 @@ auto ChaoticGoodServerTransport::SendCallBody( message_length % aligned_bytes == 0 ? 0 : aligned_bytes - message_length % aligned_bytes; - GPR_ASSERT((message_length + padding) % aligned_bytes == 0); + CHECK_EQ((message_length + padding) % aligned_bytes, 0u); frame.message = FragmentMessage(std::move(message), padding, message_length); frame.stream_id = stream_id; @@ -381,8 +382,8 @@ ChaoticGoodServerTransport::ChaoticGoodServerTransport( } void ChaoticGoodServerTransport::SetAcceptor(Acceptor* acceptor) { - GPR_ASSERT(acceptor_ == nullptr); - GPR_ASSERT(acceptor != nullptr); + CHECK_EQ(acceptor_, nullptr); + CHECK_NE(acceptor, nullptr); acceptor_ = acceptor; got_acceptor_.Set(); } diff --git a/src/core/ext/transport/chttp2/server/chttp2_server.cc b/src/core/ext/transport/chttp2/server/chttp2_server.cc index df9be768db0..239a03db478 100644 --- a/src/core/ext/transport/chttp2/server/chttp2_server.cc +++ b/src/core/ext/transport/chttp2/server/chttp2_server.cc @@ -41,7 +41,6 @@ #include #include #include -#include #include #include #include @@ -58,8 +57,6 @@ #include "src/core/lib/config/core_configuration.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/event_engine/channel_args_endpoint_config.h" -#include "src/core/lib/event_engine/extensions/supports_fd.h" -#include "src/core/lib/event_engine/query_extensions.h" #include "src/core/lib/gprpp/debug_location.h" #include "src/core/lib/gprpp/orphanable.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" @@ -69,7 +66,6 @@ #include "src/core/lib/gprpp/unique_type_name.h" #include "src/core/lib/iomgr/closure.h" #include "src/core/lib/iomgr/endpoint.h" -#include "src/core/lib/iomgr/event_engine_shims/endpoint.h" #include "src/core/lib/iomgr/iomgr_fwd.h" #include "src/core/lib/iomgr/pollset_set.h" #include "src/core/lib/iomgr/resolve_address.h" @@ -96,11 +92,9 @@ #endif // GPR_SUPPORT_CHANNELS_FROM_FD namespace grpc_core { +namespace { -using grpc_event_engine::experimental::ChannelArgsEndpointConfig; -using grpc_event_engine::experimental::EventEngine; -using grpc_event_engine::experimental::EventEngineSupportsFdExtension; -using grpc_event_engine::experimental::QueryExtension; +using ::grpc_event_engine::experimental::EventEngine; const char kUnixUriPrefix[] = "unix:"; const char kUnixAbstractUriPrefix[] = "unix-abstract:"; @@ -117,23 +111,14 @@ class Chttp2ServerListener : public Server::ListenerInterface { Server* server, const char* name, const ChannelArgs& args, Chttp2ServerArgsModifier args_modifier); - static Chttp2ServerListener* CreateForPassiveListener( - Server* server, const ChannelArgs& args, - std::shared_ptr passive_listener); - // Do not instantiate directly. Use one of the factory methods above. Chttp2ServerListener(Server* server, const ChannelArgs& args, - Chttp2ServerArgsModifier args_modifier, - grpc_server_config_fetcher* config_fetcher, - std::shared_ptr - passive_listener = nullptr); + Chttp2ServerArgsModifier args_modifier); ~Chttp2ServerListener() override; void Start(Server* server, const std::vector* pollsets) override; - void AcceptConnectedEndpoint(std::unique_ptr endpoint); - channelz::ListenSocketNode* channelz_listen_socket_node() const override { return channelz_listen_socket_.get(); } @@ -143,8 +128,6 @@ class Chttp2ServerListener : public Server::ListenerInterface { void Orphan() override; private: - friend class experimental::PassiveListenerImpl; - class ConfigFetcherWatcher : public grpc_server_config_fetcher::WatcherInterface { public: @@ -251,8 +234,34 @@ class Chttp2ServerListener : public Server::ListenerInterface { static void DestroyListener(Server* /*server*/, void* arg, grpc_closure* destroy_done); - Server* const server_ = nullptr; - grpc_tcp_server* tcp_server_ = nullptr; + // The interface required by RefCountedPtr<> has been manually implemented + // here to take a ref on tcp_server_ instead. Note that, the handshaker + // needs tcp_server_ to exist for the lifetime of the handshake since it's + // needed by acceptor. Sharing refs between the listener and tcp_server_ is + // just an optimization to avoid taking additional refs on the listener, + // since TcpServerShutdownComplete already holds a ref to the listener. + void IncrementRefCount() { grpc_tcp_server_ref(tcp_server_); } + void IncrementRefCount(const DebugLocation& /* location */, + const char* /* reason */) { + IncrementRefCount(); + } + + GRPC_MUST_USE_RESULT RefCountedPtr Ref() { + IncrementRefCount(); + return RefCountedPtr(this); + } + GRPC_MUST_USE_RESULT RefCountedPtr Ref( + const DebugLocation& /* location */, const char* /* reason */) { + return Ref(); + } + + void Unref() { grpc_tcp_server_unref(tcp_server_); } + void Unref(const DebugLocation& /* location */, const char* /* reason */) { + Unref(); + } + + Server* const server_; + grpc_tcp_server* tcp_server_; grpc_resolved_address resolved_address_; Chttp2ServerArgsModifier const args_modifier_; ConfigFetcherWatcher* config_fetcher_watcher_ = nullptr; @@ -275,10 +284,6 @@ class Chttp2ServerListener : public Server::ListenerInterface { RefCountedPtr channelz_listen_socket_; MemoryQuotaRefPtr memory_quota_; ConnectionQuotaRefPtr connection_quota_; - grpc_server_config_fetcher* config_fetcher_ = nullptr; - // TODO(yashykt): consider using absl::variant<> to minimize memory usage for - // disjoint cases where different fields are used. - std::shared_ptr passive_listener_; }; // @@ -375,17 +380,13 @@ Chttp2ServerListener::ActiveConnection::HandshakingState::HandshakingState( handshake_mgr_(MakeRefCounted()), deadline_(GetConnectionDeadline(args)), interested_parties_(grpc_pollset_set_create()) { - if (accepting_pollset != nullptr) { - grpc_pollset_set_add_pollset(interested_parties_, accepting_pollset_); - } + grpc_pollset_set_add_pollset(interested_parties_, accepting_pollset_); CoreConfiguration::Get().handshaker_registry().AddHandshakers( HANDSHAKER_SERVER, args, interested_parties_, handshake_mgr_.get()); } Chttp2ServerListener::ActiveConnection::HandshakingState::~HandshakingState() { - if (accepting_pollset_ != nullptr) { - grpc_pollset_set_del_pollset(interested_parties_, accepting_pollset_); - } + grpc_pollset_set_del_pollset(interested_parties_, accepting_pollset_); grpc_pollset_set_destroy(interested_parties_); gpr_free(acceptor_); } @@ -707,82 +708,83 @@ void Chttp2ServerListener::ActiveConnection::OnDrainGraceTimeExpiry() { grpc_error_handle Chttp2ServerListener::Create( Server* server, grpc_resolved_address* addr, const ChannelArgs& args, Chttp2ServerArgsModifier args_modifier, int* port_num) { - // Create Chttp2ServerListener. - OrphanablePtr listener = - MakeOrphanable(server, args, args_modifier, - server->config_fetcher()); - // The tcp_server will be unreffed when the listener is orphaned, which could - // be at the end of this function if the listener was not added to the - // server's set of listeners. - grpc_error_handle error = grpc_tcp_server_create( - &listener->tcp_server_shutdown_complete_, ChannelArgsEndpointConfig(args), - OnAccept, listener.get(), &listener->tcp_server_); - if (!error.ok()) return error; - if (listener->config_fetcher_ != nullptr) { - listener->resolved_address_ = *addr; - // TODO(yashykt): Consider binding so as to be able to return the port - // number. - } else { - error = grpc_tcp_server_add_port(listener->tcp_server_, addr, port_num); + Chttp2ServerListener* listener = nullptr; + // The bulk of this method is inside of a lambda to make cleanup + // easier without using goto. + grpc_error_handle error = [&]() { + grpc_error_handle error; + // Create Chttp2ServerListener. + listener = new Chttp2ServerListener(server, args, args_modifier); + error = grpc_tcp_server_create( + &listener->tcp_server_shutdown_complete_, + grpc_event_engine::experimental::ChannelArgsEndpointConfig(args), + OnAccept, listener, &listener->tcp_server_); if (!error.ok()) return error; - } - // Create channelz node. - if (args.GetBool(GRPC_ARG_ENABLE_CHANNELZ) - .value_or(GRPC_ENABLE_CHANNELZ_DEFAULT)) { - auto string_address = grpc_sockaddr_to_uri(addr); - if (!string_address.ok()) { - return GRPC_ERROR_CREATE(string_address.status().ToString()); + if (server->config_fetcher() != nullptr) { + listener->resolved_address_ = *addr; + // TODO(yashykt): Consider binding so as to be able to return the port + // number. + } else { + error = grpc_tcp_server_add_port(listener->tcp_server_, addr, port_num); + if (!error.ok()) return error; + } + // Create channelz node. + if (args.GetBool(GRPC_ARG_ENABLE_CHANNELZ) + .value_or(GRPC_ENABLE_CHANNELZ_DEFAULT)) { + auto string_address = grpc_sockaddr_to_uri(addr); + if (!string_address.ok()) { + return GRPC_ERROR_CREATE(string_address.status().ToString()); + } + listener->channelz_listen_socket_ = + MakeRefCounted( + *string_address, + absl::StrCat("chttp2 listener ", *string_address)); + } + // Register with the server only upon success + server->AddListener(OrphanablePtr(listener)); + return absl::OkStatus(); + }(); + if (!error.ok()) { + if (listener != nullptr) { + if (listener->tcp_server_ != nullptr) { + // listener is deleted when tcp_server_ is shutdown. + grpc_tcp_server_unref(listener->tcp_server_); + } else { + delete listener; + } } - listener->channelz_listen_socket_ = - MakeRefCounted( - *string_address, absl::StrCat("chttp2 listener ", *string_address)); } - // Register with the server only upon success - server->AddListener(std::move(listener)); - return absl::OkStatus(); + return error; } grpc_error_handle Chttp2ServerListener::CreateWithAcceptor( Server* server, const char* name, const ChannelArgs& args, Chttp2ServerArgsModifier args_modifier) { - auto listener = MakeOrphanable( - server, args, args_modifier, server->config_fetcher()); + Chttp2ServerListener* listener = + new Chttp2ServerListener(server, args, args_modifier); grpc_error_handle error = grpc_tcp_server_create( - &listener->tcp_server_shutdown_complete_, ChannelArgsEndpointConfig(args), - OnAccept, listener.get(), &listener->tcp_server_); - if (!error.ok()) return error; + &listener->tcp_server_shutdown_complete_, + grpc_event_engine::experimental::ChannelArgsEndpointConfig(args), + OnAccept, listener, &listener->tcp_server_); + if (!error.ok()) { + delete listener; + return error; + } // TODO(yangg) channelz TcpServerFdHandler** arg_val = args.GetPointer(name); *arg_val = grpc_tcp_server_create_fd_handler(listener->tcp_server_); - server->AddListener(std::move(listener)); + server->AddListener(OrphanablePtr(listener)); return absl::OkStatus(); } -Chttp2ServerListener* Chttp2ServerListener::CreateForPassiveListener( - Server* server, const ChannelArgs& args, - std::shared_ptr passive_listener) { - // TODO(hork): figure out how to handle channelz in this case - auto listener = MakeOrphanable( - server, args, /*args_modifier=*/ - [](const ChannelArgs& args, grpc_error_handle*) { return args; }, nullptr, - std::move(passive_listener)); - auto listener_ptr = listener.get(); - server->AddListener(std::move(listener)); - return listener_ptr; -} - Chttp2ServerListener::Chttp2ServerListener( Server* server, const ChannelArgs& args, - Chttp2ServerArgsModifier args_modifier, - grpc_server_config_fetcher* config_fetcher, - std::shared_ptr passive_listener) + Chttp2ServerArgsModifier args_modifier) : server_(server), args_modifier_(args_modifier), args_(args), memory_quota_(args.GetObject()->memory_quota()), - connection_quota_(MakeRefCounted()), - config_fetcher_(config_fetcher), - passive_listener_(std::move(passive_listener)) { + connection_quota_(MakeRefCounted()) { auto max_allowed_incoming_connections = args.GetInt(GRPC_ARG_MAX_ALLOWED_INCOMING_CONNECTIONS); if (max_allowed_incoming_connections.has_value()) { @@ -797,9 +799,6 @@ Chttp2ServerListener::~Chttp2ServerListener() { // Flush queued work before destroying handshaker factory, since that // may do a synchronous unref. ExecCtx::Get()->Flush(); - if (passive_listener_ != nullptr) { - passive_listener_->ListenerDestroyed(); - } if (on_destroy_done_ != nullptr) { ExecCtx::Run(DEBUG_LOCATION, on_destroy_done_, absl::OkStatus()); ExecCtx::Get()->Flush(); @@ -809,11 +808,10 @@ Chttp2ServerListener::~Chttp2ServerListener() { // Server callback: start listening on our ports void Chttp2ServerListener::Start( Server* /*server*/, const std::vector* /* pollsets */) { - if (config_fetcher_ != nullptr) { - auto watcher = std::make_unique( - RefAsSubclass()); + if (server_->config_fetcher() != nullptr) { + auto watcher = std::make_unique(Ref()); config_fetcher_watcher_ = watcher.get(); - config_fetcher_->StartWatch( + server_->config_fetcher()->StartWatch( grpc_sockaddr_to_string(&resolved_address_, false).value(), std::move(watcher)); } else { @@ -827,9 +825,7 @@ void Chttp2ServerListener::Start( } void Chttp2ServerListener::StartListening() { - if (tcp_server_ != nullptr) { - grpc_tcp_server_start(tcp_server_, &server_->pollsets()); - } + grpc_tcp_server_start(tcp_server_, &server_->pollsets()); } void Chttp2ServerListener::SetOnDestroyDone(grpc_closure* on_destroy_done) { @@ -837,12 +833,6 @@ void Chttp2ServerListener::SetOnDestroyDone(grpc_closure* on_destroy_done) { on_destroy_done_ = on_destroy_done; } -void Chttp2ServerListener::AcceptConnectedEndpoint( - std::unique_ptr endpoint) { - OnAccept(this, grpc_event_engine_endpoint_create(std::move(endpoint)), - /*accepting_pollset=*/nullptr, /*acceptor=*/nullptr); -} - void Chttp2ServerListener::OnAccept(void* arg, grpc_endpoint* tcp, grpc_pollset* accepting_pollset, grpc_tcp_server_acceptor* acceptor) { @@ -867,7 +857,7 @@ void Chttp2ServerListener::OnAccept(void* arg, grpc_endpoint* tcp, endpoint_cleanup(error); return; } - if (self->config_fetcher_ != nullptr) { + if (self->server_->config_fetcher() != nullptr) { if (connection_manager == nullptr) { grpc_error_handle error = GRPC_ERROR_CREATE( "No ConnectionManager configured. Closing connection."); @@ -908,7 +898,7 @@ void Chttp2ServerListener::OnAccept(void* arg, grpc_endpoint* tcp, // heap-use-after-free issues where `Ref()` is invoked when the ref of // tcp_server_ has already reached 0. (Ref() implementation of // Chttp2ServerListener is grpc_tcp_server_ref().) - listener_ref = self->RefAsSubclass(); + listener_ref = self->Ref(); self->connections_.emplace(connection.get(), std::move(connection)); } } @@ -923,7 +913,7 @@ void Chttp2ServerListener::TcpServerShutdownComplete( void* arg, grpc_error_handle /*error*/) { Chttp2ServerListener* self = static_cast(arg); self->channelz_listen_socket_.reset(); - self->Unref(); + delete self; } // Server callback: destroy the tcp listener (so we don't generate further @@ -932,8 +922,7 @@ void Chttp2ServerListener::Orphan() { // Cancel the watch before shutting down so as to avoid holding a ref to the // listener in the watcher. if (config_fetcher_watcher_ != nullptr) { - GPR_ASSERT(config_fetcher_ != nullptr); - config_fetcher_->CancelWatch(config_fetcher_watcher_); + server_->config_fetcher()->CancelWatch(config_fetcher_watcher_); } std::map> connections; grpc_tcp_server* tcp_server; @@ -951,14 +940,12 @@ void Chttp2ServerListener::Orphan() { } tcp_server = tcp_server_; } - if (tcp_server != nullptr) { - grpc_tcp_server_shutdown_listeners(tcp_server); - grpc_tcp_server_unref(tcp_server); - } else { - Unref(); - } + grpc_tcp_server_shutdown_listeners(tcp_server); + grpc_tcp_server_unref(tcp_server); } +} // namespace + // // Chttp2ServerAddPort() // @@ -1059,50 +1046,6 @@ ChannelArgs ModifyArgsForConnection(const ChannelArgs& args, } } // namespace - -namespace experimental { - -absl::Status PassiveListenerImpl::AcceptConnectedEndpoint( - std::unique_ptr endpoint) { - GPR_ASSERT(server_ != nullptr); - RefCountedPtr listener; - { - MutexLock lock(&mu_); - if (listener_ != nullptr) { - listener = - listener_->RefIfNonZero().TakeAsSubclass(); - } - } - if (listener == nullptr) { - return absl::UnavailableError("passive listener already shut down"); - } - ExecCtx exec_ctx; - listener->AcceptConnectedEndpoint(std::move(endpoint)); - return absl::OkStatus(); -} - -absl::Status PassiveListenerImpl::AcceptConnectedFd(int fd) { - GPR_ASSERT(server_ != nullptr); - ExecCtx exec_ctx; - auto& args = server_->channel_args(); - auto* supports_fd = QueryExtension( - /*engine=*/args.GetObjectRef().get()); - if (supports_fd == nullptr) { - return absl::UnimplementedError( - "The server's EventEngine does not support adding endpoints from " - "connected file descriptors."); - } - auto endpoint = - supports_fd->CreateEndpointFromFd(fd, ChannelArgsEndpointConfig(args)); - return AcceptConnectedEndpoint(std::move(endpoint)); -} - -void PassiveListenerImpl::ListenerDestroyed() { - MutexLock lock(&mu_); - listener_ = nullptr; -} - -} // namespace experimental } // namespace grpc_core int grpc_server_add_http2_port(grpc_server* server, const char* addr, @@ -1200,31 +1143,3 @@ void grpc_server_add_channel_from_fd(grpc_server* /* server */, int /* fd */, } #endif // GPR_SUPPORT_CHANNELS_FROM_FD - -absl::Status grpc_server_add_passive_listener( - grpc_core::Server* server, grpc_server_credentials* credentials, - std::shared_ptr - passive_listener) { - grpc_core::ExecCtx exec_ctx; - GRPC_API_TRACE("grpc_server_add_passive_listener(server=%p, credentials=%p)", - 2, (server, credentials)); - // Create security context. - if (credentials == nullptr) { - return absl::UnavailableError( - "No credentials specified for passive listener"); - } - auto sc = credentials->create_security_connector(grpc_core::ChannelArgs()); - if (sc == nullptr) { - return absl::UnavailableError( - absl::StrCat("Unable to create secure server with credentials of type ", - credentials->type().name())); - } - auto args = server->channel_args() - .SetObject(credentials->Ref()) - .SetObject(std::move(sc)); - passive_listener->listener_ = - grpc_core::Chttp2ServerListener::CreateForPassiveListener( - server, args, passive_listener); - passive_listener->server_ = server->Ref(); - return absl::OkStatus(); -} diff --git a/src/core/ext/transport/chttp2/server/chttp2_server.h b/src/core/ext/transport/chttp2/server/chttp2_server.h index 25d38236aed..26c178be917 100644 --- a/src/core/ext/transport/chttp2/server/chttp2_server.h +++ b/src/core/ext/transport/chttp2/server/chttp2_server.h @@ -21,7 +21,6 @@ #include -#include #include #include "src/core/lib/channel/channel_args.h" @@ -43,38 +42,6 @@ grpc_error_handle Chttp2ServerAddPort( Server* server, const char* addr, const ChannelArgs& args, Chttp2ServerArgsModifier connection_args_modifier, int* port_num); -class Chttp2ServerListener; -namespace experimental { - -// An implementation of the public C++ passive listener interface. -// The server builder holds a weak_ptr to one of these objects, and the -// application owns the instance. -class PassiveListenerImpl final : public PassiveListener { - public: - absl::Status AcceptConnectedEndpoint( - std::unique_ptr - endpoint) override ABSL_LOCKS_EXCLUDED(mu_); - - absl::Status AcceptConnectedFd(GRPC_UNUSED int fd) override - ABSL_LOCKS_EXCLUDED(mu_); - - void ListenerDestroyed() ABSL_LOCKS_EXCLUDED(mu_); - - private: - // note: the grpc_core::Server redundant namespace qualification is - // required for older gcc versions. - friend absl::Status(::grpc_server_add_passive_listener)( - grpc_core::Server* server, grpc_server_credentials* credentials, - std::shared_ptr - passive_listener); - - Mutex mu_; - // Data members will be populated when initialized. - RefCountedPtr server_; - Chttp2ServerListener* listener_; -}; - -} // namespace experimental } // namespace grpc_core #endif // GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_SERVER_CHTTP2_SERVER_H diff --git a/src/core/ext/transport/cronet/BUILD b/src/core/ext/transport/cronet/BUILD index 20bbbfc2907..50897682381 100644 --- a/src/core/ext/transport/cronet/BUILD +++ b/src/core/ext/transport/cronet/BUILD @@ -40,6 +40,7 @@ grpc_cc_library( "transport/cronet_transport.h", ], external_deps = [ + "absl/log:check", "cronet_c_for_grpc", ], language = "c++", diff --git a/src/core/ext/transport/cronet/transport/cronet_api_phony.cc b/src/core/ext/transport/cronet/transport/cronet_api_phony.cc index c0f245c5a73..57afb811468 100644 --- a/src/core/ext/transport/cronet/transport/cronet_api_phony.cc +++ b/src/core/ext/transport/cronet/transport/cronet_api_phony.cc @@ -19,6 +19,7 @@ // This file has empty implementation of all the functions exposed by the cronet // library, so we can build it in all environments +#include "absl/log/check.h" #include "third_party/objective_c/Cronet/bidirectional_stream_c.h" #include @@ -31,12 +32,12 @@ bidirectional_stream* bidirectional_stream_create( stream_engine* /*engine*/, void* /*annotation*/, bidirectional_stream_callback* /*callback*/) { - GPR_ASSERT(0); + CHECK(0); return nullptr; } int bidirectional_stream_destroy(bidirectional_stream* /*stream*/) { - GPR_ASSERT(0); + CHECK(0); return 0; } @@ -45,39 +46,35 @@ int bidirectional_stream_start( const char* /*method*/, const bidirectional_stream_header_array* /*headers*/, bool /*end_of_stream*/) { - GPR_ASSERT(0); + CHECK(0); return 0; } int bidirectional_stream_read(bidirectional_stream* /*stream*/, char* /*buffer*/, int /*capacity*/) { - GPR_ASSERT(0); + CHECK(0); return 0; } int bidirectional_stream_write(bidirectional_stream* /*stream*/, const char* /*buffer*/, int /*count*/, bool /*end_of_stream*/) { - GPR_ASSERT(0); + CHECK(0); return 0; } -void bidirectional_stream_cancel(bidirectional_stream* /*stream*/) { - GPR_ASSERT(0); -} +void bidirectional_stream_cancel(bidirectional_stream* /*stream*/) { CHECK(0); } void bidirectional_stream_disable_auto_flush(bidirectional_stream* /*stream*/, bool /*disable_auto_flush*/) { - GPR_ASSERT(0); + CHECK(0); } void bidirectional_stream_delay_request_headers_until_flush( bidirectional_stream* /*stream*/, bool /*delay_headers_until_flush*/) { - GPR_ASSERT(0); + CHECK(0); } -void bidirectional_stream_flush(bidirectional_stream* /*stream*/) { - GPR_ASSERT(0); -} +void bidirectional_stream_flush(bidirectional_stream* /*stream*/) { CHECK(0); } #endif // GRPC_COMPILE_WITH_CRONET diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.cc b/src/core/ext/transport/cronet/transport/cronet_transport.cc index 1b8c3d117cf..bd6c4b411dc 100644 --- a/src/core/ext/transport/cronet/transport/cronet_transport.cc +++ b/src/core/ext/transport/cronet/transport/cronet_transport.cc @@ -26,6 +26,7 @@ #include #include +#include "absl/log/check.h" #include "absl/status/status.h" #include "absl/strings/match.h" #include "absl/strings/str_cat.h" @@ -412,7 +413,7 @@ static void execute_from_storage(stream_obj* s) { gpr_mu_lock(&s->mu); for (struct op_and_state* curr = s->storage.head; curr != nullptr;) { CRONET_LOG(GPR_DEBUG, "calling op at %p. done = %d", curr, curr->done); - GPR_ASSERT(!curr->done); + CHECK(!curr->done); enum e_op_result result = execute_stream_op(curr); CRONET_LOG(GPR_DEBUG, "execute_stream_op[%p] returns %s", curr, op_result_string(result)); @@ -592,7 +593,7 @@ static void on_response_headers_received( s->state.state_callback_received[OP_FAILED])) { // Do an extra read to trigger on_succeeded() callback in case connection // is closed - GPR_ASSERT(s->state.rs.length_field_received == false); + CHECK(s->state.rs.length_field_received == false); read_grpc_header(s); } gpr_mu_unlock(&s->mu); @@ -794,7 +795,7 @@ class CronetMetadataEncoder { value = grpc_slice_to_c_string(value_slice.c_slice()); } CRONET_LOG(GPR_DEBUG, "header %s = %s", key, value); - GPR_ASSERT(count_ < capacity_); + CHECK_LT(count_, capacity_); headers_[count_].key = key; headers_[count_].value = value; ++count_; @@ -1057,8 +1058,8 @@ static enum e_op_result execute_stream_op(struct op_and_state* oas) { CRONET_LOG(GPR_DEBUG, "running: %p OP_SEND_INITIAL_METADATA", oas); // Start new cronet stream. It is destroyed in on_succeeded, on_canceled, // on_failed - GPR_ASSERT(s->cbs == nullptr); - GPR_ASSERT(!stream_state->state_op_done[OP_SEND_INITIAL_METADATA]); + CHECK_EQ(s->cbs, nullptr); + CHECK(!stream_state->state_op_done[OP_SEND_INITIAL_METADATA]); s->cbs = bidirectional_stream_create(t->engine, s->curr_gs, &cronet_callbacks); CRONET_LOG(GPR_DEBUG, "%p = bidirectional_stream_create()", s->cbs); @@ -1229,7 +1230,7 @@ static enum e_op_result execute_stream_op(struct op_and_state* oas) { if (stream_state->rs.length_field > 0) { stream_state->rs.read_buffer = static_cast( gpr_malloc(static_cast(stream_state->rs.length_field))); - GPR_ASSERT(stream_state->rs.read_buffer); + CHECK(stream_state->rs.read_buffer); stream_state->rs.remaining_bytes = stream_state->rs.length_field; stream_state->rs.received_bytes = 0; CRONET_LOG(GPR_DEBUG, "bidirectional_stream_read(%p)", s->cbs); diff --git a/src/core/ext/transport/inproc/inproc_transport.cc b/src/core/ext/transport/inproc/inproc_transport.cc index ffcc7469c6a..7dd316bfca8 100644 --- a/src/core/ext/transport/inproc/inproc_transport.cc +++ b/src/core/ext/transport/inproc/inproc_transport.cc @@ -16,6 +16,8 @@ #include +#include "absl/log/check.h" + #include #include #include @@ -152,8 +154,8 @@ class InprocClientTransport final : public ClientTransport { bool UsePromiseBasedTransport() { if (!IsPromiseBasedInprocTransportEnabled()) return false; - GPR_ASSERT(IsPromiseBasedClientCallEnabled()); - GPR_ASSERT(IsPromiseBasedServerCallEnabled()); + CHECK(IsPromiseBasedClientCallEnabled()); + CHECK(IsPromiseBasedServerCallEnabled()); return true; } diff --git a/src/core/ext/transport/inproc/legacy_inproc_transport.cc b/src/core/ext/transport/inproc/legacy_inproc_transport.cc index cf91abab6c5..dd5c4663abc 100644 --- a/src/core/ext/transport/inproc/legacy_inproc_transport.cc +++ b/src/core/ext/transport/inproc/legacy_inproc_transport.cc @@ -27,6 +27,7 @@ #include #include +#include "absl/log/check.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/str_cat.h" @@ -1266,7 +1267,7 @@ grpc_channel* grpc_legacy_inproc_channel_create(grpc_server* server, auto new_channel = grpc_core::ChannelCreate( "inproc", client_args, GRPC_CLIENT_DIRECT_CHANNEL, client_transport); if (!new_channel.ok()) { - GPR_ASSERT(!channel); + CHECK(!channel); gpr_log(GPR_ERROR, "Failed to create client channel: %s", grpc_core::StatusToString(error).c_str()); intptr_t integer; @@ -1284,7 +1285,7 @@ grpc_channel* grpc_legacy_inproc_channel_create(grpc_server* server, channel = new_channel->release()->c_ptr(); } } else { - GPR_ASSERT(!channel); + CHECK(!channel); gpr_log(GPR_ERROR, "Failed to create server channel: %s", grpc_core::StatusToString(error).c_str()); intptr_t integer; diff --git a/src/core/lib/event_engine/extensions/supports_fd.h b/src/core/lib/event_engine/extensions/supports_fd.h index 30f0d2ad0e6..66ea1c2b345 100644 --- a/src/core/lib/event_engine/extensions/supports_fd.h +++ b/src/core/lib/event_engine/extensions/supports_fd.h @@ -112,13 +112,6 @@ class EventEngineSupportsFdExtension { int fd, const EndpointConfig& config, MemoryAllocator memory_allocator) = 0; - /// Creates an EventEngine::Endpoint from an fd which is already assumed to be - /// connected to a remote peer. See \a CreatePosixEndpointFromFd for details. - /// This has the same behavior, but the \a memory_allocator is taken from the - /// EndpointConfig's resource quota. - virtual std::unique_ptr CreateEndpointFromFd( - int fd, const EndpointConfig& config) = 0; - /// Called when the posix listener has accepted a new client connection. /// \a listener_fd - The listening socket fd that accepted the new client /// connection. diff --git a/src/core/lib/event_engine/posix_engine/posix_engine.cc b/src/core/lib/event_engine/posix_engine/posix_engine.cc index 0ac3dfcebfe..e96c969617c 100644 --- a/src/core/lib/event_engine/posix_engine/posix_engine.cc +++ b/src/core/lib/event_engine/posix_engine/posix_engine.cc @@ -25,6 +25,7 @@ #include "absl/cleanup/cleanup.h" #include "absl/functional/any_invocable.h" +#include "absl/log/check.h" #include "absl/status/status.h" #include "absl/strings/match.h" #include "absl/strings/str_cat.h" @@ -142,7 +143,7 @@ void AsyncConnect::OnWritable(absl::Status status) absl::StatusOr> ep; mu_.Lock(); - GPR_ASSERT(fd_ != nullptr); + CHECK_NE(fd_, nullptr); fd = std::exchange(fd_, nullptr); bool connect_cancelled = connect_cancelled_; if (fd->IsHandleShutdown() && status.ok()) { @@ -334,7 +335,7 @@ PosixEnginePollerManager::PosixEnginePollerManager( poller_state_(PollerState::kExternal), executor_(nullptr), trigger_shutdown_called_(false) { - GPR_DEBUG_ASSERT(poller_ != nullptr); + DCHECK_NE(poller_, nullptr); } void PosixEnginePollerManager::Run( @@ -351,7 +352,7 @@ void PosixEnginePollerManager::Run(absl::AnyInvocable cb) { } void PosixEnginePollerManager::TriggerShutdown() { - GPR_DEBUG_ASSERT(trigger_shutdown_called_ == false); + DCHECK(trigger_shutdown_called_ == false); trigger_shutdown_called_ = true; // If the poller is external, dont try to shut it down. Otherwise // set poller state to PollerState::kShuttingDown. @@ -467,7 +468,7 @@ PosixEventEngine::~PosixEventEngine() { this, HandleToString(handle).c_str()); } } - GPR_ASSERT(GPR_LIKELY(known_handles_.empty())); + CHECK(GPR_LIKELY(known_handles_.empty())); } timer_manager_->Shutdown(); #if GRPC_PLATFORM_SUPPORTS_POSIX_POLLING @@ -592,7 +593,7 @@ bool PosixEventEngine::CancelConnect(EventEngine::ConnectionHandle handle) { auto it = shard->pending_connections.find(connection_handle); if (it != shard->pending_connections.end()) { ac = it->second; - GPR_ASSERT(ac != nullptr); + CHECK_NE(ac, nullptr); // Trying to acquire ac->mu here would could cause a deadlock because // the OnWritable method tries to acquire the two mutexes used // here in the reverse order. But we dont need to acquire ac->mu before @@ -639,7 +640,7 @@ EventEngine::ConnectionHandle PosixEventEngine::Connect( const EndpointConfig& args, MemoryAllocator memory_allocator, Duration timeout) { #if GRPC_PLATFORM_SUPPORTS_POSIX_POLLING - GPR_ASSERT(poller_manager_ != nullptr); + CHECK_NE(poller_manager_, nullptr); PosixTcpOptions options = TcpOptionsFromEndpointConfig(args); absl::StatusOr socket = PosixSocketWrapper::CreateAndPrepareTcpClientSocket(options, addr); @@ -661,9 +662,9 @@ PosixEventEngine::CreatePosixEndpointFromFd(int fd, const EndpointConfig& config, MemoryAllocator memory_allocator) { #if GRPC_PLATFORM_SUPPORTS_POSIX_POLLING - GPR_ASSERT(fd > 0); + DCHECK_GT(fd, 0); PosixEventPoller* poller = poller_manager_->Poller(); - GPR_DEBUG_ASSERT(poller != nullptr); + DCHECK_NE(poller, nullptr); EventHandle* handle = poller->CreateHandle(fd, "tcp-client", poller->CanTrackErrors()); return CreatePosixEndpoint(handle, nullptr, shared_from_this(), @@ -676,22 +677,6 @@ PosixEventEngine::CreatePosixEndpointFromFd(int fd, #endif // GRPC_PLATFORM_SUPPORTS_POSIX_POLLING } -std::unique_ptr PosixEventEngine::CreateEndpointFromFd( - int fd, const EndpointConfig& config) { - auto options = TcpOptionsFromEndpointConfig(config); - MemoryAllocator allocator; - if (options.memory_allocator_factory != nullptr) { - return CreatePosixEndpointFromFd( - fd, config, - options.memory_allocator_factory->CreateMemoryAllocator( - absl::StrCat("allocator:", fd))); - } - return CreatePosixEndpointFromFd( - fd, config, - options.resource_quota->memory_quota()->CreateMemoryAllocator( - absl::StrCat("allocator:", fd))); -} - absl::StatusOr> PosixEventEngine::CreateListener( Listener::AcceptCallback on_accept, diff --git a/src/core/lib/event_engine/posix_engine/posix_engine.h b/src/core/lib/event_engine/posix_engine/posix_engine.h index ea426c379c9..257cd6b34b5 100644 --- a/src/core/lib/event_engine/posix_engine/posix_engine.h +++ b/src/core/lib/event_engine/posix_engine/posix_engine.h @@ -172,8 +172,6 @@ class PosixEventEngine final : public PosixEventEngineWithFdSupport, std::unique_ptr CreatePosixEndpointFromFd( int fd, const EndpointConfig& config, MemoryAllocator memory_allocator) override; - std::unique_ptr CreateEndpointFromFd( - int fd, const EndpointConfig& config) override; absl::StatusOr> CreateListener( Listener::AcceptCallback on_accept, diff --git a/src/core/lib/gpr/log.cc b/src/core/lib/gpr/log.cc index 38f1a4615c6..1755d99122d 100644 --- a/src/core/lib/gpr/log.cc +++ b/src/core/lib/gpr/log.cc @@ -23,7 +23,6 @@ #include #include -#include "absl/log/globals.h" #include "absl/strings/match.h" #include "absl/strings/str_cat.h" @@ -39,7 +38,6 @@ #define GPR_DEFAULT_LOG_VERBOSITY_STRING "ERROR" #endif // !GPR_DEFAULT_LOG_VERBOSITY_STRING -static constexpr int g_absl_vlog_level_for_gpr_verbosity_debug = 2; static constexpr gpr_atm GPR_LOG_SEVERITY_UNSET = GPR_LOG_SEVERITY_ERROR + 10; static constexpr gpr_atm GPR_LOG_SEVERITY_NONE = GPR_LOG_SEVERITY_ERROR + 11; @@ -85,9 +83,8 @@ void gpr_default_log(gpr_log_func_args* args) { } switch (args->severity) { case GPR_LOG_SEVERITY_DEBUG: - VLOG(g_absl_vlog_level_for_gpr_verbosity_debug) - .AtLocation(args->file, args->line) - << args->message; + // Log DEBUG messages as VLOG(2). + VLOG(2).AtLocation(args->file, args->line) << args->message; return; case GPR_LOG_SEVERITY_INFO: LOG(INFO).AtLocation(args->file, args->line) << args->message; @@ -148,12 +145,6 @@ void gpr_log_verbosity_init() { parse_log_severity(verbosity, min_severity_to_print); } gpr_atm_no_barrier_store(&g_min_severity_to_print, min_severity_to_print); - if (grpc_core::ConfigVars::Get().AbslLogging() && - min_severity_to_print == GPR_LOG_SEVERITY_DEBUG) { - // Matches full file paths that include a `*grpc*` folder, including - // grpcpp. - absl::SetVLogLevel("*grpc*/*", g_absl_vlog_level_for_gpr_verbosity_debug); - } } // init stacktrace_minloglevel when it hasn't been set if ((gpr_atm_no_barrier_load(&g_min_severity_to_print_stacktrace)) == diff --git a/src/core/lib/slice/percent_encoding.cc b/src/core/lib/slice/percent_encoding.cc index bd5d71a0788..8931f1d716d 100644 --- a/src/core/lib/slice/percent_encoding.cc +++ b/src/core/lib/slice/percent_encoding.cc @@ -23,6 +23,8 @@ #include #include +#include "absl/log/check.h" + #include #include @@ -100,7 +102,7 @@ Slice PercentEncodeSlice(Slice slice, PercentEncodingType type) { *q++ = hex[c & 15]; } } - GPR_ASSERT(q == out.end()); + CHECK(q == out.end()); return Slice(std::move(out)); } diff --git a/src/core/lib/slice/slice.cc b/src/core/lib/slice/slice.cc index 90939fa93e4..f2d49e0bf47 100644 --- a/src/core/lib/slice/slice.cc +++ b/src/core/lib/slice/slice.cc @@ -22,6 +22,8 @@ #include +#include "absl/log/check.h" + #include #include #include @@ -244,11 +246,11 @@ static grpc_slice sub_no_ref(const grpc_slice& source, size_t begin, size_t end) { grpc_slice subset; - GPR_ASSERT(end >= begin); + CHECK(end >= begin); if (source.refcount != nullptr) { // Enforce preconditions - GPR_ASSERT(source.data.refcounted.length >= end); + CHECK(source.data.refcounted.length >= end); // Build the result subset.refcount = source.refcount; @@ -257,7 +259,7 @@ static grpc_slice sub_no_ref(const grpc_slice& source, size_t begin, subset.data.refcounted.length = end - begin; } else { // Enforce preconditions - GPR_ASSERT(source.data.inlined.length >= end); + CHECK(source.data.inlined.length >= end); subset.refcount = nullptr; subset.data.inlined.length = static_cast(end - begin); memcpy(subset.data.inlined.bytes, source.data.inlined.bytes + begin, @@ -296,7 +298,7 @@ grpc_slice grpc_slice_split_tail_maybe_ref_impl(grpc_slice* source, if (source->refcount == nullptr) { // inlined data, copy it out - GPR_ASSERT(source->data.inlined.length >= split); + CHECK(source->data.inlined.length >= split); tail.refcount = nullptr; tail.data.inlined.length = static_cast(source->data.inlined.length - split); @@ -311,7 +313,7 @@ grpc_slice grpc_slice_split_tail_maybe_ref_impl(grpc_slice* source, source->data.refcounted.length = split; } else { size_t tail_length = source->data.refcounted.length - split; - GPR_ASSERT(source->data.refcounted.length >= split); + CHECK(source->data.refcounted.length >= split); if (allow_inline && tail_length < sizeof(tail.data.inlined.bytes) && ref_whom != GRPC_SLICE_REF_TAIL) { // Copy out the bytes - it'll be cheaper than refcounting @@ -371,7 +373,7 @@ grpc_slice grpc_slice_split_head_impl(grpc_slice* source, size_t split) { grpc_slice head; if (source->refcount == nullptr) { - GPR_ASSERT(source->data.inlined.length >= split); + CHECK(source->data.inlined.length >= split); head.refcount = nullptr; head.data.inlined.length = static_cast(split); @@ -381,7 +383,7 @@ grpc_slice grpc_slice_split_head_impl(grpc_slice* source, size_t split) { memmove(source->data.inlined.bytes, source->data.inlined.bytes + split, source->data.inlined.length); } else if (allow_inline && split < sizeof(head.data.inlined.bytes)) { - GPR_ASSERT(source->data.refcounted.length >= split); + CHECK(source->data.refcounted.length >= split); head.refcount = nullptr; head.data.inlined.length = static_cast(split); @@ -389,7 +391,7 @@ grpc_slice grpc_slice_split_head_impl(grpc_slice* source, size_t split) { source->data.refcounted.bytes += split; source->data.refcounted.length -= split; } else { - GPR_ASSERT(source->data.refcounted.length >= split); + CHECK(source->data.refcounted.length >= split); // Build the result head.refcount = source->refcount; diff --git a/src/core/lib/slice/slice.h b/src/core/lib/slice/slice.h index ed9e30c2edb..06388adc19e 100644 --- a/src/core/lib/slice/slice.h +++ b/src/core/lib/slice/slice.h @@ -21,6 +21,7 @@ #include #include +#include "absl/log/check.h" #include "absl/strings/string_view.h" #include @@ -243,7 +244,7 @@ class StaticSlice : public slice_detail::BaseSlice, StaticSlice() = default; explicit StaticSlice(const grpc_slice& slice) : slice_detail::BaseSlice(slice) { - GPR_DEBUG_ASSERT(slice.refcount == grpc_slice_refcount::NoopRefcount()); + DCHECK(slice.refcount == grpc_slice_refcount::NoopRefcount()); } StaticSlice(const StaticSlice& other) @@ -267,7 +268,7 @@ class GPR_MSVC_EMPTY_BASE_CLASS_WORKAROUND MutableSlice MutableSlice() = default; explicit MutableSlice(const grpc_slice& slice) : slice_detail::BaseSlice(slice) { - GPR_DEBUG_ASSERT(slice.refcount == nullptr || slice.refcount->IsUnique()); + DCHECK(slice.refcount == nullptr || slice.refcount->IsUnique()); } ~MutableSlice() { CSliceUnref(c_slice()); } diff --git a/src/core/lib/slice/slice_buffer.cc b/src/core/lib/slice/slice_buffer.cc index c8e93b7d00c..6ea05cbc157 100644 --- a/src/core/lib/slice/slice_buffer.cc +++ b/src/core/lib/slice/slice_buffer.cc @@ -22,6 +22,8 @@ #include +#include "absl/log/check.h" + #include #include #include @@ -80,7 +82,7 @@ Slice SliceBuffer::JoinIntoSlice() const { GRPC_SLICE_LENGTH(slice_buffer_.slices[i])); ofs += GRPC_SLICE_LENGTH(slice_buffer_.slices[i]); } - GPR_ASSERT(ofs == slice_buffer_.length); + CHECK(ofs == slice_buffer_.length); return Slice(slice); } @@ -330,7 +332,7 @@ static void slice_buffer_move_first_maybe_ref(grpc_slice_buffer* src, size_t n, return; } - GPR_ASSERT(src->length >= n); + CHECK(src->length >= n); if (src->length == n) { grpc_slice_buffer_move_into(src, dst); return; @@ -358,7 +360,7 @@ static void slice_buffer_move_first_maybe_ref(grpc_slice_buffer* src, size_t n, src, grpc_slice_split_tail_maybe_ref_no_inline( &slice, n, GRPC_SLICE_REF_BOTH)); } - GPR_ASSERT(GRPC_SLICE_LENGTH(slice) == n); + CHECK(GRPC_SLICE_LENGTH(slice) == n); grpc_slice_buffer_add(dst, slice); break; } else { // n < slice_len @@ -371,14 +373,14 @@ static void slice_buffer_move_first_maybe_ref(grpc_slice_buffer* src, size_t n, src, grpc_slice_split_tail_maybe_ref_no_inline( &slice, n, GRPC_SLICE_REF_TAIL)); } - GPR_ASSERT(GRPC_SLICE_LENGTH(slice) == n); + CHECK(GRPC_SLICE_LENGTH(slice) == n); grpc_slice_buffer_add_indexed(dst, slice); break; } } - GPR_ASSERT(dst->length == output_len); - GPR_ASSERT(src->length == new_input_len); - GPR_ASSERT(src->count > 0); + CHECK(dst->length == output_len); + CHECK(src->length == new_input_len); + CHECK_GT(src->count, 0u); } void grpc_slice_buffer_move_first_no_inline(grpc_slice_buffer* src, size_t n, @@ -399,7 +401,7 @@ void grpc_slice_buffer_move_first_no_ref(grpc_slice_buffer* src, size_t n, void grpc_slice_buffer_move_first_into_buffer(grpc_slice_buffer* src, size_t n, void* dst) { char* dstp = static_cast(dst); - GPR_ASSERT(src->length >= n); + CHECK(src->length >= n); while (n > 0) { grpc_slice slice = grpc_slice_buffer_take_first(src); @@ -425,7 +427,7 @@ void grpc_slice_buffer_move_first_into_buffer(grpc_slice_buffer* src, size_t n, void grpc_slice_buffer_copy_first_into_buffer(grpc_slice_buffer* src, size_t n, void* dst) { uint8_t* dstp = static_cast(dst); - GPR_ASSERT(src->length >= n); + CHECK(src->length >= n); for (size_t i = 0; i < src->count; i++) { grpc_slice slice = src->slices[i]; @@ -442,7 +444,7 @@ void grpc_slice_buffer_copy_first_into_buffer(grpc_slice_buffer* src, size_t n, template void grpc_slice_buffer_trim_end_impl(grpc_slice_buffer* sb, size_t n, grpc_slice_buffer* garbage) { - GPR_ASSERT(n <= sb->length); + CHECK(n <= sb->length); sb->length -= n; for (;;) { size_t idx = sb->count - 1; @@ -493,7 +495,7 @@ void grpc_slice_buffer_trim_end(grpc_slice_buffer* sb, size_t n, grpc_slice grpc_slice_buffer_take_first(grpc_slice_buffer* sb) { grpc_slice slice; - GPR_ASSERT(sb->count > 0); + CHECK_GT(sb->count, 0u); slice = sb->slices[0]; sb->slices++; sb->count--; @@ -503,7 +505,7 @@ grpc_slice grpc_slice_buffer_take_first(grpc_slice_buffer* sb) { } void grpc_slice_buffer_remove_first(grpc_slice_buffer* sb) { - GPR_DEBUG_ASSERT(sb->count > 0); + DCHECK_GT(sb->count, 0u); sb->length -= GRPC_SLICE_LENGTH(sb->slices[0]); grpc_core::CSliceUnref(sb->slices[0]); sb->slices++; diff --git a/src/core/lib/slice/slice_internal.h b/src/core/lib/slice/slice_internal.h index 0ab8cd536f0..03d8fbe180d 100644 --- a/src/core/lib/slice/slice_internal.h +++ b/src/core/lib/slice/slice_internal.h @@ -25,6 +25,7 @@ #include #include "absl/hash/hash.h" +#include "absl/log/check.h" #include "absl/strings/string_view.h" #include @@ -36,7 +37,7 @@ // Returns a pointer to the first slice in the slice buffer without giving // ownership to or a reference count on that slice. inline grpc_slice* grpc_slice_buffer_peek_first(grpc_slice_buffer* sb) { - GPR_DEBUG_ASSERT(sb->count > 0); + DCHECK_GT(sb->count, 0u); return &sb->slices[0]; } diff --git a/src/core/lib/surface/byte_buffer_reader.cc b/src/core/lib/surface/byte_buffer_reader.cc index 1e1efe14f86..2053bf3f8b5 100644 --- a/src/core/lib/surface/byte_buffer_reader.cc +++ b/src/core/lib/surface/byte_buffer_reader.cc @@ -19,6 +19,8 @@ #include #include +#include "absl/log/check.h" + #include #include #include @@ -93,7 +95,7 @@ grpc_slice grpc_byte_buffer_reader_readall(grpc_byte_buffer_reader* reader) { memcpy(&(outbuf[bytes_read]), GRPC_SLICE_START_PTR(in_slice), slice_length); bytes_read += slice_length; grpc_core::CSliceUnref(in_slice); - GPR_ASSERT(bytes_read <= input_size); + CHECK(bytes_read <= input_size); } return out_slice; diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc index a8eabbd9496..4c425b87470 100644 --- a/src/core/lib/surface/call.cc +++ b/src/core/lib/surface/call.cc @@ -33,6 +33,7 @@ #include #include "absl/base/thread_annotations.h" +#include "absl/log/check.h" #include "absl/status/status.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" @@ -143,8 +144,8 @@ absl::Status Call::InitParent(Call* parent, uint32_t propagation_mask) { child_ = arena()->New(parent); parent->InternalRef("child"); - GPR_ASSERT(is_client_); - GPR_ASSERT(!parent->is_client_); + CHECK(is_client_); + CHECK(!parent->is_client_); if (propagation_mask & GRPC_PROPAGATE_DEADLINE) { send_deadline_ = std::min(send_deadline_, parent->send_deadline_); @@ -321,7 +322,7 @@ void Call::ProcessIncomingInitialMetadata(grpc_metadata_batch& md) { HandleCompressionAlgorithmDisabled(compression_algorithm); } // GRPC_COMPRESS_NONE is always set. - GPR_DEBUG_ASSERT(encodings_accepted_by_peer_.IsSet(GRPC_COMPRESS_NONE)); + DCHECK(encodings_accepted_by_peer_.IsSet(GRPC_COMPRESS_NONE)); if (GPR_UNLIKELY(!encodings_accepted_by_peer_.IsSet(compression_algorithm))) { if (GRPC_TRACE_FLAG_ENABLED(grpc_compression_trace)) { HandleCompressionAlgorithmNotAccepted(compression_algorithm); @@ -460,7 +461,7 @@ class FilterStackCall final : public Call { bool is_trailers_only() const override { bool result = is_trailers_only_; - GPR_DEBUG_ASSERT(!result || recv_initial_metadata_.TransportSize() == 0); + DCHECK(!result || recv_initial_metadata_.TransportSize() == 0); return result; } @@ -554,7 +555,7 @@ class FilterStackCall final : public Call { PendingOpString(r & ~mask).c_str(), completion_data_.notify_tag.tag); } - GPR_ASSERT((r & mask) != 0); + CHECK_NE((r & mask), 0); return r == mask; } @@ -704,8 +705,8 @@ grpc_error_handle FilterStackCall::Create(grpc_call_create_args* args, Arena* arena = channel->CreateArena(); call = new (arena->Alloc(call_alloc_size)) FilterStackCall(arena, *args); - GPR_DEBUG_ASSERT(FromC(call->c_ptr()) == call); - GPR_DEBUG_ASSERT(FromCallStack(call->call_stack()) == call); + DCHECK(FromC(call->c_ptr()) == call); + DCHECK(FromCallStack(call->call_stack()) == call); *out_call = call->c_ptr(); grpc_slice path = grpc_empty_slice(); ScopedContext ctx(call); @@ -778,9 +779,9 @@ grpc_error_handle FilterStackCall::Create(grpc_call_create_args* args, call->CancelWithError(error); } if (args->cq != nullptr) { - GPR_ASSERT(args->pollset_set_alternative == nullptr && - "Only one of 'cq' and 'pollset_set_alternative' should be " - "non-nullptr."); + CHECK(args->pollset_set_alternative == nullptr) + << "Only one of 'cq' and 'pollset_set_alternative' should be " + "non-nullptr."; GRPC_CQ_INTERNAL_REF(args->cq, "bind"); call->pollent_ = grpc_polling_entity_create_from_pollset(grpc_cq_pollset(args->cq)); @@ -817,7 +818,7 @@ grpc_error_handle FilterStackCall::Create(grpc_call_create_args* args, } void FilterStackCall::SetCompletionQueue(grpc_completion_queue* cq) { - GPR_ASSERT(cq); + CHECK(cq); if (grpc_polling_entity_pollset_set(&pollent_) != nullptr) { Crash("A pollset_set is already registered for this call."); @@ -867,7 +868,7 @@ void FilterStackCall::ExternalUnref() { MaybeUnpublishFromParent(); - GPR_ASSERT(!destroy_called_); + CHECK(!destroy_called_); destroy_called_ = true; bool cancel = gpr_atm_acq_load(&received_final_op_atm_) == 0; if (cancel) { @@ -1358,7 +1359,7 @@ void FilterStackCall::BatchControl::ReceivingInitialMetadataReady( while (true) { gpr_atm rsr_bctlp = gpr_atm_acq_load(&call->recv_state_); // Should only receive initial metadata once - GPR_ASSERT(rsr_bctlp != 1); + CHECK_NE(rsr_bctlp, 1); if (rsr_bctlp == 0) { // We haven't seen initial metadata and messages before, thus initial // metadata is received first. @@ -1412,7 +1413,7 @@ namespace { void EndOpImmediately(grpc_completion_queue* cq, void* notify_tag, bool is_notify_tag_closure) { if (!is_notify_tag_closure) { - GPR_ASSERT(grpc_cq_begin_op(cq, notify_tag)); + CHECK(grpc_cq_begin_op(cq, notify_tag)); grpc_cq_end_op( cq, notify_tag, absl::OkStatus(), [](void*, grpc_cq_completion* completion) { gpr_free(completion); }, @@ -1783,7 +1784,7 @@ grpc_call_error FilterStackCall::StartBatch(const grpc_op* ops, size_t nops, InternalRef("completion"); if (!is_notify_tag_closure) { - GPR_ASSERT(grpc_cq_begin_op(cq_, notify_tag)); + CHECK(grpc_cq_begin_op(cq_, notify_tag)); } bctl->set_pending_ops(pending_ops); @@ -2064,7 +2065,7 @@ class PromiseBasedCall : public BasicPromiseBasedCall { class Completion { public: Completion() : index_(kNullIndex) {} - ~Completion() { GPR_ASSERT(index_ == kNullIndex); } + ~Completion() { CHECK(index_ == kNullIndex); } explicit Completion(uint8_t index) : index_(index) {} Completion(const Completion& other) = delete; Completion& operator=(const Completion& other) = delete; @@ -2072,7 +2073,7 @@ class PromiseBasedCall : public BasicPromiseBasedCall { other.index_ = kNullIndex; } Completion& operator=(Completion&& other) noexcept { - GPR_ASSERT(index_ == kNullIndex); + CHECK(index_ == kNullIndex); index_ = other.index_; other.index_ = kNullIndex; return *this; @@ -2257,13 +2258,13 @@ class PromiseBasedCall : public BasicPromiseBasedCall { if (reason == PendingOp::kReceiveMessage) is_recv_message = true; auto prev = state.fetch_or(PendingOpBit(reason), std::memory_order_relaxed); - GPR_ASSERT((prev & PendingOpBit(reason)) == 0); + CHECK_EQ((prev & PendingOpBit(reason)), 0u); } CompletionState RemovePendingBit(PendingOp reason) { const uint32_t mask = ~PendingOpBit(reason); auto prev = state.fetch_and(mask, std::memory_order_acq_rel); - GPR_ASSERT((prev & PendingOpBit(reason)) != 0); + CHECK_NE((prev & PendingOpBit(reason)), 0u); switch (prev & mask) { case kOpFailed: return kFailure; @@ -2324,7 +2325,7 @@ grpc_error_handle MakePromiseBasedCall(grpc_call_create_args* args, auto* arena = channel->CreateArena(); PromiseBasedCall* call = arena->New(arena, args); *out_call = call->c_ptr(); - GPR_DEBUG_ASSERT(Call::FromC(*out_call) == call); + DCHECK(Call::FromC(*out_call) == call); return absl::OkStatus(); } @@ -2371,7 +2372,7 @@ PromiseBasedCall::Completion PromiseBasedCall::AddOpToCompletion( gpr_log(GPR_INFO, "%s[call] AddOpToCompletion %s %s", DebugTag().c_str(), CompletionString(completion).c_str(), PendingOpString(reason)); } - GPR_ASSERT(completion.has_value()); + CHECK(completion.has_value()); completion_info_[completion.index()].pending.AddPendingBit(reason); return Completion(completion.index()); } @@ -2398,7 +2399,7 @@ void PromiseBasedCall::FinishOpOnCompletion(Completion* completion, PendingOpString(reason)); } const uint8_t i = completion->TakeIndex(); - GPR_ASSERT(i < GPR_ARRAY_SIZE(completion_info_)); + CHECK(i < GPR_ARRAY_SIZE(completion_info_)); CompletionInfo::Pending& pending = completion_info_[i].pending; bool success; switch (pending.RemovePendingBit(reason)) { @@ -2579,9 +2580,9 @@ class ClientPromiseBasedCall final : public PromiseBasedCall { : grpc_polling_entity{})) { global_stats().IncrementClientCallsCreated(); if (args->cq != nullptr) { - GPR_ASSERT(args->pollset_set_alternative == nullptr && - "Only one of 'cq' and 'pollset_set_alternative' should be " - "non-nullptr."); + CHECK(args->pollset_set_alternative == nullptr) + << "Only one of 'cq' and 'pollset_set_alternative' should be " + "non-nullptr."; } ScopedContext context(this); args->channel->channel_stack()->stats_plugin_group->AddClientCallTracers( @@ -2741,12 +2742,12 @@ class ClientPromiseBasedCall final : public PromiseBasedCall { Latch cancel_error_; Latch was_cancelled_latch_; }; - GPR_ASSERT(call_args.server_initial_metadata == - &server_initial_metadata_.sender); - GPR_ASSERT(call_args.client_to_server_messages == - &client_to_server_messages_.receiver); - GPR_ASSERT(call_args.server_to_client_messages == - &server_to_client_messages_.sender); + CHECK(call_args.server_initial_metadata == + &server_initial_metadata_.sender); + CHECK(call_args.client_to_server_messages == + &client_to_server_messages_.receiver); + CHECK(call_args.server_to_client_messages == + &server_to_client_messages_.sender); call_args.client_initial_metadata_outstanding.Complete(true); return MakeRefCounted( this, std::move(call_args.client_initial_metadata)); @@ -3951,12 +3952,12 @@ void ServerCallSpine::CommitBatch(const grpc_op* ops, size_t nops, metadata->Set(GrpcMessageMetadata(), Slice(grpc_slice_copy(*details))); } - GPR_ASSERT(metadata != nullptr); + CHECK(metadata != nullptr); return [this, metadata = std::move(metadata)]() mutable { - GPR_ASSERT(metadata != nullptr); + CHECK(metadata != nullptr); return [this, metadata = std::move(metadata)]() mutable -> Poll { - GPR_ASSERT(metadata != nullptr); + CHECK(metadata != nullptr); PushServerTrailingMetadata(std::move(metadata)); return Success{}; }; @@ -3964,7 +3965,7 @@ void ServerCallSpine::CommitBatch(const grpc_op* ops, size_t nops, }); auto recv_message = MaybeOp(ops, got_ops[GRPC_OP_RECV_MESSAGE], [this](const grpc_op& op) { - GPR_ASSERT(recv_message_ == nullptr); + CHECK_EQ(recv_message_, nullptr); recv_message_ = op.data.recv_message.recv_message; return [this]() mutable { return Map(client_to_server_messages_.receiver.Next(), @@ -4087,7 +4088,7 @@ grpc_call* grpc_call_from_top_element(grpc_call_element* surface_element) { grpc_call_error grpc_call_cancel(grpc_call* call, void* reserved) { GRPC_API_TRACE("grpc_call_cancel(call=%p, reserved=%p)", 2, (call, reserved)); - GPR_ASSERT(reserved == nullptr); + CHECK_EQ(reserved, nullptr); if (call == nullptr) { return GRPC_CALL_ERROR; } @@ -4105,7 +4106,7 @@ grpc_call_error grpc_call_cancel_with_status(grpc_call* c, "grpc_call_cancel_with_status(" "c=%p, status=%d, description=%s, reserved=%p)", 4, (c, (int)status, description, reserved)); - GPR_ASSERT(reserved == nullptr); + CHECK_EQ(reserved, nullptr); if (c == nullptr) { return GRPC_CALL_ERROR; } diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index e70e1d001b9..827d37f06b6 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -16,6 +16,8 @@ #include "src/core/lib/surface/channel.h" +#include "absl/log/check.h" + #include #include #include @@ -98,7 +100,7 @@ grpc_call* grpc_channel_create_call(grpc_channel* channel, grpc_completion_queue* completion_queue, grpc_slice method, const grpc_slice* host, gpr_timespec deadline, void* reserved) { - GPR_ASSERT(!reserved); + CHECK(!reserved); grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; grpc_core::ExecCtx exec_ctx; return grpc_core::Channel::FromC(channel)->CreateCall( @@ -116,7 +118,7 @@ void* grpc_channel_register_call(grpc_channel* channel, const char* method, GRPC_API_TRACE( "grpc_channel_register_call(channel=%p, method=%s, host=%s, reserved=%p)", 4, (channel, method, host, reserved)); - GPR_ASSERT(!reserved); + CHECK(!reserved); grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; grpc_core::ExecCtx exec_ctx; return grpc_core::Channel::FromC(channel)->RegisterCall(method, host); @@ -139,7 +141,7 @@ grpc_call* grpc_channel_create_registered_call( (channel, parent_call, (unsigned)propagation_mask, completion_queue, registered_call_handle, deadline.tv_sec, deadline.tv_nsec, (int)deadline.clock_type, reserved)); - GPR_ASSERT(!reserved); + CHECK(!reserved); grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; grpc_core::ExecCtx exec_ctx; return grpc_core::Channel::FromC(channel)->CreateCall( @@ -213,6 +215,6 @@ void grpc_channel_ping(grpc_channel* channel, grpc_completion_queue* cq, grpc_core::ExecCtx exec_ctx; GRPC_API_TRACE("grpc_channel_ping(channel=%p, cq=%p, tag=%p, reserved=%p)", 4, (channel, cq, tag, reserved)); - GPR_ASSERT(reserved == nullptr); + CHECK_EQ(reserved, nullptr); grpc_core::Channel::FromC(channel)->Ping(cq, tag); } diff --git a/src/core/lib/surface/channel_create.cc b/src/core/lib/surface/channel_create.cc index 0fccd09a45b..0ad87af1f62 100644 --- a/src/core/lib/surface/channel_create.cc +++ b/src/core/lib/surface/channel_create.cc @@ -14,6 +14,8 @@ // limitations under the License. // +#include "absl/log/check.h" + #include #include #include @@ -103,6 +105,6 @@ grpc_channel* grpc_lame_client_channel_create(const char* target, auto channel = grpc_core::ChannelCreate(target == nullptr ? "" : target, std::move(args), GRPC_CLIENT_LAME_CHANNEL, nullptr); - GPR_ASSERT(channel.ok()); + CHECK(channel.ok()); return channel->release()->c_ptr(); } diff --git a/src/core/lib/surface/channel_init.cc b/src/core/lib/surface/channel_init.cc index 59aa35e3761..b94b189ffea 100644 --- a/src/core/lib/surface/channel_init.cc +++ b/src/core/lib/surface/channel_init.cc @@ -26,6 +26,7 @@ #include #include +#include "absl/log/check.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_join.h" #include "absl/strings/string_view.h" @@ -137,9 +138,9 @@ ChannelInit::StackConfig ChannelInit::BuildStackConfig( } filter_to_registration[registration->filter_] = registration.get(); if (registration->terminal_) { - GPR_ASSERT(registration->after_.empty()); - GPR_ASSERT(registration->before_.empty()); - GPR_ASSERT(!registration->before_all_); + CHECK(registration->after_.empty()); + CHECK(registration->before_.empty()); + CHECK(!registration->before_all_); terminal_filters.emplace_back( registration->filter_, nullptr, std::move(registration->predicates_), registration->skip_v3_, registration->registration_source_); @@ -149,7 +150,7 @@ ChannelInit::StackConfig ChannelInit::BuildStackConfig( } for (const auto& registration : registrations) { if (registration->terminal_) continue; - GPR_ASSERT(filter_to_registration.count(registration->filter_) > 0); + CHECK_GT(filter_to_registration.count(registration->filter_), 0u); for (F after : registration->after_) { if (filter_to_registration.count(after) == 0) { gpr_log( diff --git a/src/core/lib/surface/channel_init.h b/src/core/lib/surface/channel_init.h index 5f1bacdeff1..fcfef582994 100644 --- a/src/core/lib/surface/channel_init.h +++ b/src/core/lib/surface/channel_init.h @@ -27,6 +27,7 @@ #include #include "absl/functional/any_invocable.h" +#include "absl/log/check.h" #include #include @@ -217,7 +218,7 @@ class ChannelInit { PostProcessorSlot slot, PostProcessor post_processor) { auto& slot_value = post_processors_[type][static_cast(slot)]; - GPR_ASSERT(slot_value == nullptr); + CHECK(slot_value == nullptr); slot_value = std::move(post_processor); } diff --git a/src/core/lib/surface/completion_queue.cc b/src/core/lib/surface/completion_queue.cc index 0f76f4fd2a9..5d777b50741 100644 --- a/src/core/lib/surface/completion_queue.cc +++ b/src/core/lib/surface/completion_queue.cc @@ -27,6 +27,7 @@ #include #include +#include "absl/log/check.h" #include "absl/status/status.h" #include "absl/strings/str_format.h" #include "absl/strings/str_join.h" @@ -178,7 +179,7 @@ grpc_error_handle non_polling_poller_kick( void non_polling_poller_shutdown(grpc_pollset* pollset, grpc_closure* closure) { non_polling_poller* p = reinterpret_cast(pollset); - GPR_ASSERT(closure != nullptr); + CHECK_NE(closure, nullptr); p->shutdown = closure; if (p->root == nullptr) { grpc_core::ExecCtx::Run(DEBUG_LOCATION, closure, absl::OkStatus()); @@ -256,7 +257,7 @@ class CqEventQueue { struct cq_next_data { ~cq_next_data() { - GPR_ASSERT(queue.num_items() == 0); + CHECK_EQ(queue.num_items(), 0); #ifndef NDEBUG if (pending_events.load(std::memory_order_acquire) != 0) { gpr_log(GPR_ERROR, "Destroying CQ without draining it fully."); @@ -286,8 +287,7 @@ struct cq_pluck_data { } ~cq_pluck_data() { - GPR_ASSERT(completed_head.next == - reinterpret_cast(&completed_head)); + CHECK(completed_head.next == reinterpret_cast(&completed_head)); #ifndef NDEBUG if (pending_events.load(std::memory_order_acquire) != 0) { gpr_log(GPR_ERROR, "Destroying CQ without draining it fully."); @@ -655,7 +655,7 @@ static void cq_check_tag(grpc_completion_queue* cq, void* tag, bool lock_cq) { gpr_mu_unlock(cq->mu); } - GPR_ASSERT(found); + CHECK(found); } #else static void cq_check_tag(grpc_completion_queue* /*cq*/, void* /*tag*/, @@ -905,7 +905,7 @@ class ExecCtxNext : public grpc_core::ExecCtx { static_cast(check_ready_to_finish_arg_); grpc_completion_queue* cq = a->cq; cq_next_data* cqd = static_cast DATA_FROM_CQ(cq); - GPR_ASSERT(a->stolen_completion == nullptr); + CHECK_EQ(a->stolen_completion, nullptr); intptr_t current_last_seen_things_queued_ever = cqd->things_queued_ever.load(std::memory_order_relaxed); @@ -962,7 +962,7 @@ static grpc_event cq_next(grpc_completion_queue* cq, gpr_timespec deadline, 5, (cq, deadline.tv_sec, deadline.tv_nsec, (int)deadline.clock_type, reserved)); - GPR_ASSERT(!reserved); + CHECK(!reserved); dump_pending_tags(cq); @@ -1068,7 +1068,7 @@ static grpc_event cq_next(grpc_completion_queue* cq, gpr_timespec deadline, GRPC_SURFACE_TRACE_RETURNED_EVENT(cq, &ret); GRPC_CQ_INTERNAL_UNREF(cq, "next"); - GPR_ASSERT(is_finished_arg.stolen_completion == nullptr); + CHECK_EQ(is_finished_arg.stolen_completion, nullptr); return ret; } @@ -1082,8 +1082,8 @@ static grpc_event cq_next(grpc_completion_queue* cq, gpr_timespec deadline, static void cq_finish_shutdown_next(grpc_completion_queue* cq) { cq_next_data* cqd = static_cast DATA_FROM_CQ(cq); - GPR_ASSERT(cqd->shutdown_called); - GPR_ASSERT(cqd->pending_events.load(std::memory_order_relaxed) == 0); + CHECK(cqd->shutdown_called); + CHECK_EQ(cqd->pending_events.load(std::memory_order_relaxed), 0); cq->poller_vtable->shutdown(POLLSET_FROM_CQ(cq), &cq->pollset_shutdown_done); } @@ -1156,7 +1156,7 @@ class ExecCtxPluck : public grpc_core::ExecCtx { grpc_completion_queue* cq = a->cq; cq_pluck_data* cqd = static_cast DATA_FROM_CQ(cq); - GPR_ASSERT(a->stolen_completion == nullptr); + CHECK_EQ(a->stolen_completion, nullptr); gpr_atm current_last_seen_things_queued_ever = cqd->things_queued_ever.load(std::memory_order_relaxed); if (current_last_seen_things_queued_ever != @@ -1207,7 +1207,7 @@ static grpc_event cq_pluck(grpc_completion_queue* cq, void* tag, (cq, tag, deadline.tv_sec, deadline.tv_nsec, (int)deadline.clock_type, reserved)); } - GPR_ASSERT(!reserved); + CHECK(!reserved); dump_pending_tags(cq); @@ -1298,7 +1298,7 @@ done: GRPC_SURFACE_TRACE_RETURNED_EVENT(cq, &ret); GRPC_CQ_INTERNAL_UNREF(cq, "pluck"); - GPR_ASSERT(is_finished_arg.stolen_completion == nullptr); + CHECK_EQ(is_finished_arg.stolen_completion, nullptr); return ret; } @@ -1311,8 +1311,8 @@ grpc_event grpc_completion_queue_pluck(grpc_completion_queue* cq, void* tag, static void cq_finish_shutdown_pluck(grpc_completion_queue* cq) { cq_pluck_data* cqd = static_cast DATA_FROM_CQ(cq); - GPR_ASSERT(cqd->shutdown_called); - GPR_ASSERT(!cqd->shutdown.load(std::memory_order_relaxed)); + CHECK(cqd->shutdown_called); + CHECK(!cqd->shutdown.load(std::memory_order_relaxed)); cqd->shutdown.store(true, std::memory_order_relaxed); cq->poller_vtable->shutdown(POLLSET_FROM_CQ(cq), &cq->pollset_shutdown_done); @@ -1348,7 +1348,7 @@ static void cq_finish_shutdown_callback(grpc_completion_queue* cq) { cq_callback_data* cqd = static_cast DATA_FROM_CQ(cq); auto* callback = cqd->shutdown_callback; - GPR_ASSERT(cqd->shutdown_called); + CHECK(cqd->shutdown_called); cq->poller_vtable->shutdown(POLLSET_FROM_CQ(cq), &cq->pollset_shutdown_done); if (grpc_iomgr_is_any_background_poller_thread()) { diff --git a/src/core/lib/surface/completion_queue_factory.cc b/src/core/lib/surface/completion_queue_factory.cc index cb9a1b55d42..486cc5f00ec 100644 --- a/src/core/lib/surface/completion_queue_factory.cc +++ b/src/core/lib/surface/completion_queue_factory.cc @@ -18,6 +18,8 @@ #include "src/core/lib/surface/completion_queue_factory.h" +#include "absl/log/check.h" + #include #include #include @@ -47,8 +49,8 @@ static const grpc_completion_queue_factory g_default_cq_factory = { const grpc_completion_queue_factory* grpc_completion_queue_factory_lookup( const grpc_completion_queue_attributes* attributes) { - GPR_ASSERT(attributes->version >= 1 && - attributes->version <= GRPC_CQ_CURRENT_VERSION); + CHECK(attributes->version >= 1 && + attributes->version <= GRPC_CQ_CURRENT_VERSION); // The default factory can handle version 1 of the attributes structure. We // may have to change this as more fields are added to the structure @@ -61,7 +63,7 @@ const grpc_completion_queue_factory* grpc_completion_queue_factory_lookup( grpc_completion_queue* grpc_completion_queue_create_for_next(void* reserved) { grpc_core::ExecCtx exec_ctx; - GPR_ASSERT(!reserved); + CHECK(!reserved); grpc_completion_queue_attributes attr = {1, GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, nullptr}; return g_default_cq_factory.vtable->create(&g_default_cq_factory, &attr); @@ -69,7 +71,7 @@ grpc_completion_queue* grpc_completion_queue_create_for_next(void* reserved) { grpc_completion_queue* grpc_completion_queue_create_for_pluck(void* reserved) { grpc_core::ExecCtx exec_ctx; - GPR_ASSERT(!reserved); + CHECK(!reserved); grpc_completion_queue_attributes attr = {1, GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING, nullptr}; return g_default_cq_factory.vtable->create(&g_default_cq_factory, &attr); @@ -78,7 +80,7 @@ grpc_completion_queue* grpc_completion_queue_create_for_pluck(void* reserved) { grpc_completion_queue* grpc_completion_queue_create_for_callback( grpc_completion_queue_functor* shutdown_callback, void* reserved) { grpc_core::ExecCtx exec_ctx; - GPR_ASSERT(!reserved); + CHECK(!reserved); grpc_completion_queue_attributes attr = { 2, GRPC_CQ_CALLBACK, GRPC_CQ_DEFAULT_POLLING, shutdown_callback}; return g_default_cq_factory.vtable->create(&g_default_cq_factory, &attr); @@ -88,6 +90,6 @@ grpc_completion_queue* grpc_completion_queue_create( const grpc_completion_queue_factory* factory, const grpc_completion_queue_attributes* attr, void* reserved) { grpc_core::ExecCtx exec_ctx; - GPR_ASSERT(!reserved); + CHECK(!reserved); return factory->vtable->create(factory, attr); } diff --git a/src/core/lib/surface/legacy_channel.cc b/src/core/lib/surface/legacy_channel.cc index 0ee4cd61312..104924d42b7 100644 --- a/src/core/lib/surface/legacy_channel.cc +++ b/src/core/lib/surface/legacy_channel.cc @@ -19,6 +19,7 @@ #include "src/core/lib/surface/legacy_channel.h" #include "absl/base/thread_annotations.h" +#include "absl/log/check.h" #include "absl/status/status.h" #include "absl/types/optional.h" @@ -166,8 +167,8 @@ grpc_call* LegacyChannel::CreateCall( grpc_completion_queue* cq, grpc_pollset_set* pollset_set_alternative, Slice path, absl::optional authority, Timestamp deadline, bool registered_method) { - GPR_ASSERT(is_client_); - GPR_ASSERT(!(cq != nullptr && pollset_set_alternative != nullptr)); + CHECK(is_client_); + CHECK(!(cq != nullptr && pollset_set_alternative != nullptr)); grpc_call_create_args args; args.channel = Ref(); args.server = nullptr; @@ -213,7 +214,7 @@ class LegacyChannel::StateWatcher final : public DualRefCounted { cq_(cq), tag_(tag), state_(last_observed_state) { - GPR_ASSERT(grpc_cq_begin_op(cq, tag)); + CHECK(grpc_cq_begin_op(cq, tag)); GRPC_CLOSURE_INIT(&on_complete_, WatchComplete, this, nullptr); ClientChannelFilter* client_channel = channel_->GetClientChannelFilter(); if (client_channel == nullptr) { @@ -343,14 +344,14 @@ void LegacyChannel::AddConnectivityWatcher( grpc_connectivity_state initial_state, OrphanablePtr watcher) { auto* client_channel = GetClientChannelFilter(); - GPR_ASSERT(client_channel != nullptr); + CHECK_NE(client_channel, nullptr); client_channel->AddConnectivityWatcher(initial_state, std::move(watcher)); } void LegacyChannel::RemoveConnectivityWatcher( AsyncConnectivityStateWatcherInterface* watcher) { auto* client_channel = GetClientChannelFilter(); - GPR_ASSERT(client_channel != nullptr); + CHECK_NE(client_channel, nullptr); client_channel->RemoveConnectivityWatcher(watcher); } @@ -394,7 +395,7 @@ void LegacyChannel::Ping(grpc_completion_queue* cq, void* tag) { grpc_transport_op* op = grpc_make_transport_op(nullptr); op->send_ping.on_ack = &pr->closure; op->bind_pollset = grpc_cq_pollset(cq); - GPR_ASSERT(grpc_cq_begin_op(cq, tag)); + CHECK(grpc_cq_begin_op(cq, tag)); grpc_channel_element* top_elem = grpc_channel_stack_element(channel_stack_.get(), 0); top_elem->filter->start_transport_op(top_elem, op); diff --git a/src/core/lib/surface/validate_metadata.h b/src/core/lib/surface/validate_metadata.h index 13f44a52fdf..0607abd1e00 100644 --- a/src/core/lib/surface/validate_metadata.h +++ b/src/core/lib/surface/validate_metadata.h @@ -23,6 +23,7 @@ #include +#include "absl/log/check.h" #include "absl/strings/string_view.h" #include @@ -58,7 +59,7 @@ inline int grpc_key_is_binary_header(const uint8_t* buf, size_t length) { return 0 == memcmp(buf + length - 4, "-bin", 4); } inline int grpc_is_refcounted_slice_binary_header(const grpc_slice& slice) { - GPR_DEBUG_ASSERT(slice.refcount != nullptr); + DCHECK_NE(slice.refcount, nullptr); return grpc_key_is_binary_header(slice.data.refcounted.bytes, slice.data.refcounted.length); } diff --git a/src/core/server/server.cc b/src/core/server/server.cc index c43792935af..04d0f52da3e 100644 --- a/src/core/server/server.cc +++ b/src/core/server/server.cc @@ -32,6 +32,7 @@ #include "absl/cleanup/cleanup.h" #include "absl/container/flat_hash_map.h" +#include "absl/log/check.h" #include "absl/status/status.h" #include "absl/types/optional.h" @@ -237,7 +238,7 @@ struct Server::RequestedCall { Timestamp deadline = GetContext()->deadline(); switch (type) { case RequestedCall::Type::BATCH_CALL: - GPR_ASSERT(!payload.has_value()); + CHECK(!payload.has_value()); data.batch.details->host = CSliceRef(md.get_pointer(HttpAuthorityMetadata())->c_slice()); data.batch.details->method = @@ -294,9 +295,9 @@ class Server::RealRequestMatcherFilterStack : public RequestMatcherInterface { ~RealRequestMatcherFilterStack() override { for (LockedMultiProducerSingleConsumerQueue& queue : requests_per_cq_) { - GPR_ASSERT(queue.Pop() == nullptr); + CHECK_EQ(queue.Pop(), nullptr); } - GPR_ASSERT(pending_.empty()); + CHECK(pending_.empty()); } void ZombifyPending() override { @@ -426,7 +427,7 @@ class Server::RealRequestMatcherPromises : public RequestMatcherInterface { ~RealRequestMatcherPromises() override { for (LockedMultiProducerSingleConsumerQueue& queue : requests_per_cq_) { - GPR_ASSERT(queue.Pop() == nullptr); + CHECK_EQ(queue.Pop(), nullptr); } } @@ -563,7 +564,7 @@ class Server::RealRequestMatcherPromises : public RequestMatcherInterface { if (!result.compare_exchange_strong(expected, new_value, std::memory_order_acq_rel, std::memory_order_acquire)) { - GPR_ASSERT(new_value->value().TakeCall() == requested_call); + CHECK(new_value->value().TakeCall() == requested_call); delete new_value; return false; } @@ -600,7 +601,7 @@ class Server::AllocatingRequestMatcherBase : public RequestMatcherInterface { break; } } - GPR_ASSERT(idx < server->cqs_.size()); + CHECK(idx < server->cqs_.size()); cq_idx_ = idx; } @@ -646,9 +647,9 @@ class Server::AllocatingRequestMatcherBatch absl::MakeCleanup([this] { server()->ShutdownUnrefOnRequest(); }); if (still_running) { BatchCallAllocation call_info = allocator_(); - GPR_ASSERT(server()->ValidateServerRequest( - cq(), static_cast(call_info.tag), nullptr, - nullptr) == GRPC_CALL_OK); + CHECK(server()->ValidateServerRequest(cq(), + static_cast(call_info.tag), + nullptr, nullptr) == GRPC_CALL_OK); RequestedCall* rc = new RequestedCall( static_cast(call_info.tag), call_info.cq, call_info.call, call_info.initial_metadata, call_info.details); @@ -662,9 +663,9 @@ class Server::AllocatingRequestMatcherBatch ArenaPromise> MatchRequest( size_t /*start_request_queue_index*/) override { BatchCallAllocation call_info = allocator_(); - GPR_ASSERT(server()->ValidateServerRequest( - cq(), static_cast(call_info.tag), nullptr, nullptr) == - GRPC_CALL_OK); + CHECK(server()->ValidateServerRequest(cq(), + static_cast(call_info.tag), + nullptr, nullptr) == GRPC_CALL_OK); RequestedCall* rc = new RequestedCall( static_cast(call_info.tag), call_info.cq, call_info.call, call_info.initial_metadata, call_info.details); @@ -692,9 +693,9 @@ class Server::AllocatingRequestMatcherRegistered absl::MakeCleanup([this] { server()->ShutdownUnrefOnRequest(); }); if (server()->ShutdownRefOnRequest()) { RegisteredCallAllocation call_info = allocator_(); - GPR_ASSERT(server()->ValidateServerRequest( - cq(), call_info.tag, call_info.optional_payload, - registered_method_) == GRPC_CALL_OK); + CHECK(server()->ValidateServerRequest( + cq(), call_info.tag, call_info.optional_payload, + registered_method_) == GRPC_CALL_OK); RequestedCall* rc = new RequestedCall(call_info.tag, call_info.cq, call_info.call, call_info.initial_metadata, registered_method_, @@ -709,9 +710,9 @@ class Server::AllocatingRequestMatcherRegistered ArenaPromise> MatchRequest( size_t /*start_request_queue_index*/) override { RegisteredCallAllocation call_info = allocator_(); - GPR_ASSERT(server()->ValidateServerRequest( - cq(), call_info.tag, call_info.optional_payload, - registered_method_) == GRPC_CALL_OK); + CHECK(server()->ValidateServerRequest(cq(), call_info.tag, + call_info.optional_payload, + registered_method_) == GRPC_CALL_OK); RequestedCall* rc = new RequestedCall( call_info.tag, call_info.cq, call_info.call, call_info.initial_metadata, registered_method_, call_info.deadline, call_info.optional_payload); @@ -736,7 +737,7 @@ class ChannelBroadcaster { // Copies over the channels from the locked server. void FillChannelsLocked(std::vector> channels) { - GPR_DEBUG_ASSERT(channels_.empty()); + DCHECK(channels_.empty()); channels_ = std::move(channels); } @@ -955,7 +956,7 @@ void Server::SetRegisteredMethodAllocator( void Server::SetBatchMethodAllocator( grpc_completion_queue* cq, std::function allocator) { - GPR_DEBUG_ASSERT(unregistered_request_matcher_ == nullptr); + DCHECK(unregistered_request_matcher_ == nullptr); unregistered_request_matcher_ = std::make_unique(this, cq, std::move(allocator)); @@ -1007,7 +1008,7 @@ void Server::FailCall(size_t cq_idx, RequestedCall* rc, grpc_error_handle error) { *rc->call = nullptr; rc->initial_metadata->count = 0; - GPR_ASSERT(!error.ok()); + CHECK(!error.ok()); grpc_cq_end_op(cqs_[cq_idx], rc->tag, error, DoneRequestEvent, rc, &rc->completion); } @@ -1101,7 +1102,7 @@ void Server::ShutdownAndNotify(grpc_completion_queue* cq, void* tag) { starting_cv_.Wait(&mu_global_); } // Stay locked, and gather up some stuff to do. - GPR_ASSERT(grpc_cq_begin_op(cq, tag)); + CHECK(grpc_cq_begin_op(cq, tag)); if (shutdown_published_) { grpc_cq_end_op(cq, tag, absl::OkStatus(), DonePublishedShutdown, nullptr, new grpc_cq_completion); @@ -1162,8 +1163,8 @@ void Server::SendGoaways() { void Server::Orphan() { { MutexLock lock(&mu_global_); - GPR_ASSERT(ShutdownCalled() || listeners_.empty()); - GPR_ASSERT(listeners_destroyed_ == listeners_.size()); + CHECK(ShutdownCalled() || listeners_.empty()); + CHECK(listeners_destroyed_ == listeners_.size()); } Unref(); } @@ -1341,7 +1342,7 @@ void Server::ChannelData::InitTransport(RefCountedPtr server, ++accept_stream_types; transport->server_transport()->SetAcceptor(this); } - GPR_ASSERT(accept_stream_types == 1); + CHECK_EQ(accept_stream_types, 1); op->start_connectivity_watch = MakeOrphanable(this); if (server_->ShutdownCalled()) { op->disconnect_with_error = GRPC_ERROR_CREATE("Server shutdown"); @@ -1403,8 +1404,8 @@ void Server::ChannelData::AcceptStream(void* arg, Transport* /*transport*/, grpc_error_handle error = grpc_call_create(&args, &call); grpc_call_stack* call_stack = grpc_call_get_call_stack(call); if (call_stack == nullptr) { // Promise based calls do not have a call stack - GPR_ASSERT(error.ok()); - GPR_ASSERT(IsPromiseBasedServerCallEnabled()); + CHECK(error.ok()); + CHECK(IsPromiseBasedServerCallEnabled()); return; } else { grpc_call_element* elem = grpc_call_stack_element(call_stack, 0); @@ -1598,7 +1599,7 @@ void Server::ChannelData::FinishDestroy(void* arg, void Server::ChannelData::Destroy() { if (!list_position_.has_value()) return; - GPR_ASSERT(server_ != nullptr); + CHECK(server_ != nullptr); server_->channels_.erase(*list_position_); list_position_.reset(); server_->Ref().release(); @@ -1620,8 +1621,8 @@ void Server::ChannelData::Destroy() { grpc_error_handle Server::ChannelData::InitChannelElement( grpc_channel_element* elem, grpc_channel_element_args* args) { - GPR_ASSERT(args->is_first); - GPR_ASSERT(!args->is_last); + CHECK(args->is_first); + CHECK(!args->is_last); new (elem->channel_data) ChannelData(); return absl::OkStatus(); } @@ -1648,7 +1649,7 @@ Server::CallData::CallData(grpc_call_element* elem, } Server::CallData::~CallData() { - GPR_ASSERT(state_.load(std::memory_order_relaxed) != CallState::PENDING); + CHECK(state_.load(std::memory_order_relaxed) != CallState::PENDING); grpc_metadata_array_destroy(&initial_metadata_); grpc_byte_buffer_destroy(payload_); } @@ -1699,8 +1700,8 @@ void Server::CallData::Publish(size_t cq_idx, RequestedCall* rc) { std::swap(*rc->initial_metadata, initial_metadata_); switch (rc->type) { case RequestedCall::Type::BATCH_CALL: - GPR_ASSERT(host_.has_value()); - GPR_ASSERT(path_.has_value()); + CHECK(host_.has_value()); + CHECK(path_.has_value()); rc->data.batch.details->host = CSliceRef(host_->c_slice()); rc->data.batch.details->method = CSliceRef(path_->c_slice()); rc->data.batch.details->deadline = @@ -1914,7 +1915,7 @@ void grpc_server_register_completion_queue(grpc_server* server, GRPC_API_TRACE( "grpc_server_register_completion_queue(server=%p, cq=%p, reserved=%p)", 3, (server, cq, reserved)); - GPR_ASSERT(!reserved); + CHECK(!reserved); auto cq_type = grpc_get_cq_completion_type(cq); if (cq_type != GRPC_CQ_NEXT && cq_type != GRPC_CQ_CALLBACK) { gpr_log(GPR_INFO, diff --git a/src/core/server/server.h b/src/core/server/server.h index a4353794a37..486892b14d8 100644 --- a/src/core/server/server.h +++ b/src/core/server/server.h @@ -39,7 +39,6 @@ #include "absl/types/optional.h" #include -#include #include #include #include @@ -75,9 +74,6 @@ "grpc.server.max_pending_requests_hard_limit" namespace grpc_core { -namespace experimental { -class PassiveListenerImpl; -} // namespace experimental extern TraceFlag grpc_server_channel_trace; @@ -116,7 +112,7 @@ class Server : public ServerInterface, /// Interface for listeners. /// Implementations must override the Orphan() method, which should stop /// listening and initiate destruction of the listener. - class ListenerInterface : public InternallyRefCounted { + class ListenerInterface : public Orphanable { public: ~ListenerInterface() override = default; @@ -216,14 +212,6 @@ class Server : public ServerInterface, void SendGoaways() ABSL_LOCKS_EXCLUDED(mu_global_, mu_call_); private: - // note: the grpc_core::Server redundant namespace qualification is - // required for older gcc versions. - // TODO(yashykt): eliminate this friend statement as part of your upcoming - // server listener refactoring. - friend absl::Status(::grpc_server_add_passive_listener)( - grpc_core::Server* server, grpc_server_credentials* credentials, - std::shared_ptr - passive_listener); struct RequestedCall; class RequestMatcherInterface; diff --git a/src/core/server/server_config_selector_filter.cc b/src/core/server/server_config_selector_filter.cc index 8a17c035d3a..4da3b75398c 100644 --- a/src/core/server/server_config_selector_filter.cc +++ b/src/core/server/server_config_selector_filter.cc @@ -19,6 +19,7 @@ #include #include "absl/base/thread_annotations.h" +#include "absl/log/check.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/types/optional.h" @@ -119,7 +120,7 @@ ServerConfigSelectorFilter::ServerConfigSelectorFilter( RefCountedPtr server_config_selector_provider) : server_config_selector_provider_( std::move(server_config_selector_provider)) { - GPR_ASSERT(server_config_selector_provider_ != nullptr); + CHECK(server_config_selector_provider_ != nullptr); auto server_config_selector_watcher = std::make_unique(Ref()); auto config_selector = server_config_selector_provider_->Watch( diff --git a/src/cpp/server/server_builder.cc b/src/cpp/server/server_builder.cc index b9f71915981..f989703fe1a 100644 --- a/src/cpp/server/server_builder.cc +++ b/src/cpp/server/server_builder.cc @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include @@ -48,38 +47,11 @@ #include #include -#include "src/core/ext/transport/chttp2/server/chttp2_server.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/useful.h" -#include "src/core/server/server.h" #include "src/cpp/server/external_connection_acceptor_impl.h" namespace grpc { -namespace { - -// A PIMPL wrapper class that owns the only ref to the passive listener -// implementation. This is returned to the application. -class PassiveListenerOwner final - : public grpc_core::experimental::PassiveListener { - public: - explicit PassiveListenerOwner(std::shared_ptr listener) - : listener_(std::move(listener)) {} - - absl::Status AcceptConnectedEndpoint( - std::unique_ptr - endpoint) override { - return listener_->AcceptConnectedEndpoint(std::move(endpoint)); - } - - absl::Status AcceptConnectedFd(int fd) override { - return listener_->AcceptConnectedFd(fd); - } - - private: - std::shared_ptr listener_; -}; - -} // namespace static std::vector (*)()>* g_plugin_factory_list; @@ -253,18 +225,6 @@ ServerBuilder& ServerBuilder::SetResourceQuota( return *this; } -ServerBuilder& ServerBuilder::experimental_type::AddPassiveListener( - std::shared_ptr creds, - std::unique_ptr& passive_listener) { - auto core_passive_listener = - std::make_shared(); - builder_->unstarted_passive_listeners_.emplace_back(core_passive_listener, - std::move(creds)); - passive_listener = - std::make_unique(std::move(core_passive_listener)); - return *builder_; -} - ServerBuilder& ServerBuilder::AddListeningPort( const std::string& addr_uri, std::shared_ptr creds, int* selected_port) { @@ -438,26 +398,6 @@ std::unique_ptr ServerBuilder::BuildAndStart() { cq->RegisterServer(server.get()); } - for (auto& unstarted_listener : unstarted_passive_listeners_) { - has_frequently_polled_cqs = true; - auto passive_listener = unstarted_listener.passive_listener.lock(); - auto* core_server = grpc_core::Server::FromC(server->c_server()); - if (passive_listener != nullptr) { - auto* creds = unstarted_listener.credentials->c_creds(); - if (creds == nullptr) { - gpr_log(GPR_ERROR, "Credentials missing for PassiveListener"); - return nullptr; - } - auto success = grpc_server_add_passive_listener( - core_server, creds, std::move(passive_listener)); - if (!success.ok()) { - gpr_log(GPR_ERROR, "Failed to create a passive listener: %s", - success.ToString().c_str()); - return nullptr; - } - } - } - if (!has_frequently_polled_cqs) { gpr_log(GPR_ERROR, "At least one of the completion queues must be frequently polled"); diff --git a/test/core/event_engine/event_engine_test_utils.h b/test/core/event_engine/event_engine_test_utils.h index debef7a0449..67bbe42d35d 100644 --- a/test/core/event_engine/event_engine_test_utils.h +++ b/test/core/event_engine/event_engine_test_utils.h @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -160,70 +159,6 @@ class NotifyOnDelete { grpc_core::Notification* signal_; }; -// An endpoint implementation that supports Read and Write via std::threads. -// Passing a grpc_core::Notification will allow owners to know when all -// in-flight callbacks have been run, and all endpoint state has been destroyed. -class ThreadedNoopEndpoint : public EventEngine::Endpoint { - public: - explicit ThreadedNoopEndpoint(grpc_core::Notification* destroyed) - : state_(std::make_shared(destroyed)) {} - ~ThreadedNoopEndpoint() override { - std::thread deleter([state = state_]() { - CleanupThread(state->read); - CleanupThread(state->write); - }); - deleter.detach(); - } - - bool Read(absl::AnyInvocable on_read, SliceBuffer* buffer, - const ReadArgs* /* args */) override { - buffer->Clear(); - CleanupThread(state_->read); - state_->read = new std::thread([cb = std::move(on_read)]() mutable { - cb(absl::UnknownError("test")); - }); - return false; - } - - bool Write(absl::AnyInvocable on_writable, - SliceBuffer* data, const WriteArgs* /* args */) override { - data->Clear(); - CleanupThread(state_->write); - state_->write = new std::thread([cb = std::move(on_writable)]() mutable { - cb(absl::UnknownError("test")); - }); - return false; - } - - const EventEngine::ResolvedAddress& GetPeerAddress() const override { - return peer_; - } - - const EventEngine::ResolvedAddress& GetLocalAddress() const override { - return local_; - } - - private: - struct EndpointState { - explicit EndpointState(grpc_core::Notification* deleter) - : delete_notifier_(deleter) {} - std::thread* read = nullptr; - std::thread* write = nullptr; - NotifyOnDelete delete_notifier_; - }; - - static void CleanupThread(std::thread* thd) { - if (thd != nullptr) { - thd->join(); - delete thd; - } - } - - std::shared_ptr state_; - EventEngine::ResolvedAddress peer_; - EventEngine::ResolvedAddress local_; -}; - } // namespace experimental } // namespace grpc_event_engine diff --git a/test/cpp/microbenchmarks/BUILD b/test/cpp/microbenchmarks/BUILD index 41de193c9b0..16ed135e3a0 100644 --- a/test/cpp/microbenchmarks/BUILD +++ b/test/cpp/microbenchmarks/BUILD @@ -381,25 +381,6 @@ grpc_cc_test( ], ) -grpc_cc_test( - name = "bm_chttp2_transport", - srcs = ["bm_chttp2_transport.cc"], - args = grpc_benchmark_args(), - external_deps = [ - "absl/log:check", - ], - tags = [ - "no_mac", - "no_windows", - "nomsan", - ], - deps = [ - ":helpers", - "//src/core:closure", - "//src/core:slice", - ], -) - grpc_cc_test( name = "bm_opencensus_plugin", srcs = ["bm_opencensus_plugin.cc"], diff --git a/test/cpp/microbenchmarks/bm_chttp2_transport.cc b/test/cpp/microbenchmarks/bm_chttp2_transport.cc deleted file mode 100644 index 21b3222cd68..00000000000 --- a/test/cpp/microbenchmarks/bm_chttp2_transport.cc +++ /dev/null @@ -1,425 +0,0 @@ -// -// -// Copyright 2015 gRPC authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// - -// Microbenchmarks around CHTTP2 transport operations - -#include - -#include -#include -#include - -#include - -#include "absl/log/check.h" - -#include -#include -#include -#include - -#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" -#include "src/core/ext/transport/chttp2/transport/internal.h" -#include "src/core/lib/gprpp/crash.h" -#include "src/core/lib/iomgr/closure.h" -#include "src/core/lib/resource_quota/api.h" -#include "src/core/lib/slice/slice_internal.h" -#include "test/core/test_util/test_config.h" -#include "test/cpp/microbenchmarks/helpers.h" -#include "test/cpp/util/test_config.h" - -//////////////////////////////////////////////////////////////////////////////// -// Helper classes -// - -class PhonyEndpoint : public grpc_endpoint { - public: - PhonyEndpoint() { - static const grpc_endpoint_vtable my_vtable = {read, - write, - add_to_pollset, - add_to_pollset_set, - delete_from_pollset_set, - shutdown, - destroy, - get_peer, - get_local_address, - get_fd, - can_track_err}; - grpc_endpoint::vtable = &my_vtable; - } - - void PushInput(grpc_slice slice) { - if (read_cb_ == nullptr) { - CHECK(!have_slice_); - buffered_slice_ = slice; - have_slice_ = true; - return; - } - grpc_slice_buffer_add(slices_, slice); - grpc_core::ExecCtx::Run(DEBUG_LOCATION, read_cb_, absl::OkStatus()); - read_cb_ = nullptr; - } - - private: - grpc_closure* read_cb_ = nullptr; - grpc_slice_buffer* slices_ = nullptr; - bool have_slice_ = false; - grpc_slice buffered_slice_; - - void QueueRead(grpc_slice_buffer* slices, grpc_closure* cb) { - CHECK_EQ(read_cb_, nullptr); - if (have_slice_) { - have_slice_ = false; - grpc_slice_buffer_add(slices, buffered_slice_); - grpc_core::ExecCtx::Run(DEBUG_LOCATION, cb, absl::OkStatus()); - return; - } - read_cb_ = cb; - slices_ = slices; - } - - static void read(grpc_endpoint* ep, grpc_slice_buffer* slices, - grpc_closure* cb, bool /*urgent*/, - int /*min_progress_size*/) { - static_cast(ep)->QueueRead(slices, cb); - } - - static void write(grpc_endpoint* /*ep*/, grpc_slice_buffer* /*slices*/, - grpc_closure* cb, void* /*arg*/, int /*max_frame_size*/) { - grpc_core::ExecCtx::Run(DEBUG_LOCATION, cb, absl::OkStatus()); - } - - static void add_to_pollset(grpc_endpoint* /*ep*/, grpc_pollset* /*pollset*/) { - } - - static void add_to_pollset_set(grpc_endpoint* /*ep*/, - grpc_pollset_set* /*pollset*/) {} - - static void delete_from_pollset_set(grpc_endpoint* /*ep*/, - grpc_pollset_set* /*pollset*/) {} - - static void shutdown(grpc_endpoint* ep, grpc_error_handle why) { - grpc_core::ExecCtx::Run(DEBUG_LOCATION, - static_cast(ep)->read_cb_, why); - } - - static void destroy(grpc_endpoint* ep) { - delete static_cast(ep); - } - - static absl::string_view get_peer(grpc_endpoint* /*ep*/) { return "test"; } - static absl::string_view get_local_address(grpc_endpoint* /*ep*/) { - return "test"; - } - static int get_fd(grpc_endpoint* /*ep*/) { return 0; } - static bool can_track_err(grpc_endpoint* /*ep*/) { return false; } -}; - -class Fixture { - public: - Fixture(const grpc::ChannelArguments& args, bool client) { - grpc_channel_args c_args = args.c_channel_args(); - ep_ = new PhonyEndpoint; - auto final_args = grpc_core::CoreConfiguration::Get() - .channel_args_preconditioning() - .PreconditionChannelArgs(&c_args); - t_ = grpc_create_chttp2_transport(final_args, ep_, client); - grpc_chttp2_transport_start_reading(t_, nullptr, nullptr, nullptr); - FlushExecCtx(); - } - - void FlushExecCtx() { grpc_core::ExecCtx::Get()->Flush(); } - - ~Fixture() { t_->Orphan(); } - - grpc_chttp2_transport* chttp2_transport() { - return reinterpret_cast(t_); - } - grpc_core::Transport* transport() { return t_; } - - void PushInput(grpc_slice slice) { ep_->PushInput(slice); } - - private: - PhonyEndpoint* ep_; - grpc_core::Transport* t_; -}; - -class TestClosure : public grpc_closure { - public: - virtual ~TestClosure() {} -}; - -template -std::unique_ptr MakeTestClosure(F f) { - struct C : public TestClosure { - explicit C(const F& f) : f_(f) { - GRPC_CLOSURE_INIT(this, Execute, this, nullptr); - } - F f_; - static void Execute(void* arg, grpc_error_handle error) { - static_cast(arg)->f_(error); - } - }; - return std::unique_ptr(new C(f)); -} - -template -grpc_closure* MakeOnceClosure(F f) { - struct C : public grpc_closure { - explicit C(const F& f) : f_(f) {} - F f_; - static void Execute(void* arg, grpc_error_handle error) { - static_cast(arg)->f_(error); - delete static_cast(arg); - } - }; - auto* c = new C{f}; - return GRPC_CLOSURE_INIT(c, C::Execute, c, nullptr); -} - -class Stream { - public: - explicit Stream(Fixture* f) : f_(f) { - stream_size_ = f->transport()->filter_stack_transport()->SizeOfStream(); - stream_ = gpr_malloc(stream_size_); - arena_ = grpc_core::Arena::Create(4096, &memory_allocator_); - } - - ~Stream() { - gpr_event_wait(&done_, gpr_inf_future(GPR_CLOCK_REALTIME)); - gpr_free(stream_); - arena_->Destroy(); - } - - void Init(benchmark::State& state) { - GRPC_STREAM_REF_INIT(&refcount_, 1, &Stream::FinishDestroy, this, - "test_stream"); - gpr_event_init(&done_); - memset(stream_, 0, stream_size_); - if ((state.iterations() & 0xffff) == 0) { - arena_->Destroy(); - arena_ = grpc_core::Arena::Create(4096, &memory_allocator_); - } - f_->transport()->filter_stack_transport()->InitStream( - static_cast(stream_), &refcount_, nullptr, arena_); - } - - void DestroyThen(grpc_closure* closure) { - destroy_closure_ = closure; -#ifndef NDEBUG - grpc_stream_unref(&refcount_, "DestroyThen"); -#else - grpc_stream_unref(&refcount_); -#endif - } - - void Op(grpc_transport_stream_op_batch* op) { - f_->transport()->filter_stack_transport()->PerformStreamOp( - static_cast(stream_), op); - } - - grpc_chttp2_stream* chttp2_stream() { - return static_cast(stream_); - } - - private: - static void FinishDestroy(void* arg, grpc_error_handle /*error*/) { - auto stream = static_cast(arg); - stream->f_->transport()->filter_stack_transport()->DestroyStream( - static_cast(stream->stream_), stream->destroy_closure_); - gpr_event_set(&stream->done_, reinterpret_cast(1)); - } - - Fixture* f_; - grpc_stream_refcount refcount_; - grpc_core::MemoryAllocator memory_allocator_ = - grpc_core::MemoryAllocator(grpc_core::ResourceQuota::Default() - ->memory_quota() - ->CreateMemoryAllocator("test")); - grpc_core::Arena* arena_; - size_t stream_size_; - void* stream_; - grpc_closure* destroy_closure_ = nullptr; - gpr_event done_; -}; - -//////////////////////////////////////////////////////////////////////////////// -// Benchmarks -// -std::vector> done_events; - -static void BM_StreamCreateDestroy(benchmark::State& state) { - grpc_core::ExecCtx exec_ctx; - Fixture f(grpc::ChannelArguments(), true); - auto* s = new Stream(&f); - grpc_transport_stream_op_batch op; - grpc_transport_stream_op_batch_payload op_payload(nullptr); - op = {}; - op.cancel_stream = true; - op.payload = &op_payload; - op_payload.cancel_stream.cancel_error = absl::CancelledError(); - std::unique_ptr next = - MakeTestClosure([&, s](grpc_error_handle /*error*/) { - if (!state.KeepRunning()) { - delete s; - return; - } - s->Init(state); - s->Op(&op); - s->DestroyThen(next.get()); - }); - grpc_core::Closure::Run(DEBUG_LOCATION, next.get(), absl::OkStatus()); - f.FlushExecCtx(); -} -BENCHMARK(BM_StreamCreateDestroy); - -class RepresentativeClientInitialMetadata { - public: - static void Prepare(grpc_metadata_batch* b) { - b->Set(grpc_core::HttpSchemeMetadata(), - grpc_core::HttpSchemeMetadata::kHttp); - b->Set(grpc_core::HttpMethodMetadata(), - grpc_core::HttpMethodMetadata::kPost); - b->Set(grpc_core::HttpPathMetadata(), - grpc_core::Slice(grpc_core::StaticSlice::FromStaticString( - "/foo/bar/bm_chttp2_transport"))); - b->Set(grpc_core::HttpAuthorityMetadata(), - grpc_core::Slice(grpc_core::StaticSlice::FromStaticString( - "foo.test.google.fr:1234"))); - b->Set( - grpc_core::GrpcAcceptEncodingMetadata(), - grpc_core::CompressionAlgorithmSet( - {GRPC_COMPRESS_NONE, GRPC_COMPRESS_DEFLATE, GRPC_COMPRESS_GZIP})); - b->Set(grpc_core::TeMetadata(), grpc_core::TeMetadata::kTrailers); - b->Set(grpc_core::ContentTypeMetadata(), - grpc_core::ContentTypeMetadata::kApplicationGrpc); - b->Set(grpc_core::UserAgentMetadata(), - grpc_core::Slice(grpc_core::StaticSlice::FromStaticString( - "grpc-c/3.0.0-dev (linux; chttp2; green)"))); - } -}; - -template -static void BM_StreamCreateSendInitialMetadataDestroy(benchmark::State& state) { - grpc_core::ExecCtx exec_ctx; - Fixture f(grpc::ChannelArguments(), true); - auto* s = new Stream(&f); - grpc_transport_stream_op_batch op; - grpc_transport_stream_op_batch_payload op_payload(nullptr); - std::unique_ptr start; - std::unique_ptr done; - - auto reset_op = [&]() { - op = {}; - op.payload = &op_payload; - }; - - grpc_core::MemoryAllocator memory_allocator = - grpc_core::MemoryAllocator(grpc_core::ResourceQuota::Default() - ->memory_quota() - ->CreateMemoryAllocator("test")); - auto arena = grpc_core::MakeScopedArena(1024, &memory_allocator); - grpc_metadata_batch b; - Metadata::Prepare(&b); - - f.FlushExecCtx(); - gpr_event bm_done; - gpr_event_init(&bm_done); - start = MakeTestClosure([&, s](grpc_error_handle /*error*/) { - if (!state.KeepRunning()) { - delete s; - gpr_event_set(&bm_done, (void*)1); - return; - } - s->Init(state); - reset_op(); - op.on_complete = done.get(); - op.send_initial_metadata = true; - op.payload->send_initial_metadata.send_initial_metadata = &b; - s->Op(&op); - }); - done = MakeTestClosure([&](grpc_error_handle /*error*/) { - reset_op(); - op.cancel_stream = true; - op.payload->cancel_stream.cancel_error = absl::CancelledError(); - s->Op(&op); - s->DestroyThen(start.get()); - }); - grpc_core::ExecCtx::Run(DEBUG_LOCATION, start.get(), absl::OkStatus()); - f.FlushExecCtx(); - gpr_event_wait(&bm_done, gpr_inf_future(GPR_CLOCK_REALTIME)); -} -BENCHMARK_TEMPLATE(BM_StreamCreateSendInitialMetadataDestroy, - RepresentativeClientInitialMetadata); - -static void BM_TransportEmptyOp(benchmark::State& state) { - grpc_core::ExecCtx exec_ctx; - Fixture f(grpc::ChannelArguments(), true); - auto* s = new Stream(&f); - s->Init(state); - grpc_transport_stream_op_batch op; - grpc_transport_stream_op_batch_payload op_payload(nullptr); - auto reset_op = [&]() { - op = {}; - op.payload = &op_payload; - }; - std::unique_ptr c = - MakeTestClosure([&](grpc_error_handle /*error*/) { - if (!state.KeepRunning()) return; - reset_op(); - op.on_complete = c.get(); - s->Op(&op); - }); - grpc_core::ExecCtx::Run(DEBUG_LOCATION, c.get(), absl::OkStatus()); - f.FlushExecCtx(); - reset_op(); - op.cancel_stream = true; - op_payload.cancel_stream.cancel_error = absl::CancelledError(); - gpr_event* stream_cancel_done = new gpr_event; - gpr_event_init(stream_cancel_done); - std::unique_ptr stream_cancel_closure = - MakeTestClosure([&](grpc_error_handle error) { - CHECK_OK(error); - gpr_event_set(stream_cancel_done, reinterpret_cast(1)); - }); - op.on_complete = stream_cancel_closure.get(); - s->Op(&op); - f.FlushExecCtx(); - gpr_event_wait(stream_cancel_done, gpr_inf_future(GPR_CLOCK_REALTIME)); - done_events.emplace_back(stream_cancel_done); - s->DestroyThen( - MakeOnceClosure([s](grpc_error_handle /*error*/) { delete s; })); - f.FlushExecCtx(); -} -BENCHMARK(BM_TransportEmptyOp); - -// Some distros have RunSpecifiedBenchmarks under the benchmark namespace, -// and others do not. This allows us to support both modes. -namespace benchmark { -void RunTheBenchmarksNamespaced() { RunSpecifiedBenchmarks(); } -} // namespace benchmark - -int main(int argc, char** argv) { - grpc::testing::TestEnvironment env(&argc, argv); - LibraryInitializer libInit; - ::benchmark::Initialize(&argc, argv); - grpc::testing::InitTest(&argc, &argv, false); - benchmark::RunTheBenchmarksNamespaced(); - return 0; -} diff --git a/test/cpp/server/BUILD b/test/cpp/server/BUILD index b65ec5c9e86..ba2f115ee7a 100644 --- a/test/cpp/server/BUILD +++ b/test/cpp/server/BUILD @@ -28,7 +28,6 @@ grpc_cc_test( deps = [ "//:grpc++_unsecure", "//src/proto/grpc/testing:echo_proto", - "//test/core/event_engine:event_engine_test_utils", "//test/core/test_util:grpc_test_util_base", "//test/core/test_util:grpc_test_util_unsecure", ], diff --git a/test/cpp/server/server_builder_test.cc b/test/cpp/server/server_builder_test.cc index 089f7c38ecf..1765a1d59bf 100644 --- a/test/cpp/server/server_builder_test.cc +++ b/test/cpp/server/server_builder_test.cc @@ -16,19 +16,14 @@ // // -#include - #include -#include #include #include #include #include -#include "src/core/lib/gprpp/notification.h" #include "src/proto/grpc/testing/echo.grpc.pb.h" -#include "test/core/event_engine/event_engine_test_utils.h" #include "test/core/test_util/port.h" #include "test/core/test_util/test_config.h" @@ -88,56 +83,6 @@ TEST_F(ServerBuilderTest, CreateServerRepeatedPortWithDisallowedReusePort) { nullptr); } -TEST_F(ServerBuilderTest, AddPassiveListener) { - std::unique_ptr passive_listener; - auto server = - ServerBuilder() - .experimental() - .AddPassiveListener(InsecureServerCredentials(), passive_listener) - .BuildAndStart(); - server->Shutdown(); -} - -TEST_F(ServerBuilderTest, PassiveListenerAcceptConnectedFd) { - std::unique_ptr passive_listener; - ServerBuilder builder; - auto cq = builder.AddCompletionQueue(); - // TODO(hork): why is the service necessary? Queue isn't drained otherwise. - auto server = - builder.RegisterService(&g_service) - .experimental() - .AddPassiveListener(InsecureServerCredentials(), passive_listener) - .BuildAndStart(); - ASSERT_NE(server.get(), nullptr); -#ifdef GPR_SUPPORT_CHANNELS_FROM_FD - int fd = socket(AF_INET, SOCK_STREAM, 0); - auto accept_status = passive_listener->AcceptConnectedFd(fd); - ASSERT_TRUE(accept_status.ok()) << accept_status; -#else - int fd = -1; - auto accept_status = passive_listener->AcceptConnectedFd(fd); - ASSERT_FALSE(accept_status.ok()) << accept_status; -#endif - server->Shutdown(); -} - -TEST_F(ServerBuilderTest, PassiveListenerAcceptConnectedEndpoint) { - std::unique_ptr passive_listener; - auto server = - ServerBuilder() - .experimental() - .AddPassiveListener(InsecureServerCredentials(), passive_listener) - .BuildAndStart(); - grpc_core::Notification endpoint_destroyed; - auto success = passive_listener->AcceptConnectedEndpoint( - std::make_unique( - &endpoint_destroyed)); - ASSERT_TRUE(success.ok()) - << "AcceptConnectedEndpoint failure: " << success.ToString(); - endpoint_destroyed.WaitForNotification(); - server->Shutdown(); -} - } // namespace } // namespace grpc diff --git a/test/cpp/util/BUILD b/test/cpp/util/BUILD index c9df11d7982..95b28274cc0 100644 --- a/test/cpp/util/BUILD +++ b/test/cpp/util/BUILD @@ -45,6 +45,7 @@ grpc_cc_library( hdrs = [ "proto_reflection_descriptor_database.h", ], + external_deps = ["absl/log:log"], deps = [ "//:grpc++", "//:grpc++_config_proto", @@ -78,6 +79,7 @@ grpc_cc_library( external_deps = [ "absl/flags:flag", "absl/log:check", + "absl/log:log", "protobuf", ], deps = [ @@ -141,6 +143,7 @@ grpc_cc_library( external_deps = [ "absl/flags:flag", "absl/log:check", + "absl/log:log", "protobuf", "protobuf_clib", ], @@ -175,6 +178,7 @@ grpc_cc_library( hdrs = [ "metrics_server.h", ], + external_deps = ["absl/log:log"], deps = [ "//:grpc++", "//src/proto/grpc/testing:metrics_proto", @@ -338,6 +342,7 @@ grpc_cc_binary( external_deps = [ "absl/flags:flag", "absl/log:check", + "absl/log:log", "absl/strings", ], language = "c++", @@ -364,6 +369,7 @@ grpc_cc_test( ], external_deps = [ "absl/log:check", + "absl/log:log", "gtest", ], flaky = True, diff --git a/test/cpp/util/channelz_sampler.cc b/test/cpp/util/channelz_sampler.cc index f4aee2244f7..2619a5481d1 100644 --- a/test/cpp/util/channelz_sampler.cc +++ b/test/cpp/util/channelz_sampler.cc @@ -28,6 +28,7 @@ #include "absl/flags/flag.h" #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/str_format.h" #include "absl/strings/str_join.h" #include "google/protobuf/text_format.h" @@ -133,8 +134,8 @@ class ChannelzSampler final { Status status = channelz_stub_->GetChannel( &get_channel_context, get_channel_request, &get_channel_response); if (!status.ok()) { - gpr_log(GPR_ERROR, "GetChannelRPC failed: %s", - get_channel_context.debug_error_string().c_str()); + LOG(ERROR) << "GetChannelRPC failed: " + << get_channel_context.debug_error_string(); CHECK(0); } return get_channel_response.channel(); @@ -152,8 +153,8 @@ class ChannelzSampler final { get_subchannel_request, &get_subchannel_response); if (!status.ok()) { - gpr_log(GPR_ERROR, "GetSubchannelRPC failed: %s", - get_subchannel_context.debug_error_string().c_str()); + LOG(ERROR) << "GetSubchannelRPC failed: " + << get_subchannel_context.debug_error_string(); CHECK(0); } return get_subchannel_response.subchannel(); @@ -170,8 +171,8 @@ class ChannelzSampler final { Status status = channelz_stub_->GetSocket( &get_socket_context, get_socket_request, &get_socket_response); if (!status.ok()) { - gpr_log(GPR_ERROR, "GetSocketRPC failed: %s", - get_socket_context.debug_error_string().c_str()); + LOG(ERROR) << "GetSocketRPC failed: " + << get_socket_context.debug_error_string(); CHECK(0); } return get_socket_response.socket(); @@ -297,10 +298,9 @@ class ChannelzSampler final { grpc::testing::GetCredentialsProvider()->GetChannelCredentials( custom_credentials_type, &channel_args); if (!channel_creds) { - gpr_log(GPR_ERROR, - "Wrong user credential type: %s. Allowed credential types: " - "INSECURE_CREDENTIALS, ssl, alts, google_default_credentials.", - custom_credentials_type.c_str()); + LOG(ERROR) << "Wrong user credential type: " << custom_credentials_type + << ". Allowed credential types: INSECURE_CREDENTIALS, ssl, " + "alts, google_default_credentials."; CHECK(0); } std::shared_ptr channel = @@ -324,15 +324,14 @@ class ChannelzSampler final { &get_servers_context, get_servers_request, &get_servers_response); if (!status.ok()) { if (status.error_code() == StatusCode::UNIMPLEMENTED) { - gpr_log(GPR_ERROR, - "Error status UNIMPLEMENTED. Please check and make sure " - "channelz has been registered on the server being queried."); + LOG(ERROR) << "Error status UNIMPLEMENTED. Please check and make " + "sure channelz has been registered on the server being " + "queried."; } else { - gpr_log(GPR_ERROR, - "GetServers RPC with GetServersRequest.server_start_id=%d, " - "failed: %s", - static_cast(server_start_id), - get_servers_context.debug_error_string().c_str()); + LOG(ERROR) << "GetServers RPC with " + "GetServersRequest.server_start_id=" + << server_start_id << ", failed: " + << get_servers_context.debug_error_string(); } CHECK(0); } @@ -384,11 +383,10 @@ class ChannelzSampler final { &get_top_channels_context, get_top_channels_request, &get_top_channels_response); if (!status.ok()) { - gpr_log(GPR_ERROR, - "GetTopChannels RPC with " - "GetTopChannelsRequest.channel_start_id=%d failed: %s", - static_cast(channel_start_id), - get_top_channels_context.debug_error_string().c_str()); + LOG(ERROR) << "GetTopChannels RPC with " + "GetTopChannelsRequest.channel_start_id=" + << channel_start_id << " failed: " + << get_top_channels_context.debug_error_string(); CHECK(0); } for (const auto& _topchannel : get_top_channels_response.channel()) { diff --git a/test/cpp/util/channelz_sampler_test.cc b/test/cpp/util/channelz_sampler_test.cc index 76db3a1efab..fde2a019f97 100644 --- a/test/cpp/util/channelz_sampler_test.cc +++ b/test/cpp/util/channelz_sampler_test.cc @@ -25,6 +25,7 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/str_cat.h" #include "gtest/gtest.h" @@ -85,7 +86,7 @@ void RunClient(const std::string& client_id, gpr_event* done_ev) { std::unique_ptr stub = grpc::testing::TestService::NewStub( grpc::CreateChannel(server_address, channel_creds)); - gpr_log(GPR_INFO, "Client %s is echoing!", client_id.c_str()); + LOG(INFO) << "Client " << client_id << " is echoing!"; while (true) { if (gpr_event_wait(done_ev, grpc_timeout_seconds_to_deadline(1)) != nullptr) { @@ -96,7 +97,7 @@ void RunClient(const std::string& client_id, gpr_event* done_ev) { ClientContext context; Status status = stub->EmptyCall(&context, request, &response); if (!status.ok()) { - gpr_log(GPR_ERROR, "Client echo failed."); + LOG(ERROR) << "Client echo failed."; CHECK(0); } } @@ -125,7 +126,7 @@ TEST(ChannelzSamplerTest, SimpleTest) { builder.AddListeningPort(server_address, server_creds); builder.RegisterService(&service); std::unique_ptr server(builder.BuildAndStart()); - gpr_log(GPR_INFO, "Server listening on %s", server_address.c_str()); + LOG(INFO) << "Server listening on " << server_address; const int kWaitForServerSeconds = 10; ASSERT_TRUE(WaitForConnection(kWaitForServerSeconds)); // client threads @@ -144,19 +145,17 @@ TEST(ChannelzSamplerTest, SimpleTest) { int status = test_driver->Join(); if (WIFEXITED(status)) { if (WEXITSTATUS(status)) { - gpr_log(GPR_ERROR, - "Channelz sampler test test-runner exited with code %d", - WEXITSTATUS(status)); + LOG(ERROR) << "Channelz sampler test test-runner exited with code " + << WEXITSTATUS(status); CHECK(0); // log the line number of the assertion failure } } else if (WIFSIGNALED(status)) { - gpr_log(GPR_ERROR, "Channelz sampler test test-runner ended from signal %d", - WTERMSIG(status)); + LOG(ERROR) << "Channelz sampler test test-runner ended from signal " + << WTERMSIG(status); CHECK(0); } else { - gpr_log(GPR_ERROR, - "Channelz sampler test test-runner ended with unknown status %d", - status); + LOG(ERROR) << "Channelz sampler test test-runner ended with unknown status " + << status; CHECK(0); } delete test_driver; diff --git a/test/cpp/util/cli_credentials.cc b/test/cpp/util/cli_credentials.cc index bf9e974a196..8b178524df8 100644 --- a/test/cpp/util/cli_credentials.cc +++ b/test/cpp/util/cli_credentials.cc @@ -19,6 +19,7 @@ #include "test/cpp/util/cli_credentials.h" #include "absl/flags/flag.h" +#include "absl/log/log.h" #include #include @@ -97,9 +98,9 @@ CliCredentials::GetChannelCredentials() const { auto cert = grpc_core::LoadFile(absl::GetFlag(FLAGS_ssl_client_cert), /*add_null_terminator=*/false); if (!cert.ok()) { - gpr_log(GPR_ERROR, "error loading file %s: %s", - absl::GetFlag(FLAGS_ssl_client_cert).c_str(), - cert.status().ToString().c_str()); + LOG(ERROR) << "error loading file " + << absl::GetFlag(FLAGS_ssl_client_cert) << ": " + << cert.status(); } else { ssl_creds_options.pem_cert_chain = std::string(cert->as_string_view()); } @@ -108,9 +109,9 @@ CliCredentials::GetChannelCredentials() const { auto key = grpc_core::LoadFile(absl::GetFlag(FLAGS_ssl_client_key), /*add_null_terminator=*/false); if (!key.ok()) { - gpr_log(GPR_ERROR, "error loading file %s: %s", - absl::GetFlag(FLAGS_ssl_client_key).c_str(), - key.status().ToString().c_str()); + LOG(ERROR) << "error loading file " + << absl::GetFlag(FLAGS_ssl_client_key) << ": " + << key.status(); } else { ssl_creds_options.pem_private_key = std::string(key->as_string_view()); } diff --git a/test/cpp/util/metrics_server.cc b/test/cpp/util/metrics_server.cc index f816659f3ed..59d3dcead15 100644 --- a/test/cpp/util/metrics_server.cc +++ b/test/cpp/util/metrics_server.cc @@ -18,6 +18,8 @@ #include "test/cpp/util/metrics_server.h" +#include "absl/log/log.h" + #include #include #include @@ -54,7 +56,7 @@ long QpsGauge::Get() { grpc::Status MetricsServiceImpl::GetAllGauges( ServerContext* /*context*/, const EmptyMessage* /*request*/, ServerWriter* writer) { - gpr_log(GPR_DEBUG, "GetAllGauges called"); + VLOG(2) << "GetAllGauges called"; std::lock_guard lock(mu_); for (auto it = qps_gauges_.begin(); it != qps_gauges_.end(); it++) { @@ -99,7 +101,7 @@ std::shared_ptr MetricsServiceImpl::CreateQpsGauge( // Starts the metrics server and returns the grpc::Server instance. Call Wait() // on the returned server instance. std::unique_ptr MetricsServiceImpl::StartServer(int port) { - gpr_log(GPR_INFO, "Building metrics server.."); + LOG(INFO) << "Building metrics server.."; const std::string address = "0.0.0.0:" + std::to_string(port); @@ -108,8 +110,8 @@ std::unique_ptr MetricsServiceImpl::StartServer(int port) { builder.RegisterService(this); std::unique_ptr server(builder.BuildAndStart()); - gpr_log(GPR_INFO, "Metrics server %s started. Ready to receive requests..", - address.c_str()); + LOG(INFO) << "Metrics server " << address + << " started. Ready to receive requests.."; return server; } diff --git a/test/cpp/util/proto_reflection_descriptor_database.cc b/test/cpp/util/proto_reflection_descriptor_database.cc index 80b095c6d4b..b5441f87596 100644 --- a/test/cpp/util/proto_reflection_descriptor_database.cc +++ b/test/cpp/util/proto_reflection_descriptor_database.cc @@ -20,7 +20,7 @@ #include -#include +#include "absl/log/log.h" #include "src/core/lib/gprpp/crash.h" @@ -86,23 +86,19 @@ bool ProtoReflectionDescriptorDatabase::FindFileByName( ServerReflectionResponse::MessageResponseCase::kErrorResponse) { const ErrorResponse& error = response.error_response(); if (error.error_code() == StatusCode::NOT_FOUND) { - gpr_log(GPR_INFO, "NOT_FOUND from server for FindFileByName(%s)", - filename.c_str()); + LOG(INFO) << "NOT_FOUND from server for FindFileByName(" << filename + << ")"; } else { - gpr_log(GPR_INFO, - "Error on FindFileByName(%s)\n\tError code: %d\n" - "\tError Message: %s", - filename.c_str(), error.error_code(), - error.error_message().c_str()); + LOG(INFO) << "Error on FindFileByName(" << filename + << ")\n\tError code: " << error.error_code() + << "\n\tError Message: " << error.error_message(); } } else { - gpr_log( - GPR_INFO, - "Error on FindFileByName(%s) response type\n" - "\tExpecting: %d\n\tReceived: %d", - filename.c_str(), - ServerReflectionResponse::MessageResponseCase::kFileDescriptorResponse, - response.message_response_case()); + LOG(INFO) << "Error on FindFileByName(" << filename + << ") response type\n\tExpecting: " + << ServerReflectionResponse::MessageResponseCase:: + kFileDescriptorResponse + << "\n\tReceived: " << response.message_response_case(); } return cached_db_.FindFileByName(filename, output); @@ -134,24 +130,19 @@ bool ProtoReflectionDescriptorDatabase::FindFileContainingSymbol( const ErrorResponse& error = response.error_response(); if (error.error_code() == StatusCode::NOT_FOUND) { missing_symbols_.insert(symbol_name); - gpr_log(GPR_INFO, - "NOT_FOUND from server for FindFileContainingSymbol(%s)", - symbol_name.c_str()); + LOG(INFO) << "NOT_FOUND from server for FindFileContainingSymbol(" + << symbol_name << ")"; } else { - gpr_log(GPR_INFO, - "Error on FindFileContainingSymbol(%s)\n" - "\tError code: %d\n\tError Message: %s", - symbol_name.c_str(), error.error_code(), - error.error_message().c_str()); + LOG(INFO) << "Error on FindFileContainingSymbol(" << symbol_name + << ")\n\tError code: " << error.error_code() + << "\n\tError Message: " << error.error_message(); } } else { - gpr_log( - GPR_INFO, - "Error on FindFileContainingSymbol(%s) response type\n" - "\tExpecting: %d\n\tReceived: %d", - symbol_name.c_str(), - ServerReflectionResponse::MessageResponseCase::kFileDescriptorResponse, - response.message_response_case()); + LOG(INFO) << "Error on FindFileContainingSymbol(" << symbol_name + << ") response type\n\tExpecting: " + << ServerReflectionResponse::MessageResponseCase:: + kFileDescriptorResponse + << "\n\tReceived: " << response.message_response_case(); } return cached_db_.FindFileContainingSymbol(symbol_name, output); } @@ -167,7 +158,7 @@ bool ProtoReflectionDescriptorDatabase::FindFileContainingExtension( if (missing_extensions_.find(containing_type) != missing_extensions_.end() && missing_extensions_[containing_type].find(field_number) != missing_extensions_[containing_type].end()) { - gpr_log(GPR_INFO, "nested map."); + LOG(INFO) << "nested map."; return false; } @@ -194,24 +185,20 @@ bool ProtoReflectionDescriptorDatabase::FindFileContainingExtension( missing_extensions_[containing_type] = {}; } missing_extensions_[containing_type].insert(field_number); - gpr_log(GPR_INFO, - "NOT_FOUND from server for FindFileContainingExtension(%s, %d)", - containing_type.c_str(), field_number); + LOG(INFO) << "NOT_FOUND from server for FindFileContainingExtension(" + << containing_type << ", " << field_number << ")"; } else { - gpr_log(GPR_INFO, - "Error on FindFileContainingExtension(%s, %d)\n" - "\tError code: %d\n\tError Message: %s", - containing_type.c_str(), field_number, error.error_code(), - error.error_message().c_str()); + LOG(INFO) << "Error on FindFileContainingExtension(" << containing_type + << ", " << field_number + << ")\n\tError code: " << error.error_code() + << "\n\tError Message: " << error.error_message(); } } else { - gpr_log( - GPR_INFO, - "Error on FindFileContainingExtension(%s, %d) response type\n" - "\tExpecting: %d\n\tReceived: %d", - containing_type.c_str(), field_number, - ServerReflectionResponse::MessageResponseCase::kFileDescriptorResponse, - response.message_response_case()); + LOG(INFO) << "Error on FindFileContainingExtension(" << containing_type + << ", " << field_number << ") response type\n\tExpecting: " + << ServerReflectionResponse::MessageResponseCase:: + kFileDescriptorResponse + << "\n\tReceived: " << response.message_response_case(); } return cached_db_.FindFileContainingExtension(containing_type, field_number, @@ -245,14 +232,12 @@ bool ProtoReflectionDescriptorDatabase::FindAllExtensionNumbers( ServerReflectionResponse::MessageResponseCase::kErrorResponse) { const ErrorResponse& error = response.error_response(); if (error.error_code() == StatusCode::NOT_FOUND) { - gpr_log(GPR_INFO, "NOT_FOUND from server for FindAllExtensionNumbers(%s)", - extendee_type.c_str()); + LOG(INFO) << "NOT_FOUND from server for FindAllExtensionNumbers(" + << extendee_type << ")"; } else { - gpr_log(GPR_INFO, - "Error on FindAllExtensionNumbersExtension(%s)\n" - "\tError code: %d\n\tError Message: %s", - extendee_type.c_str(), error.error_code(), - error.error_message().c_str()); + LOG(INFO) << "Error on FindAllExtensionNumbersExtension(" << extendee_type + << ")\n\tError code: " << error.error_code() + << "\n\tError Message: " << error.error_message(); } } return false; @@ -278,16 +263,13 @@ bool ProtoReflectionDescriptorDatabase::GetServices( } else if (response.message_response_case() == ServerReflectionResponse::MessageResponseCase::kErrorResponse) { const ErrorResponse& error = response.error_response(); - gpr_log(GPR_INFO, - "Error on GetServices()\n\tError code: %d\n" - "\tError Message: %s", - error.error_code(), error.error_message().c_str()); + LOG(INFO) << "Error on GetServices()\n\tError code: " << error.error_code() + << "\n\tError Message: " << error.error_message(); } else { - gpr_log( - GPR_INFO, - "Error on GetServices() response type\n\tExpecting: %d\n\tReceived: %d", - ServerReflectionResponse::MessageResponseCase::kListServicesResponse, - response.message_response_case()); + LOG(INFO) + << "Error on GetServices() response type\n\tExpecting: " + << ServerReflectionResponse::MessageResponseCase::kListServicesResponse + << "\n\tReceived: " << response.message_response_case(); } return false; } diff --git a/test/cpp/util/test_credentials_provider.cc b/test/cpp/util/test_credentials_provider.cc index c85de0a8b25..c94f0a054bd 100644 --- a/test/cpp/util/test_credentials_provider.cc +++ b/test/cpp/util/test_credentials_provider.cc @@ -27,6 +27,7 @@ #include "absl/flags/flag.h" #include "absl/log/check.h" +#include "absl/log/log.h" #include #include @@ -104,7 +105,7 @@ class DefaultCredentialsProvider : public CredentialsProvider { auto it(std::find(added_secure_type_names_.begin(), added_secure_type_names_.end(), type)); if (it == added_secure_type_names_.end()) { - gpr_log(GPR_ERROR, "Unsupported credentials type %s.", type.c_str()); + LOG(ERROR) << "Unsupported credentials type " << type; return nullptr; } return added_secure_type_providers_[it - added_secure_type_names_.begin()] @@ -137,7 +138,7 @@ class DefaultCredentialsProvider : public CredentialsProvider { auto it(std::find(added_secure_type_names_.begin(), added_secure_type_names_.end(), type)); if (it == added_secure_type_names_.end()) { - gpr_log(GPR_ERROR, "Unsupported credentials type %s.", type.c_str()); + LOG(ERROR) << "Unsupported credentials type " << type; return nullptr; } return added_secure_type_providers_[it - added_secure_type_names_.begin()] diff --git a/tools/distrib/check_namespace_qualification.py b/tools/distrib/check_namespace_qualification.py index 51ccb71aeb8..6634d8b8830 100755 --- a/tools/distrib/check_namespace_qualification.py +++ b/tools/distrib/check_namespace_qualification.py @@ -77,10 +77,6 @@ IGNORED_FILES = [ "src/core/lib/gprpp/global_config_env.h", "src/core/lib/profiling/timers.h", "src/core/lib/gprpp/crash.h", - # The grpc_core::Server redundant namespace qualification is required for - # older gcc versions. - "src/core/ext/transport/chttp2/server/chttp2_server.h", - "src/core/server/server.h", ] # find our home diff --git a/tools/distrib/check_redundant_namespace_qualifiers.py b/tools/distrib/check_redundant_namespace_qualifiers.py index 72a5d8b7a3c..0322332209b 100755 --- a/tools/distrib/check_redundant_namespace_qualifiers.py +++ b/tools/distrib/check_redundant_namespace_qualifiers.py @@ -21,13 +21,6 @@ import os import re import sys -IGNORED_FILES = [ - # note: the grpc_core::Server redundant namespace qualification is required - # for older gcc versions. - "src/core/ext/transport/chttp2/server/chttp2_server.h", - "src/core/server/server.h", -] - def find_closing_mustache(contents, initial_depth): """Find the closing mustache for a given number of open mustaches.""" @@ -173,8 +166,6 @@ for config in _CONFIGURATION: for file in files: if file.endswith(".cc") or file.endswith(".h"): path = os.path.join(root, file) - if path in IGNORED_FILES: - continue try: with open(path) as f: contents = f.read() diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index c630913e944..6e0f4316174 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -928,7 +928,6 @@ include/grpc/impl/grpc_types.h \ include/grpc/impl/propagation_bits.h \ include/grpc/impl/slice_type.h \ include/grpc/load_reporting.h \ -include/grpc/passive_listener.h \ include/grpc/slice.h \ include/grpc/slice_buffer.h \ include/grpc/status.h \ @@ -1041,7 +1040,6 @@ include/grpcpp/impl/server_initializer.h \ include/grpcpp/impl/service_type.h \ include/grpcpp/impl/status.h \ include/grpcpp/impl/sync.h \ -include/grpcpp/passive_listener.h \ include/grpcpp/resource_quota.h \ include/grpcpp/security/audit_logging.h \ include/grpcpp/security/auth_context.h \ diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index fc07252fcd7..435df91432a 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -928,7 +928,6 @@ include/grpc/impl/grpc_types.h \ include/grpc/impl/propagation_bits.h \ include/grpc/impl/slice_type.h \ include/grpc/load_reporting.h \ -include/grpc/passive_listener.h \ include/grpc/slice.h \ include/grpc/slice_buffer.h \ include/grpc/status.h \ @@ -1041,7 +1040,6 @@ include/grpcpp/impl/server_initializer.h \ include/grpcpp/impl/service_type.h \ include/grpcpp/impl/status.h \ include/grpcpp/impl/sync.h \ -include/grpcpp/passive_listener.h \ include/grpcpp/resource_quota.h \ include/grpcpp/security/audit_logging.h \ include/grpcpp/security/auth_context.h \ diff --git a/tools/doxygen/Doxyfile.core b/tools/doxygen/Doxyfile.core index 20b553dadfe..592e357f54f 100644 --- a/tools/doxygen/Doxyfile.core +++ b/tools/doxygen/Doxyfile.core @@ -861,7 +861,6 @@ include/grpc/impl/grpc_types.h \ include/grpc/impl/propagation_bits.h \ include/grpc/impl/slice_type.h \ include/grpc/load_reporting.h \ -include/grpc/passive_listener.h \ include/grpc/slice.h \ include/grpc/slice_buffer.h \ include/grpc/status.h \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 72dbabf23dc..4026a7e0543 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -861,7 +861,6 @@ include/grpc/impl/grpc_types.h \ include/grpc/impl/propagation_bits.h \ include/grpc/impl/slice_type.h \ include/grpc/load_reporting.h \ -include/grpc/passive_listener.h \ include/grpc/slice.h \ include/grpc/slice_buffer.h \ include/grpc/status.h \ diff --git a/tools/internal_ci/linux/grpc_microbenchmark_diff_in_docker.sh b/tools/internal_ci/linux/grpc_microbenchmark_diff_in_docker.sh index a0bb42e8812..7c233f5b3e1 100755 --- a/tools/internal_ci/linux/grpc_microbenchmark_diff_in_docker.sh +++ b/tools/internal_ci/linux/grpc_microbenchmark_diff_in_docker.sh @@ -23,7 +23,7 @@ cd $(dirname $0)/../../.. time python3 -m pip install --user -r tools/internal_ci/helper_scripts/requirements.linux_perf.txt # List of benchmarks that provide good signal for analyzing performance changes in pull requests -BENCHMARKS_TO_RUN="bm_fullstack_unary_ping_pong bm_fullstack_streaming_ping_pong bm_fullstack_streaming_pump bm_closure bm_cq bm_chttp2_hpack bm_chttp2_transport" +BENCHMARKS_TO_RUN="bm_fullstack_unary_ping_pong bm_fullstack_streaming_ping_pong bm_fullstack_streaming_pump bm_closure bm_cq bm_chttp2_hpack" tools/run_tests/start_port_server.py diff --git a/tools/internal_ci/linux/grpc_xds_k8s_lb.cfg b/tools/internal_ci/linux/grpc_xds_k8s_lb.cfg index 3ba9db6be9e..67f0c0dc523 100644 --- a/tools/internal_ci/linux/grpc_xds_k8s_lb.cfg +++ b/tools/internal_ci/linux/grpc_xds_k8s_lb.cfg @@ -15,7 +15,7 @@ # Config file for the internal CI (in protobuf text format) # Location of the continuous shell script in repository. -build_file: "grpc/tools/internal_ci/linux/grpc_xds_k8s_lb.sh" +build_file: "grpc/tools/internal_ci/linux/psm-interop-test-cpp.sh" timeout_mins: 240 action { define_artifacts { @@ -24,3 +24,7 @@ action { strip_prefix: "artifacts" } } +env_vars { + key: "PSM_TEST_SUITE" + value: "lb" +} diff --git a/tools/internal_ci/linux/grpc_xds_k8s_lb.sh b/tools/internal_ci/linux/grpc_xds_k8s_lb.sh deleted file mode 100755 index 63579d7e752..00000000000 --- a/tools/internal_ci/linux/grpc_xds_k8s_lb.sh +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2021 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -eo pipefail - -# Constants -readonly GITHUB_REPOSITORY_NAME="grpc" -readonly TEST_DRIVER_INSTALL_SCRIPT_URL="https://raw.githubusercontent.com/${TEST_DRIVER_REPO_OWNER:-grpc}/psm-interop/${TEST_DRIVER_BRANCH:-main}/.kokoro/psm_interop_kokoro_lib.sh" -## xDS test client Docker images -readonly DOCKER_REGISTRY="us-docker.pkg.dev" -readonly SERVER_IMAGE_NAME="us-docker.pkg.dev/grpc-testing/psm-interop/cpp-server" -readonly CLIENT_IMAGE_NAME="us-docker.pkg.dev/grpc-testing/psm-interop/cpp-client" -readonly FORCE_IMAGE_BUILD="${FORCE_IMAGE_BUILD:-0}" -readonly BUILD_APP_PATH="interop-testing/build/install/grpc-interop-testing" - -####################################### -# Builds test app Docker images and pushes them to GCR -# Globals: -# BUILD_APP_PATH -# SERVER_IMAGE_NAME: Test server Docker image name -# CLIENT_IMAGE_NAME: Test client Docker image name -# GIT_COMMIT: SHA-1 of git commit being built -# Arguments: -# None -# Outputs: -# Writes the output of `gcloud builds submit` to stdout, stderr -####################################### -build_test_app_docker_images() { - echo "Building C++ xDS interop test app Docker images" - docker build -f "${SRC_DIR}/tools/dockerfile/interoptest/grpc_interop_cxx_xds/Dockerfile.xds_client" -t "${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" "${SRC_DIR}" - docker build -f "${SRC_DIR}/tools/dockerfile/interoptest/grpc_interop_cxx_xds/Dockerfile.xds_server" -t "${SERVER_IMAGE_NAME}:${GIT_COMMIT}" "${SRC_DIR}" - gcloud -q auth configure-docker "${DOCKER_REGISTRY}" - docker push "${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" - docker push "${SERVER_IMAGE_NAME}:${GIT_COMMIT}" - if is_version_branch "${TESTING_VERSION}"; then - tag_and_push_docker_image "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}" "${TESTING_VERSION}" - tag_and_push_docker_image "${SERVER_IMAGE_NAME}" "${GIT_COMMIT}" "${TESTING_VERSION}" - fi -} - -####################################### -# Builds test app and its docker images unless they already exist -# Globals: -# SERVER_IMAGE_NAME: Test server Docker image name -# CLIENT_IMAGE_NAME: Test client Docker image name -# GIT_COMMIT: SHA-1 of git commit being built -# FORCE_IMAGE_BUILD -# Arguments: -# None -# Outputs: -# Writes the output to stdout, stderr -####################################### -build_docker_images_if_needed() { - # Check if images already exist - server_tags="$(gcloud_gcr_list_image_tags "${SERVER_IMAGE_NAME}" "${GIT_COMMIT}")" - printf "Server image: %s:%s\n" "${SERVER_IMAGE_NAME}" "${GIT_COMMIT}" - echo "${server_tags:-Server image not found}" - - client_tags="$(gcloud_gcr_list_image_tags "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}")" - printf "Client image: %s:%s\n" "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}" - echo "${client_tags:-Client image not found}" - - # Build if any of the images are missing, or FORCE_IMAGE_BUILD=1 - if [[ "${FORCE_IMAGE_BUILD}" == "1" || -z "${server_tags}" || -z "${client_tags}" ]]; then - build_test_app_docker_images - else - echo "Skipping C++ test app build" - fi -} - -####################################### -# Executes the test case -# Globals: -# TEST_DRIVER_FLAGFILE: Relative path to test driver flagfile -# KUBE_CONTEXT: The name of kubectl context with GKE cluster access -# SECONDARY_KUBE_CONTEXT: The name of kubectl context with secondary GKE cluster access, if any -# TEST_XML_OUTPUT_DIR: Output directory for the test xUnit XML report -# SERVER_IMAGE_NAME: Test server Docker image name -# CLIENT_IMAGE_NAME: Test client Docker image name -# GIT_COMMIT: SHA-1 of git commit being built -# TESTING_VERSION: version branch under test: used by the framework to determine the supported PSM -# features. -# Arguments: -# Test case name -# Outputs: -# Writes the output of test execution to stdout, stderr -# Test xUnit report to ${TEST_XML_OUTPUT_DIR}/${test_name}/sponge_log.xml -####################################### -run_test() { - # Test driver usage: - # https://github.com/grpc/psm-interop#basic-usage - local test_name="${1:?Usage: run_test test_name}" - local out_dir="${TEST_XML_OUTPUT_DIR}/${test_name}" - mkdir -pv "${out_dir}" - set -x - python3 -m "tests.${test_name}" \ - --flagfile="${TEST_DRIVER_FLAGFILE}" \ - --kube_context="${KUBE_CONTEXT}" \ - --secondary_kube_context="${SECONDARY_KUBE_CONTEXT}" \ - --server_image="${SERVER_IMAGE_NAME}:${GIT_COMMIT}" \ - --client_image="${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" \ - --testing_version="${TESTING_VERSION}" \ - --force_cleanup \ - --collect_app_logs \ - --log_dir="${out_dir}" \ - --xml_output_file="${out_dir}/sponge_log.xml" \ - ${@:2} \ - |& tee "${out_dir}/sponge_log.log" -} - -run_alpha_test() { - local test_name=$1 - run_test ${test_name} \ - --compute_api_version="v1alpha" -} - -####################################### -# Main function: provision software necessary to execute tests, and run them -# Globals: -# KOKORO_ARTIFACTS_DIR -# GITHUB_REPOSITORY_NAME -# SRC_DIR: Populated with absolute path to the source repo -# TEST_DRIVER_REPO_DIR: Populated with the path to the repo containing -# the test driver -# TEST_DRIVER_FULL_DIR: Populated with the path to the test driver source code -# TEST_DRIVER_FLAGFILE: Populated with relative path to test driver flagfile -# TEST_XML_OUTPUT_DIR: Populated with the path to test xUnit XML report -# GIT_ORIGIN_URL: Populated with the origin URL of git repo used for the build -# GIT_COMMIT: Populated with the SHA-1 of git commit being built -# GIT_COMMIT_SHORT: Populated with the short SHA-1 of git commit being built -# KUBE_CONTEXT: Populated with name of kubectl context with GKE cluster access -# SECONDARY_KUBE_CONTEXT: Populated with name of kubectl context with secondary GKE cluster access, if any -# Arguments: -# None -# Outputs: -# Writes the output of test execution to stdout, stderr -####################################### -main() { - local script_dir - script_dir="$(dirname "$0")" - - # Source the test captured from the master branch. - echo "Sourcing test driver install captured from: ${TEST_DRIVER_INSTALL_SCRIPT_URL}" - source /dev/stdin <<< "$(curl -s "${TEST_DRIVER_INSTALL_SCRIPT_URL}")" - - activate_gke_cluster GKE_CLUSTER_PSM_LB - activate_secondary_gke_cluster GKE_CLUSTER_PSM_LB - - set -x - if [[ -n "${KOKORO_ARTIFACTS_DIR}" ]]; then - kokoro_setup_test_driver "${GITHUB_REPOSITORY_NAME}" - else - local_setup_test_driver "${script_dir}" - fi - build_docker_images_if_needed - - # Run tests - cd "${TEST_DRIVER_FULL_DIR}" - local failed_tests=0 - run_alpha_test subsetting_test || (( ++failed_tests )) - test_suites=( - "app_net_test" - "affinity_test" - "api_listener_test" - "change_backend_service_test" - "custom_lb_test" - "failover_test" - "outlier_detection_test" - "remove_neg_test" - "round_robin_test" - ) - if [[ "${TESTING_VERSION}" =~ "master" ]]; then - test_suites+=('bootstrap_generator_test') - fi - for test in "${test_suites[@]}"; do - run_test $test || (( ++failed_tests )) - done - echo "Failed test suites: ${failed_tests}" -} - -main "$@" diff --git a/tools/internal_ci/linux/grpc_xds_k8s_lb_python.cfg b/tools/internal_ci/linux/grpc_xds_k8s_lb_python.cfg index 7de169c802b..12d92f51b82 100644 --- a/tools/internal_ci/linux/grpc_xds_k8s_lb_python.cfg +++ b/tools/internal_ci/linux/grpc_xds_k8s_lb_python.cfg @@ -15,7 +15,7 @@ # Config file for the internal CI (in protobuf text format) # Location of the continuous shell script in repository. -build_file: "grpc/tools/internal_ci/linux/grpc_xds_k8s_lb_python.sh" +build_file: "grpc/tools/internal_ci/linux/psm-interop-test-python.sh" timeout_mins: 180 action { define_artifacts { @@ -24,3 +24,7 @@ action { strip_prefix: "artifacts" } } +env_vars { + key: "PSM_TEST_SUITE" + value: "lb" +} diff --git a/tools/internal_ci/linux/grpc_xds_k8s_lb_python.sh b/tools/internal_ci/linux/grpc_xds_k8s_lb_python.sh deleted file mode 100755 index 31444e7225b..00000000000 --- a/tools/internal_ci/linux/grpc_xds_k8s_lb_python.sh +++ /dev/null @@ -1,196 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2021 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -eo pipefail - -# Constants -readonly GITHUB_REPOSITORY_NAME="grpc" -readonly TEST_DRIVER_INSTALL_SCRIPT_URL="https://raw.githubusercontent.com/${TEST_DRIVER_REPO_OWNER:-grpc}/psm-interop/${TEST_DRIVER_BRANCH:-main}/.kokoro/psm_interop_kokoro_lib.sh" -## xDS test client Docker images -readonly DOCKER_REGISTRY="us-docker.pkg.dev" -readonly SERVER_IMAGE_NAME="us-docker.pkg.dev/grpc-testing/psm-interop/python-server" -readonly CLIENT_IMAGE_NAME="us-docker.pkg.dev/grpc-testing/psm-interop/python-client" -readonly FORCE_IMAGE_BUILD="${FORCE_IMAGE_BUILD:-0}" -readonly BUILD_APP_PATH="interop-testing/build/install/grpc-interop-testing" -readonly LANGUAGE_NAME="Python" - -####################################### -# Builds test app Docker images and pushes them to GCR -# Globals: -# BUILD_APP_PATH -# CLIENT_IMAGE_NAME: Test client Docker image name -# GIT_COMMIT: SHA-1 of git commit being built -# Arguments: -# None -# Outputs: -# Writes the output of `gcloud builds submit` to stdout, stderr -####################################### -build_test_app_docker_images() { - echo "Building ${LANGUAGE_NAME} xDS interop test app Docker images" - - pushd "${SRC_DIR}" - docker build \ - -f src/python/grpcio_tests/tests_py3_only/interop/Dockerfile.client \ - -t "${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" \ - . - - docker build \ - -f src/python/grpcio_tests/tests_py3_only/interop/Dockerfile.server \ - -t "${SERVER_IMAGE_NAME}:${GIT_COMMIT}" \ - . - - popd - - gcloud -q auth configure-docker "${DOCKER_REGISTRY}" - - docker push "${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" - docker push "${SERVER_IMAGE_NAME}:${GIT_COMMIT}" - - if is_version_branch "${TESTING_VERSION}"; then - tag_and_push_docker_image "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}" "${TESTING_VERSION}" - tag_and_push_docker_image "${SERVER_IMAGE_NAME}" "${GIT_COMMIT}" "${TESTING_VERSION}" - fi -} - -####################################### -# Builds test app and its docker images unless they already exist -# Globals: -# SERVER_IMAGE_NAME: Test server Docker image name -# CLIENT_IMAGE_NAME: Test client Docker image name -# GIT_COMMIT: SHA-1 of git commit being built -# FORCE_IMAGE_BUILD -# Arguments: -# None -# Outputs: -# Writes the output to stdout, stderr -####################################### -build_docker_images_if_needed() { - # Check if images already exist - server_tags="$(gcloud_gcr_list_image_tags "${SERVER_IMAGE_NAME}" "${GIT_COMMIT}")" - printf "Server image: %s:%s\n" "${SERVER_IMAGE_NAME}" "${GIT_COMMIT}" - echo "${server_tags:-Server image not found}" - - client_tags="$(gcloud_gcr_list_image_tags "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}")" - printf "Client image: %s:%s\n" "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}" - echo "${client_tags:-Client image not found}" - - # Build if any of the images are missing, or FORCE_IMAGE_BUILD=1 - if [[ "${FORCE_IMAGE_BUILD}" == "1" || -z "${server_tags}" || -z "${client_tags}" ]]; then - build_test_app_docker_images - else - echo "Skipping ${LANGUAGE_NAME} test app build" - fi -} - -####################################### -# Executes the test case -# Globals: -# TEST_DRIVER_FLAGFILE: Relative path to test driver flagfile -# KUBE_CONTEXT: The name of kubectl context with GKE cluster access -# SECONDARY_KUBE_CONTEXT: The name of kubectl context with secondary GKE cluster access, if any -# TEST_XML_OUTPUT_DIR: Output directory for the test xUnit XML report -# CLIENT_IMAGE_NAME: Test client Docker image name -# GIT_COMMIT: SHA-1 of git commit being built -# TESTING_VERSION: version branch under test: used by the framework to determine the supported PSM -# features. -# Arguments: -# Test case name -# Outputs: -# Writes the output of test execution to stdout, stderr -# Test xUnit report to ${TEST_XML_OUTPUT_DIR}/${test_name}/sponge_log.xml -####################################### -run_test() { - # Test driver usage: - # https://github.com/grpc/psm-interop#basic-usage - local test_name="${1:?Usage: run_test test_name}" - local out_dir="${TEST_XML_OUTPUT_DIR}/${test_name}" - mkdir -pv "${out_dir}" - set -x - python3 -m "tests.${test_name}" \ - --flagfile="${TEST_DRIVER_FLAGFILE}" \ - --kube_context="${KUBE_CONTEXT}" \ - --secondary_kube_context="${SECONDARY_KUBE_CONTEXT}" \ - --client_image="${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" \ - --server_image="${SERVER_IMAGE_NAME}:${GIT_COMMIT}" \ - --testing_version="${TESTING_VERSION}" \ - --force_cleanup \ - --collect_app_logs \ - --log_dir="${out_dir}" \ - --xml_output_file="${out_dir}/sponge_log.xml" \ - |& tee "${out_dir}/sponge_log.log" -} - -####################################### -# Main function: provision software necessary to execute tests, and run them -# Globals: -# KOKORO_ARTIFACTS_DIR -# GITHUB_REPOSITORY_NAME -# SRC_DIR: Populated with absolute path to the source repo -# TEST_DRIVER_REPO_DIR: Populated with the path to the repo containing -# the test driver -# TEST_DRIVER_FULL_DIR: Populated with the path to the test driver source code -# TEST_DRIVER_FLAGFILE: Populated with relative path to test driver flagfile -# TEST_XML_OUTPUT_DIR: Populated with the path to test xUnit XML report -# GIT_ORIGIN_URL: Populated with the origin URL of git repo used for the build -# GIT_COMMIT: Populated with the SHA-1 of git commit being built -# GIT_COMMIT_SHORT: Populated with the short SHA-1 of git commit being built -# KUBE_CONTEXT: Populated with name of kubectl context with GKE cluster access -# SECONDARY_KUBE_CONTEXT: Populated with name of kubectl context with secondary GKE cluster access, if any -# Arguments: -# None -# Outputs: -# Writes the output of test execution to stdout, stderr -####################################### -main() { - local script_dir - script_dir="$(dirname "$0")" - - # Source the test driver from the master branch. - echo "Sourcing test driver install script from: ${TEST_DRIVER_INSTALL_SCRIPT_URL}" - source /dev/stdin <<< "$(curl -s "${TEST_DRIVER_INSTALL_SCRIPT_URL}")" - - activate_gke_cluster GKE_CLUSTER_PSM_LB - activate_secondary_gke_cluster GKE_CLUSTER_PSM_LB - - set -x - if [[ -n "${KOKORO_ARTIFACTS_DIR}" ]]; then - kokoro_setup_test_driver "${GITHUB_REPOSITORY_NAME}" - else - local_setup_test_driver "${script_dir}" - fi - build_docker_images_if_needed - - # Run tests - cd "${TEST_DRIVER_FULL_DIR}" - local failed_tests=0 - test_suites=( - "app_net_test" - "api_listener_test" - "change_backend_service_test" - "failover_test" - "outlier_detection_test" - "remove_neg_test" - "round_robin_test" - ) - if [[ "${TESTING_VERSION}" =~ "master" ]]; then - test_suites+=('bootstrap_generator_test') - fi - for test in "${test_suites[@]}"; do - run_test $test || (( ++failed_tests )) - done - echo "Failed test suites: ${failed_tests}" -} - -main "$@" diff --git a/tools/internal_ci/linux/grpc_xds_url_map.cfg b/tools/internal_ci/linux/grpc_xds_url_map.cfg index 9ac47292452..51612499205 100644 --- a/tools/internal_ci/linux/grpc_xds_url_map.cfg +++ b/tools/internal_ci/linux/grpc_xds_url_map.cfg @@ -15,7 +15,7 @@ # Config file for the internal CI (in protobuf text format) # Location of the continuous shell script in repository. -build_file: "grpc/tools/internal_ci/linux/grpc_xds_url_map.sh" +build_file: "grpc/tools/internal_ci/linux/psm-interop-test-cpp.sh" timeout_mins: 90 action { define_artifacts { @@ -24,3 +24,7 @@ action { strip_prefix: "artifacts" } } +env_vars { + key: "PSM_TEST_SUITE" + value: "url_map" +} diff --git a/tools/internal_ci/linux/grpc_xds_url_map.sh b/tools/internal_ci/linux/grpc_xds_url_map.sh deleted file mode 100755 index bc90935573f..00000000000 --- a/tools/internal_ci/linux/grpc_xds_url_map.sh +++ /dev/null @@ -1,150 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2021 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -eo pipefail - -# Constants -readonly GITHUB_REPOSITORY_NAME="grpc" -readonly TEST_DRIVER_INSTALL_SCRIPT_URL="https://raw.githubusercontent.com/${TEST_DRIVER_REPO_OWNER:-grpc}/psm-interop/${TEST_DRIVER_BRANCH:-main}/.kokoro/psm_interop_kokoro_lib.sh" -## xDS test client Docker images -readonly DOCKER_REGISTRY="us-docker.pkg.dev" -readonly CLIENT_IMAGE_NAME="us-docker.pkg.dev/grpc-testing/psm-interop/cpp-client" -readonly FORCE_IMAGE_BUILD="${FORCE_IMAGE_BUILD:-0}" -readonly BUILD_APP_PATH="interop-testing/build/install/grpc-interop-testing" - -####################################### -# Builds test app Docker images and pushes them to GCR -# Globals: -# BUILD_APP_PATH -# CLIENT_IMAGE_NAME: Test client Docker image name -# GIT_COMMIT: SHA-1 of git commit being built -# Arguments: -# None -# Outputs: -# Writes the output of `gcloud builds submit` to stdout, stderr -####################################### -build_test_app_docker_images() { - echo "Building C++ xDS interop test app Docker images" - docker build -f "${SRC_DIR}/tools/dockerfile/interoptest/grpc_interop_cxx_xds/Dockerfile.xds_client" -t "${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" "${SRC_DIR}" - gcloud -q auth configure-docker "${DOCKER_REGISTRY}" - docker push "${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" - if is_version_branch "${TESTING_VERSION}"; then - tag_and_push_docker_image "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}" "${TESTING_VERSION}" - fi -} - -####################################### -# Builds test app and its docker images unless they already exist -# Globals: -# CLIENT_IMAGE_NAME: Test client Docker image name -# GIT_COMMIT: SHA-1 of git commit being built -# FORCE_IMAGE_BUILD -# Arguments: -# None -# Outputs: -# Writes the output to stdout, stderr -####################################### -build_docker_images_if_needed() { - # Check if images already exist - client_tags="$(gcloud_gcr_list_image_tags "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}")" - printf "Client image: %s:%s\n" "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}" - echo "${client_tags:-Client image not found}" - - # Build if any of the images are missing, or FORCE_IMAGE_BUILD=1 - if [[ "${FORCE_IMAGE_BUILD}" == "1" || -z "${client_tags}" ]]; then - build_test_app_docker_images - else - echo "Skipping C++ test app build" - fi -} - -####################################### -# Executes the test case -# Globals: -# TEST_DRIVER_FLAGFILE: Relative path to test driver flagfile -# KUBE_CONTEXT: The name of kubectl context with GKE cluster access -# TEST_XML_OUTPUT_DIR: Output directory for the test xUnit XML report -# CLIENT_IMAGE_NAME: Test client Docker image name -# GIT_COMMIT: SHA-1 of git commit being built -# TESTING_VERSION: version branch under test: used by the framework to determine the supported PSM -# features. -# Arguments: -# Test case name -# Outputs: -# Writes the output of test execution to stdout, stderr -# Test xUnit report to ${TEST_XML_OUTPUT_DIR}/${test_name}/sponge_log.xml -####################################### -run_test() { - # Test driver usage: - # https://github.com/grpc/psm-interop#basic-usage - local test_name="${1:?Usage: run_test test_name}" - local out_dir="${TEST_XML_OUTPUT_DIR}/${test_name}" - mkdir -pv "${out_dir}" - set -x - python3 -m "tests.${test_name}" \ - --flagfile="${TEST_DRIVER_FLAGFILE}" \ - --flagfile="config/url-map.cfg" \ - --kube_context="${KUBE_CONTEXT}" \ - --client_image="${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" \ - --testing_version="${TESTING_VERSION}" \ - --collect_app_logs \ - --log_dir="${out_dir}" \ - --xml_output_file="${out_dir}/sponge_log.xml" \ - |& tee "${out_dir}/sponge_log.log" -} - -####################################### -# Main function: provision software necessary to execute tests, and run them -# Globals: -# KOKORO_ARTIFACTS_DIR -# GITHUB_REPOSITORY_NAME -# SRC_DIR: Populated with absolute path to the source repo -# TEST_DRIVER_REPO_DIR: Populated with the path to the repo containing -# the test driver -# TEST_DRIVER_FULL_DIR: Populated with the path to the test driver source code -# TEST_DRIVER_FLAGFILE: Populated with relative path to test driver flagfile -# TEST_XML_OUTPUT_DIR: Populated with the path to test xUnit XML report -# GIT_ORIGIN_URL: Populated with the origin URL of git repo used for the build -# GIT_COMMIT: Populated with the SHA-1 of git commit being built -# GIT_COMMIT_SHORT: Populated with the short SHA-1 of git commit being built -# KUBE_CONTEXT: Populated with name of kubectl context with GKE cluster access -# Arguments: -# None -# Outputs: -# Writes the output of test execution to stdout, stderr -####################################### -main() { - local script_dir - script_dir="$(dirname "$0")" - - # Source the test driver from the master branch. - echo "Sourcing test driver install script from: ${TEST_DRIVER_INSTALL_SCRIPT_URL}" - source /dev/stdin <<< "$(curl -s "${TEST_DRIVER_INSTALL_SCRIPT_URL}")" - - activate_gke_cluster GKE_CLUSTER_PSM_BASIC - - set -x - if [[ -n "${KOKORO_ARTIFACTS_DIR}" ]]; then - kokoro_setup_test_driver "${GITHUB_REPOSITORY_NAME}" - else - local_setup_test_driver "${script_dir}" - fi - build_docker_images_if_needed - # Run tests - cd "${TEST_DRIVER_FULL_DIR}" - run_test url_map || echo "Failed url_map test" -} - -main "$@" diff --git a/tools/internal_ci/linux/grpc_xds_url_map_python.cfg b/tools/internal_ci/linux/grpc_xds_url_map_python.cfg index 4e91dc5b8f3..efc17f5e3e3 100644 --- a/tools/internal_ci/linux/grpc_xds_url_map_python.cfg +++ b/tools/internal_ci/linux/grpc_xds_url_map_python.cfg @@ -15,7 +15,7 @@ # Config file for the internal CI (in protobuf text format) # Location of the continuous shell script in repository. -build_file: "grpc/tools/internal_ci/linux/grpc_xds_url_map_python.sh" +build_file: "grpc/tools/internal_ci/linux/psm-interop-test-python.sh" timeout_mins: 90 action { define_artifacts { @@ -24,3 +24,7 @@ action { strip_prefix: "artifacts" } } +env_vars { + key: "PSM_TEST_SUITE" + value: "url_map" +} diff --git a/tools/internal_ci/linux/grpc_xds_url_map_python.sh b/tools/internal_ci/linux/grpc_xds_url_map_python.sh deleted file mode 100755 index e12cda8afe7..00000000000 --- a/tools/internal_ci/linux/grpc_xds_url_map_python.sh +++ /dev/null @@ -1,160 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2021 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -eo pipefail - -# Constants -readonly GITHUB_REPOSITORY_NAME="grpc" -readonly TEST_DRIVER_INSTALL_SCRIPT_URL="https://raw.githubusercontent.com/${TEST_DRIVER_REPO_OWNER:-grpc}/psm-interop/${TEST_DRIVER_BRANCH:-main}/.kokoro/psm_interop_kokoro_lib.sh" -## xDS test client Docker images -readonly DOCKER_REGISTRY="us-docker.pkg.dev" -readonly CLIENT_IMAGE_NAME="us-docker.pkg.dev/grpc-testing/psm-interop/python-client" -readonly FORCE_IMAGE_BUILD="${FORCE_IMAGE_BUILD:-0}" -readonly BUILD_APP_PATH="interop-testing/build/install/grpc-interop-testing" -readonly LANGUAGE_NAME="Python" - -####################################### -# Builds test app Docker images and pushes them to GCR -# Globals: -# BUILD_APP_PATH -# CLIENT_IMAGE_NAME: Test client Docker image name -# GIT_COMMIT: SHA-1 of git commit being built -# Arguments: -# None -# Outputs: -# Writes the output of `gcloud builds submit` to stdout, stderr -####################################### -build_test_app_docker_images() { - echo "Building ${LANGUAGE_NAME} xDS interop test app Docker images" - - pushd "${SRC_DIR}" - docker build \ - -f src/python/grpcio_tests/tests_py3_only/interop/Dockerfile.client \ - -t "${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" \ - . - - popd - - gcloud -q auth configure-docker "${DOCKER_REGISTRY}" - - docker push "${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" - if is_version_branch "${TESTING_VERSION}"; then - tag_and_push_docker_image "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}" "${TESTING_VERSION}" - fi -} - -####################################### -# Builds test app and its docker images unless they already exist -# Globals: -# CLIENT_IMAGE_NAME: Test client Docker image name -# GIT_COMMIT: SHA-1 of git commit being built -# FORCE_IMAGE_BUILD -# Arguments: -# None -# Outputs: -# Writes the output to stdout, stderr -####################################### -build_docker_images_if_needed() { - # Check if images already exist - client_tags="$(gcloud_gcr_list_image_tags "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}")" - printf "Client image: %s:%s\n" "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}" - echo "${client_tags:-Client image not found}" - - # Build if any of the images are missing, or FORCE_IMAGE_BUILD=1 - if [[ "${FORCE_IMAGE_BUILD}" == "1" || -z "${client_tags}" ]]; then - build_test_app_docker_images - else - echo "Skipping ${LANGUAGE_NAME} test app build" - fi -} - -####################################### -# Executes the test case -# Globals: -# TEST_DRIVER_FLAGFILE: Relative path to test driver flagfile -# KUBE_CONTEXT: The name of kubectl context with GKE cluster access -# TEST_XML_OUTPUT_DIR: Output directory for the test xUnit XML report -# CLIENT_IMAGE_NAME: Test client Docker image name -# GIT_COMMIT: SHA-1 of git commit being built -# TESTING_VERSION: version branch under test: used by the framework to determine the supported PSM -# features. -# Arguments: -# Test case name -# Outputs: -# Writes the output of test execution to stdout, stderr -# Test xUnit report to ${TEST_XML_OUTPUT_DIR}/${test_name}/sponge_log.xml -####################################### -run_test() { - # Test driver usage: - # https://github.com/grpc/psm-interop#basic-usage - local test_name="${1:?Usage: run_test test_name}" - local out_dir="${TEST_XML_OUTPUT_DIR}/${test_name}" - mkdir -pv "${out_dir}" - set -x - python3 -m "tests.${test_name}" \ - --flagfile="${TEST_DRIVER_FLAGFILE}" \ - --flagfile="config/url-map.cfg" \ - --kube_context="${KUBE_CONTEXT}" \ - --client_image="${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" \ - --testing_version="${TESTING_VERSION}" \ - --collect_app_logs \ - --log_dir="${out_dir}" \ - --xml_output_file="${out_dir}/sponge_log.xml" \ - |& tee "${out_dir}/sponge_log.log" -} - -####################################### -# Main function: provision software necessary to execute tests, and run them -# Globals: -# KOKORO_ARTIFACTS_DIR -# GITHUB_REPOSITORY_NAME -# SRC_DIR: Populated with absolute path to the source repo -# TEST_DRIVER_REPO_DIR: Populated with the path to the repo containing -# the test driver -# TEST_DRIVER_FULL_DIR: Populated with the path to the test driver source code -# TEST_DRIVER_FLAGFILE: Populated with relative path to test driver flagfile -# TEST_XML_OUTPUT_DIR: Populated with the path to test xUnit XML report -# GIT_ORIGIN_URL: Populated with the origin URL of git repo used for the build -# GIT_COMMIT: Populated with the SHA-1 of git commit being built -# GIT_COMMIT_SHORT: Populated with the short SHA-1 of git commit being built -# KUBE_CONTEXT: Populated with name of kubectl context with GKE cluster access -# Arguments: -# None -# Outputs: -# Writes the output of test execution to stdout, stderr -####################################### -main() { - local script_dir - script_dir="$(dirname "$0")" - - # Source the test driver from the master branch. - echo "Sourcing test driver install script from: ${TEST_DRIVER_INSTALL_SCRIPT_URL}" - source /dev/stdin <<< "$(curl -s "${TEST_DRIVER_INSTALL_SCRIPT_URL}")" - - activate_gke_cluster GKE_CLUSTER_PSM_BASIC - - set -x - if [[ -n "${KOKORO_ARTIFACTS_DIR}" ]]; then - kokoro_setup_test_driver "${GITHUB_REPOSITORY_NAME}" - else - local_setup_test_driver "${script_dir}" - fi - build_docker_images_if_needed - # Run tests - cd "${TEST_DRIVER_FULL_DIR}" - run_test url_map || echo "Failed url_map test" -} - -main "$@" diff --git a/tools/internal_ci/linux/psm-csm-python.cfg b/tools/internal_ci/linux/psm-csm-python.cfg index 5ae3f83063d..857f1fb2936 100644 --- a/tools/internal_ci/linux/psm-csm-python.cfg +++ b/tools/internal_ci/linux/psm-csm-python.cfg @@ -15,7 +15,7 @@ # Config file for the internal CI (in protobuf text format) # Location of the continuous shell script in repository. -build_file: "grpc/tools/internal_ci/linux/psm-csm-python.sh" +build_file: "grpc/tools/internal_ci/linux/psm-interop-test-python.sh" timeout_mins: 240 action { define_artifacts { @@ -24,3 +24,7 @@ action { strip_prefix: "artifacts" } } +env_vars { + key: "PSM_TEST_SUITE" + value: "csm" +} diff --git a/tools/internal_ci/linux/psm-csm-python.sh b/tools/internal_ci/linux/psm-csm-python.sh deleted file mode 100755 index 4b6ee20ce3d..00000000000 --- a/tools/internal_ci/linux/psm-csm-python.sh +++ /dev/null @@ -1,190 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2024 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -eo pipefail - -# Constants -readonly GITHUB_REPOSITORY_NAME="grpc" -readonly TEST_DRIVER_INSTALL_SCRIPT_URL="https://raw.githubusercontent.com/${TEST_DRIVER_REPO_OWNER:-grpc}/psm-interop/${TEST_DRIVER_BRANCH:-main}/.kokoro/psm_interop_kokoro_lib.sh" -## xDS test server/client Docker images -readonly DOCKER_REGISTRY="us-docker.pkg.dev" -readonly SERVER_IMAGE_NAME="us-docker.pkg.dev/grpc-testing/psm-interop/python-server" -readonly CLIENT_IMAGE_NAME="us-docker.pkg.dev/grpc-testing/psm-interop/python-client" -readonly FORCE_IMAGE_BUILD="${FORCE_IMAGE_BUILD:-0}" -readonly BUILD_APP_PATH="interop-testing/build/install/grpc-interop-testing" - -####################################### -# Builds test app Docker images and pushes them to GCR -# Globals: -# BUILD_APP_PATH -# SERVER_IMAGE_NAME: Test server Docker image name -# CLIENT_IMAGE_NAME: Test client Docker image name -# GIT_COMMIT: SHA-1 of git commit being built -# TESTING_VERSION: version branch under test, f.e. v1.42.x, master -# Arguments: -# None -# Outputs: -# Writes the output of `gcloud builds submit` to stdout, stderr -####################################### -build_test_app_docker_images() { - echo "Building Python xDS interop test app Docker images" - - pushd "${SRC_DIR}" - docker build \ - -f src/python/grpcio_tests/tests_py3_only/interop/Dockerfile.client \ - -t "${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" \ - . - - docker build \ - -f src/python/grpcio_tests/tests_py3_only/interop/Dockerfile.server \ - -t "${SERVER_IMAGE_NAME}:${GIT_COMMIT}" \ - . - - popd - - gcloud -q auth configure-docker "${DOCKER_REGISTRY}" - - docker push "${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" - docker push "${SERVER_IMAGE_NAME}:${GIT_COMMIT}" - - if is_version_branch "${TESTING_VERSION}"; then - tag_and_push_docker_image "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}" "${TESTING_VERSION}" - tag_and_push_docker_image "${SERVER_IMAGE_NAME}" "${GIT_COMMIT}" "${TESTING_VERSION}" - fi -} - -####################################### -# Builds test app and its docker images unless they already exist -# Globals: -# SERVER_IMAGE_NAME: Test server Docker image name -# CLIENT_IMAGE_NAME: Test client Docker image name -# GIT_COMMIT: SHA-1 of git commit being built -# FORCE_IMAGE_BUILD -# Arguments: -# None -# Outputs: -# Writes the output to stdout, stderr -####################################### -build_docker_images_if_needed() { - # Check if images already exist - server_tags="$(gcloud_gcr_list_image_tags "${SERVER_IMAGE_NAME}" "${GIT_COMMIT}")" - printf "Server image: %s:%s\n" "${SERVER_IMAGE_NAME}" "${GIT_COMMIT}" - echo "${server_tags:-Server image not found}" - - client_tags="$(gcloud_gcr_list_image_tags "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}")" - printf "Client image: %s:%s\n" "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}" - echo "${client_tags:-Client image not found}" - - # Build if any of the images are missing, or FORCE_IMAGE_BUILD=1 - if [[ "${FORCE_IMAGE_BUILD}" == "1" || -z "${server_tags}" || -z "${client_tags}" ]]; then - build_test_app_docker_images - else - echo "Skipping Python test app build" - fi -} - -####################################### -# Executes the test case -# Globals: -# TEST_DRIVER_FLAGFILE: Relative path to test driver flagfile -# KUBE_CONTEXT: The name of kubectl context with GKE cluster access -# TEST_XML_OUTPUT_DIR: Output directory for the test xUnit XML report -# SERVER_IMAGE_NAME: Test server Docker image name -# CLIENT_IMAGE_NAME: Test client Docker image name -# GIT_COMMIT: SHA-1 of git commit being built -# TESTING_VERSION: version branch under test: used by the framework to determine the supported PSM -# features. -# Arguments: -# Test case name -# Outputs: -# Writes the output of test execution to stdout, stderr -# Test xUnit report to ${TEST_XML_OUTPUT_DIR}/${test_name}/sponge_log.xml -####################################### -run_test() { - # Test driver usage: - # https://github.com/grpc/psm-interop#basic-usage - local test_name="${1:?Usage: run_test test_name}" - local out_dir="${TEST_XML_OUTPUT_DIR}/${test_name}" - mkdir -pv "${out_dir}" - set -x - python3 -m "tests.${test_name}" \ - --flagfile="${TEST_DRIVER_FLAGFILE}" \ - --flagfile="config/common-csm.cfg" \ - --kube_context="${KUBE_CONTEXT}" \ - --server_image="${SERVER_IMAGE_NAME}:${GIT_COMMIT}" \ - --client_image="${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" \ - --testing_version="${TESTING_VERSION}" \ - --nocheck_local_certs \ - --force_cleanup \ - --collect_app_logs \ - --log_dir="${out_dir}" \ - --xml_output_file="${out_dir}/sponge_log.xml" \ - |& tee "${out_dir}/sponge_log.log" - set +x -} - -####################################### -# Main function: provision software necessary to execute tests, and run them -# Globals: -# KOKORO_ARTIFACTS_DIR -# GITHUB_REPOSITORY_NAME -# SRC_DIR: Populated with absolute path to the source repo -# TEST_DRIVER_REPO_DIR: Populated with the path to the repo containing -# the test driver -# TEST_DRIVER_FULL_DIR: Populated with the path to the test driver source code -# TEST_DRIVER_FLAGFILE: Populated with relative path to test driver flagfile -# TEST_XML_OUTPUT_DIR: Populated with the path to test xUnit XML report -# GIT_ORIGIN_URL: Populated with the origin URL of git repo used for the build -# GIT_COMMIT: Populated with the SHA-1 of git commit being built -# GIT_COMMIT_SHORT: Populated with the short SHA-1 of git commit being built -# KUBE_CONTEXT: Populated with name of kubectl context with GKE cluster access -# Arguments: -# None -# Outputs: -# Writes the output of test execution to stdout, stderr -####################################### -main() { - local script_dir - script_dir="$(dirname "$0")" - - # Source the test driver from the master branch. - echo "Sourcing test driver install script from: ${TEST_DRIVER_INSTALL_SCRIPT_URL}" - source /dev/stdin <<< "$(curl -s "${TEST_DRIVER_INSTALL_SCRIPT_URL}")" - - activate_gke_cluster GKE_CLUSTER_PSM_CSM - - if [[ -n "${KOKORO_ARTIFACTS_DIR}" ]]; then - kokoro_setup_test_driver "${GITHUB_REPOSITORY_NAME}" - else - local_setup_test_driver "${script_dir}" - fi - build_docker_images_if_needed - # Run tests - cd "${TEST_DRIVER_FULL_DIR}" - local failed_tests=0 - test_suites=( - "gamma.gamma_baseline_test" - "gamma.affinity_session_drain_test" - "gamma.affinity_test" - "app_net_ssa_test" - ) - for test in "${test_suites[@]}"; do - run_test $test || (( ++failed_tests )) - done - echo "Failed test suites: ${failed_tests}" -} - - -main "$@" diff --git a/tools/internal_ci/linux/psm-csm.cfg b/tools/internal_ci/linux/psm-csm.cfg index 0545b9298d8..bc44a745869 100644 --- a/tools/internal_ci/linux/psm-csm.cfg +++ b/tools/internal_ci/linux/psm-csm.cfg @@ -15,7 +15,7 @@ # Config file for the internal CI (in protobuf text format) # Location of the continuous shell script in repository. -build_file: "grpc/tools/internal_ci/linux/psm-csm.sh" +build_file: "grpc/tools/internal_ci/linux/psm-interop-test-cpp.sh" timeout_mins: 120 action { define_artifacts { @@ -24,3 +24,7 @@ action { strip_prefix: "artifacts" } } +env_vars { + key: "PSM_TEST_SUITE" + value: "csm" +} diff --git a/tools/internal_ci/linux/psm-csm.sh b/tools/internal_ci/linux/psm-csm.sh deleted file mode 100755 index 7b0c596e431..00000000000 --- a/tools/internal_ci/linux/psm-csm.sh +++ /dev/null @@ -1,175 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2023 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -eo pipefail - -# Constants -readonly GITHUB_REPOSITORY_NAME="grpc" -readonly TEST_DRIVER_INSTALL_SCRIPT_URL="https://raw.githubusercontent.com/${TEST_DRIVER_REPO_OWNER:-grpc}/psm-interop/${TEST_DRIVER_BRANCH:-main}/.kokoro/psm_interop_kokoro_lib.sh" -## xDS test server/client Docker images -readonly DOCKER_REGISTRY="us-docker.pkg.dev" -readonly SERVER_IMAGE_NAME="us-docker.pkg.dev/grpc-testing/psm-interop/cpp-server" -readonly CLIENT_IMAGE_NAME="us-docker.pkg.dev/grpc-testing/psm-interop/cpp-client" -readonly FORCE_IMAGE_BUILD="${FORCE_IMAGE_BUILD:-0}" -readonly BUILD_APP_PATH="interop-testing/build/install/grpc-interop-testing" - -####################################### -# Builds test app Docker images and pushes them to GCR -# Globals: -# BUILD_APP_PATH -# SERVER_IMAGE_NAME: Test server Docker image name -# CLIENT_IMAGE_NAME: Test client Docker image name -# GIT_COMMIT: SHA-1 of git commit being built -# TESTING_VERSION: version branch under test, f.e. v1.42.x, master -# Arguments: -# None -# Outputs: -# Writes the output of `gcloud builds submit` to stdout, stderr -####################################### -build_test_app_docker_images() { - echo "Building C++ xDS interop test app Docker images" - docker build -f "${SRC_DIR}/tools/dockerfile/interoptest/grpc_interop_cxx_xds/Dockerfile.xds_client" -t "${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" "${SRC_DIR}" - docker build -f "${SRC_DIR}/tools/dockerfile/interoptest/grpc_interop_cxx_xds/Dockerfile.xds_server" -t "${SERVER_IMAGE_NAME}:${GIT_COMMIT}" "${SRC_DIR}" - gcloud -q auth configure-docker "${DOCKER_REGISTRY}" - docker push "${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" - docker push "${SERVER_IMAGE_NAME}:${GIT_COMMIT}" - if is_version_branch "${TESTING_VERSION}"; then - tag_and_push_docker_image "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}" "${TESTING_VERSION}" - tag_and_push_docker_image "${SERVER_IMAGE_NAME}" "${GIT_COMMIT}" "${TESTING_VERSION}" - fi -} - -####################################### -# Builds test app and its docker images unless they already exist -# Globals: -# SERVER_IMAGE_NAME: Test server Docker image name -# CLIENT_IMAGE_NAME: Test client Docker image name -# GIT_COMMIT: SHA-1 of git commit being built -# FORCE_IMAGE_BUILD -# Arguments: -# None -# Outputs: -# Writes the output to stdout, stderr -####################################### -build_docker_images_if_needed() { - # Check if images already exist - server_tags="$(gcloud_gcr_list_image_tags "${SERVER_IMAGE_NAME}" "${GIT_COMMIT}")" - printf "Server image: %s:%s\n" "${SERVER_IMAGE_NAME}" "${GIT_COMMIT}" - echo "${server_tags:-Server image not found}" - - client_tags="$(gcloud_gcr_list_image_tags "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}")" - printf "Client image: %s:%s\n" "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}" - echo "${client_tags:-Client image not found}" - - # Build if any of the images are missing, or FORCE_IMAGE_BUILD=1 - if [[ "${FORCE_IMAGE_BUILD}" == "1" || -z "${server_tags}" || -z "${client_tags}" ]]; then - build_test_app_docker_images - else - echo "Skipping C++ test app build" - fi -} - -####################################### -# Executes the test case -# Globals: -# TEST_DRIVER_FLAGFILE: Relative path to test driver flagfile -# KUBE_CONTEXT: The name of kubectl context with GKE cluster access -# TEST_XML_OUTPUT_DIR: Output directory for the test xUnit XML report -# SERVER_IMAGE_NAME: Test server Docker image name -# CLIENT_IMAGE_NAME: Test client Docker image name -# GIT_COMMIT: SHA-1 of git commit being built -# TESTING_VERSION: version branch under test: used by the framework to determine the supported PSM -# features. -# Arguments: -# Test case name -# Outputs: -# Writes the output of test execution to stdout, stderr -# Test xUnit report to ${TEST_XML_OUTPUT_DIR}/${test_name}/sponge_log.xml -####################################### -run_test() { - # Test driver usage: - # https://github.com/grpc/psm-interop#basic-usage - local test_name="${1:?Usage: run_test test_name}" - local out_dir="${TEST_XML_OUTPUT_DIR}/${test_name}" - mkdir -pv "${out_dir}" - set -x - python3 -m "tests.${test_name}" \ - --flagfile="${TEST_DRIVER_FLAGFILE}" \ - --flagfile="config/common-csm.cfg" \ - --kube_context="${KUBE_CONTEXT}" \ - --server_image="${SERVER_IMAGE_NAME}:${GIT_COMMIT}" \ - --client_image="${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" \ - --testing_version="${TESTING_VERSION}" \ - --force_cleanup \ - --collect_app_logs \ - --log_dir="${out_dir}" \ - --xml_output_file="${out_dir}/sponge_log.xml" \ - |& tee "${out_dir}/sponge_log.log" -} - -####################################### -# Main function: provision software necessary to execute tests, and run them -# Globals: -# KOKORO_ARTIFACTS_DIR -# GITHUB_REPOSITORY_NAME -# SRC_DIR: Populated with absolute path to the source repo -# TEST_DRIVER_REPO_DIR: Populated with the path to the repo containing -# the test driver -# TEST_DRIVER_FULL_DIR: Populated with the path to the test driver source code -# TEST_DRIVER_FLAGFILE: Populated with relative path to test driver flagfile -# TEST_XML_OUTPUT_DIR: Populated with the path to test xUnit XML report -# GIT_ORIGIN_URL: Populated with the origin URL of git repo used for the build -# GIT_COMMIT: Populated with the SHA-1 of git commit being built -# GIT_COMMIT_SHORT: Populated with the short SHA-1 of git commit being built -# KUBE_CONTEXT: Populated with name of kubectl context with GKE cluster access -# Arguments: -# None -# Outputs: -# Writes the output of test execution to stdout, stderr -####################################### -main() { - local script_dir - script_dir="$(dirname "$0")" - - # Source the test driver from the master branch. - echo "Sourcing test driver install script from: ${TEST_DRIVER_INSTALL_SCRIPT_URL}" - source /dev/stdin <<< "$(curl -s "${TEST_DRIVER_INSTALL_SCRIPT_URL}")" - - activate_gke_cluster GKE_CLUSTER_PSM_CSM - - set -x - if [[ -n "${KOKORO_ARTIFACTS_DIR}" ]]; then - kokoro_setup_test_driver "${GITHUB_REPOSITORY_NAME}" - else - local_setup_test_driver "${script_dir}" - fi - build_docker_images_if_needed - # Run tests - cd "${TEST_DRIVER_FULL_DIR}" - local failed_tests=0 - test_suites=( - "gamma.gamma_baseline_test" - "gamma.affinity_test" - "gamma.affinity_session_drain_test" - "gamma.csm_observability_test" - "app_net_ssa_test" - ) - for test in "${test_suites[@]}"; do - run_test $test || (( ++failed_tests )) - done - echo "Failed test suites: ${failed_tests}" -} - -main "$@" diff --git a/tools/internal_ci/linux/psm-interop-build-cpp.sh b/tools/internal_ci/linux/psm-interop-build-cpp.sh new file mode 100755 index 00000000000..672cb4f156c --- /dev/null +++ b/tools/internal_ci/linux/psm-interop-build-cpp.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +# Copyright 2024 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +set -eo pipefail + +####################################### +# Builds test app Docker images and pushes them to GCR. +# Called from psm_interop_kokoro_lib.sh. +# +# Globals: +# SRC_DIR: Absolute path to the source repo on Kokoro VM +# SERVER_IMAGE_NAME: Test server Docker image name +# CLIENT_IMAGE_NAME: Test client Docker image name +# GIT_COMMIT: SHA-1 of git commit being built +# DOCKER_REGISTRY: Docker registry to push to +# Outputs: +# Writes the output of docker image build stdout, stderr +####################################### +psm::lang::build_docker_images() { + local client_dockerfile="tools/dockerfile/interoptest/grpc_interop_cxx_xds/Dockerfile.xds_client" + local server_dockerfile="tools/dockerfile/interoptest/grpc_interop_cxx_xds/Dockerfile.xds_server" + psm::build::docker_images_generic "${client_dockerfile}" "${server_dockerfile}" +} diff --git a/tools/internal_ci/linux/psm-interop-build-python.sh b/tools/internal_ci/linux/psm-interop-build-python.sh new file mode 100755 index 00000000000..5a2ab9e8c01 --- /dev/null +++ b/tools/internal_ci/linux/psm-interop-build-python.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +# Copyright 2024 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +set -eo pipefail + +####################################### +# Builds test app Docker images and pushes them to GCR. +# Called from psm_interop_kokoro_lib.sh. +# +# Globals: +# SRC_DIR: Absolute path to the source repo on Kokoro VM +# SERVER_IMAGE_NAME: Test server Docker image name +# CLIENT_IMAGE_NAME: Test client Docker image name +# GIT_COMMIT: SHA-1 of git commit being built +# DOCKER_REGISTRY: Docker registry to push to +# Outputs: +# Writes the output of docker image build stdout, stderr +####################################### +psm::lang::build_docker_images() { + local client_dockerfile="src/python/grpcio_tests/tests_py3_only/interop/Dockerfile.client" + local server_dockerfile="src/python/grpcio_tests/tests_py3_only/interop/Dockerfile.server" + psm::build::docker_images_generic "${client_dockerfile}" "${server_dockerfile}" +} diff --git a/tools/internal_ci/linux/psm-interop-install-lib.sh b/tools/internal_ci/linux/psm-interop-install-lib.sh new file mode 100755 index 00000000000..8b92344e392 --- /dev/null +++ b/tools/internal_ci/linux/psm-interop-install-lib.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +# Copyright 2024 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +set -eo pipefail + +# Used locally. +readonly TEST_DRIVER_INSTALL_SCRIPT_URL="https://raw.githubusercontent.com/${TEST_DRIVER_REPO_OWNER:-grpc}/psm-interop/${TEST_DRIVER_BRANCH:-main}/.kokoro/psm_interop_kokoro_lib.sh" + +psm::lang::source_install_lib() { + echo "Sourcing test driver install script from: ${TEST_DRIVER_INSTALL_SCRIPT_URL}" + local install_lib + # Download to a tmp file. + install_lib="$(mktemp -d)/psm_interop_kokoro_lib.sh" + curl -s --retry-connrefused --retry 5 -o "${install_lib}" "${TEST_DRIVER_INSTALL_SCRIPT_URL}" + # Checksum. + if command -v sha256sum &> /dev/null; then + echo "Install script checksum:" + sha256sum "${install_lib}" + fi + source "${install_lib}" +} diff --git a/tools/internal_ci/linux/psm-interop-test-cpp.sh b/tools/internal_ci/linux/psm-interop-test-cpp.sh new file mode 100755 index 00000000000..8774b81b245 --- /dev/null +++ b/tools/internal_ci/linux/psm-interop-test-cpp.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +# Copyright 2024 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +set -eo pipefail + +# Input parameters to psm:: methods of the install script. +readonly GRPC_LANGUAGE="cpp" +readonly BUILD_SCRIPT_DIR="$(dirname "$0")" + +source "${BUILD_SCRIPT_DIR}/psm-interop-install-lib.sh" +psm::lang::source_install_lib +source "${BUILD_SCRIPT_DIR}/psm-interop-build-${GRPC_LANGUAGE}.sh" +psm::run "${PSM_TEST_SUITE}" diff --git a/tools/internal_ci/linux/psm-interop-test-python.sh b/tools/internal_ci/linux/psm-interop-test-python.sh new file mode 100755 index 00000000000..3b804946389 --- /dev/null +++ b/tools/internal_ci/linux/psm-interop-test-python.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +# Copyright 2024 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +set -eo pipefail + +# Input parameters to psm:: methods of the install script. +readonly GRPC_LANGUAGE="python" +readonly BUILD_SCRIPT_DIR="$(dirname "$0")" + +source "${BUILD_SCRIPT_DIR}/psm-interop-install-lib.sh" +psm::lang::source_install_lib +source "${BUILD_SCRIPT_DIR}/psm-interop-build-${GRPC_LANGUAGE}.sh" +psm::run "${PSM_TEST_SUITE}" diff --git a/tools/internal_ci/linux/psm-security-python.cfg b/tools/internal_ci/linux/psm-security-python.cfg index 02fe4044929..54660a18512 100644 --- a/tools/internal_ci/linux/psm-security-python.cfg +++ b/tools/internal_ci/linux/psm-security-python.cfg @@ -15,7 +15,7 @@ # Config file for the internal CI (in protobuf text format) # Location of the continuous shell script in repository. -build_file: "grpc/tools/internal_ci/linux/psm-security-python.sh" +build_file: "grpc/tools/internal_ci/linux/psm-interop-test-python.sh" timeout_mins: 240 action { define_artifacts { @@ -24,3 +24,7 @@ action { strip_prefix: "artifacts" } } +env_vars { + key: "PSM_TEST_SUITE" + value: "security" +} diff --git a/tools/internal_ci/linux/psm-security-python.sh b/tools/internal_ci/linux/psm-security-python.sh deleted file mode 100755 index ee1aa70e7c0..00000000000 --- a/tools/internal_ci/linux/psm-security-python.sh +++ /dev/null @@ -1,185 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2021 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -eo pipefail - -# Constants -readonly GITHUB_REPOSITORY_NAME="grpc" -readonly TEST_DRIVER_INSTALL_SCRIPT_URL="https://raw.githubusercontent.com/${TEST_DRIVER_REPO_OWNER:-grpc}/psm-interop/${TEST_DRIVER_BRANCH:-main}/.kokoro/psm_interop_kokoro_lib.sh" -## xDS test server/client Docker images -readonly DOCKER_REGISTRY="us-docker.pkg.dev" -readonly SERVER_IMAGE_NAME="us-docker.pkg.dev/grpc-testing/psm-interop/python-server" -readonly CLIENT_IMAGE_NAME="us-docker.pkg.dev/grpc-testing/psm-interop/python-client" -readonly FORCE_IMAGE_BUILD="${FORCE_IMAGE_BUILD:-0}" -readonly BUILD_APP_PATH="interop-testing/build/install/grpc-interop-testing" -readonly LANGUAGE_NAME="Python" - -####################################### -# Builds test app Docker images and pushes them to GCR -# Globals: -# BUILD_APP_PATH -# SERVER_IMAGE_NAME: Test server Docker image name -# CLIENT_IMAGE_NAME: Test client Docker image name -# GIT_COMMIT: SHA-1 of git commit being built -# TESTING_VERSION: version branch under test, f.e. v1.42.x, master -# Arguments: -# None -# Outputs: -# Writes the output of `gcloud builds submit` to stdout, stderr -####################################### -build_test_app_docker_images() { - echo "Building ${LANGUAGE_NAME} xDS interop test app Docker images" - - pushd "${SRC_DIR}" - docker build \ - -f src/python/grpcio_tests/tests_py3_only/interop/Dockerfile.client \ - -t "${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" \ - . - - docker build \ - -f src/python/grpcio_tests/tests_py3_only/interop/Dockerfile.server \ - -t "${SERVER_IMAGE_NAME}:${GIT_COMMIT}" \ - . - - popd - - gcloud -q auth configure-docker "${DOCKER_REGISTRY}" - - docker push "${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" - docker push "${SERVER_IMAGE_NAME}:${GIT_COMMIT}" - - if is_version_branch "${TESTING_VERSION}"; then - tag_and_push_docker_image "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}" "${TESTING_VERSION}" - tag_and_push_docker_image "${SERVER_IMAGE_NAME}" "${GIT_COMMIT}" "${TESTING_VERSION}" - fi -} - -####################################### -# Builds test app and its docker images unless they already exist -# Globals: -# SERVER_IMAGE_NAME: Test server Docker image name -# CLIENT_IMAGE_NAME: Test client Docker image name -# GIT_COMMIT: SHA-1 of git commit being built -# FORCE_IMAGE_BUILD -# Arguments: -# None -# Outputs: -# Writes the output to stdout, stderr -####################################### -build_docker_images_if_needed() { - # Check if images already exist - server_tags="$(gcloud_gcr_list_image_tags "${SERVER_IMAGE_NAME}" "${GIT_COMMIT}")" - printf "Server image: %s:%s\n" "${SERVER_IMAGE_NAME}" "${GIT_COMMIT}" - echo "${server_tags:-Server image not found}" - - client_tags="$(gcloud_gcr_list_image_tags "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}")" - printf "Client image: %s:%s\n" "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}" - echo "${client_tags:-Client image not found}" - - # Build if any of the images are missing, or FORCE_IMAGE_BUILD=1 - if [[ "${FORCE_IMAGE_BUILD}" == "1" || -z "${server_tags}" || -z "${client_tags}" ]]; then - build_test_app_docker_images - else - echo "Skipping ${LANGUAGE_NAME} test app build" - fi -} - -####################################### -# Executes the test case -# Globals: -# TEST_DRIVER_FLAGFILE: Relative path to test driver flagfile -# KUBE_CONTEXT: The name of kubectl context with GKE cluster access -# TEST_XML_OUTPUT_DIR: Output directory for the test xUnit XML report -# SERVER_IMAGE_NAME: Test server Docker image name -# CLIENT_IMAGE_NAME: Test client Docker image name -# GIT_COMMIT: SHA-1 of git commit being built -# TESTING_VERSION: version branch under test: used by the framework to determine the supported PSM -# features. -# Arguments: -# Test case name -# Outputs: -# Writes the output of test execution to stdout, stderr -# Test xUnit report to ${TEST_XML_OUTPUT_DIR}/${test_name}/sponge_log.xml -####################################### -run_test() { - # Test driver usage: - # https://github.com/grpc/psm-interop#basic-usage - local test_name="${1:?Usage: run_test test_name}" - local out_dir="${TEST_XML_OUTPUT_DIR}/${test_name}" - mkdir -pv "${out_dir}" - set -x - python3 -m "tests.${test_name}" \ - --flagfile="${TEST_DRIVER_FLAGFILE}" \ - --kube_context="${KUBE_CONTEXT}" \ - --server_image="${SERVER_IMAGE_NAME}:${GIT_COMMIT}" \ - --client_image="${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" \ - --testing_version="${TESTING_VERSION}" \ - --nocheck_local_certs \ - --force_cleanup \ - --collect_app_logs \ - --log_dir="${out_dir}" \ - --xml_output_file="${out_dir}/sponge_log.xml" \ - |& tee "${out_dir}/sponge_log.log" - set +x -} - -####################################### -# Main function: provision software necessary to execute tests, and run them -# Globals: -# KOKORO_ARTIFACTS_DIR -# GITHUB_REPOSITORY_NAME -# SRC_DIR: Populated with absolute path to the source repo -# TEST_DRIVER_REPO_DIR: Populated with the path to the repo containing -# the test driver -# TEST_DRIVER_FULL_DIR: Populated with the path to the test driver source code -# TEST_DRIVER_FLAGFILE: Populated with relative path to test driver flagfile -# TEST_XML_OUTPUT_DIR: Populated with the path to test xUnit XML report -# GIT_ORIGIN_URL: Populated with the origin URL of git repo used for the build -# GIT_COMMIT: Populated with the SHA-1 of git commit being built -# GIT_COMMIT_SHORT: Populated with the short SHA-1 of git commit being built -# KUBE_CONTEXT: Populated with name of kubectl context with GKE cluster access -# Arguments: -# None -# Outputs: -# Writes the output of test execution to stdout, stderr -####################################### -main() { - local script_dir - script_dir="$(dirname "$0")" - - # Source the test driver from the master branch. - echo "Sourcing test driver install script from: ${TEST_DRIVER_INSTALL_SCRIPT_URL}" - source /dev/stdin <<< "$(curl -s "${TEST_DRIVER_INSTALL_SCRIPT_URL}")" - - activate_gke_cluster GKE_CLUSTER_PSM_SECURITY - - set -x - if [[ -n "${KOKORO_ARTIFACTS_DIR}" ]]; then - kokoro_setup_test_driver "${GITHUB_REPOSITORY_NAME}" - else - local_setup_test_driver "${script_dir}" - fi - build_docker_images_if_needed - # Run tests - cd "${TEST_DRIVER_FULL_DIR}" - local failed_tests=0 - test_suites=("baseline_test" "security_test" "authz_test") - for test in "${test_suites[@]}"; do - run_test $test || (( ++failed_tests )) - done - echo "Failed test suites: ${failed_tests}" -} - -main "$@" diff --git a/tools/internal_ci/linux/psm-security.cfg b/tools/internal_ci/linux/psm-security.cfg index 9b00aaf40d4..098a0d60e72 100644 --- a/tools/internal_ci/linux/psm-security.cfg +++ b/tools/internal_ci/linux/psm-security.cfg @@ -15,7 +15,7 @@ # Config file for the internal CI (in protobuf text format) # Location of the continuous shell script in repository. -build_file: "grpc/tools/internal_ci/linux/psm-security.sh" +build_file: "grpc/tools/internal_ci/linux/psm-interop-test-cpp.sh" timeout_mins: 240 action { define_artifacts { @@ -24,3 +24,7 @@ action { strip_prefix: "artifacts" } } +env_vars { + key: "PSM_TEST_SUITE" + value: "security" +} diff --git a/tools/internal_ci/linux/psm-security.sh b/tools/internal_ci/linux/psm-security.sh deleted file mode 100755 index 9a55367e097..00000000000 --- a/tools/internal_ci/linux/psm-security.sh +++ /dev/null @@ -1,169 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2021 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -eo pipefail - -# Constants -readonly GITHUB_REPOSITORY_NAME="grpc" -readonly TEST_DRIVER_INSTALL_SCRIPT_URL="https://raw.githubusercontent.com/${TEST_DRIVER_REPO_OWNER:-grpc}/psm-interop/${TEST_DRIVER_BRANCH:-main}/.kokoro/psm_interop_kokoro_lib.sh" -## xDS test server/client Docker images -readonly DOCKER_REGISTRY="us-docker.pkg.dev" -readonly SERVER_IMAGE_NAME="us-docker.pkg.dev/grpc-testing/psm-interop/cpp-server" -readonly CLIENT_IMAGE_NAME="us-docker.pkg.dev/grpc-testing/psm-interop/cpp-client" -readonly FORCE_IMAGE_BUILD="${FORCE_IMAGE_BUILD:-0}" -readonly BUILD_APP_PATH="interop-testing/build/install/grpc-interop-testing" - -####################################### -# Builds test app Docker images and pushes them to GCR -# Globals: -# BUILD_APP_PATH -# SERVER_IMAGE_NAME: Test server Docker image name -# CLIENT_IMAGE_NAME: Test client Docker image name -# GIT_COMMIT: SHA-1 of git commit being built -# TESTING_VERSION: version branch under test, f.e. v1.42.x, master -# Arguments: -# None -# Outputs: -# Writes the output of `gcloud builds submit` to stdout, stderr -####################################### -build_test_app_docker_images() { - echo "Building C++ xDS interop test app Docker images" - docker build -f "${SRC_DIR}/tools/dockerfile/interoptest/grpc_interop_cxx_xds/Dockerfile.xds_client" -t "${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" "${SRC_DIR}" - docker build -f "${SRC_DIR}/tools/dockerfile/interoptest/grpc_interop_cxx_xds/Dockerfile.xds_server" -t "${SERVER_IMAGE_NAME}:${GIT_COMMIT}" "${SRC_DIR}" - gcloud -q auth configure-docker "${DOCKER_REGISTRY}" - docker push "${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" - docker push "${SERVER_IMAGE_NAME}:${GIT_COMMIT}" - if is_version_branch "${TESTING_VERSION}"; then - tag_and_push_docker_image "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}" "${TESTING_VERSION}" - tag_and_push_docker_image "${SERVER_IMAGE_NAME}" "${GIT_COMMIT}" "${TESTING_VERSION}" - fi -} - -####################################### -# Builds test app and its docker images unless they already exist -# Globals: -# SERVER_IMAGE_NAME: Test server Docker image name -# CLIENT_IMAGE_NAME: Test client Docker image name -# GIT_COMMIT: SHA-1 of git commit being built -# FORCE_IMAGE_BUILD -# Arguments: -# None -# Outputs: -# Writes the output to stdout, stderr -####################################### -build_docker_images_if_needed() { - # Check if images already exist - server_tags="$(gcloud_gcr_list_image_tags "${SERVER_IMAGE_NAME}" "${GIT_COMMIT}")" - printf "Server image: %s:%s\n" "${SERVER_IMAGE_NAME}" "${GIT_COMMIT}" - echo "${server_tags:-Server image not found}" - - client_tags="$(gcloud_gcr_list_image_tags "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}")" - printf "Client image: %s:%s\n" "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}" - echo "${client_tags:-Client image not found}" - - # Build if any of the images are missing, or FORCE_IMAGE_BUILD=1 - if [[ "${FORCE_IMAGE_BUILD}" == "1" || -z "${server_tags}" || -z "${client_tags}" ]]; then - build_test_app_docker_images - else - echo "Skipping C++ test app build" - fi -} - -####################################### -# Executes the test case -# Globals: -# TEST_DRIVER_FLAGFILE: Relative path to test driver flagfile -# KUBE_CONTEXT: The name of kubectl context with GKE cluster access -# TEST_XML_OUTPUT_DIR: Output directory for the test xUnit XML report -# SERVER_IMAGE_NAME: Test server Docker image name -# CLIENT_IMAGE_NAME: Test client Docker image name -# GIT_COMMIT: SHA-1 of git commit being built -# TESTING_VERSION: version branch under test: used by the framework to determine the supported PSM -# features. -# Arguments: -# Test case name -# Outputs: -# Writes the output of test execution to stdout, stderr -# Test xUnit report to ${TEST_XML_OUTPUT_DIR}/${test_name}/sponge_log.xml -####################################### -run_test() { - # Test driver usage: - # https://github.com/grpc/psm-interop#basic-usage - local test_name="${1:?Usage: run_test test_name}" - local out_dir="${TEST_XML_OUTPUT_DIR}/${test_name}" - mkdir -pv "${out_dir}" - set -x - python3 -m "tests.${test_name}" \ - --flagfile="${TEST_DRIVER_FLAGFILE}" \ - --kube_context="${KUBE_CONTEXT}" \ - --server_image="${SERVER_IMAGE_NAME}:${GIT_COMMIT}" \ - --client_image="${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" \ - --testing_version="${TESTING_VERSION}" \ - --nocheck_local_certs \ - --force_cleanup \ - --collect_app_logs \ - --log_dir="${out_dir}" \ - --xml_output_file="${out_dir}/sponge_log.xml" \ - |& tee "${out_dir}/sponge_log.log" -} - -####################################### -# Main function: provision software necessary to execute tests, and run them -# Globals: -# KOKORO_ARTIFACTS_DIR -# GITHUB_REPOSITORY_NAME -# SRC_DIR: Populated with absolute path to the source repo -# TEST_DRIVER_REPO_DIR: Populated with the path to the repo containing -# the test driver -# TEST_DRIVER_FULL_DIR: Populated with the path to the test driver source code -# TEST_DRIVER_FLAGFILE: Populated with relative path to test driver flagfile -# TEST_XML_OUTPUT_DIR: Populated with the path to test xUnit XML report -# GIT_ORIGIN_URL: Populated with the origin URL of git repo used for the build -# GIT_COMMIT: Populated with the SHA-1 of git commit being built -# GIT_COMMIT_SHORT: Populated with the short SHA-1 of git commit being built -# KUBE_CONTEXT: Populated with name of kubectl context with GKE cluster access -# Arguments: -# None -# Outputs: -# Writes the output of test execution to stdout, stderr -####################################### -main() { - local script_dir - script_dir="$(dirname "$0")" - - # Source the test driver from the master branch. - echo "Sourcing test driver install script from: ${TEST_DRIVER_INSTALL_SCRIPT_URL}" - source /dev/stdin <<< "$(curl -s "${TEST_DRIVER_INSTALL_SCRIPT_URL}")" - - activate_gke_cluster GKE_CLUSTER_PSM_SECURITY - - set -x - if [[ -n "${KOKORO_ARTIFACTS_DIR}" ]]; then - kokoro_setup_test_driver "${GITHUB_REPOSITORY_NAME}" - else - local_setup_test_driver "${script_dir}" - fi - build_docker_images_if_needed - # Run tests - cd "${TEST_DRIVER_FULL_DIR}" - local failed_tests=0 - test_suites=("baseline_test" "security_test" "authz_test") - for test in "${test_suites[@]}"; do - run_test $test || (( ++failed_tests )) - done - echo "Failed test suites: ${failed_tests}" -} - -main "$@" diff --git a/tools/interop_matrix/client_matrix.py b/tools/interop_matrix/client_matrix.py index bcb9bcf8769..ccaf83cc1e6 100644 --- a/tools/interop_matrix/client_matrix.py +++ b/tools/interop_matrix/client_matrix.py @@ -132,6 +132,7 @@ LANG_RELEASE_MATRIX = { ("v1.60.0", ReleaseInfo()), ("v1.61.0", ReleaseInfo()), ("v1.62.0", ReleaseInfo()), + ("v1.63.0", ReleaseInfo()), ] ), "go": OrderedDict( @@ -781,6 +782,12 @@ LANG_RELEASE_MATRIX = { runtimes=["python"], testcases_file="python__master" ), ), + ( + "v1.63.0", + ReleaseInfo( + runtimes=["python"], testcases_file="python__master" + ), + ), ] ), "node": OrderedDict( @@ -877,6 +884,7 @@ LANG_RELEASE_MATRIX = { ("v1.60.0", ReleaseInfo()), ("v1.61.0", ReleaseInfo()), ("v1.62.0", ReleaseInfo()), + ("v1.63.0", ReleaseInfo()), ] ), "php": OrderedDict( @@ -937,6 +945,7 @@ LANG_RELEASE_MATRIX = { ("v1.60.0", ReleaseInfo()), ("v1.61.0", ReleaseInfo()), ("v1.62.0", ReleaseInfo()), + ("v1.63.0", ReleaseInfo()), ] ), "csharp": OrderedDict( diff --git a/tools/profiling/microbenchmarks/bm_diff/bm_constants.py b/tools/profiling/microbenchmarks/bm_diff/bm_constants.py index c654145ac06..b3b0738a4a4 100644 --- a/tools/profiling/microbenchmarks/bm_diff/bm_constants.py +++ b/tools/profiling/microbenchmarks/bm_diff/bm_constants.py @@ -22,7 +22,6 @@ _AVAILABLE_BENCHMARK_TESTS = [ "bm_closure", "bm_cq", "bm_chttp2_hpack", - "bm_chttp2_transport", ] _INTERESTING = (